1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Merge remote-tracking branch 'origin/stac/usb-composite-device-v2' into next

This commit is contained in:
Stacey Sheldon 2012-01-17 22:26:38 -05:00
commit ad141c908a
69 changed files with 1481 additions and 1105 deletions

View File

@ -41,5 +41,6 @@
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_EXTI
#define PIOS_INCLUDE_BL_HELPER
#define PIOS_INCLUDE_IAP
#endif /* PIOS_CONFIG_H */

View File

@ -36,5 +36,6 @@
#define PIOS_INCLUDE_BL_HELPER
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_IAP
#endif /* PIOS_CONFIG_H */

View File

@ -104,7 +104,6 @@ SRC += $(PIOSSTM32F10X)/pios_irq.c
SRC += $(PIOSSTM32F10X)/pios_debug.c
SRC += $(PIOSSTM32F10X)/pios_gpio.c
# PIOS USB related files (seperated to make code maintenance more easy)
SRC += $(PIOSSTM32F10X)/pios_usb.c
SRC += $(PIOSSTM32F10X)/pios_usbhook.c
@ -116,7 +115,7 @@ SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
## PIOS Hardware (Common)
SRC += $(PIOSCOMMON)/pios_board_info.c
SRC += $(PIOSCOMMON)/pios_com.c
SRC += $(PIOSCOMMON)/pios_com_msg.c
SRC += $(PIOSCOMMON)/pios_bl_helper.c
SRC += $(PIOSCOMMON)/pios_iap.c
SRC += $(PIOSCOMMON)/printf-stdarg.c

View File

@ -39,8 +39,9 @@
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_USB
#define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_IAP
#define PIOS_NO_GPS
#endif /* PIOS_CONFIG_H */

View File

@ -37,33 +37,6 @@
#include "pios_usb_defs.h" /* struct usb_* */
struct usb_board_config {
struct usb_configuration_desc config;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
} __attribute__((packed));
extern const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor;
extern const struct usb_board_config PIOS_USB_BOARD_Configuration;
extern const struct usb_string_langid PIOS_USB_BOARD_StringLangID;
/* NOTE NOTE NOTE
*
* Care must be taken to ensure that the _actual_ contents of
* these arrays (in each board's pios_usb_board_data.c) is no
* smaller than the stated sizes here or these descriptors
* will end up with trailing zeros on the wire.
*
* The compiler will catch any time that these definitions are
* too small.
*/
extern const uint8_t PIOS_USB_BOARD_HidReportDescriptor[36];
extern const uint8_t PIOS_USB_BOARD_StringVendorID[28];
extern const uint8_t PIOS_USB_BOARD_StringProductID[28];
extern uint8_t PIOS_USB_BOARD_StringSerial[52];
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_COPTERCONTROL
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_COPTERCONTROL, USB_OP_BOARD_MODE_BL)

View File

@ -32,6 +32,7 @@
#include "usb_lib.h"
#include "pios_iap.h"
#include "fifo_buffer.h"
#include "pios_com_msg.h"
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void FLASH_Download();
@ -62,7 +63,7 @@ uint8_t JumpToApp = FALSE;
uint8_t GO_dfu = FALSE;
uint8_t USB_connected = FALSE;
uint8_t User_DFU_request = FALSE;
static uint8_t mReceive_Buffer[64];
static uint8_t mReceive_Buffer[63];
/* Private function prototypes -----------------------------------------------*/
uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count);
uint8_t processRX();
@ -198,7 +199,7 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
}
uint8_t processRX() {
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
if (PIOS_COM_MSG_Receive(PIOS_COM_TELEM_USB, mReceive_Buffer, sizeof(mReceive_Buffer))) {
processComand(mReceive_Buffer);
}
return TRUE;

View File

@ -30,6 +30,7 @@
#include "pios.h"
#include "op_dfu.h"
#include "pios_bl_helper.h"
#include "pios_com_msg.h"
#include <pios_board_info.h>
//programmable devices
Device devicesTable[10];
@ -446,9 +447,7 @@ uint32_t CalcFirmCRC() {
}
void sendData(uint8_t * buf, uint16_t size) {
PIOS_COM_SendBuffer(PIOS_COM_TELEM_USB, buf, size);
if (DeviceState == downloading)
PIOS_DELAY_WaitmS(20);//this is an hack, we should check wtf is wrong with hid
PIOS_COM_MSG_Send(PIOS_COM_TELEM_USB, buf, size);
}
bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {

View File

@ -27,17 +27,11 @@
// ***********************************************************************************
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_COM_MSG)
#include <pios_com_priv.h>
#include <pios_com_msg_priv.h>
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 192
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192
static uint8_t pios_com_telem_usb_rx_buffer[PIOS_COM_TELEM_USB_RX_BUF_LEN];
static uint8_t pios_com_telem_usb_tx_buffer[PIOS_COM_TELEM_USB_TX_BUF_LEN];
#endif /* PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_COM_MSG */
// ***********************************************************************************
@ -54,6 +48,10 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
},
},
};
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_USB_HID)
@ -93,21 +91,25 @@ void PIOS_Board_Init(void) {
PIOS_GPIO_Init();
#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
/* Activate the HID-only USB configuration */
PIOS_USB_DESC_HID_ONLY_Init();
uint32_t pios_usb_id;
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
uint32_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
pios_com_telem_usb_rx_buffer, sizeof(pios_com_telem_usb_rx_buffer),
pios_com_telem_usb_tx_buffer, sizeof(pios_com_telem_usb_tx_buffer))) {
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
PIOS_Assert(0);
}
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
#endif /* PIOS_INCLUDE_USB */

View File

@ -29,9 +29,11 @@
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
const uint8_t PIOS_USB_BOARD_StringProductID[] = {
sizeof(PIOS_USB_BOARD_StringProductID),
static const uint8_t usb_product_id[28] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'C', 0,
'o', 0,
@ -48,3 +50,74 @@ const uint8_t PIOS_USB_BOARD_StringProductID[] = {
'l', 0,
};
static uint8_t usb_serial_number[52] = {
sizeof(usb_serial_number),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
static const struct usb_string_langid usb_lang_id = {
.bLength = sizeof(usb_lang_id),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
static const uint8_t usb_vendor_id[28] = {
sizeof(usb_vendor_id),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_BOARD_DATA_Init(void)
{
/* Load device serial number into serial number string */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
usb_serial_number[2 + 2 * i] = sn[i];
}
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
return 0;
}

View File

@ -119,6 +119,7 @@ SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
## PIOS Hardware (Common)
SRC += $(PIOSCOMMON)/pios_board_info.c
SRC += $(PIOSCOMMON)/pios_com_msg.c
SRC += $(PIOSCOMMON)/pios_com.c
SRC += $(PIOSCOMMON)/pios_opahrs_v0.c
SRC += $(PIOSCOMMON)/pios_bl_helper.c
@ -292,7 +293,7 @@ CSTANDARD = -std=gnu99
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
ifeq ($(DEBUG),YES)
CFLAGS = -DDEBUG
CFLAGS += -DDEBUG
endif
CFLAGS += -g$(DEBUGF)

View File

@ -42,7 +42,9 @@
#define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_OPAHRS
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_IAP
//#define DEBUG_SSP
/* Defaults for Logging */

View File

@ -37,33 +37,6 @@
#include "pios_usb_defs.h" /* struct usb_* */
struct usb_board_config {
struct usb_configuration_desc config;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
} __attribute__((packed));
extern const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor;
extern const struct usb_board_config PIOS_USB_BOARD_Configuration;
extern const struct usb_string_langid PIOS_USB_BOARD_StringLangID;
/* NOTE NOTE NOTE
*
* Care must be taken to ensure that the _actual_ contents of
* these arrays (in each board's pios_usb_board_data.c) is no
* smaller than the stated sizes here or these descriptors
* will end up with trailing zeros on the wire.
*
* The compiler will catch any time that these definitions are
* too small.
*/
extern const uint8_t PIOS_USB_BOARD_HidReportDescriptor[36];
extern const uint8_t PIOS_USB_BOARD_StringVendorID[28];
extern const uint8_t PIOS_USB_BOARD_StringProductID[20];
extern uint8_t PIOS_USB_BOARD_StringSerial[52];
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_OPENPILOT_MAIN
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_OPENPILOT_MAIN, USB_OP_BOARD_MODE_BL)

View File

@ -35,6 +35,7 @@
#include "pios_iap.h"
#include "ssp.h"
#include "fifo_buffer.h"
#include "pios_com_msg.h"
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void FLASH_Download();
@ -90,7 +91,7 @@ uint8_t JumpToApp = FALSE;
uint8_t GO_dfu = FALSE;
uint8_t USB_connected = FALSE;
uint8_t User_DFU_request = FALSE;
static uint8_t mReceive_Buffer[64];
static uint8_t mReceive_Buffer[63];
/* Private function prototypes -----------------------------------------------*/
uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count);
uint8_t processRX();
@ -101,10 +102,6 @@ uint32_t sspTimeSource();
#define RED LED2
#define LED_PWM_TIMER TIM6
int main() {
/* NOTE: Do NOT modify the following start-up sequence */
/* Any new initialization functions should be added in OpenPilotInit() */
/* Brings up System using CMSIS functions, enables the LEDs. */
PIOS_SYS_Init();
if (BSL_HOLD_STATE == 0)
USB_connected = TRUE;
@ -227,7 +224,6 @@ void jump_to_app() {
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);
_SetCNTR(0); // clear interrupt mask
_SetISTR(0); // clear all requests
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
@ -249,7 +245,7 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
uint8_t processRX() {
if (ProgPort == Usb) {
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
if (PIOS_COM_MSG_Receive(PIOS_COM_TELEM_USB, mReceive_Buffer, sizeof(mReceive_Buffer))) {
processComand(mReceive_Buffer);
}
} else if (ProgPort == Serial) {

View File

@ -30,13 +30,10 @@
#include "pios.h"
#include "op_dfu.h"
#include "pios_bl_helper.h"
#include "pios_com_msg.h"
#include <pios_board_info.h>
#include "pios_opahrs.h"
#include "ssp.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
//programmable devices
Device devicesTable[10];
uint8_t numberOfDevices = 0;
@ -222,7 +219,7 @@ void processComand(uint8_t *xReceive_Buffer) {
}
}
if (result != 1) {
DeviceState = Last_operation_failed;//ok
DeviceState = Last_operation_failed;
Aditionals = (uint32_t) Command;
} else {
@ -299,7 +296,6 @@ void processComand(uint8_t *xReceive_Buffer) {
++Next_Packet;
} else {
DeviceState = wrong_packet_received;
Aditionals = Count;
}
@ -353,10 +349,18 @@ void processComand(uint8_t *xReceive_Buffer) {
DeviceState = failed_jump;
break;
} else {
if (Data == 0x5AFE) {
/* Force board into safe mode */
PIOS_IAP_WriteBootCount(0xFFFF);
}
FLASH_Lock();
JumpToApp = 1;
}
} else {
if (Data == 0x5AFE) {
/* Force board into safe mode */
PIOS_IAP_WriteBootCount(0xFFFF);
}
FLASH_Lock();
JumpToApp = 1;
}
@ -384,7 +388,6 @@ void processComand(uint8_t *xReceive_Buffer) {
DeviceState = too_few_packets;
}
}
break;
case Download_Req:
#ifdef DEBUG_SSP
@ -508,6 +511,7 @@ uint32_t baseOfAdressType(DFUTransfer type) {
return currentDevice.startOfUserCode + currentDevice.sizeOfCode;
break;
default:
return 0;
}
}
@ -550,11 +554,7 @@ uint32_t CalcFirmCRC() {
}
void sendData(uint8_t * buf, uint16_t size) {
if (ProgPort == Usb) {
PIOS_COM_SendBuffer(PIOS_COM_TELEM_USB, buf, size);
if (DeviceState == downloading)
PIOS_DELAY_WaitmS(10);
PIOS_COM_MSG_Send(PIOS_COM_TELEM_USB, buf, size);
} else if (ProgPort == Serial) {
ssp_SendData(&ssp_port, buf, size);
}

View File

@ -184,12 +184,6 @@ const struct pios_usart_cfg pios_usart_telem_cfg = {
#include "pios_com_priv.h"
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 192
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192
static uint8_t pios_com_telem_usb_rx_buffer[PIOS_COM_TELEM_USB_RX_BUF_LEN];
static uint8_t pios_com_telem_usb_tx_buffer[PIOS_COM_TELEM_USB_TX_BUF_LEN];
#define PIOS_COM_TELEM_RF_RX_BUF_LEN 192
#define PIOS_COM_TELEM_RF_TX_BUF_LEN 192
@ -198,6 +192,16 @@ static uint8_t pios_com_telem_rf_tx_buffer[PIOS_COM_TELEM_RF_TX_BUF_LEN];
#endif /* PIOS_INCLUDE_COM */
// ***********************************************************************************
#if defined(PIOS_INCLUDE_COM_MSG)
#include <pios_com_msg_priv.h>
#endif /* PIOS_INCLUDE_COM_MSG */
// ***********************************************************************************
#if defined(PIOS_INCLUDE_USB)
#include "pios_usb_priv.h"
@ -211,7 +215,11 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
},
},
};
#endif /* PIOS_INCLUDE_USB_HID */
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_USB_HID)
#include <pios_usb_hid_priv.h>
@ -266,21 +274,25 @@ void PIOS_Board_Init(void) {
PIOS_GPIO_Init();
#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
/* Activate the HID-only USB configuration */
PIOS_USB_DESC_HID_ONLY_Init();
uint32_t pios_usb_id;
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
uint32_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
pios_com_telem_usb_rx_buffer, sizeof(pios_com_telem_usb_rx_buffer),
pios_com_telem_usb_tx_buffer, sizeof(pios_com_telem_usb_tx_buffer))) {
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
PIOS_Assert(0);
}
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
#endif /* PIOS_INCLUDE_USB */

View File

@ -29,9 +29,11 @@
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
const uint8_t PIOS_USB_BOARD_StringProductID[] = {
sizeof(PIOS_USB_BOARD_StringProductID),
static const uint8_t usb_product_id[20] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'O', 0,
'p', 0,
@ -43,3 +45,75 @@ const uint8_t PIOS_USB_BOARD_StringProductID[] = {
'o', 0,
't', 0,
};
static uint8_t usb_serial_number[52] = {
sizeof(usb_serial_number),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
static const struct usb_string_langid usb_lang_id = {
.bLength = sizeof(usb_lang_id),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
static const uint8_t usb_vendor_id[28] = {
sizeof(usb_vendor_id),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_BOARD_DATA_Init(void)
{
/* Load device serial number into serial number string */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
usb_serial_number[2 + 2 * i] = sn[i];
}
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
return 0;
}

View File

@ -115,7 +115,7 @@ SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
## PIOS Hardware (Common)
SRC += $(PIOSCOMMON)/pios_board_info.c
SRC += $(PIOSCOMMON)/pios_com.c
SRC += $(PIOSCOMMON)/pios_com_msg.c
SRC += $(PIOSCOMMON)/pios_bl_helper.c
SRC += $(PIOSCOMMON)/pios_iap.c
SRC += $(PIOSCOMMON)/printf-stdarg.c
@ -287,7 +287,7 @@ CSTANDARD = -std=gnu99
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
ifeq ($(DEBUG),YES)
CFLAGS = -DDEBUG
CFLAGS += -DDEBUG
endif
CFLAGS += -g$(DEBUGF)

View File

@ -38,9 +38,9 @@
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_USB
#define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_GPIO
//#define DEBUG_SSP
#define PIOS_INCLUDE_IAP
/* Defaults for Logging */
#define LOG_FILENAME "PIOS.LOG"

View File

@ -37,33 +37,6 @@
#include "pios_usb_defs.h" /* struct usb_* */
struct usb_board_config {
struct usb_configuration_desc config;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
} __attribute__((packed));
extern const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor;
extern const struct usb_board_config PIOS_USB_BOARD_Configuration;
extern const struct usb_string_langid PIOS_USB_BOARD_StringLangID;
/* NOTE NOTE NOTE
*
* Care must be taken to ensure that the _actual_ contents of
* these arrays (in each board's pios_usb_board_data.c) is no
* smaller than the stated sizes here or these descriptors
* will end up with trailing zeros on the wire.
*
* The compiler will catch any time that these definitions are
* too small.
*/
extern const uint8_t PIOS_USB_BOARD_HidReportDescriptor[36];
extern const uint8_t PIOS_USB_BOARD_StringVendorID[28];
extern const uint8_t PIOS_USB_BOARD_StringProductID[20];
extern uint8_t PIOS_USB_BOARD_StringSerial[52];
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_PIPXTREME
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_PIPXTREME, USB_OP_BOARD_MODE_BL)

View File

@ -32,6 +32,7 @@
#include "usb_lib.h"
#include "pios_iap.h"
#include "fifo_buffer.h"
#include "pios_com_msg.h"
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void FLASH_Download();
@ -62,7 +63,7 @@ uint8_t JumpToApp = FALSE;
uint8_t GO_dfu = FALSE;
uint8_t USB_connected = FALSE;
uint8_t User_DFU_request = FALSE;
static uint8_t mReceive_Buffer[64];
static uint8_t mReceive_Buffer[63];
/* Private function prototypes -----------------------------------------------*/
uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count);
uint8_t processRX();
@ -71,10 +72,6 @@ void jump_to_app();
#define BLUE LED1
#define RED LED4
int main() {
/* NOTE: Do NOT modify the following start-up sequence */
/* Any new initialization functions should be added in OpenPilotInit() */
/* Brings up System using CMSIS functions, enables the LEDs. */
PIOS_SYS_Init();
if (BSL_HOLD_STATE == 0)
USB_connected = TRUE;
@ -181,7 +178,6 @@ void jump_to_app() {
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);
_SetCNTR(0); // clear interrupt mask
_SetISTR(0); // clear all requests
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
@ -204,7 +200,7 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
}
uint8_t processRX() {
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
if (PIOS_COM_MSG_Receive(PIOS_COM_TELEM_USB, mReceive_Buffer, sizeof(mReceive_Buffer))) {
processComand(mReceive_Buffer);
}
return TRUE;

View File

@ -30,11 +30,8 @@
#include "pios.h"
#include "op_dfu.h"
#include "pios_bl_helper.h"
#include "pios_com_msg.h"
#include <pios_board_info.h>
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
//programmable devices
Device devicesTable[10];
uint8_t numberOfDevices = 0;
@ -102,33 +99,9 @@ void DataDownload(DownloadAction action) {
currentProgrammingDestination)) {
DeviceState = Last_operation_failed;
}
/*
switch (currentProgrammingDestination) {
case Remote_flash_via_spi:
if (downType == Descript) {
SendBuffer[6 + (x * 4)]
= spi_dev_desc[(uint8_t) partoffset];
SendBuffer[7 + (x * 4)] = spi_dev_desc[(uint8_t) partoffset
+ 1];
SendBuffer[8 + (x * 4)] = spi_dev_desc[(uint8_t) partoffset
+ 2];
SendBuffer[9 + (x * 4)] = spi_dev_desc[(uint8_t) partoffset
+ 3];
}
break;
case Self_flash:
SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset);
SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1);
SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2);
SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3);
break;
}
*/
}
//PIOS USB_SIL_Write(EP1_IN, (uint8_t*) SendBuffer, 64);
downPacketCurrent = downPacketCurrent + 1;
if (downPacketCurrent > downPacketTotal - 1) {
// STM_EVAL_LEDOn(LED2);
DeviceState = Last_operation_Success;
Aditionals = (uint32_t) Download;
}
@ -168,7 +141,7 @@ void processComand(uint8_t *xReceive_Buffer) {
case EnterDFU:
if (((DeviceState == BLidle) && (Data0 < numberOfDevices))
|| (DeviceState == DFUidle)) {
if (Data0 > 0)//PORQUE???
if (Data0 > 0)
OPDfuIni(TRUE);
DeviceState = DFUidle;
currentProgrammingDestination = devicesTable[Data0].programmingType;
@ -225,7 +198,7 @@ void processComand(uint8_t *xReceive_Buffer) {
}
}
if (result != 1) {
DeviceState = Last_operation_failed;//ok
DeviceState = Last_operation_failed;
Aditionals = (uint32_t) Command;
} else {
@ -276,11 +249,9 @@ void processComand(uint8_t *xReceive_Buffer) {
++Next_Packet;
} else {
DeviceState = wrong_packet_received;
Aditionals = Count;
}
// FLASH_ProgramWord(MemLocations[TransferType]+4,++Next_Packet);//+Count,Data);
} else {
DeviceState = Last_operation_failed;
Aditionals = (uint32_t) Command;
@ -322,9 +293,12 @@ void processComand(uint8_t *xReceive_Buffer) {
Buffer[15] = devicesTable[Data0 - 1].devID;
}
sendData(Buffer + 1, 63);
//PIOS_COM_SendBuffer(PIOS_COM_TELEM_USB, Buffer + 1, 63);//FIX+1
break;
case JumpFW:
if (Data == 0x5AFE) {
/* Force board into safe mode */
PIOS_IAP_WriteBootCount(0xFFFF);
}
FLASH_Lock();
JumpToApp = 1;
break;
@ -351,7 +325,6 @@ void processComand(uint8_t *xReceive_Buffer) {
DeviceState = too_few_packets;
}
}
break;
case Download_Req:
#ifdef DEBUG_SSP
@ -474,9 +447,7 @@ uint32_t CalcFirmCRC() {
}
void sendData(uint8_t * buf, uint16_t size) {
PIOS_COM_SendBuffer(PIOS_COM_TELEM_USB, buf, size);
if (DeviceState == downloading)
PIOS_DELAY_WaitmS(10);
PIOS_COM_MSG_Send(PIOS_COM_TELEM_USB, buf, size);
}
bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {

View File

@ -27,17 +27,11 @@
// ***********************************************************************************
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_COM_MSG)
#include <pios_com_priv.h>
#include <pios_com_msg_priv.h>
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 192
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192
static uint8_t pios_com_telem_usb_rx_buffer[PIOS_COM_TELEM_USB_RX_BUF_LEN];
static uint8_t pios_com_telem_usb_tx_buffer[PIOS_COM_TELEM_USB_TX_BUF_LEN];
#endif /* PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_COM_MSG */
// ***********************************************************************************
@ -55,6 +49,9 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
},
};
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_USB_HID)
@ -94,21 +91,26 @@ void PIOS_Board_Init(void) {
PIOS_GPIO_Init();
#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
/* Activate the HID-only USB configuration */
PIOS_USB_DESC_HID_ONLY_Init();
uint32_t pios_usb_id;
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM)
uint32_t pios_usb_com_id;
if (PIOS_USB_HID_Init(&pios_usb_com_id, &pios_usb_hid_cfg, pios_usb_id)) {
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
uint32_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_com_id,
pios_com_telem_usb_rx_buffer, sizeof(pios_com_telem_usb_rx_buffer),
pios_com_telem_usb_tx_buffer, sizeof(pios_com_telem_usb_tx_buffer))) {
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
PIOS_Assert(0);
}
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
#endif /* PIOS_INCLUDE_USB */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);//TODO Tirar

View File

@ -29,9 +29,11 @@
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
const uint8_t PIOS_USB_BOARD_StringProductID[] = {
sizeof(PIOS_USB_BOARD_StringProductID),
static const uint8_t usb_product_id[20] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'P', 0,
'i', 0,
@ -44,3 +46,74 @@ const uint8_t PIOS_USB_BOARD_StringProductID[] = {
'e', 0,
};
static uint8_t usb_serial_number[52] = {
sizeof(usb_serial_number),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
static const struct usb_string_langid usb_lang_id = {
.bLength = sizeof(usb_lang_id),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
static const uint8_t usb_vendor_id[28] = {
sizeof(usb_vendor_id),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_BOARD_DATA_Init(void)
{
/* Load device serial number into serial number string */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
usb_serial_number[2 + 2 * i] = sn[i];
}
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
return 0;
}

View File

@ -136,7 +136,6 @@ SRC += ${OPMODULEDIR}/System/systemmod.c
SRC += $(OPSYSTEM)/coptercontrol.c
SRC += $(OPSYSTEM)/pios_board.c
SRC += $(OPSYSTEM)/alarms.c
SRC += $(OPSYSTEM)/taskmonitor.c
SRC += $(OPUAVTALK)/uavtalk.c
SRC += $(OPUAVOBJ)/uavobjectmanager.c
SRC += $(OPUAVOBJ)/eventdispatcher.c
@ -216,6 +215,7 @@ SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c
SRC += $(OPSYSTEM)/pios_usb_board_data.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
## PIOS Hardware (Common)
SRC += $(PIOSCOMMON)/pios_crc.c
@ -232,6 +232,7 @@ SRC += $(PIOSCOMMON)/printf-stdarg.c
## Libraries for flight calculations
SRC += $(FLIGHTLIB)/fifo_buffer.c
SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(FLIGHTLIB)/taskmonitor.c
## CMSIS for STM32
SRC += $(CMSISDIR)/core_cm3.c
@ -435,15 +436,15 @@ CSTANDARD = -std=gnu99
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
ifeq ($(DEBUG),YES)
CFLAGS = -DDEBUG
CFLAGS += -DDEBUG
endif
ifeq ($(DIAGNOSTICS),YES)
CFLAGS = -DDIAGNOSTICS
CFLAGS += -DDIAGNOSTICS
endif
ifeq ($(DIAG_TASKS),YES)
CFLAGS = -DDIAG_TASKS
CFLAGS += -DDIAG_TASKS
endif
CFLAGS += -g$(DEBUGF)

View File

@ -42,6 +42,7 @@
#endif
#define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_RCVR

View File

@ -37,44 +37,7 @@
#define PIOS_USB_BOARD_EP_NUM 4
#include "pios_usb_defs.h" /* struct usb_* */
struct usb_board_config {
struct usb_configuration_desc config;
struct usb_interface_association_desc iad;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
struct usb_interface_desc cdc_control_if;
struct usb_cdc_header_func_desc cdc_header;
struct usb_cdc_callmgmt_func_desc cdc_callmgmt;
struct usb_cdc_acm_func_desc cdc_acm;
struct usb_cdc_union_func_desc cdc_union;
struct usb_endpoint_desc cdc_mgmt_in;
struct usb_interface_desc cdc_data_if;
struct usb_endpoint_desc cdc_in;
struct usb_endpoint_desc cdc_out;
} __attribute__((packed));
extern const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor;
extern const struct usb_board_config PIOS_USB_BOARD_Configuration;
extern const struct usb_string_langid PIOS_USB_BOARD_StringLangID;
/* NOTE NOTE NOTE
*
* Care must be taken to ensure that the _actual_ contents of
* these arrays (in each board's pios_usb_board_data.c) is no
* smaller than the stated sizes here or these descriptors
* will end up with trailing zeros on the wire.
*
* The compiler will catch any time that these definitions are
* too small.
*/
extern const uint8_t PIOS_USB_BOARD_HidReportDescriptor[36];
extern const uint8_t PIOS_USB_BOARD_StringVendorID[28];
extern const uint8_t PIOS_USB_BOARD_StringProductID[28];
extern uint8_t PIOS_USB_BOARD_StringSerial[52];
#include "pios_usb_defs.h" /* USB_* macros */
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_COPTERCONTROL
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_COPTERCONTROL, USB_OP_BOARD_MODE_FW)

View File

@ -998,6 +998,11 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
},
},
};
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_cdc_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_USB_HID)
@ -1090,14 +1095,50 @@ void PIOS_Board_Init(void) {
PIOS_TIM_InitClock(&tim_4_cfg);
#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
/* Flags to determine if various USB interfaces are advertised */
bool usb_hid_present = false;
bool usb_cdc_present = false;
uint8_t hwsettings_usb_devicetype;
HwSettingsUSB_DeviceTypeGet(&hwsettings_usb_devicetype);
switch (hwsettings_usb_devicetype) {
case HWSETTINGS_USB_DEVICETYPE_HIDONLY:
if (PIOS_USB_DESC_HID_ONLY_Init()) {
PIOS_Assert(0);
}
usb_hid_present = true;
break;
case HWSETTINGS_USB_DEVICETYPE_HIDVCP:
if (PIOS_USB_DESC_HID_CDC_Init()) {
PIOS_Assert(0);
}
usb_hid_present = true;
usb_cdc_present = true;
break;
case HWSETTINGS_USB_DEVICETYPE_VCPONLY:
break;
default:
PIOS_Assert(0);
}
uint32_t pios_usb_id;
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
#if defined(PIOS_INCLUDE_USB_CDC)
/* Configure the USB VCP port */
uint8_t hwsettings_usb_vcpport;
/* Configure the USB VCP port */
HwSettingsUSB_VCPPortGet(&hwsettings_usb_vcpport);
if (!usb_cdc_present) {
/* Force VCP port function to disabled if we haven't advertised VCP in our USB descriptor */
hwsettings_usb_vcpport = HWSETTINGS_USB_VCPPORT_DISABLED;
}
switch (hwsettings_usb_vcpport) {
case HWSETTINGS_USB_VCPPORT_DISABLED:
break;
@ -1136,7 +1177,6 @@ void PIOS_Board_Init(void) {
tx_buffer, PIOS_COM_BRIDGE_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_COM */
break;
@ -1148,6 +1188,11 @@ void PIOS_Board_Init(void) {
uint8_t hwsettings_usb_hidport;
HwSettingsUSB_HIDPortGet(&hwsettings_usb_hidport);
if (!usb_hid_present) {
/* Force HID port function to disabled if we haven't advertised HID in our USB descriptor */
hwsettings_usb_hidport = HWSETTINGS_USB_HIDPORT_DISABLED;
}
switch (hwsettings_usb_hidport) {
case HWSETTINGS_USB_HIDPORT_DISABLED:
break;

View File

@ -29,9 +29,11 @@
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
const uint8_t PIOS_USB_BOARD_StringProductID[] = {
sizeof(PIOS_USB_BOARD_StringProductID),
static const uint8_t usb_product_id[28] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'C', 0,
'o', 0,
@ -48,3 +50,74 @@ const uint8_t PIOS_USB_BOARD_StringProductID[] = {
'l', 0,
};
static uint8_t usb_serial_number[52] = {
sizeof(usb_serial_number),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
static const struct usb_string_langid usb_lang_id = {
.bLength = sizeof(usb_lang_id),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
static const uint8_t usb_vendor_id[28] = {
sizeof(usb_vendor_id),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_BOARD_DATA_Init(void)
{
/* Load device serial number into serial number string */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
usb_serial_number[2 + 2 * i] = sn[i];
}
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
return 0;
}

View File

@ -1,131 +0,0 @@
/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
* @{
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
* @{
* @file taskmonitor.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Task monitoring library
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
//#include "taskmonitor.h"
// Private constants
// Private types
// Private variables
static xSemaphoreHandle lock;
static xTaskHandle handles[TASKINFO_RUNNING_NUMELEM];
static uint32_t lastMonitorTime;
// Private functions
/**
* Initialize library
*/
int32_t TaskMonitorInitialize(void)
{
lock = xSemaphoreCreateRecursiveMutex();
memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM);
lastMonitorTime = 0;
#if defined(DIAG_TASKS)
lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif
return 0;
}
/**
* Register a task handle with the library
*/
int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle)
{
if (task < TASKINFO_RUNNING_NUMELEM)
{
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
handles[task] = handle;
xSemaphoreGiveRecursive(lock);
return 0;
}
else
{
return -1;
}
}
/**
* Update the status of all tasks
*/
void TaskMonitorUpdateAll(void)
{
#if defined(DIAG_TASKS)
TaskInfoData data;
int n;
// Lock
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
#if ( configGENERATE_RUN_TIME_STATS == 1 )
uint32_t currentTime;
uint32_t deltaTime;
/*
* Calculate the amount of elapsed run time between the last time we
* measured and now. Scale so that we can convert task run times
* directly to percentages.
*/
currentTime = portGET_RUN_TIME_COUNTER_VALUE();
deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */
lastMonitorTime = currentTime;
#endif
// Update all task information
for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n)
{
if (handles[n] != 0)
{
data.Running[n] = TASKINFO_RUNNING_TRUE;
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
data.StackRemaining[n] = 10000;
#else
data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4;
#if ( configGENERATE_RUN_TIME_STATS == 1 )
/* Generate run time stats */
data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;
#endif
#endif
}
else
{
data.Running[n] = TASKINFO_RUNNING_FALSE;
data.StackRemaining[n] = 0;
data.RunningTime[n] = 0;
}
}
// Update object
TaskInfoSet(&data);
// Done
xSemaphoreGiveRecursive(lock);
#endif
}

View File

@ -51,6 +51,7 @@
#define PIOS_INCLUDE_IMU3000
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_EXTI
#define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_BMA180

View File

@ -47,7 +47,7 @@ int32_t TaskMonitorInitialize(void)
lock = xSemaphoreCreateRecursiveMutex();
memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM);
lastMonitorTime = 0;
#if defined(DIAGNOSTICS)
#if defined(DIAG_TASKS)
lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif
return 0;
@ -94,7 +94,7 @@ int32_t TaskMonitorRemove(TaskInfoRunningElem task)
*/
void TaskMonitorUpdateAll(void)
{
#if defined(DIAGNOSTICS)
#if defined(DIAG_TASKS)
TaskInfoData data;
int n;
@ -128,7 +128,6 @@ void TaskMonitorUpdateAll(void)
#if ( configGENERATE_RUN_TIME_STATS == 1 )
/* Generate run time stats */
data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;
#endif
#endif

View File

@ -48,8 +48,6 @@
#include "taskinfo.h"
#include "watchdogstatus.h"
#include "taskmonitor.h"
#include "pios_iap.h"
// Private constants
#define SYSTEM_UPDATE_PERIOD_MS 1000
@ -148,8 +146,10 @@ static void systemTask(void *parameters)
PIOS_SYS_Reset();
}
#if defined(PIOS_INCLUDE_IAP)
/* Record a successful boot */
PIOS_IAP_WriteBootCount(0);
#endif
// Initialize vars
idleCounter = 0;
@ -170,8 +170,11 @@ static void systemTask(void *parameters)
updateI2Cstats();
updateWDGstats();
#endif
#if defined(DIAG_TASKS)
// Update the task status object
TaskMonitorUpdateAll();
#endif
// Flash the heartbeat LED
PIOS_LED_Toggle(LED1);

View File

@ -35,7 +35,6 @@
#include "flighttelemetrystats.h"
#include "gcstelemetrystats.h"
#include "hwsettings.h"
#include "pios_usb.h" /* PIOS_USB_* */
// Private constants
#define MAX_QUEUE_SIZE TELEM_QUEUE_SIZE

View File

@ -39,6 +39,7 @@ DEBUG ?= YES
# Include objects that are just nice information to show
DIAGNOSTICS ?= YES
DIAG_TASKS ?= YES
# Set to YES to use the Servo output pins for debugging via scope or logic analyser
ENABLE_DEBUG_PINS ?= NO
@ -138,7 +139,6 @@ SRC += ${OPMODULEDIR}/System/systemmod.c
SRC += $(OPSYSTEM)/openpilot.c
SRC += $(OPSYSTEM)/pios_board.c
SRC += $(OPSYSTEM)/alarms.c
SRC += $(OPSYSTEM)/taskmonitor.c
SRC += $(OPUAVTALK)/uavtalk.c
SRC += $(OPUAVOBJ)/uavobjectmanager.c
SRC += $(OPUAVOBJ)/eventdispatcher.c
@ -183,9 +183,11 @@ SRC += $(PIOSSTM32F10X)/pios_wdg.c
SRC += $(PIOSSTM32F10X)/pios_usb.c
SRC += $(PIOSSTM32F10X)/pios_usbhook.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid.c
SRC += $(PIOSSTM32F10X)/pios_usb_cdc.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c
SRC += $(OPSYSTEM)/pios_usb_board_data.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
## PIOS Hardware (Common)
@ -205,6 +207,7 @@ SRC += $(FLIGHTLIB)/ahrs_comm_objects.c
SRC += $(FLIGHTLIB)/fifo_buffer.c
SRC += $(FLIGHTLIB)/WorldMagModel.c
SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(FLIGHTLIB)/taskmonitor.c
## CMSIS for STM32
SRC += $(CMSISDIR)/core_cm3.c
@ -393,11 +396,15 @@ CSTANDARD = -std=gnu99
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
ifeq ($(DEBUG),YES)
CFLAGS = -DDEBUG
CFLAGS += -DDEBUG
endif
ifeq ($(DIAGNOSTICS),YES)
CFLAGS = -DDIAGNOSTICS
CFLAGS += -DDIAGNOSTICS
endif
ifeq ($(DIAG_TASKS),YES)
CFLAGS += -DDIAG_TASKS
endif
CFLAGS += -g$(DEBUGF)

View File

@ -149,7 +149,6 @@ SRC += ${OPMODULEDIR}/System/systemmod.c
SRC += $(OPSYSTEM)/openpilot.c
SRC += $(OPSYSTEM)/pios_board_posix.c
SRC += $(OPSYSTEM)/alarms.c
SRC += $(OPSYSTEM)/taskmonitor.c
SRC += $(OPUAVTALK)/uavtalk.c
SRC += $(OPUAVOBJ)/uavobjectmanager.c
SRC += $(OPUAVOBJ)/eventdispatcher.c
@ -189,6 +188,7 @@ SRC += $(PIOSPOSIX)/pios_rcvr.c
SRC += $(FLIGHTLIB)/fifo_buffer.c
SRC += $(FLIGHTLIB)/WorldMagModel.c
SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(FLIGHTLIB)/taskmonitor.c
## RTOS and RTOS Portable
SRC += $(RTOSSRCDIR)/list.c
SRC += $(RTOSSRCDIR)/queue.c

View File

@ -41,6 +41,7 @@
#define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_RCVR
@ -57,6 +58,7 @@
#define PIOS_INCLUDE_USART
#define PIOS_INCLUDE_USB
#define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_USB_CDC
#define PIOS_INCLUDE_BMP085
//#define PIOS_INCLUDE_HCSR04
#define PIOS_INCLUDE_OPAHRS

View File

@ -39,43 +39,6 @@
#include "pios_usb_defs.h" /* struct usb_* */
struct usb_board_config {
struct usb_configuration_desc config;
struct usb_interface_association_desc iad;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
struct usb_interface_desc cdc_control_if;
struct usb_cdc_header_func_desc cdc_header;
struct usb_cdc_callmgmt_func_desc cdc_callmgmt;
struct usb_cdc_acm_func_desc cdc_acm;
struct usb_cdc_union_func_desc cdc_union;
struct usb_endpoint_desc cdc_mgmt_in;
struct usb_interface_desc cdc_data_if;
struct usb_endpoint_desc cdc_in;
struct usb_endpoint_desc cdc_out;
} __attribute__((packed));
extern const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor;
extern const struct usb_board_config PIOS_USB_BOARD_Configuration;
extern const struct usb_string_langid PIOS_USB_BOARD_StringLangID;
/* NOTE NOTE NOTE
*
* Care must be taken to ensure that the _actual_ contents of
* these arrays (in each board's pios_usb_board_data.c) is no
* smaller than the stated sizes here or these descriptors
* will end up with trailing zeros on the wire.
*
* The compiler will catch any time that these definitions are
* too small.
*/
extern const uint8_t PIOS_USB_BOARD_HidReportDescriptor[36];
extern const uint8_t PIOS_USB_BOARD_StringVendorID[28];
extern const uint8_t PIOS_USB_BOARD_StringProductID[20];
extern uint8_t PIOS_USB_BOARD_StringSerial[52];
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_OPENPILOT_MAIN
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_OPENPILOT_MAIN, USB_OP_BOARD_MODE_FW)

View File

@ -611,6 +611,9 @@ static const struct pios_dsm_cfg pios_dsm_cfg = {
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 192
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192
#define PIOS_COM_BRIDGE_RX_BUF_LEN 65
#define PIOS_COM_BRIDGE_TX_BUF_LEN 12
#endif /* PIOS_INCLUDE_COM */
/**
@ -1054,6 +1057,10 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
},
},
};
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_cdc_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_USB_HID)
@ -1067,8 +1074,22 @@ const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
#endif /* PIOS_INCLUDE_USB_HID */
#if defined(PIOS_INCLUDE_USB_CDC)
#include <pios_usb_cdc_priv.h>
const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = {
.ctrl_if = 1,
.ctrl_tx_ep = 2,
.data_if = 2,
.data_rx_ep = 3,
.data_tx_ep = 3,
};
#endif /* PIOS_INCLUDE_USB_CDC */
uint32_t pios_com_telem_rf_id;
uint32_t pios_com_telem_usb_id;
uint32_t pios_com_vcp_id;
uint32_t pios_com_gps_id;
uint32_t pios_com_aux_id;
uint32_t pios_com_dsm_id;
@ -1109,14 +1130,27 @@ void PIOS_Board_Init(void) {
HwSettingsInitialize();
PIOS_WDG_Init();
/* Initialize the alarms library */
AlarmsInitialize();
PIOS_IAP_Init();
uint16_t boot_count = PIOS_IAP_ReadBootCount();
if (boot_count < 3) {
PIOS_IAP_WriteBootCount(++boot_count);
AlarmsClear(SYSTEMALARMS_ALARM_BOOTFAULT);
} else {
/* Too many failed boot attempts, force hwsettings to defaults */
HwSettingsSetDefaults(HwSettingsHandle(), 0);
AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
}
#if defined(PIOS_INCLUDE_RTC)
/* Initialize the real-time clock and its associated tick */
PIOS_RTC_Init(&pios_rtc_main_cfg);
#endif
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
@ -1124,7 +1158,6 @@ void PIOS_Board_Init(void) {
PIOS_TIM_InitClock(&tim_1_cfg);
PIOS_TIM_InitClock(&tim_3_cfg);
PIOS_TIM_InitClock(&tim_5_cfg);
PIOS_TIM_InitClock(&tim_4_cfg);
PIOS_TIM_InitClock(&tim_8_cfg);
@ -1139,6 +1172,133 @@ void PIOS_Board_Init(void) {
/* Bind the AHRS comms layer to the AHRS SPI link */
AhrsConnect(pios_spi_ahrs_id);
#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
/* Flags to determine if various USB interfaces are advertised */
bool usb_hid_present = false;
bool usb_cdc_present = false;
uint8_t hwsettings_usb_devicetype;
HwSettingsUSB_DeviceTypeGet(&hwsettings_usb_devicetype);
switch (hwsettings_usb_devicetype) {
case HWSETTINGS_USB_DEVICETYPE_HIDONLY:
if (PIOS_USB_DESC_HID_ONLY_Init()) {
PIOS_Assert(0);
}
usb_hid_present = true;
break;
case HWSETTINGS_USB_DEVICETYPE_HIDVCP:
if (PIOS_USB_DESC_HID_CDC_Init()) {
PIOS_Assert(0);
}
usb_hid_present = true;
usb_cdc_present = true;
break;
case HWSETTINGS_USB_DEVICETYPE_VCPONLY:
break;
default:
PIOS_Assert(0);
}
uint32_t pios_usb_id;
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
#if defined(PIOS_INCLUDE_USB_CDC)
/* Configure the USB VCP port */
uint8_t hwsettings_usb_vcpport;
HwSettingsUSB_VCPPortGet(&hwsettings_usb_vcpport);
if (!usb_cdc_present) {
/* Force VCP port function to disabled if we haven't advertised VCP in our USB descriptor */
hwsettings_usb_vcpport = HWSETTINGS_USB_VCPPORT_DISABLED;
}
switch (hwsettings_usb_vcpport) {
case HWSETTINGS_USB_VCPPORT_DISABLED:
break;
case HWSETTINGS_USB_VCPPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint32_t pios_usb_cdc_id;
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN,
tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_COM */
break;
case HWSETTINGS_USB_VCPPORT_COMBRIDGE:
#if defined(PIOS_INCLUDE_COM)
{
uint32_t pios_usb_cdc_id;
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
rx_buffer, PIOS_COM_BRIDGE_RX_BUF_LEN,
tx_buffer, PIOS_COM_BRIDGE_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_COM */
break;
}
#endif /* PIOS_INCLUDE_USB_CDC */
#if defined(PIOS_INCLUDE_USB_HID)
/* Configure the usb HID port */
uint8_t hwsettings_usb_hidport;
HwSettingsUSB_HIDPortGet(&hwsettings_usb_hidport);
if (!usb_hid_present) {
/* Force HID port function to disabled if we haven't advertised HID in our USB descriptor */
hwsettings_usb_hidport = HWSETTINGS_USB_HIDPORT_DISABLED;
}
switch (hwsettings_usb_hidport) {
case HWSETTINGS_USB_HIDPORT_DISABLED:
break;
case HWSETTINGS_USB_HIDPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint32_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN,
tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_COM */
break;
}
#endif /* PIOS_INCLUDE_USB_HID */
#endif /* PIOS_INCLUDE_USB */
/* Configure the main IO port */
uint8_t hwsettings_op_mainport;
HwSettingsOP_MainPortGet(&hwsettings_op_mainport);
@ -1285,36 +1445,14 @@ void PIOS_Board_Init(void) {
break;
}
#if defined(PIOS_INCLUDE_USB)
uint32_t pios_usb_id;
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM)
uint32_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN,
tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) {
PIOS_Assert(0);
}
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_I2C)
if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) {
PIOS_Assert(0);
}
#endif /* PIOS_INCLUDE_I2C */
PIOS_IAP_Init();
PIOS_WDG_Init();
/* Make sure we have at least one telemetry link configured or else fail initialization */
PIOS_Assert(pios_com_telem_rf_id || pios_com_telem_usb_id);
}
/**

View File

@ -29,9 +29,11 @@
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
const uint8_t PIOS_USB_BOARD_StringProductID[] = {
sizeof(PIOS_USB_BOARD_StringProductID),
static const uint8_t usb_product_id[20] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'O', 0,
'p', 0,
@ -43,3 +45,76 @@ const uint8_t PIOS_USB_BOARD_StringProductID[] = {
'o', 0,
't', 0,
};
static uint8_t usb_serial_number[52] = {
sizeof(usb_serial_number),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
static const struct usb_string_langid usb_lang_id = {
.bLength = sizeof(usb_lang_id),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
static const uint8_t usb_vendor_id[28] = {
sizeof(usb_vendor_id),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_BOARD_DATA_Init(void)
{
/* Load device serial number into serial number string */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
usb_serial_number[2 + 2 * i] = sn[i];
}
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
return 0;
}

View File

@ -0,0 +1,185 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_COM COM MSG layer functions
* @brief Hardware communication layer
* @{
*
* @file pios_com_msg.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief COM MSG layer functions
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Project Includes */
#include "pios.h"
#if defined(PIOS_INCLUDE_COM_MSG)
#include "pios_com.h"
#define PIOS_COM_MSG_MAX_LEN 63
struct pios_com_msg_dev {
uint32_t lower_id;
const struct pios_com_driver * driver;
uint8_t rx_msg_buffer[PIOS_COM_MSG_MAX_LEN];
volatile bool rx_msg_full;
uint8_t tx_msg_buffer[PIOS_COM_MSG_MAX_LEN];
volatile bool tx_msg_full;
};
static struct pios_com_msg_dev com_msg_dev;
static uint16_t PIOS_COM_MSG_TxOutCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield);
static uint16_t PIOS_COM_MSG_RxInCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield);
int32_t PIOS_COM_MSG_Init(uint32_t * com_id, const struct pios_com_driver * driver, uint32_t lower_id)
{
PIOS_Assert(com_id);
PIOS_Assert(driver);
PIOS_Assert(driver->bind_tx_cb);
PIOS_Assert(driver->bind_rx_cb);
struct pios_com_msg_dev * com_dev = &com_msg_dev;
com_dev->driver = driver;
com_dev->lower_id = lower_id;
com_dev->rx_msg_full = false;
(com_dev->driver->bind_rx_cb)(lower_id, PIOS_COM_MSG_RxInCallback, (uint32_t)com_dev);
(com_dev->driver->rx_start)(com_dev->lower_id, sizeof(com_dev->rx_msg_buffer));
com_dev->tx_msg_full = false;
(com_dev->driver->bind_tx_cb)(lower_id, PIOS_COM_MSG_TxOutCallback, (uint32_t)com_dev);
*com_id = (uint32_t)com_dev;
return(0);
}
static uint16_t PIOS_COM_MSG_TxOutCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield)
{
struct pios_com_msg_dev * com_dev = (struct pios_com_msg_dev *)context;
PIOS_Assert(buf);
PIOS_Assert(buf_len);
uint16_t bytes_from_fifo = 0;
if (com_dev->tx_msg_full && (buf_len >= sizeof(com_dev->tx_msg_buffer))) {
/* Room for an entire message, send it */
memcpy(buf, com_dev->tx_msg_buffer, sizeof(com_dev->tx_msg_buffer));
bytes_from_fifo = sizeof(com_dev->tx_msg_buffer);
com_dev->tx_msg_full = false;
}
if (headroom) {
if (com_dev->tx_msg_full) {
*headroom = sizeof(com_dev->tx_msg_buffer);
} else {
*headroom = 0;
}
}
return (bytes_from_fifo);
}
static uint16_t PIOS_COM_MSG_RxInCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield)
{
struct pios_com_msg_dev * com_dev = (struct pios_com_msg_dev *)context;
uint16_t bytes_into_fifo = 0;
if (!com_dev->rx_msg_full && (buf_len >= sizeof(com_dev->rx_msg_buffer))) {
memcpy(com_dev->rx_msg_buffer, buf, sizeof(com_dev->rx_msg_buffer));
bytes_into_fifo = sizeof(com_dev->rx_msg_buffer);
com_dev->rx_msg_full = true;
}
if (headroom) {
if (!com_dev->rx_msg_full) {
*headroom = sizeof(com_dev->rx_msg_buffer);
} else {
*headroom = 0;
}
}
return (bytes_into_fifo);
}
int32_t PIOS_COM_MSG_Send(uint32_t com_id, const uint8_t *msg, uint16_t msg_len)
{
PIOS_Assert(msg);
PIOS_Assert(msg_len);
struct pios_com_msg_dev * com_dev = (struct pios_com_msg_dev *)com_id;
PIOS_Assert(msg_len == sizeof(com_dev->tx_msg_buffer));
/* Wait forever for room in the tx buffer */
while (com_dev->tx_msg_full) {
/* Kick the transmitter while we wait */
if (com_dev->driver->tx_start) {
(com_dev->driver->tx_start)(com_dev->lower_id, sizeof(com_dev->tx_msg_buffer));
}
}
memcpy((void *) com_dev->tx_msg_buffer, msg, msg_len);
com_dev->tx_msg_full = true;
/* Kick the transmitter now that we've queued our message */
if (com_dev->driver->tx_start) {
(com_dev->driver->tx_start)(com_dev->lower_id, sizeof(com_dev->tx_msg_buffer));
}
return 0;
}
uint16_t PIOS_COM_MSG_Receive(uint32_t com_id, uint8_t * msg, uint16_t msg_len)
{
PIOS_Assert(msg);
PIOS_Assert(msg_len);
struct pios_com_msg_dev * com_dev = (struct pios_com_msg_dev *)com_id;
PIOS_Assert(msg_len == sizeof(com_dev->rx_msg_buffer));
if (!com_dev->rx_msg_full) {
/* There's room in our buffer, kick the receiver */
(com_dev->driver->rx_start)(com_dev->lower_id, sizeof(com_dev->rx_msg_buffer));
} else {
memcpy(msg, com_dev->rx_msg_buffer, msg_len);
com_dev->rx_msg_full = false;
return msg_len;
}
return 0;
}
#endif /* PIOS_INCLUDE_COM_MSG */
/**
* @}
* @}
*/

View File

@ -28,9 +28,12 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_usb_desc_hid_cdc_priv.h" /* exported API */
#include "pios_usb_defs.h" /* struct usb_*, USB_* */
#include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */
#include "pios_usbhook.h" /* PIOS_USBHOOK_Register* */
const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor = {
static const struct usb_device_desc device_desc = {
.bLength = sizeof(struct usb_device_desc),
.bDescriptorType = USB_DESC_TYPE_DEVICE,
.bcdUSB = htousbs(0x0200),
@ -41,17 +44,79 @@ const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor = {
.idVendor = htousbs(USB_VENDOR_ID_OPENPILOT),
.idProduct = htousbs(PIOS_USB_BOARD_PRODUCT_ID),
.bcdDevice = htousbs(PIOS_USB_BOARD_DEVICE_VER),
.iManufacturer = 1,
.iProduct = 2,
.iSerialNumber = 3,
.iManufacturer = USB_STRING_DESC_VENDOR,
.iProduct = USB_STRING_DESC_PRODUCT,
.iSerialNumber = USB_STRING_DESC_SERIAL,
.bNumConfigurations = 1,
};
const struct usb_board_config PIOS_USB_BOARD_Configuration = {
static const uint8_t hid_report_desc[36] = {
HID_GLOBAL_ITEM_2 (HID_TAG_GLOBAL_USAGE_PAGE),
0x9C, 0xFF, /* Usage Page 0xFF9C (Vendor Defined) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
0x01, /* Usage ID 0x0001 (0x01-0x1F uaually for top-level collections) */
HID_MAIN_ITEM_1 (HID_TAG_MAIN_COLLECTION),
0x01, /* Application */
/* Device -> Host emulated serial channel */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_ID),
0x01, /* OpenPilot emulated serial channel (Device -> Host) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
0x02,
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MIN),
0x00, /* Values range from min = 0x00 */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MAX),
0xFF, /* Values range to max = 0xFF */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_SIZE),
0x08, /* 8 bits wide */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_CNT),
PIOS_USB_BOARD_HID_DATA_LENGTH-1, /* Need to leave room for a report ID */
HID_MAIN_ITEM_1 (HID_TAG_MAIN_INPUT),
0x03, /* Variable, Constant (read-only) */
/* Host -> Host emulated serial channel */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_ID),
0x02, /* OpenPilot emulated Serial Channel (Host -> Device) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
0x02,
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MIN),
0x00, /* Values range from min = 0x00 */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MAX),
0xFF, /* Values range to max = 0xFF */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_SIZE),
0x08, /* 8 bits wide */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_CNT),
PIOS_USB_BOARD_HID_DATA_LENGTH-1, /* Need to leave room for a report ID */
HID_MAIN_ITEM_1 (HID_TAG_MAIN_OUTPUT),
0x82, /* Volatile, Variable */
HID_MAIN_ITEM_0 (HID_TAG_MAIN_ENDCOLLECTION),
};
struct usb_config_hid_cdc {
struct usb_configuration_desc config;
struct usb_interface_association_desc iad;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
struct usb_interface_desc cdc_control_if;
struct usb_cdc_header_func_desc cdc_header;
struct usb_cdc_callmgmt_func_desc cdc_callmgmt;
struct usb_cdc_acm_func_desc cdc_acm;
struct usb_cdc_union_func_desc cdc_union;
struct usb_endpoint_desc cdc_mgmt_in;
struct usb_interface_desc cdc_data_if;
struct usb_endpoint_desc cdc_in;
struct usb_endpoint_desc cdc_out;
} __attribute__((packed));
static const struct usb_config_hid_cdc config_hid_cdc = {
.config = {
.bLength = sizeof(struct usb_configuration_desc),
.bDescriptorType = USB_DESC_TYPE_CONFIGURATION,
.wTotalLength = htousbs(sizeof(struct usb_board_config)),
.wTotalLength = htousbs(sizeof(struct usb_config_hid_cdc)),
.bNumInterfaces = 3,
.bConfigurationValue = 1,
.iConfiguration = 0,
@ -86,7 +151,7 @@ const struct usb_board_config PIOS_USB_BOARD_Configuration = {
.bCountryCode = 0,
.bNumDescriptors = 1,
.bClassDescriptorType = USB_DESC_TYPE_REPORT,
.wItemLength = htousbs(sizeof(PIOS_USB_BOARD_HidReportDescriptor)),
.wItemLength = htousbs(sizeof(hid_report_desc)),
},
.hid_in = {
.bLength = sizeof(struct usb_endpoint_desc),
@ -178,100 +243,14 @@ const struct usb_board_config PIOS_USB_BOARD_Configuration = {
},
};
const uint8_t PIOS_USB_BOARD_HidReportDescriptor[] = {
HID_GLOBAL_ITEM_2 (HID_TAG_GLOBAL_USAGE_PAGE),
0x9C, 0xFF, /* Usage Page 0xFF9C (Vendor Defined) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
0x01, /* Usage ID 0x0001 (0x01-0x1F uaually for top-level collections) */
int32_t PIOS_USB_DESC_HID_CDC_Init(void)
{
PIOS_USBHOOK_RegisterConfig(1, (uint8_t *)&config_hid_cdc, sizeof(config_hid_cdc));
HID_MAIN_ITEM_1 (HID_TAG_MAIN_COLLECTION),
0x01, /* Application */
PIOS_USBHOOK_RegisterDevice((uint8_t *)&device_desc, sizeof(device_desc));
/* Device -> Host emulated serial channel */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_ID),
0x01, /* OpenPilot emulated serial channel (Device -> Host) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
0x02,
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MIN),
0x00, /* Values range from min = 0x00 */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MAX),
0xFF, /* Values range to max = 0xFF */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_SIZE),
0x08, /* 8 bits wide */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_CNT),
PIOS_USB_BOARD_HID_DATA_LENGTH-1, /* Need to leave room for a report ID */
HID_MAIN_ITEM_1 (HID_TAG_MAIN_INPUT),
0x03, /* Variable, Constant (read-only) */
PIOS_USBHOOK_RegisterHidInterface((uint8_t *)&(config_hid_cdc.hid_if), sizeof(config_hid_cdc.hid_if));
PIOS_USBHOOK_RegisterHidReport((uint8_t *)hid_report_desc, sizeof(hid_report_desc));
/* Host -> Host emulated serial channel */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_ID),
0x02, /* OpenPilot emulated Serial Channel (Host -> Device) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
0x02,
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MIN),
0x00, /* Values range from min = 0x00 */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_LOGICAL_MAX),
0xFF, /* Values range to max = 0xFF */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_SIZE),
0x08, /* 8 bits wide */
HID_GLOBAL_ITEM_1 (HID_TAG_GLOBAL_REPORT_CNT),
PIOS_USB_BOARD_HID_DATA_LENGTH-1, /* Need to leave room for a report ID */
HID_MAIN_ITEM_1 (HID_TAG_MAIN_OUTPUT),
0x82, /* Volatile, Variable */
HID_MAIN_ITEM_0 (HID_TAG_MAIN_ENDCOLLECTION),
};
const struct usb_string_langid PIOS_USB_BOARD_StringLangID = {
.bLength = sizeof(PIOS_USB_BOARD_StringLangID),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
const uint8_t PIOS_USB_BOARD_StringVendorID[] = {
sizeof(PIOS_USB_BOARD_StringVendorID),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
uint8_t PIOS_USB_BOARD_StringSerial[] = {
sizeof(PIOS_USB_BOARD_StringSerial),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
return 0;
}

View File

@ -28,9 +28,12 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_usb_desc_hid_only_priv.h" /* exported API */
#include "pios_usb_defs.h" /* struct usb_*, USB_* */
#include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */
#include "pios_usbhook.h" /* PIOS_USBHOOK_Register* */
const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor = {
static const struct usb_device_desc device_desc = {
.bLength = sizeof(struct usb_device_desc),
.bDescriptorType = USB_DESC_TYPE_DEVICE,
.bcdUSB = htousbs(0x0200),
@ -47,56 +50,7 @@ const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor = {
.bNumConfigurations = 1,
};
const struct usb_board_config PIOS_USB_BOARD_Configuration = {
.config = {
.bLength = sizeof(struct usb_configuration_desc),
.bDescriptorType = USB_DESC_TYPE_CONFIGURATION,
.wTotalLength = htousbs(sizeof(struct usb_board_config)),
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 0,
.bmAttributes = 0xC0,
.bMaxPower = 250/2, /* in units of 2ma */
},
.hid_if = {
.bLength = sizeof(struct usb_interface_desc),
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 2,
.bInterfaceClass = USB_INTERFACE_CLASS_HID,
.bInterfaceSubClass = 0, /* no boot */
.nInterfaceProtocol = 0, /* none */
.iInterface = 0,
},
.hid = {
.bLength = sizeof(struct usb_hid_desc),
.bDescriptorType = USB_DESC_TYPE_HID,
.bcdHID = htousbs(0x0110),
.bCountryCode = 0,
.bNumDescriptors = 1,
.bClassDescriptorType = USB_DESC_TYPE_REPORT,
.wItemLength = htousbs(sizeof(PIOS_USB_BOARD_HidReportDescriptor)),
},
.hid_in = {
.bLength = sizeof(struct usb_endpoint_desc),
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = USB_EP_IN(1),
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
.bInterval = 4, /* ms */
},
.hid_out = {
.bLength = sizeof(struct usb_endpoint_desc),
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = USB_EP_OUT(1),
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
.bInterval = 4, /* ms */
},
};
const uint8_t PIOS_USB_BOARD_HidReportDescriptor[] = {
static const uint8_t hid_report_desc[36] = {
HID_GLOBAL_ITEM_2 (HID_TAG_GLOBAL_USAGE_PAGE),
0x9C, 0xFF, /* Usage Page 0xFF9C (Vendor Defined) */
HID_LOCAL_ITEM_1 (HID_TAG_LOCAL_USAGE),
@ -140,56 +94,71 @@ const uint8_t PIOS_USB_BOARD_HidReportDescriptor[] = {
HID_MAIN_ITEM_0 (HID_TAG_MAIN_ENDCOLLECTION),
};
const struct usb_string_langid PIOS_USB_BOARD_StringLangID = {
.bLength = sizeof(PIOS_USB_BOARD_StringLangID),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
struct usb_config_hid_only {
struct usb_configuration_desc config;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
} __attribute__((packed));
const struct usb_config_hid_only config_hid_only = {
.config = {
.bLength = sizeof(struct usb_configuration_desc),
.bDescriptorType = USB_DESC_TYPE_CONFIGURATION,
.wTotalLength = htousbs(sizeof(struct usb_config_hid_only)),
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 0,
.bmAttributes = 0xC0,
.bMaxPower = 250/2, /* in units of 2ma */
},
.hid_if = {
.bLength = sizeof(struct usb_interface_desc),
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 2,
.bInterfaceClass = USB_INTERFACE_CLASS_HID,
.bInterfaceSubClass = 0, /* no boot */
.nInterfaceProtocol = 0, /* none */
.iInterface = 0,
},
.hid = {
.bLength = sizeof(struct usb_hid_desc),
.bDescriptorType = USB_DESC_TYPE_HID,
.bcdHID = htousbs(0x0110),
.bCountryCode = 0,
.bNumDescriptors = 1,
.bClassDescriptorType = USB_DESC_TYPE_REPORT,
.wItemLength = htousbs(sizeof(hid_report_desc)),
},
.hid_in = {
.bLength = sizeof(struct usb_endpoint_desc),
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = USB_EP_IN(1),
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
.bInterval = 4, /* ms */
},
.hid_out = {
.bLength = sizeof(struct usb_endpoint_desc),
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = USB_EP_OUT(1),
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
.bInterval = 4, /* ms */
},
};
const uint8_t PIOS_USB_BOARD_StringVendorID[] = {
sizeof(PIOS_USB_BOARD_StringVendorID),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_DESC_HID_ONLY_Init(void)
{
PIOS_USBHOOK_RegisterConfig(1, (uint8_t *)&config_hid_only, sizeof(config_hid_only));
uint8_t PIOS_USB_BOARD_StringSerial[] = {
sizeof(PIOS_USB_BOARD_StringSerial),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
PIOS_USBHOOK_RegisterDevice((uint8_t *)&device_desc, sizeof(device_desc));
PIOS_USBHOOK_RegisterHidInterface((uint8_t *)&(config_hid_only.hid_if), sizeof(config_hid_only.hid_if));
PIOS_USBHOOK_RegisterHidReport((uint8_t *)hid_report_desc, sizeof(hid_report_desc));
return 0;
}

View File

@ -35,7 +35,7 @@ typedef enum _CONTROL_STATE
typedef struct OneDescriptor
{
uint8_t *Descriptor;
const uint8_t *Descriptor;
uint16_t Descriptor_Size;
}
ONE_DESCRIPTOR, *PONE_DESCRIPTOR;
@ -80,7 +80,8 @@ typedef struct _ENDPOINT_INFO
uint16_t Usb_wLength;
uint16_t Usb_wOffset;
uint16_t PacketSize;
uint8_t *(*CopyData)(uint16_t Length);
const uint8_t *(*CopyDataIn)(uint16_t Length);
uint8_t *(*CopyDataOut)(uint16_t Length);
}ENDPOINT_INFO;
/*-*-*-*-*-*-*-*-*-*-*-* Definitions for device level -*-*-*-*-*-*-*-*-*-*-*-*/
@ -169,9 +170,9 @@ typedef struct _DEVICE_PROP
RESULT (*Class_Get_Interface_Setting)(uint8_t Interface, uint8_t AlternateSetting);
uint8_t* (*GetDeviceDescriptor)(uint16_t Length);
uint8_t* (*GetConfigDescriptor)(uint16_t Length);
uint8_t* (*GetStringDescriptor)(uint16_t Length);
const uint8_t* (*GetDeviceDescriptor)(uint16_t Length);
const uint8_t* (*GetConfigDescriptor)(uint16_t Length);
const uint8_t* (*GetStringDescriptor)(uint16_t Length);
/* This field is not used in current library version. It is kept only for
compatibility with previous versions */
@ -221,13 +222,13 @@ uint8_t In0_Process(void);
RESULT Standard_SetEndPointFeature(void);
RESULT Standard_SetDeviceFeature(void);
uint8_t *Standard_GetConfiguration(uint16_t Length);
const uint8_t *Standard_GetConfiguration(uint16_t Length);
RESULT Standard_SetConfiguration(void);
uint8_t *Standard_GetInterface(uint16_t Length);
const uint8_t *Standard_GetInterface(uint16_t Length);
RESULT Standard_SetInterface(void);
uint8_t *Standard_GetDescriptorData(uint16_t Length, const ONE_DESCRIPTOR * pDesc);
const uint8_t *Standard_GetDescriptorData(uint16_t Length, ONE_DESCRIPTOR *pDesc);
uint8_t *Standard_GetStatus(uint16_t Length);
const uint8_t *Standard_GetStatus(uint16_t Length);
RESULT Standard_ClearFeature(void);
void SetDeviceAddress(uint8_t);
void NOP_Process(void);

View File

@ -22,7 +22,7 @@
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
void UserToPMABufferCopy(const uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
/* External variables --------------------------------------------------------*/

View File

@ -58,7 +58,7 @@ static void Data_Setup0(void);
* Return : Return 1 , if the request is invalid when "Length" is 0.
* Return "Buffer" if the "Length" is not 0.
*******************************************************************************/
uint8_t *Standard_GetConfiguration(uint16_t Length)
const uint8_t *Standard_GetConfiguration(uint16_t Length)
{
if (Length == 0)
{
@ -104,7 +104,7 @@ RESULT Standard_SetConfiguration(void)
* Return : Return 0, if the request is invalid when "Length" is 0.
* Return "Buffer" if the "Length" is not 0.
*******************************************************************************/
uint8_t *Standard_GetInterface(uint16_t Length)
const uint8_t *Standard_GetInterface(uint16_t Length)
{
if (Length == 0)
{
@ -160,7 +160,7 @@ RESULT Standard_SetInterface(void)
* Return : Return 0, if the request is at end of data block,
* or is invalid when "Length" is 0.
*******************************************************************************/
uint8_t *Standard_GetStatus(uint16_t Length)
const uint8_t *Standard_GetStatus(uint16_t Length)
{
if (Length == 0)
{
@ -415,7 +415,7 @@ RESULT Standard_SetDeviceFeature(void)
* wOffset The buffer pointed by this address contains at least
* Length bytes.
*******************************************************************************/
uint8_t *Standard_GetDescriptorData(uint16_t Length, const ONE_DESCRIPTOR * pDesc)
const uint8_t *Standard_GetDescriptorData(uint16_t Length, PONE_DESCRIPTOR pDesc)
{
uint32_t wOffset;
@ -443,7 +443,7 @@ void DataStageOut(void)
save_rLength = pEPinfo->Usb_rLength;
if (pEPinfo->CopyData && save_rLength)
if (pEPinfo->CopyDataOut && save_rLength)
{
uint8_t *Buffer;
uint32_t Length;
@ -454,7 +454,7 @@ void DataStageOut(void)
Length = save_rLength;
}
Buffer = (*pEPinfo->CopyData)(Length);
Buffer = (*pEPinfo->CopyDataOut)(Length);
pEPinfo->Usb_rLength -= Length;
pEPinfo->Usb_rOffset += Length;
@ -503,7 +503,7 @@ void DataStageIn(void)
uint32_t save_wLength = pEPinfo->Usb_wLength;
uint32_t ControlState = pInformation->ControlState;
uint8_t *DataBuffer;
const uint8_t *DataBuffer;
uint32_t Length;
if ((save_wLength == 0) && (ControlState == LAST_IN_DATA))
@ -540,7 +540,7 @@ void DataStageIn(void)
Length = save_wLength;
}
DataBuffer = (*pEPinfo->CopyData)(Length);
DataBuffer = (*pEPinfo->CopyDataIn)(Length);
#ifdef STM32F10X_CL
PCD_EP_Write (ENDP0, DataBuffer, Length);
@ -697,7 +697,7 @@ exit_NoData_Setup0:
*******************************************************************************/
void Data_Setup0(void)
{
uint8_t *(*CopyRoutine)(uint16_t);
const uint8_t *(*CopyRoutine)(uint16_t);
RESULT Result;
uint32_t Request_No = pInformation->USBbRequest;
@ -802,7 +802,7 @@ void Data_Setup0(void)
if (CopyRoutine)
{
pInformation->Ctrl_Info.Usb_wOffset = wOffset;
pInformation->Ctrl_Info.CopyData = CopyRoutine;
pInformation->Ctrl_Info.CopyDataIn = CopyRoutine;
/* sb in the original the cast to word was directly */
/* now the cast is made step by step */
(*CopyRoutine)(0);

View File

@ -33,7 +33,7 @@
* Output : None.
* Return : None .
*******************************************************************************/
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
void UserToPMABufferCopy(const uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
{
uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
uint32_t i, temp1, temp2;

View File

@ -123,13 +123,6 @@ int32_t PIOS_USB_Init(uint32_t * usb_id, const struct pios_usb_cfg * cfg)
/* Enable the USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
/* Update the USB serial number from the chip */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < PIOS_USB_BOARD_StringSerial[0]; i++) {
PIOS_USB_BOARD_StringSerial[2 + 2 * i] = sn[i];
}
USB_Init();
USB_SIL_Init();

View File

@ -346,7 +346,7 @@ RESULT PIOS_USB_CDC_SetLineCoding(void)
return USB_SUCCESS;
}
uint8_t *PIOS_USB_CDC_GetLineCoding(uint16_t Length)
const uint8_t *PIOS_USB_CDC_GetLineCoding(uint16_t Length)
{
struct pios_usb_cdc_dev * usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_usb_cdc_id;

View File

@ -207,9 +207,15 @@ static void PIOS_USB_HID_RxStart(uint32_t usbhid_id, uint16_t rx_bytes_avail) {
}
// If endpoint was stalled and there is now space make it valid
#ifdef PIOS_USB_BOARD_BL_HID_HAS_NO_LENGTH_BYTE
uint16_t max_payload_length = PIOS_USB_BOARD_HID_DATA_LENGTH - 1;
#else
uint16_t max_payload_length = PIOS_USB_BOARD_HID_DATA_LENGTH - 2;
#endif
PIOS_IRQ_Disable();
if ((GetEPRxStatus(usb_hid_dev->cfg->data_rx_ep) != EP_RX_VALID) &&
(rx_bytes_avail >= PIOS_USB_BOARD_HID_DATA_LENGTH)) {
(rx_bytes_avail >= max_payload_length)) {
SetEPRxStatus(usb_hid_dev->cfg->data_rx_ep, EP_RX_VALID);
}
PIOS_IRQ_Enable();
@ -328,7 +334,15 @@ static void PIOS_USB_HID_EP_OUT_Callback(void)
&headroom,
&need_yield);
#endif
if (headroom >= PIOS_USB_BOARD_HID_DATA_LENGTH) {
#ifdef PIOS_USB_BOARD_BL_HID_HAS_NO_LENGTH_BYTE
uint16_t max_payload_length = PIOS_USB_BOARD_HID_DATA_LENGTH - 1;
#else
uint16_t max_payload_length = PIOS_USB_BOARD_HID_DATA_LENGTH - 2;
#endif
if (headroom >= max_payload_length) {
/* We have room for a maximum length message */
SetEPRxStatus(usb_hid_dev->cfg->data_rx_ep, EP_RX_VALID);
} else {

View File

@ -36,6 +36,48 @@
#include "pios_usb_cdc_priv.h" /* PIOS_USB_CDC_* */
#include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */
static ONE_DESCRIPTOR Device_Descriptor;
void PIOS_USBHOOK_RegisterDevice(const uint8_t * desc, uint16_t desc_size)
{
Device_Descriptor.Descriptor = desc;
Device_Descriptor.Descriptor_Size = desc_size;
}
static ONE_DESCRIPTOR Config_Descriptor;
void PIOS_USBHOOK_RegisterConfig(uint8_t config_id, const uint8_t * desc, uint16_t desc_size)
{
Config_Descriptor.Descriptor = desc;
Config_Descriptor.Descriptor_Size = desc_size;
}
static ONE_DESCRIPTOR String_Descriptor[4];
void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t * desc, uint16_t desc_size)
{
if (string_id < NELEMENTS(String_Descriptor)) {
String_Descriptor[string_id].Descriptor = desc;
String_Descriptor[string_id].Descriptor_Size = desc_size;
}
}
static ONE_DESCRIPTOR Hid_Interface_Descriptor;
void PIOS_USBHOOK_RegisterHidInterface(const uint8_t * desc, uint16_t desc_size)
{
Hid_Interface_Descriptor.Descriptor = desc;
Hid_Interface_Descriptor.Descriptor_Size = desc_size;
}
static ONE_DESCRIPTOR Hid_Report_Descriptor;
void PIOS_USBHOOK_RegisterHidReport(const uint8_t * desc, uint16_t desc_size)
{
Hid_Report_Descriptor.Descriptor = desc;
Hid_Report_Descriptor.Descriptor_Size = desc_size;
}
#include "stm32f10x.h" /* __IO */
__IO uint8_t EXTI_Enable;
@ -53,9 +95,9 @@ static void PIOS_USBHOOK_Status_Out(void);
static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo);
static RESULT PIOS_USBHOOK_NoData_Setup(uint8_t RequestNo);
static RESULT PIOS_USBHOOK_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting);
static uint8_t *PIOS_USBHOOK_GetDeviceDescriptor(uint16_t Length);
static uint8_t *PIOS_USBHOOK_GetConfigDescriptor(uint16_t Length);
static uint8_t *PIOS_USBHOOK_GetStringDescriptor(uint16_t Length);
static const uint8_t *PIOS_USBHOOK_GetDeviceDescriptor(uint16_t Length);
static const uint8_t *PIOS_USBHOOK_GetConfigDescriptor(uint16_t Length);
static const uint8_t *PIOS_USBHOOK_GetStringDescriptor(uint16_t Length);
DEVICE_PROP Device_Property = {
.Init = PIOS_USBHOOK_Init,
@ -87,49 +129,10 @@ USER_STANDARD_REQUESTS User_Standard_Requests = {
.User_SetDeviceAddress = PIOS_USBHOOK_SetDeviceAddress
};
const static ONE_DESCRIPTOR Device_Descriptor = {
(uint8_t *) &PIOS_USB_BOARD_DeviceDescriptor,
sizeof(PIOS_USB_BOARD_DeviceDescriptor),
};
static ONE_DESCRIPTOR Config_Descriptor = {
(uint8_t *) &PIOS_USB_BOARD_Configuration,
sizeof(PIOS_USB_BOARD_Configuration),
};
const static ONE_DESCRIPTOR Hid_Report_Descriptor = {
(uint8_t *) &PIOS_USB_BOARD_HidReportDescriptor,
sizeof(PIOS_USB_BOARD_HidReportDescriptor),
};
const static ONE_DESCRIPTOR Hid_Interface_Descriptor = {
(uint8_t *) &PIOS_USB_BOARD_Configuration.hid_if,
sizeof(PIOS_USB_BOARD_Configuration.hid_if),
};
const static ONE_DESCRIPTOR String_Descriptor[] = {
{
(uint8_t *) &PIOS_USB_BOARD_StringLangID,
sizeof(PIOS_USB_BOARD_StringLangID),
},
{
(uint8_t *) PIOS_USB_BOARD_StringVendorID,
sizeof(PIOS_USB_BOARD_StringVendorID),
},
{
(uint8_t *) PIOS_USB_BOARD_StringProductID,
sizeof(PIOS_USB_BOARD_StringProductID),
},
{
(uint8_t *) PIOS_USB_BOARD_StringSerial,
sizeof(PIOS_USB_BOARD_StringSerial),
},
};
static RESULT PIOS_USBHOOK_SetProtocol(void);
static uint8_t *PIOS_USBHOOK_GetProtocolValue(uint16_t Length);
static uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length);
static uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length);
static const uint8_t *PIOS_USBHOOK_GetProtocolValue(uint16_t Length);
static const uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length);
static const uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length);
/*******************************************************************************
* Function Name : PIOS_USBHOOK_Init.
@ -140,11 +143,8 @@ static uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length);
*******************************************************************************/
static void PIOS_USBHOOK_Init(void)
{
/* Update the serial number string descriptor with the data from the unique
ID */
//Get_SerialNum();
pInformation->Current_Configuration = 0;
/* Connect the device */
PowerOn();
@ -292,7 +292,7 @@ static void PIOS_USBHOOK_Status_Out(void)
*******************************************************************************/
static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
{
uint8_t *(*CopyRoutine) (uint16_t);
const uint8_t *(*CopyRoutine) (uint16_t);
CopyRoutine = NULL;
@ -350,7 +350,7 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
return USB_UNSUPPORT;
}
pInformation->Ctrl_Info.CopyData = CopyRoutine;
pInformation->Ctrl_Info.CopyDataIn = CopyRoutine;
pInformation->Ctrl_Info.Usb_wOffset = 0;
(*CopyRoutine) (0);
return USB_SUCCESS;
@ -405,7 +405,7 @@ static RESULT PIOS_USBHOOK_NoData_Setup(uint8_t RequestNo)
* Output : None.
* Return : The address of the device descriptor.
*******************************************************************************/
static uint8_t *PIOS_USBHOOK_GetDeviceDescriptor(uint16_t Length)
static const uint8_t *PIOS_USBHOOK_GetDeviceDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Device_Descriptor);
}
@ -417,7 +417,7 @@ static uint8_t *PIOS_USBHOOK_GetDeviceDescriptor(uint16_t Length)
* Output : None.
* Return : The address of the configuration descriptor.
*******************************************************************************/
static uint8_t *PIOS_USBHOOK_GetConfigDescriptor(uint16_t Length)
static const uint8_t *PIOS_USBHOOK_GetConfigDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Config_Descriptor);
}
@ -429,7 +429,7 @@ static uint8_t *PIOS_USBHOOK_GetConfigDescriptor(uint16_t Length)
* Output : None.
* Return : The address of the string descriptors.
*******************************************************************************/
static uint8_t *PIOS_USBHOOK_GetStringDescriptor(uint16_t Length)
static const uint8_t *PIOS_USBHOOK_GetStringDescriptor(uint16_t Length)
{
uint8_t wValue0 = pInformation->USBwValue0;
if (wValue0 > 4) {
@ -446,7 +446,7 @@ static uint8_t *PIOS_USBHOOK_GetStringDescriptor(uint16_t Length)
* Output : None.
* Return : The address of the configuration descriptor.
*******************************************************************************/
static uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length)
static const uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Hid_Report_Descriptor);
}
@ -458,7 +458,7 @@ static uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length)
* Output : None.
* Return : The address of the configuration descriptor.
*******************************************************************************/
static uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length)
static const uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Hid_Interface_Descriptor);
}
@ -503,7 +503,7 @@ static RESULT PIOS_USBHOOK_SetProtocol(void)
* Output : None.
* Return : address of the protcol value.
*******************************************************************************/
static uint8_t *PIOS_USBHOOK_GetProtocolValue(uint16_t Length)
static const uint8_t *PIOS_USBHOOK_GetProtocolValue(uint16_t Length)
{
if (Length == 0) {
pInformation->Ctrl_Info.Usb_wLength = 1;

View File

@ -31,6 +31,9 @@
#ifndef PIOS_COM_H
#define PIOS_COM_H
#include <stdint.h> /* uint*_t */
#include <stdbool.h> /* bool */
typedef uint16_t (*pios_com_callback)(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * task_woken);
struct pios_com_driver {
@ -43,7 +46,6 @@ struct pios_com_driver {
};
/* Public Functions */
extern int32_t PIOS_COM_Init(uint32_t * com_id, const struct pios_com_driver * driver, uint32_t lower_id, uint8_t * rx_buffer, uint16_t rx_buffer_len, uint8_t * tx_buffer, uint16_t tx_buffer_len);
extern int32_t PIOS_COM_ChangeBaud(uint32_t com_id, uint32_t baud);
extern int32_t PIOS_COM_SendCharNonBlocking(uint32_t com_id, char c);
extern int32_t PIOS_COM_SendChar(uint32_t com_id, char c);

View File

@ -0,0 +1,45 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_COM COM MSG layer functions
* @brief Hardware communication layer
* @{
*
* @file pios_com_msg.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief COM MSG layer functions header
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_COM_MSG_H
#define PIOS_COM_MSG_H
#include <stdint.h> /* uint*_t */
/* Public Functions */
extern int32_t PIOS_COM_MSG_Send(uint32_t com_id, const uint8_t *msg, uint16_t msg_len);
extern uint16_t PIOS_COM_MSG_Receive(uint32_t com_id, uint8_t * buf, uint16_t buf_len);
#endif /* PIOS_COM_MSG_H */
/**
* @}
* @}
*/

View File

@ -1,12 +1,14 @@
/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
* @addtogroup PIOS_COM COM MSG layer functions
* @brief Hardware communication layer
* @{
* @file taskmonitor.h
*
* @file pios_com_msg_priv.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Include file of the task monitoring library
* @brief COM MSG private definitions.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
@ -25,16 +27,16 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TASKMONITOR_H
#define TASKMONITOR_H
#include "taskinfo.h"
#ifndef PIOS_COM_MSG_PRIV_H
#define PIOS_COM_MSG_PRIV_H
int32_t TaskMonitorInitialize(void);
int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle);
void TaskMonitorUpdateAll(void);
#include <stdint.h> /* uint*_t */
#include "pios_com_priv.h" /* struct pios_com_driver */
#endif // TASKMONITOR_H
extern int32_t PIOS_COM_MSG_Init(uint32_t * com_id, const struct pios_com_driver * driver, uint32_t lower_id);
#endif /* PIOS_COM_MSG_PRIV_H */
/**
* @}

View File

@ -31,6 +31,8 @@
#ifndef PIOS_COM_PRIV_H
#define PIOS_COM_PRIV_H
extern int32_t PIOS_COM_Init(uint32_t * com_id, const struct pios_com_driver * driver, uint32_t lower_id, uint8_t * rx_buffer, uint16_t rx_buffer_len, uint8_t * tx_buffer, uint16_t tx_buffer_len);
#endif /* PIOS_COM_PRIV_H */
/**

View File

@ -0,0 +1,40 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_USB_BOARD USB board layer functions
* @{
*
* @file pios_usb_board_data_priv.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Defines the API to the board-specific USB data setup code
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_USB_BOARD_DATA_PRIV_H
#define PIOS_USB_BOARD_DATA_PRIV_H
extern int32_t PIOS_USB_BOARD_DATA_Init(void);
#endif /* PIOS_USB_BOARD_DATA_PRIV_H */
/**
* @}
* @}
*/

View File

@ -46,7 +46,7 @@ extern const struct pios_com_driver pios_usb_cdc_com_driver;
extern int32_t PIOS_USB_CDC_Init(uint32_t * usbcdc_id, const struct pios_usb_cdc_cfg * cfg, uint32_t lower_id);
extern uint8_t *PIOS_USB_CDC_GetLineCoding(uint16_t Length);
extern const uint8_t *PIOS_USB_CDC_GetLineCoding(uint16_t Length);
extern RESULT PIOS_USB_CDC_SetControlLineState(void);
extern RESULT PIOS_USB_CDC_SetLineCoding(void);

View File

@ -0,0 +1,42 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_USB_DESC USB descriptor layer functions
* @{
*
* @file pios_usb_desc_hid_cdc_priv.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Defines the API to set up the HID + CDC USB descriptor config
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_USB_DESC_HID_CDC_PRIV_H
#define PIOS_USB_DESC_HID_CDC_PRIV_H
#include <stdint.h>
extern int32_t PIOS_USB_DESC_HID_CDC_Init(void);
#endif /* PIOS_USB_DESC_HID_CDC_PRIV_H */
/**
* @}
* @}
*/

View File

@ -0,0 +1,42 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_USB_DESC USB descriptor layer functions
* @{
*
* @file pios_usb_desc_hid_only_priv.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Defines the API to set up the HID-only USB descriptor config
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_USB_DESC_HID_ONLY_PRIV_H
#define PIOS_USB_DESC_HID_ONLY_PRIV_H
#include <stdint.h>
extern int32_t PIOS_USB_DESC_HID_ONLY_Init(void);
#endif /* PIOS_USB_DESC_HID_ONLY_PRIV_H */
/**
* @}
* @}
*/

View File

@ -47,5 +47,18 @@ typedef enum CDC_REQUESTS {
SET_CONTROL_LINE_STATE = 0x23,
} CDC_REQUESTS;
enum usb_string_desc {
USB_STRING_DESC_LANG = 0,
USB_STRING_DESC_VENDOR = 1,
USB_STRING_DESC_PRODUCT = 2,
USB_STRING_DESC_SERIAL = 3,
} __attribute__((packed));
extern void PIOS_USBHOOK_RegisterDevice(const uint8_t * desc, uint16_t desc_size);
extern void PIOS_USBHOOK_RegisterConfig(uint8_t config_id, const uint8_t * desc, uint16_t desc_size);
extern void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t * desc, uint16_t desc_size);
extern void PIOS_USBHOOK_RegisterHidInterface(const uint8_t * desc, uint16_t desc_size);
extern void PIOS_USBHOOK_RegisterHidReport(const uint8_t * desc, uint16_t desc_size);
#endif /* PIOS_USBHOOK_H */

View File

@ -112,7 +112,10 @@
#if defined(PIOS_INCLUDE_IMU3000)
#include <pios_imu3000.h>
#endif
#if defined(PIOS_INCLUDE_IAP)
#include <pios_iap.h>
#endif
#if defined(PIOS_INCLUDE_ADXL345)
#include <pios_adxl345.h>
@ -134,6 +137,7 @@
#if defined(PIOS_INCLUDE_USB)
/* USB Libs */
#include <usb_lib.h>
#include <pios_usb.h>
#endif
#include <pios_crc.h>

View File

@ -37,33 +37,6 @@
#include "pios_usb_defs.h" /* struct usb_* */
struct usb_board_config {
struct usb_configuration_desc config;
struct usb_interface_desc hid_if;
struct usb_hid_desc hid;
struct usb_endpoint_desc hid_in;
struct usb_endpoint_desc hid_out;
} __attribute__((packed));
extern const struct usb_device_desc PIOS_USB_BOARD_DeviceDescriptor;
extern const struct usb_board_config PIOS_USB_BOARD_Configuration;
extern const struct usb_string_langid PIOS_USB_BOARD_StringLangID;
/* NOTE NOTE NOTE
*
* Care must be taken to ensure that the _actual_ contents of
* these arrays (in each board's pios_usb_board_data.c) is no
* smaller than the stated sizes here or these descriptors
* will end up with trailing zeros on the wire.
*
* The compiler will catch any time that these definitions are
* too small.
*/
extern const uint8_t PIOS_USB_BOARD_HidReportDescriptor[36];
extern const uint8_t PIOS_USB_BOARD_StringVendorID[28];
extern const uint8_t PIOS_USB_BOARD_StringProductID[20];
extern uint8_t PIOS_USB_BOARD_StringSerial[52];
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_PIPXTREME
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_PIPXTREME, USB_OP_BOARD_MODE_FW)

View File

@ -1,56 +0,0 @@
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
* File Name : usb_desc.h
* Author : MCD Application Team
* Version : V3.2.1
* Date : 07/05/2010
* Description : Descriptor Header for Custom HID Demo
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_DESC_H
#define __USB_DESC_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
#define USB_STRING_DESCRIPTOR_TYPE 0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
#define HID_DESCRIPTOR_TYPE 0x21
#define PIOS_HID_SIZ_HID_DESC 0x09
#define PIOS_HID_OFF_HID_DESC 0x12
#define PIOS_HID_SIZ_DEVICE_DESC 18
#define PIOS_HID_SIZ_CONFIG_DESC 41
#define PIOS_HID_SIZ_REPORT_DESC 36
#define PIOS_HID_SIZ_STRING_LANGID 4
#define PIOS_HID_SIZ_STRING_VENDOR 28
#define PIOS_HID_SIZ_STRING_PRODUCT 20
#define PIOS_HID_SIZ_STRING_SERIAL 52 /* 96 bits, 12 bytes, 24 characters, 48 in unicode */
#define STANDARD_ENDPOINT_DESC_SIZE 0x09
/* Exported functions ------------------------------------------------------- */
extern const uint8_t PIOS_HID_DeviceDescriptor[PIOS_HID_SIZ_DEVICE_DESC];
extern const uint8_t PIOS_HID_ConfigDescriptor[PIOS_HID_SIZ_CONFIG_DESC];
extern const uint8_t PIOS_HID_ReportDescriptor[PIOS_HID_SIZ_REPORT_DESC];
extern const uint8_t PIOS_HID_StringLangID[PIOS_HID_SIZ_STRING_LANGID];
extern const uint8_t PIOS_HID_StringVendor[PIOS_HID_SIZ_STRING_VENDOR];
extern const uint8_t PIOS_HID_StringProduct[PIOS_HID_SIZ_STRING_PRODUCT];
extern uint8_t PIOS_HID_StringSerial[PIOS_HID_SIZ_STRING_SERIAL];
#endif /* __USB_DESC_H */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

View File

@ -324,6 +324,10 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
},
},
};
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_USB_HID)
@ -369,10 +373,16 @@ void PIOS_Board_Init(void) {
}
#if defined(PIOS_INCLUDE_USB)
uint32_t pios_usb_id;
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
if (PIOS_USB_DESC_HID_ONLY_Init()) {
PIOS_Assert(0);
}
uint32_t pios_usb_id;
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM)
uint32_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {

View File

@ -29,9 +29,11 @@
*/
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
const uint8_t PIOS_USB_BOARD_StringProductID[] = {
sizeof(PIOS_USB_BOARD_StringProductID),
static const uint8_t usb_product_id[20] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'P', 0,
'i', 0,
@ -44,3 +46,74 @@ const uint8_t PIOS_USB_BOARD_StringProductID[] = {
'e', 0,
};
static uint8_t usb_serial_number[52] = {
sizeof(usb_serial_number),
USB_DESC_TYPE_STRING,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
static const struct usb_string_langid usb_lang_id = {
.bLength = sizeof(usb_lang_id),
.bDescriptorType = USB_DESC_TYPE_STRING,
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
};
static const uint8_t usb_vendor_id[28] = {
sizeof(usb_vendor_id),
USB_DESC_TYPE_STRING,
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
int32_t PIOS_USB_BOARD_DATA_Init(void)
{
/* Load device serial number into serial number string */
uint8_t sn[25];
PIOS_SYS_SerialNumberGet((char *)sn);
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
usb_serial_number[2 + 2 * i] = sn[i];
}
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
return 0;
}

View File

@ -1,220 +0,0 @@
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
* File Name : usb_desc.c
* Author : MCD Application Team
* Version : V3.2.1
* Date : 07/05/2010
* Description : Descriptors for Custom HID Demo
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#include "usb_lib.h"
#include "pios_usb.h"
#include "pios_usb_hid.h"
#include "pios_usb_hid_desc.h"
// *************************************************
// USB Standard Device Descriptor
const uint8_t PIOS_HID_DeviceDescriptor[PIOS_HID_SIZ_DEVICE_DESC] =
{
0x12, // bLength
USB_DEVICE_DESCRIPTOR_TYPE, // bDescriptorType
0x00, // bcdUSB
0x02,
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
0x40, // bMaxPacketSize40
(uint8_t)((PIOS_USB_VENDOR_ID) & 0xff), // idVendor
(uint8_t)((PIOS_USB_VENDOR_ID) >> 8),
(uint8_t)((PIOS_USB_PRODUCT_ID) & 0xff), // idProduct
(uint8_t)((PIOS_USB_PRODUCT_ID) >> 8),
(uint8_t)((PIOS_USB_VERSION_ID) & 0xff), // bcdDevice
(uint8_t)((PIOS_USB_VERSION_ID) >> 8),
0x01, // Index of string descriptor describing manufacturer
0x02, // Index of string descriptor describing product
0x03, // Index of string descriptor describing the device serial number
0x01 // bNumConfigurations
};
// *************************************************
// USB Configuration Descriptor
// All Descriptors (Configuration, Interface, Endpoint, Class, Vendor
const uint8_t PIOS_HID_ConfigDescriptor[PIOS_HID_SIZ_CONFIG_DESC] =
{
0x09, // bLength: Configuation Descriptor size
USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType: Configuration
PIOS_HID_SIZ_CONFIG_DESC,
// wTotalLength: Bytes returned
0x00,
0x01, // bNumInterfaces: 1 interface
0x01, // bConfigurationValue: Configuration value
0x00, // iConfiguration: Index of string descriptor describing the configuration
0xC0, // bmAttributes: Bus powered
0x7D, // MaxPower 250 mA - needed to power the RF transmitter
// ************** Descriptor of Custom HID interface ****************
// 09
0x09, // bLength: Interface Descriptor size
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType: Interface descriptor type
0x00, // bInterfaceNumber: Number of Interface
0x00, // bAlternateSetting: Alternate setting
0x02, // bNumEndpoints
0x03, // bInterfaceClass: HID
0x00, // bInterfaceSubClass : 1=BOOT, 0=no boot
0x00, // nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
0, // iInterface: Index of string descriptor
// ******************** Descriptor of Custom HID HID ********************
// 18
0x09, // bLength: HID Descriptor size
HID_DESCRIPTOR_TYPE, // bDescriptorType: HID
0x10, // bcdHID: HID Class Spec release number
0x01,
0x00, // bCountryCode: Hardware target country
0x01, // bNumDescriptors: Number of HID class descriptors to follow
0x22, // bDescriptorType
PIOS_HID_SIZ_REPORT_DESC, // wItemLength: Total length of Report descriptor
0x00,
// ******************** Descriptor of Custom HID endpoints ******************
// 27
0x07, // bLength: Endpoint Descriptor size
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType:
0x81, // bEndpointAddress: Endpoint Address (IN)
0x03, // bmAttributes: Interrupt endpoint
0x40, // wMaxPacketSize: 2 Bytes max
0x00,
0x04, // bInterval: Polling Interval in ms
// 34
0x07, // bLength: Endpoint Descriptor size
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType:
// Endpoint descriptor type
0x01, // bEndpointAddress:
// Endpoint Address (OUT)
0x03, // bmAttributes: Interrupt endpoint
0x40, // wMaxPacketSize: 2 Bytes max
0x00,
0x04, // bInterval: Polling Interval in ms
// 41
};
// *************************************************
const uint8_t PIOS_HID_ReportDescriptor[PIOS_HID_SIZ_REPORT_DESC] =
{
0x06, 0x9c, 0xff, // USAGE_PAGE (Vendor Page: 0xFF00)
0x09, 0x01, // USAGE (Demo Kit)
0xa1, 0x01, // COLLECTION (Application)
// 6
// Data 1
0x85, 0x01, // REPORT_ID (1)
0x09, 0x02, // USAGE (LED 1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0xff, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, PIOS_USB_COM_DATA_LENGTH+1, // REPORT_COUNT (1)
0x81, 0x83, // INPUT (Const,Var,Array)
// 20
// Data 1
0x85, 0x02, // REPORT_ID (2)
0x09, 0x03, // USAGE (LED 1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0xff, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, PIOS_USB_COM_DATA_LENGTH+1, // REPORT_COUNT (1)
0x91, 0x82, // OUTPUT (Data,Var,Abs,Vol)
// 34
0xc0 // END_COLLECTION
};
// *************************************************
// USB String Descriptors (optional)
const uint8_t PIOS_HID_StringLangID[PIOS_HID_SIZ_STRING_LANGID] =
{
PIOS_HID_SIZ_STRING_LANGID,
USB_STRING_DESCRIPTOR_TYPE,
0x09, 0x08 // LangID = 0x0809: UK. English
// 0x09, 0x04 // LangID = 0x0409: U.S. English
};
const uint8_t PIOS_HID_StringVendor[PIOS_HID_SIZ_STRING_VENDOR] =
{
PIOS_HID_SIZ_STRING_VENDOR, // Size of Vendor string
USB_STRING_DESCRIPTOR_TYPE, // bDescriptorType
// Manufacturer: "STMicroelectronics"
'o', 0,
'p', 0,
'e', 0,
'n', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0,
'.', 0,
'o', 0,
'r', 0,
'g', 0
};
const uint8_t PIOS_HID_StringProduct[PIOS_HID_SIZ_STRING_PRODUCT] =
{
PIOS_HID_SIZ_STRING_PRODUCT, // bLength
USB_STRING_DESCRIPTOR_TYPE, // bDescriptorType
'P', 0,
'i', 0,
'p', 0,
'X', 0,
't', 0,
'r', 0,
'e', 0,
'm', 0,
'e', 0
};
uint8_t PIOS_HID_StringSerial[PIOS_HID_SIZ_STRING_SERIAL] =
{
PIOS_HID_SIZ_STRING_SERIAL, // bLength
USB_STRING_DESCRIPTOR_TYPE, // bDescriptorType
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0
};
// *************************************************

View File

@ -1,6 +1,6 @@
BOARD_TYPE := 0x01
BOARD_REVISION := 0x01
BOOTLOADER_VERSION := 0x00
BOOTLOADER_VERSION := 0x01
HW_TYPE := 0x00
MCU := cortex-m3

View File

@ -1,6 +1,6 @@
BOARD_TYPE := 0x03
BOARD_REVISION := 0x01
BOOTLOADER_VERSION := 0x00
BOOTLOADER_VERSION := 0x01
HW_TYPE := 0x01
MCU := cortex-m3

View File

@ -12,6 +12,7 @@
<field name="TelemetrySpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="57600"/>
<field name="GPSSpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="57600"/>
<field name="ComUsbBridgeSpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="57600"/>
<field name="USB_DeviceType" units="descriptor" type="enum" elements="1" options="HID-only,HID+VCP,VCP-only" defaultvalue="HID-only"/>
<field name="USB_HIDPort" units="function" type="enum" elements="1" options="USBTelemetry,Disabled" defaultvalue="USBTelemetry"/>
<field name="USB_VCPPort" units="function" type="enum" elements="1" options="USBTelemetry,ComBridge,Disabled" defaultvalue="Disabled"/>