diff --git a/lib/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper/src/usbd_hid_cdc_wrapper.c b/lib/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper/src/usbd_hid_cdc_wrapper.c index 3e50e36e5..032223f5f 100644 --- a/lib/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper/src/usbd_hid_cdc_wrapper.c +++ b/lib/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper/src/usbd_hid_cdc_wrapper.c @@ -134,7 +134,7 @@ static uint8_t USBD_HID_CDC_DataOut (void *pdev , uint8_t epnum); static uint8_t USBD_HID_CDC_SOF (void *pdev); static uint8_t* USBD_HID_CDC_GetConfigDescriptor( uint8_t speed , uint16_t *length); -#define USB_HID_CDC_CONFIG_DESC_SIZ (USB_HID_CONFIG_DESC_SIZ - 9 + USB_CDC_CONFIG_DESC_SIZ) +#define USB_HID_CDC_CONFIG_DESC_SIZ (USB_HID_CONFIG_DESC_SIZ - 9 + USB_CDC_CONFIG_DESC_SIZ + 8) #define HID_INTERFACE 0x0 #define CDC_COM_INTERFACE 0x1 @@ -169,7 +169,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CDC_CfgDesc[USB_HID_CDC_CONFIG_DESC_SIZ] _ USB_HID_CDC_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */ 0x00, - 0x02, /*bNumInterfaces: 2 interfaces (1 for CDC, 1 for HID)*/ + 0x03, /*bNumInterfaces: 2 interfaces (1 for CDC, 1 for HID)*/ 0x01, /*bConfigurationValue: Configuration value*/ 0x00, /*iConfiguration: Index of string descriptor describing the configuration*/ @@ -210,6 +210,18 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CDC_CfgDesc[USB_HID_CDC_CONFIG_DESC_SIZ] _ 0x0A, /*bInterval: Polling Interval (10 ms)*/ /* 34 */ + /******** /IAD should be positioned just before the CDC interfaces ****** + IAD to associate the two CDC interfaces */ + + 0x08, /* bLength */ + 0x0B, /* bDescriptorType */ + 0x01, /* bFirstInterface */ + 0x02, /* bInterfaceCount */ + 0x02, /* bFunctionClass */ + 0x02, /* bFunctionSubClass */ + 0x01, /* bFunctionProtocol */ + 0x00, /* iFunction (Index of string descriptor describing this function) */ + /*Interface Descriptor */ 0x09, /* bLength: Interface Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */ @@ -220,7 +232,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CDC_CfgDesc[USB_HID_CDC_CONFIG_DESC_SIZ] _ 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: Common AT commands */ - 0x01, /* iInterface: */ + 0x00, /* iInterface: */ /*Header Functional Descriptor*/ 0x05, /* bLength: Endpoint Descriptor size */ diff --git a/src/main/target/WORMFC/target.h b/src/main/target/WORMFC/target.h index cb503e072..4dd704d6a 100644 --- a/src/main/target/WORMFC/target.h +++ b/src/main/target/WORMFC/target.h @@ -67,7 +67,7 @@ #define USE_VCP #define USB_MSC -#define MSC_BUTTON PB2 +#define USB_CDC_HID #define VBUS_SENSING_PIN PA9 #define VBUS_SENSING_ENABLED diff --git a/src/main/target/common_fc_pre.h b/src/main/target/common_fc_pre.h index 63835adbc..af947f4fc 100644 --- a/src/main/target/common_fc_pre.h +++ b/src/main/target/common_fc_pre.h @@ -51,7 +51,6 @@ #define USE_GYRO_DATA_ANALYSE #define USE_ADC #define USE_ADC_INTERNAL -#define USB_CDC_HID #if defined(STM32F40_41xxx) || defined(STM32F411xE) #define USE_OVERCLOCK diff --git a/src/main/vcpf4/usbd_desc.c b/src/main/vcpf4/usbd_desc.c index 768e2928d..e117cbd7b 100644 --- a/src/main/vcpf4/usbd_desc.c +++ b/src/main/vcpf4/usbd_desc.c @@ -52,7 +52,11 @@ #define USBD_VID 0x0483 +#ifdef USB_CDC_HID +#define USBD_PID 0x3256 +#else #define USBD_PID 0x5740 +#endif /** @defgroup USB_String_Descriptors * @{ @@ -116,6 +120,26 @@ USBD_DEVICE USR_desc = #pragma data_alignment=4 #endif #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ +#ifdef USB_CDC_HID +/* USB Standard Device Descriptor */ +__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = + { + 0x12, /*bLength */ + USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ + 0x00, 0x02, /*bcdUSB */ + 0xEF, /*bDeviceClass*/ + 0x02, /*bDeviceSubClass*/ + 0x01, /*bDeviceProtocol*/ + USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID), HIBYTE(USBD_PID), /*idProduct*/ + 0x00, 0x02, /*bcdDevice rel. 2.00*/ + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_CFG_MAX_NUM /*bNumConfigurations*/ + } ; /* USB_DeviceDescriptor */ +#else /* USB Standard Device Descriptor */ __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = { @@ -134,6 +158,7 @@ __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = USBD_IDX_SERIAL_STR, /*Index of serial number string*/ USBD_CFG_MAX_NUM /*bNumConfigurations*/ } ; /* USB_DeviceDescriptor */ +#endif #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED #if defined ( __ICCARM__ ) /*!< IAR Compiler */