mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Merge branch 'basenext' into corvuscorax/new_navigation
This commit is contained in:
commit
ea7d9b6610
2
Makefile
2
Makefile
@ -232,7 +232,7 @@ openocd_install: openocd_clean
|
||||
$(V1) mkdir -p "$(OPENOCD_DIR)"
|
||||
$(V1) ( \
|
||||
cd $(OPENOCD_BUILD_DIR)/openocd-0.5.0 ; \
|
||||
./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate; \
|
||||
./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi ; \
|
||||
$(MAKE) --silent ; \
|
||||
$(MAKE) --silent install ; \
|
||||
)
|
||||
|
@ -28,6 +28,7 @@
|
||||
/* Bootloader Includes */
|
||||
#include <pios.h>
|
||||
#include <stdbool.h>
|
||||
#include "pios_board_info.h"
|
||||
|
||||
#define MAX_WRI_RETRYS 3
|
||||
/* Prototype of PIOS_Board_Init() function */
|
||||
@ -56,6 +57,31 @@ int main() {
|
||||
if ((0x08000000 + embedded_image_size) > base_address)
|
||||
error();
|
||||
///
|
||||
|
||||
/*
|
||||
* Make sure the bootloader we're carrying is for the same
|
||||
* board type and board revision as the one we're running on.
|
||||
*
|
||||
* Assume the bootloader in flash and the bootloader contained in
|
||||
* the updater both carry a board_info_blob at the end of the image.
|
||||
*/
|
||||
|
||||
/* Calculate how far the board_info_blob is from the beginning of the bootloader */
|
||||
uint32_t board_info_blob_offset = (uint32_t)&pios_board_info_blob - (uint32_t)0x08000000;
|
||||
|
||||
/* Use the same offset into our embedded bootloader image */
|
||||
struct pios_board_info * new_board_info_blob = (struct pios_board_info *)
|
||||
((uint32_t)embedded_image_start + board_info_blob_offset);
|
||||
|
||||
/* Compare the two board info blobs to make sure they're for the same HW revision */
|
||||
if ((pios_board_info_blob.magic != new_board_info_blob->magic) ||
|
||||
(pios_board_info_blob.board_type != new_board_info_blob->board_type) ||
|
||||
(pios_board_info_blob.board_rev != new_board_info_blob->board_rev)) {
|
||||
error();
|
||||
}
|
||||
|
||||
/* Embedded bootloader looks like it's the right one for this HW, proceed... */
|
||||
|
||||
FLASH_Unlock();
|
||||
|
||||
/// Bootloader memory space erase
|
||||
|
@ -115,6 +115,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_only.c
|
||||
SRC += $(PIOSCOMMON)/pios_usb_util.c
|
||||
|
||||
## PIOS Hardware (Common)
|
||||
SRC += $(PIOSCOMMON)/pios_board_info.c
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#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)
|
||||
#define PIOS_USB_BOARD_SN_SUFFIX "+BL"
|
||||
|
||||
/*
|
||||
* The bootloader uses a simplified report structure
|
||||
|
@ -74,7 +74,7 @@ int main() {
|
||||
PIOS_Board_Init();
|
||||
PIOS_IAP_Init();
|
||||
|
||||
USB_connected = PIOS_USB_CheckAvailable(0);
|
||||
USB_connected = PIOS_USB_CableConnected(0);
|
||||
|
||||
if (PIOS_IAP_CheckRequest() == TRUE) {
|
||||
PIOS_DELAY_WaitmS(1000);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
|
||||
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
|
||||
|
||||
static const uint8_t usb_product_id[28] = {
|
||||
sizeof(usb_product_id),
|
||||
@ -50,40 +51,15 @@ static const uint8_t usb_product_id[28] = {
|
||||
'l', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[52] = {
|
||||
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
|
||||
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),
|
||||
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
|
||||
};
|
||||
|
||||
static const uint8_t usb_vendor_id[28] = {
|
||||
@ -107,11 +83,13 @@ static const uint8_t usb_vendor_id[28] = {
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25];
|
||||
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
|
||||
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];
|
||||
}
|
||||
|
||||
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
|
||||
uint8_t * utf8 = &(usb_serial_number[2]);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
|
||||
|
||||
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));
|
||||
|
@ -114,6 +114,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_only.c
|
||||
SRC += $(PIOSCOMMON)/pios_usb_util.c
|
||||
|
||||
## PIOS Hardware (Common)
|
||||
SRC += $(PIOSCOMMON)/pios_board_info.c
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#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)
|
||||
#define PIOS_USB_BOARD_SN_SUFFIX "+BL"
|
||||
|
||||
/*
|
||||
* The bootloader uses a simplified report structure
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
|
||||
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
|
||||
|
||||
static const uint8_t usb_product_id[20] = {
|
||||
sizeof(usb_product_id),
|
||||
@ -46,40 +47,15 @@ static const uint8_t usb_product_id[20] = {
|
||||
'e', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[52] = {
|
||||
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
|
||||
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),
|
||||
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
|
||||
};
|
||||
|
||||
static const uint8_t usb_vendor_id[28] = {
|
||||
@ -103,11 +79,13 @@ static const uint8_t usb_vendor_id[28] = {
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25];
|
||||
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
|
||||
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];
|
||||
}
|
||||
|
||||
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
|
||||
uint8_t * utf8 = &(usb_serial_number[2]);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
|
||||
|
||||
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));
|
||||
|
@ -243,6 +243,7 @@ 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
|
||||
SRC += $(PIOSCOMMON)/pios_usb_util.c
|
||||
|
||||
## PIOS Hardware (Common)
|
||||
SRC += $(PIOSCOMMON)/pios_crc.c
|
||||
|
@ -41,5 +41,6 @@
|
||||
|
||||
#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)
|
||||
#define PIOS_USB_BOARD_SN_SUFFIX "+FW"
|
||||
|
||||
#endif /* PIOS_USB_BOARD_DATA_H */
|
||||
|
@ -246,32 +246,23 @@ void PIOS_Board_Init(void) {
|
||||
/* 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:
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
if (PIOS_USB_DESC_HID_CDC_Init()) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
usb_hid_present = true;
|
||||
usb_cdc_present = true;
|
||||
#else
|
||||
if (PIOS_USB_DESC_HID_ONLY_Init()) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
usb_hid_present = true;
|
||||
#endif
|
||||
|
||||
uint32_t pios_usb_id;
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
|
||||
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
|
||||
|
||||
static const uint8_t usb_product_id[28] = {
|
||||
sizeof(usb_product_id),
|
||||
@ -50,40 +51,15 @@ static const uint8_t usb_product_id[28] = {
|
||||
'l', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[52] = {
|
||||
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
|
||||
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),
|
||||
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
|
||||
};
|
||||
|
||||
static const uint8_t usb_vendor_id[28] = {
|
||||
@ -107,11 +83,13 @@ static const uint8_t usb_vendor_id[28] = {
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25];
|
||||
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
|
||||
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];
|
||||
}
|
||||
|
||||
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
|
||||
uint8_t * utf8 = &(usb_serial_number[2]);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
|
||||
|
||||
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));
|
||||
|
@ -38,9 +38,9 @@ static const struct usb_device_desc device_desc = {
|
||||
.bLength = sizeof(struct usb_device_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_DEVICE,
|
||||
.bcdUSB = htousbs(0x0200),
|
||||
.bDeviceClass = 0x02,
|
||||
.bDeviceSubClass = 0x00,
|
||||
.bDeviceProtocol = 0x00,
|
||||
.bDeviceClass = 0xef,
|
||||
.bDeviceSubClass = 0x02,
|
||||
.bDeviceProtocol = 0x01,
|
||||
.bMaxPacketSize0 = 64, /* Must be 64 for high-speed devices */
|
||||
.idVendor = htousbs(USB_VENDOR_ID_OPENPILOT),
|
||||
.idProduct = htousbs(PIOS_USB_BOARD_PRODUCT_ID),
|
||||
@ -98,10 +98,6 @@ static const uint8_t hid_report_desc[36] = {
|
||||
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;
|
||||
@ -111,6 +107,10 @@ struct usb_config_hid_cdc {
|
||||
struct usb_interface_desc cdc_data_if;
|
||||
struct usb_endpoint_desc cdc_in;
|
||||
struct usb_endpoint_desc cdc_out;
|
||||
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));
|
||||
|
||||
static const struct usb_config_hid_cdc config_hid_cdc = {
|
||||
@ -129,15 +129,87 @@ static const struct usb_config_hid_cdc config_hid_cdc = {
|
||||
.bDescriptorType = USB_DESC_TYPE_IAD,
|
||||
.bFirstInterface = 0,
|
||||
.bInterfaceCount = 2,
|
||||
.bFunctionClass = 2, /* Communication */
|
||||
.bFunctionSubClass = 2, /* Abstract Control Model */
|
||||
.bFunctionProtocol = 0, /* V.25ter, Common AT commands */
|
||||
.bFunctionClass = USB_INTERFACE_CLASS_CDC, /* Communication */
|
||||
.bFunctionSubClass = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL, /* Abstract Control Model */
|
||||
.bFunctionProtocol = 1, /* V.25ter, Common AT commands */
|
||||
.iInterface = 0,
|
||||
},
|
||||
.cdc_control_if = {
|
||||
.bLength = sizeof(struct usb_interface_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||
.bInterfaceNumber = 0,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 1,
|
||||
.bInterfaceClass = USB_INTERFACE_CLASS_CDC,
|
||||
.bInterfaceSubClass = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL, /* Abstract Control Model */
|
||||
.nInterfaceProtocol = 1, /* V.25ter, Common AT commands */
|
||||
.iInterface = 0,
|
||||
},
|
||||
.cdc_header = {
|
||||
.bLength = sizeof(struct usb_cdc_header_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_HEADER,
|
||||
.bcdCDC = htousbs(0x0110),
|
||||
},
|
||||
.cdc_callmgmt = {
|
||||
.bLength = sizeof(struct usb_cdc_callmgmt_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_CALLMGMT,
|
||||
.bmCapabilities = 0x00, /* No call handling */
|
||||
.bDataInterface = 1,
|
||||
},
|
||||
.cdc_acm = {
|
||||
.bLength = sizeof(struct usb_cdc_acm_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL,
|
||||
.bmCapabilities = 0x00,
|
||||
},
|
||||
.cdc_union = {
|
||||
.bLength = sizeof(struct usb_cdc_union_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_UNION,
|
||||
.bMasterInterface = 0,
|
||||
.bSlaveInterface = 1,
|
||||
},
|
||||
.cdc_mgmt_in = {
|
||||
.bLength = sizeof(struct usb_endpoint_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||
.bEndpointAddress = USB_EP_IN(2),
|
||||
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_MGMT_LENGTH),
|
||||
.bInterval = 4, /* ms */
|
||||
},
|
||||
.cdc_data_if = {
|
||||
.bLength = sizeof(struct usb_interface_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||
.bInterfaceNumber = 1,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = USB_INTERFACE_CLASS_DATA,
|
||||
.bInterfaceSubClass = 0,
|
||||
.nInterfaceProtocol = 0, /* No class specific protocol */
|
||||
.iInterface = 0,
|
||||
},
|
||||
.cdc_in = {
|
||||
.bLength = sizeof(struct usb_endpoint_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||
.bEndpointAddress = USB_EP_IN(3),
|
||||
.bmAttributes = USB_EP_ATTR_TT_BULK,
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
||||
.bInterval = 0, /* ms */
|
||||
},
|
||||
.cdc_out = {
|
||||
.bLength = sizeof(struct usb_endpoint_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||
.bEndpointAddress = USB_EP_OUT(3),
|
||||
.bmAttributes = USB_EP_ATTR_TT_BULK, /* Bulk */
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
||||
.bInterval = 0, /* ms */
|
||||
},
|
||||
.hid_if = {
|
||||
.bLength = sizeof(struct usb_interface_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||
.bInterfaceNumber = 0,
|
||||
.bInterfaceNumber = 2,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = USB_INTERFACE_CLASS_HID,
|
||||
@ -170,78 +242,6 @@ static const struct usb_config_hid_cdc config_hid_cdc = {
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
|
||||
.bInterval = 4, /* ms */
|
||||
},
|
||||
.cdc_control_if = {
|
||||
.bLength = sizeof(struct usb_interface_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||
.bInterfaceNumber = 1,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 1,
|
||||
.bInterfaceClass = USB_INTERFACE_CLASS_CDC,
|
||||
.bInterfaceSubClass = 2, /* Abstract Control Model */
|
||||
.nInterfaceProtocol = 1, /* V.25ter, Common AT commands */
|
||||
.iInterface = 0,
|
||||
},
|
||||
.cdc_header = {
|
||||
.bLength = sizeof(struct usb_cdc_header_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_HEADER,
|
||||
.bcdCDC = htousbs(0x0110),
|
||||
},
|
||||
.cdc_callmgmt = {
|
||||
.bLength = sizeof(struct usb_cdc_callmgmt_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_CALLMGMT,
|
||||
.bmCapabilities = 0x00, /* No call handling */
|
||||
.bDataInterface = 2,
|
||||
},
|
||||
.cdc_acm = {
|
||||
.bLength = sizeof(struct usb_cdc_acm_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL,
|
||||
.bmCapabilities = 0,
|
||||
},
|
||||
.cdc_union = {
|
||||
.bLength = sizeof(struct usb_cdc_union_func_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_UNION,
|
||||
.bMasterInterface = 1,
|
||||
.bSlaveInterface = 2,
|
||||
},
|
||||
.cdc_mgmt_in = {
|
||||
.bLength = sizeof(struct usb_endpoint_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||
.bEndpointAddress = USB_EP_IN(2),
|
||||
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_MGMT_LENGTH),
|
||||
.bInterval = 4, /* ms */
|
||||
},
|
||||
.cdc_data_if = {
|
||||
.bLength = sizeof(struct usb_interface_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||
.bInterfaceNumber = 2,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = USB_INTERFACE_CLASS_DATA,
|
||||
.bInterfaceSubClass = 0,
|
||||
.nInterfaceProtocol = 0, /* No class specific protocol */
|
||||
.iInterface = 0,
|
||||
},
|
||||
.cdc_in = {
|
||||
.bLength = sizeof(struct usb_endpoint_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||
.bEndpointAddress = USB_EP_IN(3),
|
||||
.bmAttributes = USB_EP_ATTR_TT_BULK,
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
||||
.bInterval = 0, /* ms */
|
||||
},
|
||||
.cdc_out = {
|
||||
.bLength = sizeof(struct usb_endpoint_desc),
|
||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||
.bEndpointAddress = USB_EP_OUT(3),
|
||||
.bmAttributes = USB_EP_ATTR_TT_BULK, /* Bulk */
|
||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
||||
.bInterval = 0, /* ms */
|
||||
},
|
||||
};
|
||||
|
||||
int32_t PIOS_USB_DESC_HID_CDC_Init(void)
|
||||
|
42
flight/PiOS/Common/pios_usb_util.c
Normal file
42
flight/PiOS/Common/pios_usb_util.c
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_USB_UTIL USB utility functions
|
||||
* @brief USB utility functions
|
||||
* @{
|
||||
*
|
||||
* @file pios_usb_util.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief USB utility 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
|
||||
*/
|
||||
|
||||
#include "pios_usb_util.h"
|
||||
|
||||
uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srclen)
|
||||
{
|
||||
for (uint8_t i = 0; i < srclen; i++) {
|
||||
*dst = *src;
|
||||
dst += 2;
|
||||
src += 1;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
@ -118,8 +118,8 @@ uint32_t PIOS_SYS_getCPUFlashSize(void)
|
||||
|
||||
/**
|
||||
* Returns the serial number as a string
|
||||
* param[out] str pointer to a string which can store at least 32 digits + zero terminator!
|
||||
* (24 digits returned for STM32)
|
||||
* param[out] uint8_t pointer to a string which can store at least 12 bytes
|
||||
* (12 bytes returned for STM32)
|
||||
* return < 0 if feature not supported
|
||||
*/
|
||||
int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array)
|
||||
@ -127,7 +127,7 @@ int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array)
|
||||
int i;
|
||||
|
||||
/* Stored in the so called "electronic signature" */
|
||||
for (i = 0; i < 12; ++i) {
|
||||
for (i = 0; i < PIOS_SYS_SERIAL_NUM_BINARY_LEN; ++i) {
|
||||
uint8_t b = MEM8(0x1ffff7e8 + i);
|
||||
|
||||
array[i] = b;
|
||||
@ -148,7 +148,7 @@ int32_t PIOS_SYS_SerialNumberGet(char *str)
|
||||
int i;
|
||||
|
||||
/* Stored in the so called "electronic signature" */
|
||||
for (i = 0; i < 24; ++i) {
|
||||
for (i = 0; i < PIOS_SYS_SERIAL_NUM_ASCII_LEN; ++i) {
|
||||
uint8_t b = MEM8(0x1ffff7e8 + (i / 2));
|
||||
if (!(i & 1))
|
||||
b >>= 4;
|
||||
|
@ -40,7 +40,7 @@
|
||||
#if defined(PIOS_INCLUDE_USB_HID)
|
||||
|
||||
/* Rx/Tx status */
|
||||
static uint8_t transfer_possible = 0;
|
||||
static bool transfer_possible = false;
|
||||
|
||||
enum pios_usb_dev_magic {
|
||||
PIOS_USB_DEV_MAGIC = 0x17365904,
|
||||
@ -152,7 +152,7 @@ int32_t PIOS_USB_ChangeConnectionState(bool Connected)
|
||||
{
|
||||
// In all cases: re-initialise USB HID driver
|
||||
if (Connected) {
|
||||
transfer_possible = 1;
|
||||
transfer_possible = true;
|
||||
|
||||
//TODO: Check SetEPRxValid(ENDP1);
|
||||
|
||||
@ -161,7 +161,7 @@ int32_t PIOS_USB_ChangeConnectionState(bool Connected)
|
||||
#endif
|
||||
} else {
|
||||
// Cable disconnected: disable transfers
|
||||
transfer_possible = 0;
|
||||
transfer_possible = false;
|
||||
|
||||
#if defined(USB_LED_OFF)
|
||||
USB_LED_OFF; // turn the USB led off
|
||||
@ -207,23 +207,30 @@ int32_t PIOS_USB_Reenumerate()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PIOS_USB_CableConnected(uint8_t id)
|
||||
{
|
||||
struct pios_usb_dev * usb_dev = (struct pios_usb_dev *) pios_usb_com_id;
|
||||
|
||||
if (PIOS_USB_validate(usb_dev) != 0)
|
||||
return false;
|
||||
|
||||
return usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the connection status of the USB HID interface
|
||||
* \return 1: interface available
|
||||
* \return 0: interface not available
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
uint32_t usb_found;
|
||||
bool PIOS_USB_CheckAvailable(uint8_t id)
|
||||
{
|
||||
struct pios_usb_dev * usb_dev = (struct pios_usb_dev *) pios_usb_com_id;
|
||||
|
||||
if(PIOS_USB_validate(usb_dev) != 0)
|
||||
return 0;
|
||||
if (PIOS_USB_validate(usb_dev) != 0)
|
||||
return false;
|
||||
|
||||
usb_found = (usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin);
|
||||
return usb_found;
|
||||
return usb_found != 0 && transfer_possible ? 1 : 0;
|
||||
return PIOS_USB_CableConnected(id) && transfer_possible;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -304,7 +304,11 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
||||
switch (Type_Recipient) {
|
||||
case (STANDARD_REQUEST | INTERFACE_RECIPIENT):
|
||||
switch (pInformation->USBwIndex0) {
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
case 2: /* HID Interface */
|
||||
#else
|
||||
case 0: /* HID Interface */
|
||||
#endif
|
||||
switch (RequestNo) {
|
||||
case GET_DESCRIPTOR:
|
||||
switch (pInformation->USBwValue1) {
|
||||
@ -321,7 +325,11 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
||||
|
||||
case (CLASS_REQUEST | INTERFACE_RECIPIENT):
|
||||
switch (pInformation->USBwIndex0) {
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
case 2: /* HID Interface */
|
||||
#else
|
||||
case 0: /* HID Interface */
|
||||
#endif
|
||||
switch (RequestNo) {
|
||||
case USB_HID_REQ_GET_PROTOCOL:
|
||||
CopyRoutine = PIOS_USBHOOK_GetProtocolValue;
|
||||
@ -330,16 +338,16 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
||||
|
||||
break;
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
case 1: /* CDC Call Control Interface */
|
||||
case 0: /* CDC Call Control Interface */
|
||||
switch (RequestNo) {
|
||||
case USB_CDC_REQ_GET_LINE_CODING:
|
||||
CopyRoutine = PIOS_USB_CDC_GetLineCoding;
|
||||
//CopyRoutine = PIOS_USB_CDC_GetLineCoding;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2: /* CDC Data Interface */
|
||||
case 1: /* CDC Data Interface */
|
||||
switch (RequestNo) {
|
||||
case 0:
|
||||
break;
|
||||
@ -376,7 +384,11 @@ static RESULT PIOS_USBHOOK_NoData_Setup(uint8_t RequestNo)
|
||||
switch (Type_Recipient) {
|
||||
case (CLASS_REQUEST | INTERFACE_RECIPIENT):
|
||||
switch (pInformation->USBwIndex0) {
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
case 2: /* HID */
|
||||
#else
|
||||
case 0: /* HID */
|
||||
#endif
|
||||
switch (RequestNo) {
|
||||
case USB_HID_REQ_SET_PROTOCOL:
|
||||
return PIOS_USBHOOK_SetProtocol();
|
||||
@ -386,7 +398,7 @@ static RESULT PIOS_USBHOOK_NoData_Setup(uint8_t RequestNo)
|
||||
break;
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
case 1: /* CDC Call Control Interface */
|
||||
case 0: /* CDC Call Control Interface */
|
||||
switch (RequestNo) {
|
||||
case USB_CDC_REQ_SET_LINE_CODING:
|
||||
return PIOS_USB_CDC_SetLineCoding();
|
||||
|
@ -32,12 +32,15 @@
|
||||
#ifndef PIOS_SYS_H
|
||||
#define PIOS_SYS_H
|
||||
|
||||
#define PIOS_SYS_SERIAL_NUM_BINARY_LEN 12
|
||||
#define PIOS_SYS_SERIAL_NUM_ASCII_LEN (PIOS_SYS_SERIAL_NUM_BINARY_LEN * 2)
|
||||
|
||||
/* Public Functions */
|
||||
extern void PIOS_SYS_Init(void);
|
||||
extern int32_t PIOS_SYS_Reset(void);
|
||||
extern uint32_t PIOS_SYS_getCPUFlashSize(void);
|
||||
extern int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array);
|
||||
extern int32_t PIOS_SYS_SerialNumberGet(char *str);
|
||||
extern int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t array[PIOS_SYS_SERIAL_NUM_BINARY_LEN]);
|
||||
extern int32_t PIOS_SYS_SerialNumberGet(char str[PIOS_SYS_SERIAL_NUM_ASCII_LEN+1]);
|
||||
|
||||
#endif /* PIOS_SYS_H */
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
/* Global functions */
|
||||
extern int32_t PIOS_USB_Reenumerate();
|
||||
extern int32_t PIOS_USB_ChangeConnectionState(bool connected);
|
||||
extern bool PIOS_USB_CableConnected(uint8_t id);
|
||||
extern bool PIOS_USB_CheckAvailable(uint8_t id);
|
||||
|
||||
#endif /* PIOS_USB_H */
|
||||
|
@ -300,7 +300,7 @@ struct usb_cdc_union_func_desc {
|
||||
uint8_t bSlaveInterface;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_LANGID_ENGLISH_UK 0x0809
|
||||
#define USB_LANGID_ENGLISH_US 0x0409
|
||||
|
||||
struct usb_string_langid {
|
||||
uint8_t bLength;
|
||||
|
38
flight/PiOS/inc/pios_usb_util.h
Normal file
38
flight/PiOS/inc/pios_usb_util.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_USB_UTIL USB utility functions
|
||||
* @brief USB utility functions
|
||||
* @{
|
||||
*
|
||||
* @file pios_usb_util.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief USB utility 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
|
||||
*/
|
||||
|
||||
#ifndef PIOS_USB_UTIL_H
|
||||
#define PIOS_USB_UTIL_H
|
||||
|
||||
#include <stdint.h> /* uint8_t */
|
||||
|
||||
uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srclen);
|
||||
|
||||
#endif /* PIOS_USB_UTIL_H */
|
@ -118,6 +118,7 @@ ifeq ($(USE_USB), YES)
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c
|
||||
SRC += $(HOME_DIR)/pios_usb_board_data.c
|
||||
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
|
||||
SRC += $(PIOSCOMMON)/pios_usb_util.c
|
||||
endif
|
||||
|
||||
## PIOS Hardware (Common)
|
||||
|
@ -39,5 +39,6 @@
|
||||
|
||||
#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)
|
||||
#define PIOS_USB_BOARD_SN_SUFFIX "+FW"
|
||||
|
||||
#endif /* PIOS_USB_BOARD_DATA_H */
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
|
||||
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
|
||||
|
||||
static const uint8_t usb_product_id[20] = {
|
||||
sizeof(usb_product_id),
|
||||
@ -46,40 +47,15 @@ static const uint8_t usb_product_id[20] = {
|
||||
'e', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[52] = {
|
||||
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
|
||||
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),
|
||||
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
|
||||
};
|
||||
|
||||
static const uint8_t usb_vendor_id[28] = {
|
||||
@ -103,11 +79,13 @@ static const uint8_t usb_vendor_id[28] = {
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25];
|
||||
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
|
||||
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];
|
||||
}
|
||||
|
||||
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
|
||||
uint8_t * utf8 = &(usb_serial_number[2]);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
|
||||
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
|
||||
|
||||
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));
|
||||
|
32
flight/Project/Windows USB/OpenPilot-CDC.inf
Normal file
32
flight/Project/Windows USB/OpenPilot-CDC.inf
Normal file
@ -0,0 +1,32 @@
|
||||
[Version]
|
||||
Signature="$Windows NT$"
|
||||
Class=Ports
|
||||
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
|
||||
Provider=%ProviderName%
|
||||
DriverVer=10/15/2009,1.0.0.0
|
||||
|
||||
[MANUFACTURER]
|
||||
%ProviderName%=DeviceList, NTx86, NTamd64
|
||||
|
||||
[DeviceList.NTx86]
|
||||
%CopterControl%= DriverInstall,USB\VID_20A0&PID_415b&MI_00
|
||||
|
||||
[DeviceList.NTamd64]
|
||||
%CopterControl%= DriverInstall,USB\VID_20A0&PID_415b&MI_00
|
||||
|
||||
[DriverInstall]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=FakeModemCopyFileSection
|
||||
AddReg=LowerFilterAddReg,SerialPropPageAddReg
|
||||
|
||||
[DriverInstall.Services]
|
||||
include = mdmcpq.inf
|
||||
AddService = usbser, 0x00000002, LowerFilter_Service_Inst
|
||||
|
||||
; This adds the serial port property tab to the device properties dialog
|
||||
[SerialPropPageAddReg]
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[Strings]
|
||||
ProviderName = "CDC Driver"
|
||||
CopterControl = "OpenPilot CDC Driver"
|
@ -1263,20 +1263,21 @@ static const struct pios_usb_cfg pios_usb_main_cfg_cc3d = {
|
||||
#include <pios_usb_hid_priv.h>
|
||||
|
||||
const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
|
||||
.data_if = 0,
|
||||
.data_if = 2,
|
||||
.data_rx_ep = 1,
|
||||
.data_tx_ep = 1,
|
||||
};
|
||||
|
||||
#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_if = 0,
|
||||
.ctrl_tx_ep = 2,
|
||||
|
||||
.data_if = 2,
|
||||
.data_if = 1,
|
||||
.data_rx_ep = 3,
|
||||
.data_tx_ep = 3,
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
BOARD_TYPE := 0x04
|
||||
BOARD_REVISION := 0x02
|
||||
BOOTLOADER_VERSION := 0x02
|
||||
BOOTLOADER_VERSION := 0x03
|
||||
HW_TYPE := 0x01
|
||||
|
||||
MCU := cortex-m3
|
||||
|
@ -1,6 +1,6 @@
|
||||
BOARD_TYPE := 0x03
|
||||
BOARD_REVISION := 0x01
|
||||
BOOTLOADER_VERSION := 0x01
|
||||
BOOTLOADER_VERSION := 0x02
|
||||
HW_TYPE := 0x01
|
||||
|
||||
MCU := cortex-m3
|
||||
|
@ -15,7 +15,6 @@
|
||||
<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"/>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user