CDC+HID HotFixes (#5512)

- For now disables Composite (it can be enabled, with USB_CDC_HID define)
- Modified descriptors so they are properly recognized
- Changed PID for Composite device (otherwise it doesn't work probably due to windows feature - automatically finding drivers based on those values)
This commit is contained in:
conkerkh 2018-03-23 01:19:14 +01:00 committed by Michael Keller
parent 5dc23e662f
commit a539bd60bc
4 changed files with 41 additions and 5 deletions

View File

@ -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_SOF (void *pdev);
static uint8_t* USBD_HID_CDC_GetConfigDescriptor( uint8_t speed , uint16_t *length); 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 HID_INTERFACE 0x0
#define CDC_COM_INTERFACE 0x1 #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, USB_HID_CDC_CONFIG_DESC_SIZ,
/* wTotalLength: Bytes returned */ /* wTotalLength: Bytes returned */
0x00, 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*/ 0x01, /*bConfigurationValue: Configuration value*/
0x00, /*iConfiguration: Index of string descriptor describing 0x00, /*iConfiguration: Index of string descriptor describing
the configuration*/ 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)*/ 0x0A, /*bInterval: Polling Interval (10 ms)*/
/* 34 */ /* 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 */ /*Interface Descriptor */
0x09, /* bLength: Interface Descriptor size */ 0x09, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */ 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, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x02, /* bInterfaceSubClass: Abstract Control Model */
0x01, /* bInterfaceProtocol: Common AT commands */ 0x01, /* bInterfaceProtocol: Common AT commands */
0x01, /* iInterface: */ 0x00, /* iInterface: */
/*Header Functional Descriptor*/ /*Header Functional Descriptor*/
0x05, /* bLength: Endpoint Descriptor size */ 0x05, /* bLength: Endpoint Descriptor size */

View File

@ -67,7 +67,7 @@
#define USE_VCP #define USE_VCP
#define USB_MSC #define USB_MSC
#define MSC_BUTTON PB2 #define USB_CDC_HID
#define VBUS_SENSING_PIN PA9 #define VBUS_SENSING_PIN PA9
#define VBUS_SENSING_ENABLED #define VBUS_SENSING_ENABLED

View File

@ -51,7 +51,6 @@
#define USE_GYRO_DATA_ANALYSE #define USE_GYRO_DATA_ANALYSE
#define USE_ADC #define USE_ADC
#define USE_ADC_INTERNAL #define USE_ADC_INTERNAL
#define USB_CDC_HID
#if defined(STM32F40_41xxx) || defined(STM32F411xE) #if defined(STM32F40_41xxx) || defined(STM32F411xE)
#define USE_OVERCLOCK #define USE_OVERCLOCK

View File

@ -52,7 +52,11 @@
#define USBD_VID 0x0483 #define USBD_VID 0x0483
#ifdef USB_CDC_HID
#define USBD_PID 0x3256
#else
#define USBD_PID 0x5740 #define USBD_PID 0x5740
#endif
/** @defgroup USB_String_Descriptors /** @defgroup USB_String_Descriptors
* @{ * @{
@ -116,6 +120,26 @@ USBD_DEVICE USR_desc =
#pragma data_alignment=4 #pragma data_alignment=4
#endif #endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ #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 */ /* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = __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_IDX_SERIAL_STR, /*Index of serial number string*/
USBD_CFG_MAX_NUM /*bNumConfigurations*/ USBD_CFG_MAX_NUM /*bNumConfigurations*/
} ; /* USB_DeviceDescriptor */ } ; /* USB_DeviceDescriptor */
#endif
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */