1 Commits

Author SHA1 Message Date
slimih
5af065de85 Release v2.8.0 2021-03-16 12:39:31 +01:00
20 changed files with 1374 additions and 261 deletions

View File

@@ -157,7 +157,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI
/* Configuration 1 */ /* Configuration 1 */
0x09, /* bLength */ 0x09, /* bLength */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType */ 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), HIBYTE(USB_AUDIO_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces */ 0x02, /* bNumInterfaces */
0x01, /* bConfigurationValue */ 0x01, /* bConfigurationValue */
@@ -167,7 +167,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* bMaxPower = 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/* 09 byte*/ /* 09 byte*/
/* USB Speaker Standard interface descriptor */ /* 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 */ AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */
0x00, /* 1.00 */ /* bcdADC */ 0x00, /* 1.00 */ /* bcdADC */
0x01, 0x01,
0x27, /* wTotalLength = 39*/ 0x27, /* wTotalLength */
0x00, 0x00,
0x01, /* bInCollection */ 0x01, /* bInCollection */
0x01, /* baInterfaceNr */ 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) */ AUDIO_CONTROL_MUTE, /* bmaControls(0) */
0, /* bmaControls(1) */ 0, /* bmaControls(1) */
0x00, /* iTerminal */ 0x00, /* iTerminal */
/* 09 byte*/ /* 09 byte */
/*USB Speaker Output Terminal Descriptor */ /* USB Speaker Output Terminal Descriptor */
0x09, /* bLength */ 0x09, /* bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */ AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */
0x03, /* bTerminalID */ 0x03, /* bTerminalID */
0x01, /* wTerminalType 0x0301*/ 0x01, /* wTerminalType 0x0301 */
0x03, 0x03,
0x00, /* bAssocTerminal */ 0x00, /* bAssocTerminal */
0x02, /* bSourceID */ 0x02, /* bSourceID */
0x00, /* iTerminal */ 0x00, /* iTerminal */
/* 09 byte*/ /* 09 byte */
/* USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwidth */ /* 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 */ AUDIO_INTERFACE_DESC_SIZE, /* bLength */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType */ USB_DESC_TYPE_INTERFACE, /* bDescriptorType */
0x01, /* bInterfaceNumber */ 0x01, /* bInterfaceNumber */
@@ -292,7 +292,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI
0x00, /* bSynchAddress */ 0x00, /* bSynchAddress */
/* 09 byte*/ /* 09 byte*/
/* Endpoint - Audio Streaming Descriptor*/ /* Endpoint - Audio Streaming Descriptor */
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */ AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
AUDIO_ENDPOINT_GENERAL, /* bDescriptor */ AUDIO_ENDPOINT_GENERAL, /* bDescriptor */
@@ -339,7 +339,7 @@ static uint8_t USBD_AUDIO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
USBD_AUDIO_HandleTypeDef *haudio; USBD_AUDIO_HandleTypeDef *haudio;
/* Allocate Audio structure */ /* Allocate Audio structure */
haudio = USBD_malloc(sizeof(USBD_AUDIO_HandleTypeDef)); haudio = (USBD_AUDIO_HandleTypeDef *)USBD_malloc(sizeof(USBD_AUDIO_HandleTypeDef));
if (haudio == NULL) if (haudio == NULL)
{ {
@@ -791,10 +791,11 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
return; 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 */ /* 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) 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.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 */ 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);
} }
} }

View File

@@ -155,7 +155,7 @@ __ALIGN_BEGIN static uint8_t USBD_BB_CfgDesc[USB_BB_CONFIG_DESC_SIZ] __ALIGN_EN
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/* 09 */ /* 09 */
/************** Descriptor of BillBoard interface ****************/ /************** 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, USB_BB_CONFIG_DESC_SIZ,
0x00, 0x00,
0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: */ 0x01, /* bConfigurationValue */
USBD_IDX_CONFIG_STR, /* iConfiguration: */ USBD_IDX_CONFIG_STR, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of BillBoard interface ****************/ /************** Descriptor of BillBoard interface ****************/
/* 09 */ /* 09 */

View File

@@ -111,7 +111,7 @@ typedef struct _USBD_CDC_Itf
typedef struct 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 CmdOpCode;
uint8_t CmdLength; uint8_t CmdLength;
uint8_t *RxBuffer; uint8_t *RxBuffer;

View File

@@ -142,7 +142,7 @@ USBD_ClassTypeDef USBD_CDC =
USBD_CDC_Init, USBD_CDC_Init,
USBD_CDC_DeInit, USBD_CDC_DeInit,
USBD_CDC_Setup, USBD_CDC_Setup,
NULL, /* EP0_TxSent, */ NULL, /* EP0_TxSent */
USBD_CDC_EP0_RxReady, USBD_CDC_EP0_RxReady,
USBD_CDC_DataIn, USBD_CDC_DataIn,
USBD_CDC_DataOut, 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_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */ USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
0x00, 0x00,
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -171,7 +171,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #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, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x02, /* bInterfaceSubClass: Abstract Control Model */
0x01, /* bInterfaceProtocol: Common AT commands */ 0x01, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_CMD_EP, /* bEndpointAddress */ CDC_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_CMD_PACKET_SIZE), HIBYTE(CDC_CMD_PACKET_SIZE),
CDC_HS_BINTERVAL, /* bInterval: */ CDC_HS_BINTERVAL, /* bInterval */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Data class interface descriptor */ /* 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 */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_OUT_EP, /* bEndpointAddress */ CDC_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), HIBYTE(CDC_DATA_HS_MAX_PACKET_SIZE),
0x00, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_IN_EP, /* bEndpointAddress */ CDC_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), 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 */ /* Configuration Descriptor */
0x09, /* bLength: Configuration Descriptor size */ 0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */ USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength */
0x00, 0x00,
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -270,7 +270,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #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 */ /* Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x01, /* bNumEndpoints: One endpoints used */ 0x01, /* bNumEndpoints: One endpoint used */
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 */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ 0x24, /* bDescriptorType: CS_INTERFACE */
0x01, /* bDescriptorSubtype: Call Management Func Desc */ 0x01, /* bDescriptorSubtype: Call Management Func Desc */
0x00, /* bmCapabilities: D0+D1 */ 0x00, /* bmCapabilities: D0+D1 */
0x01, /* bDataInterface: 1 */ 0x01, /* bDataInterface */
/* ACM Functional Descriptor */ /* ACM Functional Descriptor */
0x04, /* bFunctionLength */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_CMD_EP, /* bEndpointAddress */ CDC_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_CMD_PACKET_SIZE), HIBYTE(CDC_CMD_PACKET_SIZE),
CDC_FS_BINTERVAL, /* bInterval: */ CDC_FS_BINTERVAL, /* bInterval */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Data class interface descriptor */ /* 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 */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_OUT_EP, /* bEndpointAddress */ CDC_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
0x00, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_IN_EP, /* bEndpointAddress */ CDC_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), 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 = __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, USB_CDC_CONFIG_DESC_SIZ,
0x00, 0x00,
0x02, /* bNumInterfaces: 2 interfaces */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: */ 0x01, /* bConfigurationValue */
0x04, /* iConfiguration: */ 0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/*Interface Descriptor */ /* Interface Descriptor */
0x09, /* bLength: Interface Descriptor size */ 0x09, /* bLength: Interface Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
/* Interface descriptor type */ /* 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, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x02, /* bInterfaceSubClass: Abstract Control Model */
0x01, /* bInterfaceProtocol: Common AT commands */ 0x01, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ 0x10, /* bcdCDC: spec release number */
0x01, 0x01,
/*Call Management Functional Descriptor*/ /* Call Management Functional Descriptor */
0x05, /* bFunctionLength */ 0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */ 0x24, /* bDescriptorType: CS_INTERFACE */
0x01, /* bDescriptorSubtype: Call Management Func Desc */ 0x01, /* bDescriptorSubtype: Call Management Func Desc */
0x00, /* bmCapabilities: D0+D1 */ 0x00, /* bmCapabilities */
0x01, /* bDataInterface: 1 */ 0x01, /* bDataInterface */
/*ACM Functional Descriptor*/ /* ACM Functional Descriptor */
0x04, /* bFunctionLength */ 0x04, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */ 0x24, /* bDescriptorType: CS_INTERFACE */
0x02, /* bDescriptorSubtype: Abstract Control Management desc */ 0x02, /* bDescriptorSubtype: Abstract Control Management desc */
0x02, /* bmCapabilities */ 0x02, /* bmCapabilities */
/*Union Functional Descriptor*/ /* Union Functional Descriptor */
0x05, /* bFunctionLength */ 0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */ 0x24, /* bDescriptorType: CS_INTERFACE */
0x06, /* bDescriptorSubtype: Union func desc */ 0x06, /* bDescriptorSubtype: Union func desc */
0x00, /* bMasterInterface: Communication class interface */ 0x00, /* bMasterInterface: Communication class interface */
0x01, /* bSlaveInterface0: Data Class Interface */ 0x01, /* bSlaveInterface0: Data Class Interface */
/*Endpoint 2 Descriptor*/ /* Endpoint 2 Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_CMD_EP, /* bEndpointAddress */ CDC_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_CMD_PACKET_SIZE), 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 */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/*Endpoint OUT Descriptor*/ /*Endpoint OUT Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_OUT_EP, /* bEndpointAddress */ CDC_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 0x02, /* bmAttributes: Bulk */
0x40, /* wMaxPacketSize: */ 0x40, /* wMaxPacketSize */
0x00, 0x00,
0x00, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/*Endpoint IN Descriptor*/ /*Endpoint IN Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_IN_EP, /* bEndpointAddress */ CDC_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 0x02, /* bmAttributes: Bulk */
0x40, /* wMaxPacketSize: */ 0x40, /* wMaxPacketSize */
0x00, 0x00,
0x00 /* bInterval */ 0x00 /* bInterval */
}; };
@@ -469,7 +469,7 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
UNUSED(cfgidx); UNUSED(cfgidx);
USBD_CDC_HandleTypeDef *hcdc; USBD_CDC_HandleTypeDef *hcdc;
hcdc = USBD_malloc(sizeof(USBD_CDC_HandleTypeDef)); hcdc = (USBD_CDC_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
if (hcdc == NULL) if (hcdc == NULL)
{ {
@@ -614,9 +614,9 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
else else
{ {
hcdc->CmdOpCode = req->bRequest; 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 else

View File

@@ -175,7 +175,7 @@ typedef struct
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 CmdOpCode;
uint8_t CmdLength; uint8_t CmdLength;
uint8_t Reserved1; /* Reserved Byte to force 4 bytes alignment of following fields */ uint8_t Reserved1; /* Reserved Byte to force 4 bytes alignment of following fields */

View File

@@ -155,7 +155,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END =
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */ LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */
HIBYTE(CDC_ECM_CONFIG_DESC_SIZ), HIBYTE(CDC_ECM_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -163,7 +163,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END =
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #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 */ 0x02, /* bInterfaceClass: Communication Interface Class */
0x06, /* bInterfaceSubClass: Ethernet Control Model */ 0x06, /* bInterfaceSubClass: Ethernet Control Model */
0x00, /* bInterfaceProtocol: No specific protocol required */ 0x00, /* bInterfaceProtocol: No specific protocol required */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_CMD_EP, /* bEndpointAddress */ CDC_ECM_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_ECM_CMD_PACKET_SIZE), HIBYTE(CDC_ECM_CMD_PACKET_SIZE),
CDC_ECM_HS_BINTERVAL, /* bInterval */ CDC_ECM_HS_BINTERVAL, /* bInterval */
@@ -235,27 +235,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END =
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_OUT_EP, /* bEndpointAddress */ CDC_ECM_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), HIBYTE(CDC_ECM_DATA_HS_MAX_PACKET_SIZE),
0xFF, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_IN_EP, /* bEndpointAddress */ CDC_ECM_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), 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 */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */ LOBYTE(CDC_ECM_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */
HIBYTE(CDC_ECM_CONFIG_DESC_SIZ), HIBYTE(CDC_ECM_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -275,7 +275,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END =
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* IAD descriptor */ /* IAD descriptor */
@@ -297,7 +297,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END =
0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceClass: Communication Interface Class */
0x06, /* bInterfaceSubClass: Ethernet Control Model */ 0x06, /* bInterfaceSubClass: Ethernet Control Model */
0x00, /* bInterfaceProtocol: No specific protocol required */ 0x00, /* bInterfaceProtocol: No specific protocol required */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_CMD_EP, /* bEndpointAddress */ CDC_ECM_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_ECM_CMD_PACKET_SIZE), HIBYTE(CDC_ECM_CMD_PACKET_SIZE),
CDC_ECM_FS_BINTERVAL, /* bInterval */ CDC_ECM_FS_BINTERVAL, /* bInterval */
@@ -347,27 +347,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END =
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC_ECM */ 0x0A, /* bInterfaceClass: CDC_ECM */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_OUT_EP, /* bEndpointAddress */ CDC_ECM_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), HIBYTE(CDC_ECM_DATA_FS_MAX_PACKET_SIZE),
0xFF, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_IN_EP, /* bEndpointAddress */ CDC_ECM_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), 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 = __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 */ /* Configuration Descriptor */
0x09, /* bLength: Configuration Descriptor size */ 0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ 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), HIBYTE(CDC_ECM_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x04, /* iConfiguration: Index of string descriptor describing the configuration */ 0x04, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -385,7 +385,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END =
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/*--------------------------------------- ------------------------------------*/ /*--------------------------------------- ------------------------------------*/
/* IAD descriptor */ /* IAD descriptor */
@@ -443,7 +443,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END =
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_CMD_EP, /* bEndpointAddress */ CDC_ECM_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_ECM_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_ECM_CMD_PACKET_SIZE), HIBYTE(CDC_ECM_CMD_PACKET_SIZE),
CDC_ECM_FS_BINTERVAL, /* bInterval */ CDC_ECM_FS_BINTERVAL, /* bInterval */
@@ -451,13 +451,13 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END =
/* Data class interface descriptor */ /* Data class interface descriptor */
0x09, /* bLength: Endpoint Descriptor size */ 0x09, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: interface */
0x01, /* bInterfaceNumber: Number of Interface */ 0x01, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface: */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
@@ -465,18 +465,18 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END =
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_OUT_EP, /* bEndpointAddress */ CDC_ECM_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 0x02, /* bmAttributes: Bulk */
0x40, /* wMaxPacketSize: */ 0x40, /* wMaxPacketSize */
0x00, 0x00,
0xFF, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_ECM_IN_EP, /* bEndpointAddress */ CDC_ECM_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 0x02, /* bmAttributes: Bulk */
0x40, /* wMaxPacketSize: */ 0x40, /* wMaxPacketSize */
0x00, 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; 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) if (hcdc == NULL)
{ {
@@ -640,9 +640,9 @@ static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev,
else else
{ {
hcdc->CmdOpCode = req->bRequest; 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 else

View File

@@ -243,7 +243,7 @@ typedef struct
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 CmdOpCode;
uint8_t CmdLength; uint8_t CmdLength;
uint8_t ResponseRdy; /* Indicates if the Device Response to an CDC_RNDIS msg is ready */ uint8_t ResponseRdy; /* Indicates if the Device Response to an CDC_RNDIS msg is ready */

View File

@@ -192,7 +192,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */ LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */
HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -200,7 +200,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* IAD descriptor */ /* IAD descriptor */
@@ -223,7 +223,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass:Abstract Control Model */ 0x02, /* bInterfaceSubClass:Abstract Control Model */
0xFF, /* bInterfaceProtocol: Common AT commands */ 0xFF, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_CMD_EP, /* bEndpointAddress */ CDC_RNDIS_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE), HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE),
CDC_RNDIS_HS_BINTERVAL, /* bInterval */ CDC_RNDIS_HS_BINTERVAL, /* bInterval */
@@ -269,18 +269,18 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_OUT_EP, /* bEndpointAddress */ CDC_RNDIS_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), HIBYTE(CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE),
0xFF, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
@@ -289,7 +289,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
0x02, /* bmAttributes: Bulk */ 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), 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 */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */ LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength: Total size of the Config descriptor */
HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -309,7 +309,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END =
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* IAD descriptor */ /* IAD descriptor */
@@ -332,7 +332,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END =
0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass:Abstract Control Model */ 0x02, /* bInterfaceSubClass:Abstract Control Model */
0xFF, /* bInterfaceProtocol: Common AT commands */ 0xFF, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_CMD_EP, /* bEndpointAddress */ CDC_RNDIS_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE), HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE),
CDC_RNDIS_FS_BINTERVAL, /* bInterval */ CDC_RNDIS_FS_BINTERVAL, /* bInterval */
@@ -378,9 +378,9 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END =
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
@@ -389,16 +389,16 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END =
0x02, /* bmAttributes: Bulk */ 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), HIBYTE(CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE),
0xFF, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_IN_EP, /* bEndpointAddress */ CDC_RNDIS_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 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), 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 = __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 */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */ LOBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), /* wTotalLength:no of returned bytes */
HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ), HIBYTE(CDC_RNDIS_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x04, /* iConfiguration: Index of string descriptor describing the configuration */ 0x04, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -416,7 +416,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END =
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* IAD descriptor */ /* IAD descriptor */
@@ -439,7 +439,7 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END =
0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass:Abstract Control Model */ 0x02, /* bInterfaceSubClass:Abstract Control Model */
0xFF, /* bInterfaceProtocol: Common AT commands */ 0xFF, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, /* bLength: Endpoint Descriptor size */ 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 */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_CMD_EP, /* bEndpointAddress */ CDC_RNDIS_CMD_EP, /* bEndpointAddress */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize: */ LOBYTE(CDC_RNDIS_CMD_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE), HIBYTE(CDC_RNDIS_CMD_PACKET_SIZE),
CDC_RNDIS_FS_BINTERVAL, /* bInterval */ CDC_RNDIS_FS_BINTERVAL, /* bInterval */
@@ -485,27 +485,27 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END =
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */ 0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */ 0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol: */ 0x00, /* bInterfaceProtocol */
0x00, /* iInterface: */ 0x00, /* iInterface */
/* Endpoint OUT Descriptor */ /* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_OUT_EP, /* bEndpointAddress */ CDC_RNDIS_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 0x02, /* bmAttributes: Bulk */
0x40, /* wMaxPacketSize: */ 0x40, /* wMaxPacketSize */
0x00, 0x00,
0xFF, /* bInterval: ignore for Bulk transfer */ 0x00, /* bInterval */
/* Endpoint IN Descriptor */ /* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
CDC_RNDIS_IN_EP, /* bEndpointAddress */ CDC_RNDIS_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */ 0x02, /* bmAttributes: Bulk */
0x40, /* wMaxPacketSize: */ 0x40, /* wMaxPacketSize */
0x00, 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); UNUSED(cfgidx);
USBD_CDC_RNDIS_HandleTypeDef *hcdc; 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) if (hcdc == NULL)
{ {
@@ -713,7 +713,8 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev,
hcdc->ResponseRdy = 0U; hcdc->ResponseRdy = 0U;
/* Send data on control endpoint */ /* 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 else
{ {
@@ -728,9 +729,9 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev,
else else
{ {
hcdc->CmdOpCode = req->bRequest; 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, /* No Data control request: there is no such request for CDC_RNDIS protocol,

View File

@@ -138,7 +138,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgFSDesc[USB_CUSTOM_HID_CONFIG_DES
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of CUSTOM HID interface ****************/ /************** Descriptor of CUSTOM HID interface ****************/
/* 09 */ /* 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) */ CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
0x03, /* bmAttributes: Interrupt endpoint */ 0x03, /* bmAttributes: Interrupt endpoint */
CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Byte max */ CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Bytes max */
0x00, 0x00,
CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */ CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
/* 34 */ /* 34 */
@@ -199,7 +199,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc[USB_CUSTOM_HID_CONFIG_DES
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of CUSTOM HID interface ****************/ /************** Descriptor of CUSTOM HID interface ****************/
/* 09 */ /* 09 */
@@ -226,11 +226,11 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc[USB_CUSTOM_HID_CONFIG_DES
/******************** Descriptor of Custom HID endpoints ********************/ /******************** Descriptor of Custom HID endpoints ********************/
/* 27 */ /* 27 */
0x07, /* bLength: Endpoint Descriptor size */ 0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */
CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */ CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
0x03, /* bmAttributes: Interrupt endpoint */ 0x03, /* bmAttributes: Interrupt endpoint */
CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Byte max */ CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Bytes max */
0x00, 0x00,
CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */ CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */
/* 34 */ /* 34 */
@@ -260,7 +260,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_OtherSpeedCfgDesc[USB_CUSTOM_HID_CO
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of CUSTOM HID interface ****************/ /************** Descriptor of CUSTOM HID interface ****************/
/* 09 */ /* 09 */
@@ -356,7 +356,7 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
UNUSED(cfgidx); UNUSED(cfgidx);
USBD_CUSTOM_HID_HandleTypeDef *hhid; 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) if (hhid == NULL)
{ {
@@ -476,7 +476,8 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
case CUSTOM_HID_REQ_SET_REPORT: case CUSTOM_HID_REQ_SET_REPORT:
hhid->IsReportAvailable = 1U; 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; break;
default: default:

View File

@@ -165,7 +165,7 @@ __ALIGN_BEGIN static uint8_t USBD_DFU_CfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_E
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/* 09 */ /* 09 */
/********** Descriptor of DFU interface 0 Alternate setting 0 **************/ /********** 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; USBD_DFU_HandleTypeDef *hdfu;
/* Allocate Audio structure */ /* Allocate Audio structure */
hdfu = USBD_malloc(sizeof(USBD_DFU_HandleTypeDef)); hdfu = (USBD_DFU_HandleTypeDef *)USBD_malloc(sizeof(USBD_DFU_HandleTypeDef));
if (hdfu == NULL) if (hdfu == NULL)
{ {
@@ -744,7 +744,7 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
{ {
/* Update the global length and block number */ /* Update the global length and block number */
hdfu->wblock_num = req->wValue; hdfu->wblock_num = req->wValue;
hdfu->wlength = req->wLength; hdfu->wlength = MIN(req->wLength, USBD_DFU_XFER_SIZE);
/* Update the state machine */ /* Update the state machine */
hdfu->dev_state = DFU_STATE_DNLOAD_SYNC; 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 */ /* Update the global length and block number */
hdfu->wblock_num = req->wValue; hdfu->wblock_num = req->wValue;
hdfu->wlength = req->wLength; hdfu->wlength = MIN(req->wLength, USBD_DFU_XFER_SIZE);
/* DFU Get Command */ /* DFU Get Command */
if (hdfu->wblock_num == 0U) if (hdfu->wblock_num == 0U)

View File

@@ -138,7 +138,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgFSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN
#else #else
0xA0, /* bmAttributes: Bus Powered according to user configuration */ 0xA0, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of Joystick Mouse interface ****************/ /************** Descriptor of Joystick Mouse interface ****************/
/* 09 */ /* 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) */ HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
0x03, /* bmAttributes: Interrupt endpoint */ 0x03, /* bmAttributes: Interrupt endpoint */
HID_EPIN_SIZE, /* wMaxPacketSize: 4 Byte max */ HID_EPIN_SIZE, /* wMaxPacketSize: 4 Bytes max */
0x00, 0x00,
HID_FS_BINTERVAL, /* bInterval: Polling Interval */ HID_FS_BINTERVAL, /* bInterval: Polling Interval */
/* 34 */ /* 34 */
@@ -190,7 +190,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgHSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN
#else #else
0xA0, /* bmAttributes: Bus Powered according to user configuration */ 0xA0, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of Joystick Mouse interface ****************/ /************** Descriptor of Joystick Mouse interface ****************/
/* 09 */ /* 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) */ HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
0x03, /* bmAttributes: Interrupt endpoint */ 0x03, /* bmAttributes: Interrupt endpoint */
HID_EPIN_SIZE, /* wMaxPacketSize: 4 Byte max */ HID_EPIN_SIZE, /* wMaxPacketSize: 4 Bytes max */
0x00, 0x00,
HID_HS_BINTERVAL, /* bInterval: Polling Interval */ HID_HS_BINTERVAL, /* bInterval: Polling Interval */
/* 34 */ /* 34 */
@@ -242,7 +242,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[USB_HID_CONFIG_DESC_SIZ]
#else #else
0xA0, /* bmAttributes: Bus Powered according to user configuration */ 0xA0, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */ USBD_MAX_POWER, /* MaxPower (mA) */
/************** Descriptor of Joystick Mouse interface ****************/ /************** Descriptor of Joystick Mouse interface ****************/
/* 09 */ /* 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) */ HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
0x03, /* bmAttributes: Interrupt endpoint */ 0x03, /* bmAttributes: Interrupt endpoint */
HID_EPIN_SIZE, /* wMaxPacketSize: 4 Byte max */ HID_EPIN_SIZE, /* wMaxPacketSize: 4 Bytes max */
0x00, 0x00,
HID_FS_BINTERVAL, /* bInterval: Polling Interval */ HID_FS_BINTERVAL, /* bInterval: Polling Interval */
/* 34 */ /* 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 = __ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
{ {
0x05, 0x01, 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
0x09, 0x02, 0x09, 0x02, /* Usage (Mouse) */
0xA1, 0x01, 0xA1, 0x01, /* Collection (Application) */
0x09, 0x01, 0x09, 0x01, /* Usage (Pointer) */
0xA1, 0x00, /* Collection (Physical) */
0xA1, 0x00, 0x05, 0x09, /* Usage Page (Button) */
0x05, 0x09, 0x19, 0x01, /* Usage Minimum (0x01) */
0x19, 0x01, 0x29, 0x03, /* Usage Maximum (0x03) */
0x29, 0x03, 0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x01, /* Logical Maximum (1) */
0x15, 0x00, 0x95, 0x03, /* Report Count (3) */
0x25, 0x01, 0x75, 0x01, /* Report Size (1) */
0x95, 0x03, 0x81, 0x02, /* Input (Data,Var,Abs) */
0x75, 0x01, 0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */
0x81, 0x02, 0x81, 0x01, /* Input (Const,Array,Abs) */
0x95, 0x01, 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
0x75, 0x05, 0x09, 0x30, /* Usage (X) */
0x81, 0x01, 0x09, 0x31, /* Usage (Y) */
0x09, 0x38, /* Usage (Wheel) */
0x05, 0x01, 0x15, 0x81, /* Logical Minimum (-127) */
0x09, 0x30, 0x25, 0x7F, /* Logical Maximum (127) */
0x09, 0x31, 0x75, 0x08, /* Report Size (8) */
0x09, 0x38, 0x95, 0x03, /* Report Count (3) */
0x81, 0x06, /* Input (Data,Var,Rel) */
0x15, 0x81, 0xC0, /* End Collection */
0x25, 0x7F, 0x09, 0x3C, /* Usage (Motion Wakeup) */
0x75, 0x08, 0x05, 0xFF, /* Usage Page (Reserved 0xFF) */
0x95, 0x03, 0x09, 0x01, /* Usage (0x01) */
0x15, 0x00, /* Logical Minimum (0) */
0x81, 0x06, 0x25, 0x01, /* Logical Maximum (1) */
0xC0, 0x09, 0x75, 0x01, /* Report Size (1) */
0x3c, 0x05, 0x95, 0x02, /* Report Count (2) */
0xff, 0x09, 0xB1, 0x22, /* Feature (Data,Var,Abs,NoWrp) */
0x75, 0x06, /* Report Size (6) */
0x01, 0x15, 0x95, 0x01, /* Report Count (1) */
0x00, 0x25, 0xB1, 0x01, /* Feature (Const,Array,Abs,NoWrp) */
0x01, 0x75, 0xC0 /* End Collection */
0x01, 0x95,
0x02, 0xb1,
0x22, 0x75,
0x06, 0x95,
0x01, 0xb1,
0x01, 0xc0
}; };
/** /**
@@ -381,7 +373,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
USBD_HID_HandleTypeDef *hhid; USBD_HID_HandleTypeDef *hhid;
hhid = USBD_malloc(sizeof(USBD_HID_HandleTypeDef)); hhid = (USBD_HID_HandleTypeDef *)USBD_malloc(sizeof(USBD_HID_HandleTypeDef));
if (hhid == NULL) if (hhid == NULL)
{ {

View File

@@ -129,14 +129,14 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG
0x00, 0x00,
0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: */ 0x01, /* bConfigurationValue */
0x04, /* iConfiguration: */ 0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/ /******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */ 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 */ 0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent */ 0x06, /* bInterfaceSubClass : SCSI transparent */
0x50, /* nInterfaceProtocol */ 0x50, /* nInterfaceProtocol */
0x05, /* iInterface: */ 0x05, /* iInterface */
/******************** Mass Storage Endpoints ********************/ /******************** Mass Storage Endpoints ********************/
0x07, /* Endpoint descriptor length = 7 */ 0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */ 0x05, /* Endpoint descriptor type */
@@ -176,21 +176,21 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG
0x00, 0x00,
0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: */ 0x01, /* bConfigurationValue */
0x04, /* iConfiguration: */ 0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/ /******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */ 0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */ 0x04, /* bDescriptorType: */
0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints*/ 0x02, /* bNumEndpoints */
0x08, /* bInterfaceClass: MSC Class */ 0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent*/ 0x06, /* bInterfaceSubClass : SCSI transparent*/
0x50, /* nInterfaceProtocol */ 0x50, /* nInterfaceProtocol */
@@ -221,25 +221,25 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_OtherSpeedCfgDesc[USB_MSC_CONFIG_DESC_SIZ]
0x00, 0x00,
0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: */ 0x01, /* bConfigurationValue */
0x04, /* iConfiguration: */ 0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else #else
0x80, /* bmAttributes: Bus Powered according to user configuration */ 0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif #endif
USBD_MAX_POWER, /* MaxPower 100 mA */ USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/ /******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */ 0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */ 0x04, /* bDescriptorType */
0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints */ 0x02, /* bNumEndpoints */
0x08, /* bInterfaceClass: MSC Class */ 0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent command set */ 0x06, /* bInterfaceSubClass : SCSI transparent command set */
0x50, /* nInterfaceProtocol */ 0x50, /* nInterfaceProtocol */
0x05, /* iInterface: */ 0x05, /* iInterface */
/******************** Mass Storage Endpoints ********************/ /******************** Mass Storage Endpoints ********************/
0x07, /* Endpoint descriptor length = 7 */ 0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */ 0x05, /* Endpoint descriptor type */
@@ -293,7 +293,7 @@ uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
UNUSED(cfgidx); UNUSED(cfgidx);
USBD_MSC_BOT_HandleTypeDef *hmsc; 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) if (hmsc == NULL)
{ {

View File

@@ -0,0 +1,164 @@
/**
******************************************************************************
* @file usbd_printer.h
* @author MCD Application Team
* @brief header file for the usbd_printer.c file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_PRNT_H
#define __USB_PRNT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_ioreq.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup usbd_PRNT
* @brief This file is the Header file for usbd_PRNT.c
* @{
*/
/** @defgroup usbd_PRNT_Exported_Defines
* @{
*/
#ifndef PRNT_IN_EP
#define PRNT_IN_EP 0x81U /* Default: EP1 for data IN */
#endif /* PRNT_IN_EP */
#ifndef PRNT_OUT_EP
#define PRNT_OUT_EP 0x01U /* Default: EP1 for data OUT */
#endif /* PRNT_OUT_EP */
#ifndef PRNT_DATA_HS_MAX_PACKET_SIZE
#define PRNT_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
#endif /* PRNT_DATA_HS_MAX_PACKET_SIZE */
#ifndef PRNT_DATA_FS_MAX_PACKET_SIZE
#define PRNT_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
#endif /* PRNT_DATA_FS_MAX_PACKET_SIZE */
#define USB_PRNT_CONFIG_DESC_SIZ 32U
#define PRNT_DATA_HS_IN_PACKET_SIZE PRNT_DATA_HS_MAX_PACKET_SIZE
#define PRNT_DATA_HS_OUT_PACKET_SIZE PRNT_DATA_HS_MAX_PACKET_SIZE
#define PRNT_DATA_FS_IN_PACKET_SIZE PRNT_DATA_FS_MAX_PACKET_SIZE
#define PRNT_DATA_FS_OUT_PACKET_SIZE PRNT_DATA_FS_MAX_PACKET_SIZE
/*---------------------------------------------------------------------*/
/* PRNT definitions */
/*---------------------------------------------------------------------*/
#define PRNT_STATUS_PAPER_EMPTY 0x10U
#define PRNT_STATUS_SELECTED 0x08U
#define PRNT_STATUS_NO_ERROR 0x00U
#define USB_PRNT_SUBCLASS 0x01U
#define USB_PRNT_UNIDIRECTIONAL 0x01U
#define USB_PRNT_BIDIRECTIONAL 0x02U
/* USB PRNT Request types */
#define PRNT_GET_DEVICE_ID 0x00U
#define PRNT_GET_PORT_STATUS 0x01U
#define PRNT_SOFT_RESET 0x02U
/**
* @}
*/
/** @defgroup USBD_CORE_Exported_TypesDefinitions
* @{
*/
/**
* @}
*/
typedef struct _USBD_PRNT_Itf
{
int8_t (* Init)(void);
int8_t (* DeInit)(void);
int8_t (* Control_req)(uint8_t req, uint8_t *pbuf, uint16_t *length);
int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
} USBD_PRNT_ItfTypeDef;
typedef struct
{
uint32_t data[PRNT_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */
uint8_t CmdOpCode;
uint8_t CmdLength;
uint8_t *RxBuffer;
uint8_t *TxBuffer;
uint32_t RxLength;
uint32_t TxLength;
__IO uint32_t TxState;
__IO uint32_t RxState;
}
USBD_PRNT_HandleTypeDef;
/** @defgroup USBD_CORE_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Exported_Variables
* @{
*/
extern USBD_ClassTypeDef USBD_PRNT;
#define USBD_PRNT_CLASS &USBD_PRNT
/**
* @}
*/
/** @defgroup USB_CORE_Exported_Functions
* @{
*/
uint8_t USBD_PRNT_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_PRNT_ItfTypeDef *fops);
uint8_t USBD_PRNT_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
uint8_t USBD_PRNT_ReceivePacket(USBD_HandleTypeDef *pdev);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USB_PRNT_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,45 @@
/**
******************************************************************************
* @file usbd_printer_if_template.h
* @author MCD Application Team
* @brief Header for usbd_PRNT_if_template.c file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_PRNT_IF_TEMPLATE_H
#define __USBD_PRNT_IF_TEMPLATE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_printer.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
extern USBD_PRNT_ItfTypeDef USBD_PRNT_Template_fops;
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __USBD_PRNT_IF_TEMPLATE_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,673 @@
/**
******************************************************************************
* @file usbd_printer.c
* @author MCD Application Team
* @brief This file provides the high layer firmware functions to manage the
* following functionalities of the USB printer Class:
* - Initialization and Configuration of high and low layer
* - Enumeration as printer Device (and enumeration for each implemented memory interface)
* - OUT data transfer
* - Command OUT transfer (class requests management)
* - Error management
*
* @verbatim
*
* ===================================================================
* PRINTER Class Driver Description
* ===================================================================
* This driver manages the "Universal Serial Bus Class Definitions for Communications Devices
* Revision 1.2 November 16, 2007" and the sub-protocol specification of "Universal Serial Bus
* printer Class Subclass Specification for PSTN Devices Revision 1.2 February 9, 2007"
* This driver implements the following aspects of the specification:
* - Device descriptor management
* - Configuration descriptor management
* - Enumeration as printer device with 2 data endpoints (IN and OUT)
* - Control Requests management (PRNT_GET_DEVICE_ID,PRNT_GET_PORT_STATUS,PRNT_SOFT_RESET)
* - protocol USB_PRNT_BIDIRECTIONAL
*
*
*
* These aspects may be enriched or modified for a specific user application.
*
* This driver doesn't implement the following aspects of the specification
* (but it is possible to manage these features with some modifications on this driver):
* - Any class-specific aspect relative to communication classes should be managed by user application.
* - All communication classes other than PSTN are not managed
*
* @endverbatim
*
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* BSPDependencies
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
- "stm32xxxxx_{eval}{discovery}_io.c"
EndBSPDependencies */
/* Includes ------------------------------------------------------------------*/
#include "usbd_printer.h"
#include "usbd_ctlreq.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup USBD_PRNT
* @brief usbd core module
* @{
*/
/** @defgroup USBD_PRNT_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
static uint32_t usbd_PRNT_altset = 0U;
/** @defgroup USBD_PRNT_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_FunctionPrototypes
* @{
*/
static uint8_t USBD_PRNT_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
static uint8_t USBD_PRNT_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
static uint8_t USBD_PRNT_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
static uint8_t USBD_PRNT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
static uint8_t USBD_PRNT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
static uint8_t *USBD_PRNT_GetFSCfgDesc(uint16_t *length);
static uint8_t *USBD_PRNT_GetHSCfgDesc(uint16_t *length);
static uint8_t *USBD_PRNT_GetOtherSpeedCfgDesc(uint16_t *length);
static uint8_t *USBD_PRNT_GetOtherSpeedCfgDesc(uint16_t *length);
uint8_t *USBD_PRNT_GetDeviceQualifierDescriptor(uint16_t *length);
/* USB Standard Device Descriptor */
__ALIGN_BEGIN static uint8_t USBD_PRNT_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
{
USB_LEN_DEV_QUALIFIER_DESC,
USB_DESC_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
0x40,
0x01,
0x00,
};
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_Variables
* @{
*/
/* PRNT interface class callbacks structure */
USBD_ClassTypeDef USBD_PRNT =
{
USBD_PRNT_Init,
USBD_PRNT_DeInit,
USBD_PRNT_Setup,
NULL,
NULL,
USBD_PRNT_DataIn,
USBD_PRNT_DataOut,
NULL,
NULL,
NULL,
USBD_PRNT_GetHSCfgDesc,
USBD_PRNT_GetFSCfgDesc,
USBD_PRNT_GetOtherSpeedCfgDesc,
USBD_PRNT_GetDeviceQualifierDescriptor,
};
/* USB PRNT device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_PRNT_CfgHSDesc[] __ALIGN_END =
{
/*Configuration Descriptor*/
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_PRNT_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Self Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif
USBD_MAX_POWER, /* MaxPower in mA */
/* Interface Descriptor */
0x09, /* bLength: Interface Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: 2 endpoints used */
0x07, /* bInterfaceClass: Communication Interface Class */
0x01, /* bInterfaceSubClass: Abstract Control Model */
USB_PRNT_BIDIRECTIONAL, /* bDeviceProtocol */
0x00, /* iInterface */
/* Endpoint IN Descriptor */
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
PRNT_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */
LOBYTE(PRNT_DATA_HS_IN_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(PRNT_DATA_HS_IN_PACKET_SIZE),
0x00, /* bInterval */
/* Endpoint OUT Descriptor */
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
PRNT_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */
LOBYTE(PRNT_DATA_HS_OUT_PACKET_SIZE),/* wMaxPacketSize */
HIBYTE(PRNT_DATA_HS_OUT_PACKET_SIZE),
0x00 /* bInterval */
};
/* USB PRNT device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_PRNT_CfgFSDesc[] __ALIGN_END =
{
/*Configuration Descriptor*/
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_PRNT_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Self Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif
USBD_MAX_POWER, /* MaxPower in mA */
/*Interface Descriptor */
0x09, /* bLength: Interface Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: 2 endpoints used */
0x07, /* bInterfaceClass: Communication Interface Class */
0x01, /* bInterfaceSubClass: Abstract Control Model */
USB_PRNT_BIDIRECTIONAL, /* bDeviceProtocol */
0x00, /* iInterface */
/*Endpoint IN Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
PRNT_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */
LOBYTE(PRNT_DATA_FS_IN_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(PRNT_DATA_FS_IN_PACKET_SIZE),
0x00, /* bInterval */
/*Endpoint OUT Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
PRNT_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */
LOBYTE(PRNT_DATA_FS_OUT_PACKET_SIZE),/* wMaxPacketSize */
HIBYTE(PRNT_DATA_FS_OUT_PACKET_SIZE),
0x00 /* bInterval */
};
__ALIGN_BEGIN static uint8_t USBD_PRNT_OtherSpeedCfgDesc[] __ALIGN_END =
{
/*Configuration Descriptor*/
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_PRNT_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Self Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif
USBD_MAX_POWER, /* MaxPower in mA */
/*Interface Descriptor */
0x09, /* bLength: Interface Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: 2 endpoints used */
0x07, /* bInterfaceClass: Communication Interface Class */
0x01, /* bInterfaceSubClass: Abstract Control Model */
USB_PRNT_BIDIRECTIONAL, /* bDeviceProtocol */
0x00, /* iInterface */
/*Endpoint IN Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
PRNT_IN_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */
LOBYTE(PRNT_DATA_FS_IN_PACKET_SIZE), /* wMaxPacketSize */
HIBYTE(PRNT_DATA_FS_IN_PACKET_SIZE),
0x00, /* bInterval */
/*Endpoint OUT Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
PRNT_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes: Bulk */
LOBYTE(PRNT_DATA_FS_OUT_PACKET_SIZE),/* wMaxPacketSize */
HIBYTE(PRNT_DATA_FS_OUT_PACKET_SIZE),
0x00 /* bInterval */
};
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_Functions
* @{
*/
/**
* @brief USBD_PRNT_Init
* Initialize the PRNT interface
* @param pdev: device instance
* @param cfgidx: Configuration index
* @retval status
*/
static uint8_t USBD_PRNT_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
UNUSED(cfgidx);
USBD_PRNT_HandleTypeDef *hPRNT;
uint16_t mps;
hPRNT = (USBD_PRNT_HandleTypeDef *)USBD_malloc(sizeof(USBD_PRNT_HandleTypeDef));
if (hPRNT == NULL)
{
pdev->pClassData = NULL;
return (uint8_t)USBD_EMEM;
}
/* Setup the pClassData pointer */
pdev->pClassData = (void *)hPRNT;
/* Setup the max packet size according to selected speed */
if (pdev->dev_speed == USBD_SPEED_HIGH)
{
mps = PRNT_DATA_HS_IN_PACKET_SIZE;
}
else
{
mps = PRNT_DATA_FS_IN_PACKET_SIZE;
}
/* Open EP IN */
(void)USBD_LL_OpenEP(pdev, PRNT_IN_EP, USBD_EP_TYPE_BULK, mps);
/* Set endpoint as used */
pdev->ep_in[PRNT_IN_EP & 0xFU].is_used = 1U;
/* Open EP OUT */
(void)USBD_LL_OpenEP(pdev, PRNT_OUT_EP, USBD_EP_TYPE_BULK, mps);
/* Set endpoint as used */
pdev->ep_out[PRNT_OUT_EP & 0xFU].is_used = 1U;
/* Init physical Interface components */
((USBD_PRNT_ItfTypeDef *)pdev->pUserData)->Init();
/* Prepare Out endpoint to receive next packet */
(void)USBD_LL_PrepareReceive(pdev, PRNT_OUT_EP, hPRNT->RxBuffer, mps);
/* End of initialization phase */
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_PRNT_DeInit
* DeInitialize the PRNT layer
* @param pdev: device instance
* @param cfgidx: Configuration index
* @retval status
*/
static uint8_t USBD_PRNT_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
UNUSED(cfgidx);
/* Close EP IN */
(void)USBD_LL_CloseEP(pdev, PRNT_IN_EP);
pdev->ep_in[PRNT_IN_EP & 0xFU].is_used = 0U;
/* Close EP OUT */
(void)USBD_LL_CloseEP(pdev, PRNT_OUT_EP);
pdev->ep_out[PRNT_OUT_EP & 0xFU].is_used = 0U;
/* DeInit physical Interface components */
if (pdev->pClassData != NULL)
{
((USBD_PRNT_ItfTypeDef *)pdev->pUserData)->DeInit();
(void)USBD_free(pdev->pClassData);
pdev->pClassData = NULL;
}
return 0U;
}
/**
* @brief USBD_PRNT_Setup
* Handle the PRNT specific requests
* @param pdev: instance
* @param req: usb requests
* @retval status
*/
static uint8_t USBD_PRNT_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
{
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
USBD_PRNT_ItfTypeDef *hPRNTitf = (USBD_PRNT_ItfTypeDef *)pdev->pUserData;
USBD_StatusTypeDef ret = USBD_OK;
uint16_t status_info = 0U;
uint16_t data_length;
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
if (req->wLength != 0U)
{
data_length = MIN(req->wLength, PRNT_DATA_HS_MAX_PACKET_SIZE);
if ((req->bmRequest & 0x80U) != 0U)
{
/* Call the User class interface function to process the command */
hPRNTitf->Control_req(req->bRequest, (uint8_t *)hPRNT->data, &data_length);
/* Return the answer to host */
(void) USBD_CtlSendData(pdev, (uint8_t *)hPRNT->data, data_length);
}
else
{
/* Prepare for control data reception */
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)hPRNT->data, data_length);
}
}
else
{
data_length = 0U;
hPRNTitf->Control_req(req->bRequest, (uint8_t *)req, &data_length);
}
break;
case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_STATUS:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
(void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_GET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
(void)USBD_CtlSendData(pdev, (uint8_t *)&usbd_PRNT_altset, 1U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_SET_INTERFACE:
if (pdev->dev_state != USBD_STATE_CONFIGURED)
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_CLEAR_FEATURE:
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
return (uint8_t)ret;
}
/**
* @brief USBD_PRNT_DataIn
* Data sent on non-control IN endpoint
* @param pdev: device instance
* @param epnum: endpoint number
* @retval status
*/
static uint8_t USBD_PRNT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
PCD_HandleTypeDef *hpcd = pdev->pData;
if (hPRNT == NULL)
{
return (uint8_t)USBD_FAIL;
}
if ((pdev->ep_in[epnum].total_length > 0U) &&
((pdev->ep_in[epnum].total_length % hpcd->IN_ep[epnum].maxpacket) == 0U))
{
/* Update the packet total length */
pdev->ep_in[epnum].total_length = 0U;
/* Send ZLP */
(void) USBD_LL_Transmit(pdev, epnum, NULL, 0U);
}
else
{
hPRNT->TxState = 0U;
}
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_PRNT_DataOut
* Data received on non-control Out endpoint
* @param pdev: device instance
* @param epnum: endpoint number
* @retval status
*/
static uint8_t USBD_PRNT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
if (hPRNT == NULL)
{
return (uint8_t)USBD_FAIL;
}
/* Get the received data length */
hPRNT->RxLength = USBD_LL_GetRxDataSize(pdev, epnum);
/* USB data will be immediately processed, this allow next USB traffic being
NAKed till the end of the application Xfer */
((USBD_PRNT_ItfTypeDef *)pdev->pUserData)->Receive(hPRNT->RxBuffer, &hPRNT->RxLength);
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_PRNT_GetFSCfgDesc
* Return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
static uint8_t *USBD_PRNT_GetFSCfgDesc(uint16_t *length)
{
*length = (uint16_t) sizeof(USBD_PRNT_CfgFSDesc);
return USBD_PRNT_CfgFSDesc;
}
/**
* @brief USBD_PRNT_GetHSCfgDesc
* Return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
static uint8_t *USBD_PRNT_GetHSCfgDesc(uint16_t *length)
{
*length = (uint16_t) sizeof(USBD_PRNT_CfgHSDesc);
return USBD_PRNT_CfgHSDesc;
}
/**
* @brief USBD_PRNT_GetOtherSpeedCfgDesc
* Return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
static uint8_t *USBD_PRNT_GetOtherSpeedCfgDesc(uint16_t *length)
{
*length = (uint16_t) sizeof(USBD_PRNT_OtherSpeedCfgDesc);
return USBD_PRNT_OtherSpeedCfgDesc;
}
/**
* @brief USBD_PRNT_GetDeviceQualifierDescriptor
* return Device Qualifier descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_PRNT_GetDeviceQualifierDescriptor(uint16_t *length)
{
*length = (uint16_t)sizeof(USBD_PRNT_DeviceQualifierDesc);
return USBD_PRNT_DeviceQualifierDesc;
}
/**
* @brief USBD_PRNT_RegisterInterface
* @param pdev: device instance
* @param fops: Interface callbacks
* @retval status
*/
uint8_t USBD_PRNT_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_PRNT_ItfTypeDef *fops)
{
/* Check if the fops pointer is valid */
if (fops == NULL)
{
return (uint8_t)USBD_FAIL;
}
/* Setup the fops pointer */
pdev->pUserData = fops;
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_PRNT_SetRxBuffer
* @param pdev: device instance
* @param pbuff: Rx Buffer
* @retval status
*/
uint8_t USBD_PRNT_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
{
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *) pdev->pClassData;
hPRNT->RxBuffer = pbuff;
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_PRNT_ReceivePacket
* prepare OUT Endpoint for reception
* @param pdev: device instance
* @retval status
*/
uint8_t USBD_PRNT_ReceivePacket(USBD_HandleTypeDef *pdev)
{
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
if (hPRNT == NULL)
{
return (uint8_t)USBD_FAIL;
}
if (pdev->dev_speed == USBD_SPEED_HIGH)
{
/* Prepare Out endpoint to receive next packet */
(void)USBD_LL_PrepareReceive(pdev, PRNT_OUT_EP, hPRNT->RxBuffer,
PRNT_DATA_HS_OUT_PACKET_SIZE);
}
else
{
/* Prepare Out endpoint to receive next packet */
(void)USBD_LL_PrepareReceive(pdev, PRNT_OUT_EP, hPRNT->RxBuffer,
PRNT_DATA_FS_OUT_PACKET_SIZE);
}
return (uint8_t)USBD_OK;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,218 @@
/**
******************************************************************************
* @file usbd_printer_if_template.c
* @author MCD Application Team
* @brief Generic media access Layer.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.st.com/SLA0044
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usbd_printer_if_template.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup USBD_PRNT
* @brief usbd core module
* @{
*/
/** @defgroup USBD_PRNT_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_PRNT_Private_FunctionPrototypes
* @{
*/
static int8_t TEMPLATE_Init(void);
static int8_t TEMPLATE_DeInit(void);
static int8_t TEMPLATE_Control_req(uint8_t req, uint8_t *pbuf, uint16_t *length);
static int8_t TEMPLATE_Receive(uint8_t *pbuf, uint32_t *Len);
/*printer Private function prototypes*/
void TEMPLATE_PRNT_PageEndManager(uint8_t *Buf, uint32_t Len);
USBD_PRNT_ItfTypeDef USBD_PRNT_Template_fops =
{
TEMPLATE_Init,
TEMPLATE_DeInit,
TEMPLATE_Control_req
TEMPLATE_Receive
};
static uint8_t PRNT_DEVICE_ID[DEVICE_ID_LEN] =
{
0x00, 0x6D,
'M', 'A', 'N', 'U', 'F', 'A', 'C', 'T', 'U', 'R', 'E', 'R', ':',
'S', 'T', 'M', 'i', 'c', 'r', 'o', 'e', 'l', 'e', 'c', 't', 'r', 'o', 'n', 'i', 'c', 's', ';',
'C', 'O', 'M', 'M', 'A', 'N', 'D', ' ', 'S', 'E', 'T', ':',
'P', 'D', 'L', ',', 'P', 'C', 'P', ';',
'M', 'O', 'D', 'E', 'L', ':',
'U', 'S', 'B', 'P', 'r', 'i', 'n', 't', 'e', 'r', ';',
'C', 'O', 'M', 'M', 'E', 'N', 'T', ':',
'G', 'o', 'o', 'd', ' ', '!', ';',
'A', 'C', 'T', 'I', 'V', 'E', ' ', 'C', 'O', 'M', 'M', 'A', 'N', 'D', ' ', 'S', 'E', 'T', ':',
'P', 'C', 'P', ';'
};
/* Private functions ---------------------------------------------------------*/
/**
* @brief TEMPLATE_Init
* Initializes the PRNT media low layer
* @param None
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t TEMPLATE_Init(void)
{
/*
Add your initialization code here
*/
return (0);
}
/**
* @brief TEMPLATE_DeInit
* DeInitializes the PRNT media low layer
* @param None
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t TEMPLATE_DeInit(void)
{
/*
Add your deinitialization code here
*/
return (0);
}
/**
* @brief TEMPLATE_Receive
* Data received over USB OUT endpoint are sent over PRNT interface
* through this function.
*
* @note
* This function will issue a NAK packet on any OUT packet received on
* USB endpoint untill exiting this function. If you exit this function
* before transfer is complete on PRNT interface (ie. using DMA controller)
* it will result in receiving more data while previous ones are still
* not sent.
*
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t TEMPLATE_Receive(uint8_t *Buf, uint32_t *Len)
{
UNUSED(Buf);
UNUSED(Len);
return (0);
}
/**
* @brief TEMPLATE_PRNT_Itf_Control_req
* Manage the PRNT class requests
* @param req: Command code
* @param pbuf: Buffer containing command data (request parameters)
* @param length: Number of data to be sent (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t TEMPLATE_PRNT_Itf_Control_req(uint8_t req, uint8_t *pbuf, uint16_t *length)
{
uint32_t i = 0;
/* Check on the setup request value */
switch (req)
{
/* Get Printer Device ID request */
case PRNT_GET_DEVICE_ID:
/* Not using for loop here due to MISRA-C2012-Rule-16.1 */
while (i < sizeof(PRNT_DEVICE_ID))
{
pbuf[i] = PRNT_DEVICE_ID[i];
i++;
}
*length = i;
break;
/* Get Printer current status */
case PRNT_GET_PORT_STATUS:
pbuf[0] = PRNT_STATUS_PAPER_EMPTY |
PRNT_STATUS_SELECTED |
PRNT_STATUS_NO_ERROR;
*length = 1U;
break;
/* Printer SOFT RESET request: cleanup pending tasks */
case PRNT_SOFT_RESET:
(void)f_close(&hSD.MyFile);
break;
default:
/* Unkown commands are not managed */
break;
}
/**
* @brief TEMPLATE_PRNT_PageEndManager, defined by user
* Call this function frequently to check if data is received.
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
*/
void TEMPLATE_PRNT_PageEndManager(uint8_t *Buf, uint32_t Len)
{
UNUSED(Buf);
UNUSED(Len);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -453,5 +453,8 @@ uint8_t USBD_VIDEO_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_VIDEO_ItfTyp
* @} * @}
*/ */
#ifdef __cplusplus
}
#endif
#endif /* _USBD_VIDEO_H_ */ #endif /* _USBD_VIDEO_H_ */

View File

@@ -138,7 +138,7 @@ __ALIGN_BEGIN static uint8_t USBD_VIDEO_CfgDesc[] __ALIGN_END =
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
LOBYTE(UVC_CONFIG_DESC_SIZ), /* wTotalLength: no of returned bytes */ LOBYTE(UVC_CONFIG_DESC_SIZ), /* wTotalLength: no of returned bytes */
HIBYTE(UVC_CONFIG_DESC_SIZ), HIBYTE(UVC_CONFIG_DESC_SIZ),
0x02, /* bNumInterfaces: 2 interface */ 0x02, /* bNumInterfaces: 2 interfaces */
0x01, /* bConfigurationValue: Configuration value */ 0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
#if (USBD_SELF_POWERED == 1U) #if (USBD_SELF_POWERED == 1U)
@@ -260,7 +260,11 @@ __ALIGN_BEGIN static uint8_t USBD_VIDEO_CfgDesc[] __ALIGN_END =
CS_INTERFACE, /* bDescriptorType */ CS_INTERFACE, /* bDescriptorType */
VS_FRAME_SUBTYPE, /* bDescriptorSubType */ VS_FRAME_SUBTYPE, /* bDescriptorSubType */
0x01, /* bFrameIndex */ 0x01, /* bFrameIndex */
#ifdef USBD_UVC_FORMAT_UNCOMPRESSED
0x00, /* bmCapabilities: no till image capture */
#else
0x02, /* bmCapabilities: fixed frame rate supported */ 0x02, /* bmCapabilities: fixed frame rate supported */
#endif
WBVAL(UVC_WIDTH), /* wWidth: Image Frame Width */ WBVAL(UVC_WIDTH), /* wWidth: Image Frame Width */
WBVAL(UVC_HEIGHT), /* wHeight: Image Frame Height */ WBVAL(UVC_HEIGHT), /* wHeight: Image Frame Height */
DBVAL(UVC_MIN_BIT_RATE(UVC_CAM_FPS_FS)), /* dwMinBitRate: Minimum supported bit rate in bits/s */ DBVAL(UVC_MIN_BIT_RATE(UVC_CAM_FPS_FS)), /* dwMinBitRate: Minimum supported bit rate in bits/s */
@@ -378,7 +382,7 @@ static uint8_t USBD_VIDEO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
USBD_VIDEO_HandleTypeDef *hVIDEO; USBD_VIDEO_HandleTypeDef *hVIDEO;
/* Allocate memory for the video control structure */ /* Allocate memory for the video control structure */
hVIDEO = USBD_malloc(sizeof(USBD_VIDEO_HandleTypeDef)); hVIDEO = (USBD_VIDEO_HandleTypeDef *)USBD_malloc(sizeof(USBD_VIDEO_HandleTypeDef));
/* Check if allocated point is NULL, then exit with error code */ /* Check if allocated point is NULL, then exit with error code */
if (hVIDEO == NULL) if (hVIDEO == NULL)
@@ -518,7 +522,7 @@ static uint8_t USBD_VIDEO_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
case USB_REQ_GET_INTERFACE : case USB_REQ_GET_INTERFACE :
if (pdev->dev_state == USBD_STATE_CONFIGURED) if (pdev->dev_state == USBD_STATE_CONFIGURED)
{ {
(void) USBD_CtlSendData(pdev, (uint8_t *)&hVIDEO->interface, 1); (void)USBD_CtlSendData(pdev, (uint8_t *)&hVIDEO->interface, 1U);
} }
else else
{ {
@@ -752,7 +756,8 @@ static void VIDEO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
} }
/* Probe Request */ /* Probe Request */
(void) USBD_CtlSendData(pdev, (uint8_t *)&video_Probe_Control, req->wLength); (void)USBD_CtlSendData(pdev, (uint8_t *)&video_Probe_Control,
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
} }
else if (LOBYTE(req->wValue) == (uint8_t)VS_COMMIT_CONTROL) else if (LOBYTE(req->wValue) == (uint8_t)VS_COMMIT_CONTROL)
{ {
@@ -768,12 +773,14 @@ static void VIDEO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
} }
/* Commit Request */ /* Commit Request */
(void) USBD_CtlSendData(pdev, (uint8_t *)&video_Commit_Control, req->wLength); (void)USBD_CtlSendData(pdev, (uint8_t *)&video_Commit_Control,
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
} }
else else
{ {
/* Send the current mute state */ /* Send the current state */
(void) USBD_CtlSendData(pdev, hVIDEO->control.data, req->wLength); (void) USBD_CtlSendData(pdev, hVIDEO->control.data,
MIN(req->wLength, USB_MAX_EP0_SIZE));
} }
} }
} }
@@ -796,17 +803,20 @@ static void VIDEO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
if (LOBYTE(req->wValue) == (uint8_t)VS_PROBE_CONTROL) if (LOBYTE(req->wValue) == (uint8_t)VS_PROBE_CONTROL)
{ {
/* Probe Request */ /* Probe Request */
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Probe_Control, req->wLength); (void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Probe_Control,
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
} }
else if (LOBYTE(req->wValue) == (uint8_t)VS_COMMIT_CONTROL) else if (LOBYTE(req->wValue) == (uint8_t)VS_COMMIT_CONTROL)
{ {
/* Commit Request */ /* Commit Request */
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Commit_Control, req->wLength); (void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Commit_Control,
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
} }
else else
{ {
/* Prepare the reception of the buffer over EP0 */ /* Prepare the reception of the buffer over EP0 */
(void) USBD_CtlPrepareRx(pdev, hVIDEO->control.data, req->wLength); (void) USBD_CtlPrepareRx(pdev, hVIDEO->control.data,
MIN(req->wLength, USB_MAX_EP0_SIZE));
} }
} }
} }
@@ -946,8 +956,9 @@ static void *USBD_VIDEO_GetVSFrameDesc(uint8_t *pConfDesc)
{ {
pdesc = USBD_VIDEO_GetNextDesc((uint8_t *)pdesc, &ptr); pdesc = USBD_VIDEO_GetNextDesc((uint8_t *)pdesc, &ptr);
if ((pdesc->bDescriptorSubType == VS_FRAME_MJPEG) || if (((pdesc->bDescriptorSubType == VS_FRAME_MJPEG) ||
(pdesc->bDescriptorSubType == VS_FRAME_UNCOMPRESSED)) (pdesc->bDescriptorSubType == VS_FRAME_UNCOMPRESSED)) &&
(pdesc->bLength == VS_FRAME_DESC_SIZE))
{ {
pVSFrameDesc = (USBD_VIDEO_VSFrameDescTypeDef *)(void *)pdesc; pVSFrameDesc = (USBD_VIDEO_VSFrameDescTypeDef *)(void *)pdesc;
break; break;

View File

@@ -169,14 +169,14 @@ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
/** /**
* @brief Assigns a USB address to the device. * @brief Assigns a USB address to the device.
* @param pdev: Device handle * @param pdev: Device handle
* @param ep_addr: Endpoint Number * @param dev_addr: Endpoint Number
* @retval USBD Status * @retval USBD Status
*/ */
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev,
uint8_t dev_addr) uint8_t dev_addr)
{ {
UNUSED(pdev); UNUSED(pdev);
UNUSED(ep_addr); UNUSED(dev_addr);
return USBD_OK; return USBD_OK;
} }

View File

@@ -893,7 +893,8 @@ ul
</xml><![endif]--><!--[if gte mso 9]><xml> </xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit"> <o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/> <o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]--><meta content="MCD Application Team" name="author"></head><body style="" link="blue" vlink="blue"> </o:shapelayout></xml><![endif]--><meta content="MCD Application Team" name="author"></head>
<body style="" link="blue" vlink="blue">
<div class="WordSection1"> <div class="WordSection1">
@@ -923,12 +924,15 @@ ul
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" width="900"> <table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" width="900">
<tbody><tr> <tbody><tr>
<td style="padding: 0in;" valign="top"> <td style="padding: 0in;" valign="top">
<h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><a name="History"></a><span style="font-size: 12pt; color: white;">Update History</span></h2> <h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"><a name="History"></a><span style="font-size: 12pt; color: white;">Update History</span></h2>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.7.1 / 18-August-2020</span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.8.0 / 10-Mars-2021</span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
<b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main Changes</span></u></b></p><ul style="margin-top: 0cm;" type="square"><li>Integration of&nbsp; new USB device Class driver:</li><ul><li>USB Printer Class driver based on&nbsp;Universal Serial Bus
Changes<br> Device Class Definition
</span></u></b> for
Printing Devices Version 1.1</li></ul><li>USB All Classes:</li><ul><li>Fix USB buffer overflow vulnerability for CDC, CDC-ECM, CDC-RNDIS, DFU, AUDIO, CustomHID, and Video Classes</li><li>fix compilation warning with C++ due to missing casting during class handler allocation</li><li>Enhance comments of USB configuration descriptors fields</li></ul><li>USB Video Class:</li><ul><li>fix missing closing bracket for extern "C" in usbd_video.h</li><li>fix USBCV test with Uncompressed video format support</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.7.1 / 18-August-2020</span></h3>
<b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;"></span></u></b><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes</span></u></b></p>
<ul style="margin-top: 0cm;" type="square"> <ul style="margin-top: 0cm;" type="square">
<li>USB All Class:</li> <li>USB All Class:</li>
<ul> <ul>
@@ -937,7 +941,7 @@ Changes<br>
</ul> </ul>
</ul> </ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.7.0 / 12-August-2020</span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.7.0 / 12-August-2020</span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main <p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes</span></u></b></p><ul style="margin-top: 0cm;" type="square"><li>Integration of&nbsp; new USB device Class driver:</li><ul><li>USB video Class driver based on USB-IF video class definition version 1.1</li></ul></ul> Changes</span></u></b></p><ul style="margin-top: 0cm;" type="square"><li>Integration of&nbsp; new USB device Class driver:</li><ul><li>USB video Class driver based on USB-IF video class definition version 1.1</li></ul></ul>
@@ -966,7 +970,7 @@ Changes</span></u></b></p><ul style="margin-top: 0cm;" type="square"><li>Integra
<ul style="margin-top: 0cm;" type="square"><li>USB Core:</li><ul><li>Enhance NULL pointer check in Core APIs</li><li>Allow supporting both USER and USER Class string desc</li><li>Add support of USB controller which handles packet-size splitting by hardware</li><li>Avoid compilation warning due macro redefinition</li><li>change <ul style="margin-top: 0cm;" type="square"><li>USB Core:</li><ul><li>Enhance NULL pointer check in Core APIs</li><li>Allow supporting both USER and USER Class string desc</li><li>Add support of USB controller which handles packet-size splitting by hardware</li><li>Avoid compilation warning due macro redefinition</li><li>change
added to USBD_HandleTypeDef structure: dev_state, old_dev_state and added to USBD_HandleTypeDef structure: dev_state, old_dev_state and
ep0_state declaration become volatile to disable compiler optimization</li><li>Word spelling correction and file indentation improved</li><li>usbd_conf.h/c Template file updated to suggest using by default a static memory allocation for Class handler</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB All Classes</li><ul><li>Word spelling correction and file indentation improved</li><li>Allow updating device config descriptor Max power from user code usbd_conf.h using USBD_MAX_POWER define</li><li>Fix device config descriptor bmAttributes value which depends on user code define USBD_SELF_POWERED</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB CDC Class:</li><ul><li>Class specific request, add protection to limit the maximum data length to be sent by the CDC device</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB CustomHID Class:</li><ul><li>Allow changing CustomHID data EP size from user code </li></ul></ul> ep0_state declaration become volatile to disable compiler optimization</li><li>Word spelling correction and file indentation improved</li><li>usbd_conf.h/c Template file updated to suggest using by default a static memory allocation for Class handler</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB All Classes</li><ul><li>Word spelling correction and file indentation improved</li><li>Allow updating device config descriptor Max power from user code usbd_conf.h using USBD_MAX_POWER define</li><li>Fix device config descriptor bmAttributes value which depends on user code define USBD_SELF_POWERED</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB CDC Class:</li><ul><li>Class specific request, add protection to limit the maximum data length to be sent by the CDC device</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB CustomHID Class:</li><ul><li>Allow changing CustomHID data EP size from user code </li></ul></ul>
<br><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.6.1 / 05-June-2020</span></h3> <br><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.6.1 / 05-June-2020</span></h3>
@@ -1015,7 +1019,7 @@ compatibility with device library version below v2.6.0<br>
<ul style="margin-top: 0cm;" type="square"> <ul style="margin-top: 0cm;" type="square">
<li>Fix minor misra-c 2012 violations</li> <li>Fix minor misra-c 2012 violations</li>
</ul> </ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.6.0 / 27-December-2019</span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.6.0 / 27-December-2019</span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main <p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></p> Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></p>
@@ -1039,7 +1043,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
<ul style="margin-top: 0cm;" type="square"><li>Integration of three new USB device Class drivers:</li><ul><li>USB CDC ECM Class driver</li><li>USB CDC RNDIS Microsoft Class driver</li><li>USB Billboard Class driver</li></ul><li>Fix mandatory misra-c 2012 violations</li><li>update user core and class template files</li><li>USB Core:</li><ul><li>Fix unexpected EP0 stall during enumeration phase&nbsp;</li><li>Improve APIs error&nbsp;management and prevent accessing NULL pointers</li></ul><li>USB MSC Class:</li><ul><li>Fix USBCV specific class tests</li><li>Fix multiple error with SCSI commands handling</li><li>Protect medium access when host ask for medium ejection</li></ul><li>USB CDC Class:</li><ul><li>Add new function to inform user that current IN transfer is completed</li><li>update transmit and receive APIs to transfer up to 64KB</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB AUDIO Class:</li><ul><li>Fix audio sync start buffer size</li><li>update user callback periodicTC args by adding pointer to user buffer and size</li></ul><li>USB CustomHID Class:</li><ul><li>Rework the OUT transfer complete and prevent automatically re-enabling the OUT EP&nbsp;</li><li>Add new user API to restart the OUT transfer: USBD_CUSTOM_HID_ReceivePacket()</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.3 / 30-April-2019</span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main <ul style="margin-top: 0cm;" type="square"><li>Integration of three new USB device Class drivers:</li><ul><li>USB CDC ECM Class driver</li><li>USB CDC RNDIS Microsoft Class driver</li><li>USB Billboard Class driver</li></ul><li>Fix mandatory misra-c 2012 violations</li><li>update user core and class template files</li><li>USB Core:</li><ul><li>Fix unexpected EP0 stall during enumeration phase&nbsp;</li><li>Improve APIs error&nbsp;management and prevent accessing NULL pointers</li></ul><li>USB MSC Class:</li><ul><li>Fix USBCV specific class tests</li><li>Fix multiple error with SCSI commands handling</li><li>Protect medium access when host ask for medium ejection</li></ul><li>USB CDC Class:</li><ul><li>Add new function to inform user that current IN transfer is completed</li><li>update transmit and receive APIs to transfer up to 64KB</li></ul></ul><ul style="margin-top: 0cm;" type="square"><li>USB AUDIO Class:</li><ul><li>Fix audio sync start buffer size</li><li>update user callback periodicTC args by adding pointer to user buffer and size</li></ul><li>USB CustomHID Class:</li><ul><li>Rework the OUT transfer complete and prevent automatically re-enabling the OUT EP&nbsp;</li><li>Add new user API to restart the OUT transfer: USBD_CUSTOM_HID_ReceivePacket()</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.3 / 30-April-2019</span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></p> Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></p>
@@ -1062,7 +1066,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
<ul style="margin-top: 0cm;" type="square"><li>Fix misra-c 2012 high severity violations</li><li>Core driver:</li><ul><li>protect shared macros __ALIGN_BEGIN, __ALIGN_END with C directive #ifndef</li><li>update Core driver and DFU Class driver to use&nbsp;USBD_SUPPORT_USER_STRING_DESC instead of &nbsp;USBD_SUPPORT_USER_STRING</li><li>&nbsp;prevent accessing to NULL pointer if the get descriptor functions are not defined</li><li>Update on USBD_LL_Resume(),&nbsp; restore the device state only if the current state is USBD_STATE_SUSPENDED </li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.2 / 27-Mars-2019</span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main <ul style="margin-top: 0cm;" type="square"><li>Fix misra-c 2012 high severity violations</li><li>Core driver:</li><ul><li>protect shared macros __ALIGN_BEGIN, __ALIGN_END with C directive #ifndef</li><li>update Core driver and DFU Class driver to use&nbsp;USBD_SUPPORT_USER_STRING_DESC instead of &nbsp;USBD_SUPPORT_USER_STRING</li><li>&nbsp;prevent accessing to NULL pointer if the get descriptor functions are not defined</li><li>Update on USBD_LL_Resume(),&nbsp; restore the device state only if the current state is USBD_STATE_SUSPENDED </li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.2 / 27-Mars-2019</span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></p> Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></p>
@@ -1086,7 +1090,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
<ul style="margin-top: 0cm;" type="square"><li><span style="font-family: Verdana; font-size: 10pt;">DFU Class:</span></li><ul><li><span style="font-family: Verdana; font-size: 10pt;"></span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,sans-serif;" lang="EN-US"></span><span style="font-family: Verdana; font-size: 10pt;"></span>fix compilation warning due to&nbsp;<span style="font-size: 11pt; font-family: &quot;Calibri&quot;,sans-serif;" lang="EN-US">unreachable <ul style="margin-top: 0cm;" type="square"><li><span style="font-family: Verdana; font-size: 10pt;">DFU Class:</span></li><ul><li><span style="font-family: Verdana; font-size: 10pt;"></span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,sans-serif;" lang="EN-US"></span><span style="font-family: Verdana; font-size: 10pt;"></span>fix compilation warning due to&nbsp;<span style="font-size: 11pt; font-family: &quot;Calibri&quot;,sans-serif;" lang="EN-US">unreachable
</span> instruction code introduced with CMSIS V5.4.0 NVIC_SystemReset() prototype change</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.1 / 03-August-2018<br> </span> instruction code introduced with CMSIS V5.4.0 NVIC_SystemReset() prototype change</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.1 / 03-August-2018<br>
</span></h3> </span></h3>
@@ -1128,7 +1132,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
<ul style="margin-top: 0cm;" type="square"><li><span style="font-size: 10pt; font-family: Verdana;">Update license section by adding path to get copy of ST Ultimate Liberty license</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Core: Fix unexpected stall during status OUT phase</span></li><li><span style="font-family: Verdana; font-size: 10pt;">DFU Class:</span></li><ul><li><span style="font-family: Verdana; font-size: 10pt;">rework hdfu struct to prevent&nbsp;</span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,sans-serif;" lang="EN-US">unaligned </span><span style="font-family: Verdana; font-size: 10pt;"> addresses</span></li></ul><li>MSC Class:</li><ul><li>fix lba address overflow during large file transfers &gt; 4Go</li></ul><li>Template Class:</li><ul><li>add missing Switch case Break on USBD_Template_Setup API</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.0 / 15-December-2017<br> <ul style="margin-top: 0cm;" type="square"><li><span style="font-size: 10pt; font-family: Verdana;">Update license section by adding path to get copy of ST Ultimate Liberty license</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Core: Fix unexpected stall during status OUT phase</span></li><li><span style="font-family: Verdana; font-size: 10pt;">DFU Class:</span></li><ul><li><span style="font-family: Verdana; font-size: 10pt;">rework hdfu struct to prevent&nbsp;</span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,sans-serif;" lang="EN-US">unaligned </span><span style="font-family: Verdana; font-size: 10pt;"> addresses</span></li></ul><li>MSC Class:</li><ul><li>fix lba address overflow during large file transfers &gt; 4Go</li></ul><li>Template Class:</li><ul><li>add missing Switch case Break on USBD_Template_Setup API</li></ul></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.5.0 / 15-December-2017<br>
</span></h3> </span></h3>
@@ -1170,7 +1174,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
<ul style="margin-top: 0cm;" type="square"><li><span style="font-size: 10pt; font-family: Verdana;">Update license section</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Update</span><span style="font-size: 10pt; font-family: Verdana;">&nbsp;some functions to be&nbsp;</span><span style="font-size: 10pt; font-family: Verdana;">MISRAC 2004</span><span style="font-size: 10pt; font-family: Verdana;"> compliant</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Add HS and OtherSpeed configuration descriptor for HID and&nbsp;CustomHID classes</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Correct error handling in all class setup function</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Add usbd_desc_template.c/ usbd_desc_template.h templates files</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Add support of class and vendor request<br></span></li><li><span style="font-family: Verdana; font-size: 10pt;">CDC Class:&nbsp;</span><span style="font-family: Verdana; font-size: 10pt;">fix zero-length packet issue in bulk IN transfer</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Fix compilation warning with unused arguments for some functions</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Improve USB Core enumeration state machine<br></span></li></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.4.2 / 11-December-2015<br> <ul style="margin-top: 0cm;" type="square"><li><span style="font-size: 10pt; font-family: Verdana;">Update license section</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Update</span><span style="font-size: 10pt; font-family: Verdana;">&nbsp;some functions to be&nbsp;</span><span style="font-size: 10pt; font-family: Verdana;">MISRAC 2004</span><span style="font-size: 10pt; font-family: Verdana;"> compliant</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Add HS and OtherSpeed configuration descriptor for HID and&nbsp;CustomHID classes</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Correct error handling in all class setup function</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Add usbd_desc_template.c/ usbd_desc_template.h templates files</span></li><li><span style="font-size: 10pt; font-family: Verdana;">Add support of class and vendor request<br></span></li><li><span style="font-family: Verdana; font-size: 10pt;">CDC Class:&nbsp;</span><span style="font-family: Verdana; font-size: 10pt;">fix zero-length packet issue in bulk IN transfer</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Fix compilation warning with unused arguments for some functions</span></li><li><span style="font-family: Verdana; font-size: 10pt;">Improve USB Core enumeration state machine<br></span></li></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.4.2 / 11-December-2015<br>
</span></h3> </span></h3>
@@ -1217,7 +1221,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
</ul> </ul>
<br> <br>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.4.1 / 19-June-2015<br> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.4.1 / 19-June-2015<br>
</span></h3> </span></h3>
@@ -1276,7 +1280,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.4.0 / 28-February-2015<br> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.4.0 / 28-February-2015<br>
</span></h3> </span></h3>
@@ -1326,7 +1330,7 @@ USBD_CDC_Setup() function to allow correct user implementation of
CDC_SET_CONTROL_LINE_STATE and similar no-data setup requests.<br></span></li></ul></ul> CDC_SET_CONTROL_LINE_STATE and similar no-data setup requests.<br></span></li></ul></ul>
</ul> </ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.3.0 / 04-November-2014<br> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.3.0 / 04-November-2014<br>
</span></h3> </span></h3>
@@ -1369,7 +1373,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
</ul> </ul>
<li><span style="font-size: 10pt; font-family: Verdana;">Miscellaneous source code comments update</span></li> <li><span style="font-size: 10pt; font-family: Verdana;">Miscellaneous source code comments update</span></li>
</ul> </ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.2.0 / 13-June-2014</span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.2.0 / 13-June-2014</span></h3>
@@ -1415,7 +1419,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
</ul> </ul>
</ul> </ul>
<div style="margin-left: 80px;"><span style="font-size: 10pt; font-family: Verdana;">ex. for the HID, the <span style="font-style: italic;">USBD_HID_CLASS</span> macro is defined this way </span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic;">#define USBD_HID_CLASS&nbsp; &amp;USBD_HID</span></span><br>&nbsp; <span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;">and the application code can use the previous definition: <span style="font-style: italic;">&amp;USBD_HID</span> ex. <span style="font-style: italic;">USBD_RegisterClass(&amp;USBD_Device, &amp;USBD_HID)</span> or the new <span style="font-style: italic;">USBD_HID_CLASS</span> ex. <span style="font-style: italic;">USBD_RegisterClass(&amp;USBD_Device, USBD_HID_CLASS)</span></span></div> <div style="margin-left: 80px;"><span style="font-size: 10pt; font-family: Verdana;">ex. for the HID, the <span style="font-style: italic;">USBD_HID_CLASS</span> macro is defined this way </span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic;">#define USBD_HID_CLASS&nbsp; &amp;USBD_HID</span></span><br>&nbsp; <span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;">and the application code can use the previous definition: <span style="font-style: italic;">&amp;USBD_HID</span> ex. <span style="font-style: italic;">USBD_RegisterClass(&amp;USBD_Device, &amp;USBD_HID)</span> or the new <span style="font-style: italic;">USBD_HID_CLASS</span> ex. <span style="font-style: italic;">USBD_RegisterClass(&amp;USBD_Device, USBD_HID_CLASS)</span></span></div>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.1.0 / 22-April-2014</span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.1.0 / 22-April-2014</span></h3>
@@ -1453,7 +1457,7 @@ Changes</span></u></b><u><span style="font-size: 10pt; font-family: Verdana; col
</ul> </ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.0.0 / 18-February-2014</span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.0.0 / 18-February-2014</span></h3>
@@ -1478,14 +1482,14 @@ modified vs. V1.1.0, and thus the 2 versions are not compatible.<br>
</ul> </ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 200px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.1.0 / 19-March-2012<o:p></o:p></span></h3> <h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 200px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.1.0 / 19-March-2012<o:p></o:p></span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main <p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p> Changes<o:p></o:p></span></u></b></p>
<ul style="margin-top: 0cm;" type="square"><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Official support of </span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-weight: bold; font-style: italic;">STM32F4xx</span> devices</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">All source files: license disclaimer text update and add link to the License file on ST Internet.<br></span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Handle test mode in the set feature request</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Handle dynamically the USB SELF POWERED feature</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Handle correctly the USBD_CtlError process to take into account error during Control OUT stage</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Miscellaneous bug fix</span></li></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 171px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.0.0 / 22-July-2011<o:p></o:p></span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main <ul style="margin-top: 0cm;" type="square"><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Official support of </span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-weight: bold; font-style: italic;">STM32F4xx</span> devices</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">All source files: license disclaimer text update and add link to the License file on ST Internet.<br></span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Handle test mode in the set feature request</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Handle dynamically the USB SELF POWERED feature</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Handle correctly the USBD_CtlError process to take into account error during Control OUT stage</span></li><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">Miscellaneous bug fix</span></li></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 171px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.0.0 / 22-July-2011<o:p></o:p></span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p> Changes<o:p></o:p></span></u></b></p>
<ul style="margin-top: 0cm;" type="square"><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">First official version for <span style="font-weight: bold; font-style: italic;">STM32F105/7xx</span> and <span style="font-weight: bold; font-style: italic;">STM32F2xx</span> devices</span></li></ul><span style="font-size: 10pt; font-family: Verdana;"></span><br><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"></span> <ul style="margin-top: 0cm;" type="square"><li class="MsoNormal" style="color: black; margin-top: 4.5pt; margin-bottom: 4.5pt;"><span style="font-size: 10pt; font-family: Verdana;">First official version for <span style="font-weight: bold; font-style: italic;">STM32F105/7xx</span> and <span style="font-weight: bold; font-style: italic;">STM32F2xx</span> devices</span></li></ul><span style="font-size: 10pt; font-family: Verdana;"></span><br><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"></span>
<h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><a name="License"></a><span style="font-size: 12pt; color: white;">License<o:p></o:p></span></h2><p>This <h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"><a name="License"></a><span style="font-size: 12pt; color: white;">License<o:p></o:p></span></h2><p>This
software component is licensed by ST under Ultimate Liberty license software component is licensed by ST under Ultimate Liberty license
SLA0044,&nbsp;the "License"; You may not use this component except in SLA0044,&nbsp;the "License"; You may not use this component except in
compliance with the License. You may obtain a copy of the License at:</p><p style="text-align: center;"><a href="http://www.st.com/SLA0044" target="_blank">http://www.st.com/SLA0044</a></p><p class="MsoNormal" style="text-align: justify;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,sans-serif; color: black;"></span><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,serif;"><o:p></o:p></span></p> compliance with the License. You may obtain a copy of the License at:</p><p style="text-align: center;"><a href="http://www.st.com/SLA0044" target="_blank">http://www.st.com/SLA0044</a></p><p class="MsoNormal" style="text-align: justify;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,sans-serif; color: black;"></span><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,serif;"><o:p></o:p></span></p>
@@ -1498,7 +1502,7 @@ compliance with the License. You may obtain a copy of the License at:</p><p styl
Microcontrollers visit </span><u><span style="color: blue;"><a href="http://www.st.com/internet/mcu/family/141.jsp" target="_blank">www.st.com/STM32</a></span></u></span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"><u><span style="color: blue;"><a href="http://www.st.com/stm32" target="_blank"></a></span></u></span><span style="color: black;"><o:p></o:p></span></p> Microcontrollers visit </span><u><span style="color: blue;"><a href="http://www.st.com/internet/mcu/family/141.jsp" target="_blank">www.st.com/STM32</a></span></u></span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"><u><span style="color: blue;"><a href="http://www.st.com/stm32" target="_blank"></a></span></u></span><span style="color: black;"><o:p></o:p></span></p>
</td> </td>
</tr> </tr>
</tbody></table> <tr><td style="padding: 0in;" valign="top"></td></tr></tbody></table>
<p class="MsoNormal"><span style="font-size: 10pt;"><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;"><o:p></o:p></span></p>
</td> </td>
</tr> </tr>