diff --git a/Class/AUDIO/Src/usbd_audio.c b/Class/AUDIO/Src/usbd_audio.c index e8c093f..acaaf05 100644 --- a/Class/AUDIO/Src/usbd_audio.c +++ b/Class/AUDIO/Src/usbd_audio.c @@ -157,7 +157,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI /* Configuration 1 */ 0x09, /* bLength */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType */ - LOBYTE(USB_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength 109 bytes*/ + LOBYTE(USB_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ HIBYTE(USB_AUDIO_CONFIG_DESC_SIZ), 0x02, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ @@ -167,7 +167,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* bMaxPower = 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /* 09 byte*/ /* USB Speaker Standard interface descriptor */ @@ -188,7 +188,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */ 0x00, /* 1.00 */ /* bcdADC */ 0x01, - 0x27, /* wTotalLength = 39*/ + 0x27, /* wTotalLength */ 0x00, 0x01, /* bInCollection */ 0x01, /* baInterfaceNr */ @@ -219,22 +219,22 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI AUDIO_CONTROL_MUTE, /* bmaControls(0) */ 0, /* bmaControls(1) */ 0x00, /* iTerminal */ - /* 09 byte*/ + /* 09 byte */ - /*USB Speaker Output Terminal Descriptor */ + /* USB Speaker Output Terminal Descriptor */ 0x09, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */ 0x03, /* bTerminalID */ - 0x01, /* wTerminalType 0x0301*/ + 0x01, /* wTerminalType 0x0301 */ 0x03, 0x00, /* bAssocTerminal */ 0x02, /* bSourceID */ 0x00, /* iTerminal */ - /* 09 byte*/ + /* 09 byte */ /* USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwidth */ - /* Interface 1, Alternate Setting 0 */ + /* Interface 1, Alternate Setting 0 */ AUDIO_INTERFACE_DESC_SIZE, /* bLength */ USB_DESC_TYPE_INTERFACE, /* bDescriptorType */ 0x01, /* bInterfaceNumber */ @@ -292,7 +292,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI 0x00, /* bSynchAddress */ /* 09 byte*/ - /* Endpoint - Audio Streaming Descriptor*/ + /* Endpoint - Audio Streaming Descriptor */ AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */ AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_ENDPOINT_GENERAL, /* bDescriptor */ @@ -339,7 +339,7 @@ static uint8_t USBD_AUDIO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_AUDIO_HandleTypeDef *haudio; /* Allocate Audio structure */ - haudio = USBD_malloc(sizeof(USBD_AUDIO_HandleTypeDef)); + haudio = (USBD_AUDIO_HandleTypeDef *)USBD_malloc(sizeof(USBD_AUDIO_HandleTypeDef)); if (haudio == NULL) { @@ -791,10 +791,11 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef return; } - (void)USBD_memset(haudio->control.data, 0, 64U); + (void)USBD_memset(haudio->control.data, 0, USB_MAX_EP0_SIZE); /* Send the current mute state */ - (void)USBD_CtlSendData(pdev, haudio->control.data, req->wLength); + (void)USBD_CtlSendData(pdev, haudio->control.data, + MIN(req->wLength, USB_MAX_EP0_SIZE)); } /** @@ -816,12 +817,12 @@ static void AUDIO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef if (req->wLength != 0U) { - /* Prepare the reception of the buffer over EP0 */ - (void)USBD_CtlPrepareRx(pdev, haudio->control.data, req->wLength); - haudio->control.cmd = AUDIO_REQ_SET_CUR; /* Set the request value */ - haudio->control.len = (uint8_t)req->wLength; /* Set the request data length */ + haudio->control.len = (uint8_t)MIN(req->wLength, USB_MAX_EP0_SIZE); /* Set the request data length */ haudio->control.unit = HIBYTE(req->wIndex); /* Set the request target unit */ + + /* Prepare the reception of the buffer over EP0 */ + (void)USBD_CtlPrepareRx(pdev, haudio->control.data, haudio->control.len); } } diff --git a/Class/BillBoard/Src/usbd_billboard.c b/Class/BillBoard/Src/usbd_billboard.c index b14a469..e0bacaa 100644 --- a/Class/BillBoard/Src/usbd_billboard.c +++ b/Class/BillBoard/Src/usbd_billboard.c @@ -155,7 +155,7 @@ __ALIGN_BEGIN static uint8_t USBD_BB_CfgDesc[USB_BB_CONFIG_DESC_SIZ] __ALIGN_EN #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /* 09 */ /************** Descriptor of BillBoard interface ****************/ @@ -179,14 +179,14 @@ __ALIGN_BEGIN static uint8_t USBD_BB_OtherSpeedCfgDesc[USB_BB_CONFIG_DESC_SIZ] USB_BB_CONFIG_DESC_SIZ, 0x00, 0x01, /* bNumInterfaces: 1 interface */ - 0x01, /* bConfigurationValue: */ - USBD_IDX_CONFIG_STR, /* iConfiguration: */ + 0x01, /* bConfigurationValue */ + USBD_IDX_CONFIG_STR, /* iConfiguration */ #if (USBD_SELF_POWERED == 1U) 0xC0, /* bmAttributes: Bus Powered according to user configuration */ #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of BillBoard interface ****************/ /* 09 */ diff --git a/Class/CDC/Inc/usbd_cdc.h b/Class/CDC/Inc/usbd_cdc.h index 89e4d05..cb5c6d8 100644 --- a/Class/CDC/Inc/usbd_cdc.h +++ b/Class/CDC/Inc/usbd_cdc.h @@ -111,7 +111,7 @@ typedef struct _USBD_CDC_Itf typedef struct { - uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ + uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */ uint8_t CmdOpCode; uint8_t CmdLength; uint8_t *RxBuffer; diff --git a/Class/CDC/Src/usbd_cdc.c b/Class/CDC/Src/usbd_cdc.c index 631520b..d6ed6ce 100644 --- a/Class/CDC/Src/usbd_cdc.c +++ b/Class/CDC/Src/usbd_cdc.c @@ -142,7 +142,7 @@ USBD_ClassTypeDef USBD_CDC = USBD_CDC_Init, USBD_CDC_DeInit, USBD_CDC_Setup, - NULL, /* EP0_TxSent, */ + NULL, /* EP0_TxSent */ USBD_CDC_EP0_RxReady, USBD_CDC_DataIn, USBD_CDC_DataOut, @@ -163,7 +163,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */ 0x00, - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -171,7 +171,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ @@ -184,7 +184,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: Common AT commands */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -218,9 +218,9 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_CMD_PACKET_SIZE), - CDC_HS_BINTERVAL, /* bInterval: */ + CDC_HS_BINTERVAL, /* bInterval */ /*---------------------------------------------------------------------------*/ /* Data class interface descriptor */ @@ -230,27 +230,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_DATA_HS_MAX_PACKET_SIZE), - 0x00, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_DATA_HS_MAX_PACKET_SIZE), - 0x00 /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ }; @@ -260,9 +260,9 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN /* Configuration Descriptor */ 0x09, /* bLength: Configuration Descriptor size */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ - USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */ + USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength */ 0x00, - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -270,7 +270,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ @@ -280,11 +280,11 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ - 0x01, /* bNumEndpoints: One endpoints used */ + 0x01, /* bNumEndpoints: One endpoint used */ 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: Common AT commands */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -298,7 +298,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN 0x24, /* bDescriptorType: CS_INTERFACE */ 0x01, /* bDescriptorSubtype: Call Management Func Desc */ 0x00, /* bmCapabilities: D0+D1 */ - 0x01, /* bDataInterface: 1 */ + 0x01, /* bDataInterface */ /* ACM Functional Descriptor */ 0x04, /* bFunctionLength */ @@ -318,9 +318,9 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_CMD_PACKET_SIZE), - CDC_FS_BINTERVAL, /* bInterval: */ + CDC_FS_BINTERVAL, /* bInterval */ /*---------------------------------------------------------------------------*/ /* Data class interface descriptor */ @@ -330,27 +330,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), - 0x00, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), - 0x00 /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ }; __ALIGN_BEGIN static uint8_t USBD_CDC_OtherSpeedCfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END = @@ -360,16 +360,16 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_OtherSpeedCfgDesc[USB_CDC_CONFIG_DESC_SIZ] USB_CDC_CONFIG_DESC_SIZ, 0x00, 0x02, /* bNumInterfaces: 2 interfaces */ - 0x01, /* bConfigurationValue: */ - 0x04, /* iConfiguration: */ + 0x01, /* bConfigurationValue */ + 0x04, /* iConfiguration */ #if (USBD_SELF_POWERED == 1U) 0xC0, /* bmAttributes: Bus Powered according to user configuration */ #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ - /*Interface Descriptor */ + /* Interface Descriptor */ 0x09, /* bLength: Interface Descriptor size */ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */ /* Interface descriptor type */ @@ -379,7 +379,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_OtherSpeedCfgDesc[USB_CDC_CONFIG_DESC_SIZ] 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: Common AT commands */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -388,34 +388,34 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_OtherSpeedCfgDesc[USB_CDC_CONFIG_DESC_SIZ] 0x10, /* bcdCDC: spec release number */ 0x01, - /*Call Management Functional Descriptor*/ + /* Call Management Functional Descriptor */ 0x05, /* bFunctionLength */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x01, /* bDescriptorSubtype: Call Management Func Desc */ - 0x00, /* bmCapabilities: D0+D1 */ - 0x01, /* bDataInterface: 1 */ + 0x00, /* bmCapabilities */ + 0x01, /* bDataInterface */ - /*ACM Functional Descriptor*/ + /* ACM Functional Descriptor */ 0x04, /* bFunctionLength */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x02, /* bDescriptorSubtype: Abstract Control Management desc */ 0x02, /* bmCapabilities */ - /*Union Functional Descriptor*/ + /* Union Functional Descriptor */ 0x05, /* bFunctionLength */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x06, /* bDescriptorSubtype: Union func desc */ 0x00, /* bMasterInterface: Communication class interface */ 0x01, /* bSlaveInterface0: Data Class Interface */ - /*Endpoint 2 Descriptor*/ + /* Endpoint 2 Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_CMD_PACKET_SIZE), - CDC_FS_BINTERVAL, /* bInterval: */ + CDC_FS_BINTERVAL, /* bInterval */ /*---------------------------------------------------------------------------*/ @@ -426,25 +426,25 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_OtherSpeedCfgDesc[USB_CDC_CONFIG_DESC_SIZ] 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /*Endpoint OUT Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - 0x40, /* wMaxPacketSize: */ + 0x40, /* wMaxPacketSize */ 0x00, - 0x00, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /*Endpoint IN Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - 0x40, /* wMaxPacketSize: */ + 0x40, /* wMaxPacketSize */ 0x00, 0x00 /* bInterval */ }; @@ -469,7 +469,7 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) UNUSED(cfgidx); USBD_CDC_HandleTypeDef *hcdc; - hcdc = USBD_malloc(sizeof(USBD_CDC_HandleTypeDef)); + hcdc = (USBD_CDC_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_HandleTypeDef)); if (hcdc == NULL) { @@ -614,9 +614,9 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev, else { hcdc->CmdOpCode = req->bRequest; - hcdc->CmdLength = (uint8_t)req->wLength; + hcdc->CmdLength = (uint8_t)MIN(req->wLength, USB_MAX_EP0_SIZE); - (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, req->wLength); + (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, hcdc->CmdLength); } } else diff --git a/Class/CDC_ECM/Inc/usbd_cdc_ecm.h b/Class/CDC_ECM/Inc/usbd_cdc_ecm.h index cdc2d6c..1cd71fa 100644 --- a/Class/CDC_ECM/Inc/usbd_cdc_ecm.h +++ b/Class/CDC_ECM/Inc/usbd_cdc_ecm.h @@ -175,7 +175,7 @@ typedef struct typedef struct { - uint32_t data[CDC_ECM_DATA_BUFFER_SIZE / 4]; /* Force 32bits alignment */ + uint32_t data[CDC_ECM_DATA_BUFFER_SIZE / 4U]; /* Force 32-bit alignment */ uint8_t CmdOpCode; uint8_t CmdLength; uint8_t Reserved1; /* Reserved Byte to force 4 bytes alignment of following fields */ diff --git a/Class/CDC_ECM/Src/usbd_cdc_ecm.c b/Class/CDC_ECM/Src/usbd_cdc_ecm.c index a0f4856..4b34d7c 100644 --- a/Class/CDC_ECM/Src/usbd_cdc_ecm.c +++ b/Class/CDC_ECM/Src/usbd_cdc_ecm.c @@ -155,7 +155,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END = USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */ HIBYTE(CDC_ECM_CONFIG_DESC_SIZ), - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -163,7 +163,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END = #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ @@ -186,7 +186,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END = 0x02, /* bInterfaceClass: Communication Interface Class */ 0x06, /* bInterfaceSubClass: Ethernet Control Model */ 0x00, /* bInterfaceProtocol: No specific protocol required */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -222,7 +222,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_CMD_PACKET_SIZE), CDC_ECM_HS_BINTERVAL, /* bInterval */ @@ -235,27 +235,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END = 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE), - 0xFF, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE), - 0xFF /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ }; @@ -267,7 +267,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END = USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */ HIBYTE(CDC_ECM_CONFIG_DESC_SIZ), - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -275,7 +275,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END = #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ /* IAD descriptor */ @@ -297,7 +297,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END = 0x02, /* bInterfaceClass: Communication Interface Class */ 0x06, /* bInterfaceSubClass: Ethernet Control Model */ 0x00, /* bInterfaceProtocol: No specific protocol required */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -334,7 +334,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_CMD_PACKET_SIZE), CDC_ECM_FS_BINTERVAL, /* bInterval */ @@ -347,27 +347,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END = 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC_ECM */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE), - 0xFF, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE), - 0xFF /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ } ; __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END = @@ -375,9 +375,9 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END = /* Configuration Descriptor */ 0x09, /* bLength: Configuration Descriptor size */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ - LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */ + LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength */ HIBYTE(CDC_ECM_CONFIG_DESC_SIZ), - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x04, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -385,7 +385,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END = #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*--------------------------------------- ------------------------------------*/ /* IAD descriptor */ @@ -443,7 +443,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_ECM_CMD_PACKET_SIZE), CDC_ECM_FS_BINTERVAL, /* bInterval */ @@ -451,13 +451,13 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END = /* Data class interface descriptor */ 0x09, /* bLength: Endpoint Descriptor size */ - USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */ + USB_DESC_TYPE_INTERFACE, /* bDescriptorType: interface */ 0x01, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ 0x00, /* iInterface: */ /* Endpoint OUT Descriptor */ @@ -465,18 +465,18 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - 0x40, /* wMaxPacketSize: */ + 0x40, /* wMaxPacketSize */ 0x00, - 0xFF, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_ECM_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - 0x40, /* wMaxPacketSize: */ + 0x40, /* wMaxPacketSize */ 0x00, - 0xFF /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ }; /** @@ -500,7 +500,7 @@ static uint8_t USBD_CDC_ECM_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_CDC_ECM_HandleTypeDef *hcdc; - hcdc = USBD_malloc(sizeof(USBD_CDC_ECM_HandleTypeDef)); + hcdc = (USBD_CDC_ECM_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_ECM_HandleTypeDef)); if (hcdc == NULL) { @@ -640,9 +640,9 @@ static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev, else { hcdc->CmdOpCode = req->bRequest; - hcdc->CmdLength = (uint8_t)req->wLength; + hcdc->CmdLength = (uint8_t)MIN(req->wLength, USB_MAX_EP0_SIZE); - (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, req->wLength); + (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, hcdc->CmdLength); } } else diff --git a/Class/CDC_RNDIS/Inc/usbd_cdc_rndis.h b/Class/CDC_RNDIS/Inc/usbd_cdc_rndis.h index ef76894..a2fb432 100644 --- a/Class/CDC_RNDIS/Inc/usbd_cdc_rndis.h +++ b/Class/CDC_RNDIS/Inc/usbd_cdc_rndis.h @@ -243,7 +243,7 @@ typedef struct typedef struct { - uint32_t data[2000 / 4]; /* Force 32bits alignment */ + uint32_t data[CDC_RNDIS_MAX_DATA_SZE / 4U]; /* Force 32-bit alignment */ uint8_t CmdOpCode; uint8_t CmdLength; uint8_t ResponseRdy; /* Indicates if the Device Response to an CDC_RNDIS msg is ready */ diff --git a/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c b/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c index 4a08d35..a7c2cbc 100644 --- a/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c +++ b/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c @@ -192,7 +192,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END = USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */ HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -200,7 +200,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END = #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ /* IAD descriptor */ @@ -223,7 +223,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END = 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass:Abstract Control Model */ 0xFF, /* bInterfaceProtocol: Common AT commands */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -257,7 +257,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE), CDC_RNDIS_HS_BINTERVAL, /* bInterval */ @@ -269,18 +269,18 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END = 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE), - 0xFF, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ @@ -289,7 +289,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END = 0x02, /* bmAttributes: Bulk */ LOBYTE(CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ HIBYTE(CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE), - 0xFF /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ }; @@ -301,7 +301,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END = USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */ HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -309,7 +309,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END = #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ /* IAD descriptor */ @@ -332,7 +332,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END = 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass:Abstract Control Model */ 0xFF, /* bInterfaceProtocol: Common AT commands */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -366,7 +366,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE), CDC_RNDIS_FS_BINTERVAL, /* bInterval */ @@ -378,9 +378,9 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END = 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ @@ -389,16 +389,16 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END = 0x02, /* bmAttributes: Bulk */ LOBYTE(CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ HIBYTE(CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE), - 0xFF, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - LOBYTE(CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE), - 0xFF /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ } ; __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END = @@ -408,7 +408,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END = USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */ HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), - 0x02, /* bNumInterfaces: 2 interface */ + 0x02, /* bNumInterfaces: 2 interfaces */ 0x01, /* bConfigurationValue: Configuration value */ 0x04, /* iConfiguration: Index of string descriptor describing the configuration */ #if (USBD_SELF_POWERED == 1U) @@ -416,7 +416,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END = #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /*---------------------------------------------------------------------------*/ /* IAD descriptor */ @@ -439,7 +439,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END = 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass:Abstract Control Model */ 0xFF, /* bInterfaceProtocol: Common AT commands */ - 0x00, /* iInterface: */ + 0x00, /* iInterface */ /* Header Functional Descriptor */ 0x05, /* bLength: Endpoint Descriptor size */ @@ -473,7 +473,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END = USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_CMD_EP, /* bEndpointAddress */ 0x03, /* bmAttributes: Interrupt */ - LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize: */ + LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE), CDC_RNDIS_FS_BINTERVAL, /* bInterval */ @@ -485,27 +485,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END = 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ - 0x00, /* bInterfaceSubClass: */ - 0x00, /* bInterfaceProtocol: */ - 0x00, /* iInterface: */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ /* Endpoint OUT Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_OUT_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - 0x40, /* wMaxPacketSize: */ + 0x40, /* wMaxPacketSize */ 0x00, - 0xFF, /* bInterval: ignore for Bulk transfer */ + 0x00, /* bInterval */ /* Endpoint IN Descriptor */ 0x07, /* bLength: Endpoint Descriptor size */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ CDC_RNDIS_IN_EP, /* bEndpointAddress */ 0x02, /* bmAttributes: Bulk */ - 0x40, /* wMaxPacketSize: */ + 0x40, /* wMaxPacketSize */ 0x00, - 0xFF /* bInterval: ignore for Bulk transfer */ + 0x00 /* bInterval */ }; @@ -554,7 +554,7 @@ static uint8_t USBD_CDC_RNDIS_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) UNUSED(cfgidx); USBD_CDC_RNDIS_HandleTypeDef *hcdc; - hcdc = USBD_malloc(sizeof(USBD_CDC_RNDIS_HandleTypeDef)); + hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_RNDIS_HandleTypeDef)); if (hcdc == NULL) { @@ -713,7 +713,8 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev, hcdc->ResponseRdy = 0U; /* Send data on control endpoint */ - (void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, Msg->MsgLength); + (void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, + MIN(CDC_RNDIS_MAX_DATA_SZE, Msg->MsgLength)); } else { @@ -728,9 +729,9 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev, else { hcdc->CmdOpCode = req->bRequest; - hcdc->CmdLength = (uint8_t)req->wLength; + hcdc->CmdLength = (uint8_t)MIN(CDC_RNDIS_CMD_PACKET_SIZE, req->wLength); - (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, req->wLength); + (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, hcdc->CmdLength); } } /* No Data control request: there is no such request for CDC_RNDIS protocol, diff --git a/Class/CustomHID/Src/usbd_customhid.c b/Class/CustomHID/Src/usbd_customhid.c index 504ff4a..2fbc057 100644 --- a/Class/CustomHID/Src/usbd_customhid.c +++ b/Class/CustomHID/Src/usbd_customhid.c @@ -138,7 +138,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgFSDesc[USB_CUSTOM_HID_CONFIG_DES #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of CUSTOM HID interface ****************/ /* 09 */ @@ -169,7 +169,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgFSDesc[USB_CUSTOM_HID_CONFIG_DES CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ - CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Byte max */ + CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Bytes max */ 0x00, CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */ /* 34 */ @@ -199,7 +199,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc[USB_CUSTOM_HID_CONFIG_DES #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of CUSTOM HID interface ****************/ /* 09 */ @@ -226,11 +226,11 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc[USB_CUSTOM_HID_CONFIG_DES /******************** Descriptor of Custom HID endpoints ********************/ /* 27 */ 0x07, /* bLength: Endpoint Descriptor size */ - USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */ + USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ - CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Byte max */ + CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Bytes max */ 0x00, CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */ /* 34 */ @@ -260,7 +260,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_OtherSpeedCfgDesc[USB_CUSTOM_HID_CO #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of CUSTOM HID interface ****************/ /* 09 */ @@ -356,7 +356,7 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) UNUSED(cfgidx); USBD_CUSTOM_HID_HandleTypeDef *hhid; - hhid = USBD_malloc(sizeof(USBD_CUSTOM_HID_HandleTypeDef)); + hhid = (USBD_CUSTOM_HID_HandleTypeDef *)USBD_malloc(sizeof(USBD_CUSTOM_HID_HandleTypeDef)); if (hhid == NULL) { @@ -476,7 +476,8 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev, case CUSTOM_HID_REQ_SET_REPORT: hhid->IsReportAvailable = 1U; - (void)USBD_CtlPrepareRx(pdev, hhid->Report_buf, req->wLength); + (void)USBD_CtlPrepareRx(pdev, hhid->Report_buf, + MIN(req->wLength, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE)); break; default: diff --git a/Class/DFU/Src/usbd_dfu.c b/Class/DFU/Src/usbd_dfu.c index c3f1b7a..fc942a7 100644 --- a/Class/DFU/Src/usbd_dfu.c +++ b/Class/DFU/Src/usbd_dfu.c @@ -165,7 +165,7 @@ __ALIGN_BEGIN static uint8_t USBD_DFU_CfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_E #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /* 09 */ /********** Descriptor of DFU interface 0 Alternate setting 0 **************/ @@ -258,7 +258,7 @@ static uint8_t USBD_DFU_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_DFU_HandleTypeDef *hdfu; /* Allocate Audio structure */ - hdfu = USBD_malloc(sizeof(USBD_DFU_HandleTypeDef)); + hdfu = (USBD_DFU_HandleTypeDef *)USBD_malloc(sizeof(USBD_DFU_HandleTypeDef)); if (hdfu == NULL) { @@ -744,7 +744,7 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) { /* Update the global length and block number */ hdfu->wblock_num = req->wValue; - hdfu->wlength = req->wLength; + hdfu->wlength = MIN(req->wLength, USBD_DFU_XFER_SIZE); /* Update the state machine */ hdfu->dev_state = DFU_STATE_DNLOAD_SYNC; @@ -807,7 +807,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) { /* Update the global length and block number */ hdfu->wblock_num = req->wValue; - hdfu->wlength = req->wLength; + hdfu->wlength = MIN(req->wLength, USBD_DFU_XFER_SIZE); /* DFU Get Command */ if (hdfu->wblock_num == 0U) diff --git a/Class/HID/Src/usbd_hid.c b/Class/HID/Src/usbd_hid.c index 9301625..75256d2 100644 --- a/Class/HID/Src/usbd_hid.c +++ b/Class/HID/Src/usbd_hid.c @@ -138,7 +138,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgFSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN #else 0xA0, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of Joystick Mouse interface ****************/ /* 09 */ @@ -169,7 +169,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgFSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ - HID_EPIN_SIZE, /* wMaxPacketSize: 4 Byte max */ + HID_EPIN_SIZE, /* wMaxPacketSize: 4 Bytes max */ 0x00, HID_FS_BINTERVAL, /* bInterval: Polling Interval */ /* 34 */ @@ -190,7 +190,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgHSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN #else 0xA0, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of Joystick Mouse interface ****************/ /* 09 */ @@ -221,7 +221,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgHSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ - HID_EPIN_SIZE, /* wMaxPacketSize: 4 Byte max */ + HID_EPIN_SIZE, /* wMaxPacketSize: 4 Bytes max */ 0x00, HID_HS_BINTERVAL, /* bInterval: Polling Interval */ /* 34 */ @@ -242,7 +242,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[USB_HID_CONFIG_DESC_SIZ] #else 0xA0, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ + USBD_MAX_POWER, /* MaxPower (mA) */ /************** Descriptor of Joystick Mouse interface ****************/ /* 09 */ @@ -273,7 +273,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[USB_HID_CONFIG_DESC_SIZ] HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ - HID_EPIN_SIZE, /* wMaxPacketSize: 4 Byte max */ + HID_EPIN_SIZE, /* wMaxPacketSize: 4 Bytes max */ 0x00, HID_FS_BINTERVAL, /* bInterval: Polling Interval */ /* 34 */ @@ -312,52 +312,44 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_ __ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END = { - 0x05, 0x01, - 0x09, 0x02, - 0xA1, 0x01, - 0x09, 0x01, - - 0xA1, 0x00, - 0x05, 0x09, - 0x19, 0x01, - 0x29, 0x03, - - 0x15, 0x00, - 0x25, 0x01, - 0x95, 0x03, - 0x75, 0x01, - - 0x81, 0x02, - 0x95, 0x01, - 0x75, 0x05, - 0x81, 0x01, - - 0x05, 0x01, - 0x09, 0x30, - 0x09, 0x31, - 0x09, 0x38, - - 0x15, 0x81, - 0x25, 0x7F, - 0x75, 0x08, - 0x95, 0x03, - - 0x81, 0x06, - 0xC0, 0x09, - 0x3c, 0x05, - 0xff, 0x09, - - 0x01, 0x15, - 0x00, 0x25, - 0x01, 0x75, - 0x01, 0x95, - - 0x02, 0xb1, - 0x22, 0x75, - 0x06, 0x95, - 0x01, 0xb1, - - 0x01, 0xc0 + 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */ + 0x09, 0x02, /* Usage (Mouse) */ + 0xA1, 0x01, /* Collection (Application) */ + 0x09, 0x01, /* Usage (Pointer) */ + 0xA1, 0x00, /* Collection (Physical) */ + 0x05, 0x09, /* Usage Page (Button) */ + 0x19, 0x01, /* Usage Minimum (0x01) */ + 0x29, 0x03, /* Usage Maximum (0x03) */ + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0x01, /* Logical Maximum (1) */ + 0x95, 0x03, /* Report Count (3) */ + 0x75, 0x01, /* Report Size (1) */ + 0x81, 0x02, /* Input (Data,Var,Abs) */ + 0x95, 0x01, /* Report Count (1) */ + 0x75, 0x05, /* Report Size (5) */ + 0x81, 0x01, /* Input (Const,Array,Abs) */ + 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */ + 0x09, 0x30, /* Usage (X) */ + 0x09, 0x31, /* Usage (Y) */ + 0x09, 0x38, /* Usage (Wheel) */ + 0x15, 0x81, /* Logical Minimum (-127) */ + 0x25, 0x7F, /* Logical Maximum (127) */ + 0x75, 0x08, /* Report Size (8) */ + 0x95, 0x03, /* Report Count (3) */ + 0x81, 0x06, /* Input (Data,Var,Rel) */ + 0xC0, /* End Collection */ + 0x09, 0x3C, /* Usage (Motion Wakeup) */ + 0x05, 0xFF, /* Usage Page (Reserved 0xFF) */ + 0x09, 0x01, /* Usage (0x01) */ + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0x01, /* Logical Maximum (1) */ + 0x75, 0x01, /* Report Size (1) */ + 0x95, 0x02, /* Report Count (2) */ + 0xB1, 0x22, /* Feature (Data,Var,Abs,NoWrp) */ + 0x75, 0x06, /* Report Size (6) */ + 0x95, 0x01, /* Report Count (1) */ + 0xB1, 0x01, /* Feature (Const,Array,Abs,NoWrp) */ + 0xC0 /* End Collection */ }; /** @@ -381,7 +373,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_HID_HandleTypeDef *hhid; - hhid = USBD_malloc(sizeof(USBD_HID_HandleTypeDef)); + hhid = (USBD_HID_HandleTypeDef *)USBD_malloc(sizeof(USBD_HID_HandleTypeDef)); if (hhid == NULL) { diff --git a/Class/MSC/Src/usbd_msc.c b/Class/MSC/Src/usbd_msc.c index 4b96dbd..09a61a6 100644 --- a/Class/MSC/Src/usbd_msc.c +++ b/Class/MSC/Src/usbd_msc.c @@ -129,14 +129,14 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG 0x00, 0x01, /* bNumInterfaces: 1 interface */ - 0x01, /* bConfigurationValue: */ - 0x04, /* iConfiguration: */ + 0x01, /* bConfigurationValue */ + 0x04, /* iConfiguration */ #if (USBD_SELF_POWERED == 1U) 0xC0, /* bmAttributes: Bus Powered according to user configuration */ #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /******************** Mass Storage interface ********************/ 0x09, /* bLength: Interface Descriptor size */ @@ -147,7 +147,7 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG 0x08, /* bInterfaceClass: MSC Class */ 0x06, /* bInterfaceSubClass : SCSI transparent */ 0x50, /* nInterfaceProtocol */ - 0x05, /* iInterface: */ + 0x05, /* iInterface */ /******************** Mass Storage Endpoints ********************/ 0x07, /* Endpoint descriptor length = 7 */ 0x05, /* Endpoint descriptor type */ @@ -176,21 +176,21 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG 0x00, 0x01, /* bNumInterfaces: 1 interface */ - 0x01, /* bConfigurationValue: */ - 0x04, /* iConfiguration: */ + 0x01, /* bConfigurationValue */ + 0x04, /* iConfiguration */ #if (USBD_SELF_POWERED == 1U) 0xC0, /* bmAttributes: Bus Powered according to user configuration */ #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /******************** Mass Storage interface ********************/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ - 0x02, /* bNumEndpoints*/ + 0x02, /* bNumEndpoints */ 0x08, /* bInterfaceClass: MSC Class */ 0x06, /* bInterfaceSubClass : SCSI transparent*/ 0x50, /* nInterfaceProtocol */ @@ -221,25 +221,25 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_OtherSpeedCfgDesc[USB_MSC_CONFIG_DESC_SIZ] 0x00, 0x01, /* bNumInterfaces: 1 interface */ - 0x01, /* bConfigurationValue: */ - 0x04, /* iConfiguration: */ + 0x01, /* bConfigurationValue */ + 0x04, /* iConfiguration */ #if (USBD_SELF_POWERED == 1U) 0xC0, /* bmAttributes: Bus Powered according to user configuration */ #else 0x80, /* bmAttributes: Bus Powered according to user configuration */ #endif - USBD_MAX_POWER, /* MaxPower 100 mA */ + USBD_MAX_POWER, /* MaxPower (mA) */ /******************** Mass Storage interface ********************/ 0x09, /* bLength: Interface Descriptor size */ - 0x04, /* bDescriptorType: */ + 0x04, /* bDescriptorType */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints */ 0x08, /* bInterfaceClass: MSC Class */ 0x06, /* bInterfaceSubClass : SCSI transparent command set */ 0x50, /* nInterfaceProtocol */ - 0x05, /* iInterface: */ + 0x05, /* iInterface */ /******************** Mass Storage Endpoints ********************/ 0x07, /* Endpoint descriptor length = 7 */ 0x05, /* Endpoint descriptor type */ @@ -293,7 +293,7 @@ uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) UNUSED(cfgidx); USBD_MSC_BOT_HandleTypeDef *hmsc; - hmsc = USBD_malloc(sizeof(USBD_MSC_BOT_HandleTypeDef)); + hmsc = (USBD_MSC_BOT_HandleTypeDef *)USBD_malloc(sizeof(USBD_MSC_BOT_HandleTypeDef)); if (hmsc == NULL) { diff --git a/Class/Printer/Inc/usbd_printer.h b/Class/Printer/Inc/usbd_printer.h new file mode 100644 index 0000000..ec73edc --- /dev/null +++ b/Class/Printer/Inc/usbd_printer.h @@ -0,0 +1,164 @@ +/** + ****************************************************************************** + * @file usbd_printer.h + * @author MCD Application Team + * @brief header file for the usbd_printer.c file. + ****************************************************************************** + * @attention + * + *