forked from stm/stm32-mw-usb-device
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1a9b6baea | ||
|
|
edbaa3cd1d |
@@ -162,8 +162,12 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI
|
|||||||
0x02, /* bNumInterfaces */
|
0x02, /* bNumInterfaces */
|
||||||
0x01, /* bConfigurationValue */
|
0x01, /* bConfigurationValue */
|
||||||
0x00, /* iConfiguration */
|
0x00, /* iConfiguration */
|
||||||
0xC0, /* bmAttributes BUS Powred*/
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* bMaxPower = 100 mA*/
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* bMaxPower = 100 mA */
|
||||||
/* 09 byte*/
|
/* 09 byte*/
|
||||||
|
|
||||||
/* USB Speaker Standard interface descriptor */
|
/* USB Speaker Standard interface descriptor */
|
||||||
@@ -229,7 +233,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI
|
|||||||
0x00, /* iTerminal */
|
0x00, /* iTerminal */
|
||||||
/* 09 byte*/
|
/* 09 byte*/
|
||||||
|
|
||||||
/* USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwith */
|
/* 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 */
|
||||||
@@ -490,7 +494,7 @@ static uint8_t USBD_AUDIO_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Call the error management function (command will be nacked */
|
/* Call the error management function (command will be NAKed */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
ret = USBD_FAIL;
|
ret = USBD_FAIL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,8 +150,12 @@ __ALIGN_BEGIN static uint8_t USBD_BB_CfgDesc[USB_BB_CONFIG_DESC_SIZ] __ALIGN_EN
|
|||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: Configuration value */
|
0x01, /* bConfigurationValue: Configuration value */
|
||||||
USBD_IDX_CONFIG_STR, /* iConfiguration: Index of string descriptor describing the configuration */
|
USBD_IDX_CONFIG_STR, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||||
0xC0, /* bmAttributes: bus powered and Support Remote Wake-up */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x00, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
/* 09 */
|
/* 09 */
|
||||||
|
|
||||||
/************** Descriptor of BillBoard interface ****************/
|
/************** Descriptor of BillBoard interface ****************/
|
||||||
@@ -170,15 +174,19 @@ __ALIGN_BEGIN static uint8_t USBD_BB_CfgDesc[USB_BB_CONFIG_DESC_SIZ] __ALIGN_EN
|
|||||||
/* USB device Other Speed Configuration Descriptor */
|
/* USB device Other Speed Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_BB_OtherSpeedCfgDesc[USB_BB_CONFIG_DESC_SIZ] __ALIGN_END =
|
__ALIGN_BEGIN static uint8_t USBD_BB_OtherSpeedCfgDesc[USB_BB_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
||||||
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: */
|
||||||
0xC0, /* bmAttributes: */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x00, /* MaxPower 100 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/************** Descriptor of BillBoard interface ****************/
|
/************** Descriptor of BillBoard interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -391,10 +399,10 @@ static uint8_t *USBD_BB_GetDeviceQualifierDesc(uint16_t *length)
|
|||||||
*/
|
*/
|
||||||
USBD_BB_DescHeader_t *USBD_BB_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
|
USBD_BB_DescHeader_t *USBD_BB_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
|
||||||
{
|
{
|
||||||
USBD_BB_DescHeader_t *pnext = (USBD_BB_DescHeader_t *)pbuf;
|
USBD_BB_DescHeader_t *pnext = (USBD_BB_DescHeader_t *)(void *)pbuf;
|
||||||
|
|
||||||
*ptr += pnext->bLength;
|
*ptr += pnext->bLength;
|
||||||
pnext = (USBD_BB_DescHeader_t *)(pbuf + pnext->bLength);
|
pnext = (USBD_BB_DescHeader_t *)(void *)(pbuf + pnext->bLength);
|
||||||
|
|
||||||
return (pnext);
|
return (pnext);
|
||||||
}
|
}
|
||||||
@@ -411,8 +419,8 @@ void *USBD_BB_GetCapDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc)
|
|||||||
{
|
{
|
||||||
UNUSED(pdev);
|
UNUSED(pdev);
|
||||||
|
|
||||||
USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)pBosDesc;
|
USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)(void *)pBosDesc;
|
||||||
USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)pBosDesc;
|
USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)(void *)pBosDesc;
|
||||||
USBD_BosBBCapDescTypedef *pCapDesc = NULL;
|
USBD_BosBBCapDescTypedef *pCapDesc = NULL;
|
||||||
uint16_t ptr;
|
uint16_t ptr;
|
||||||
|
|
||||||
@@ -426,7 +434,7 @@ void *USBD_BB_GetCapDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc)
|
|||||||
|
|
||||||
if (pdesc->bDevCapabilityType == USBD_BILLBOARD_CAPABILITY)
|
if (pdesc->bDevCapabilityType == USBD_BILLBOARD_CAPABILITY)
|
||||||
{
|
{
|
||||||
pCapDesc = (USBD_BosBBCapDescTypedef *)pdesc;
|
pCapDesc = (USBD_BosBBCapDescTypedef *)(void *)pdesc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,8 +455,8 @@ void *USBD_BB_GetAltModeDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc, uint8_
|
|||||||
{
|
{
|
||||||
UNUSED(pdev);
|
UNUSED(pdev);
|
||||||
|
|
||||||
USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)pBosDesc;
|
USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)(void *)pBosDesc;
|
||||||
USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)pBosDesc;
|
USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)(void *)pBosDesc;
|
||||||
USBD_BB_AltModeCapDescTypeDef *pAltModDesc = NULL;
|
USBD_BB_AltModeCapDescTypeDef *pAltModDesc = NULL;
|
||||||
uint8_t cnt = 0U;
|
uint8_t cnt = 0U;
|
||||||
uint16_t ptr;
|
uint16_t ptr;
|
||||||
@@ -465,7 +473,7 @@ void *USBD_BB_GetAltModeDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc, uint8_
|
|||||||
{
|
{
|
||||||
if (cnt == idx)
|
if (cnt == idx)
|
||||||
{
|
{
|
||||||
pAltModDesc = (USBD_BB_AltModeCapDescTypeDef *)pdesc;
|
pAltModDesc = (USBD_BB_AltModeCapDescTypeDef *)(void *)pdesc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ extern "C" {
|
|||||||
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
||||||
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
||||||
|
|
||||||
|
#define CDC_REQ_MAX_DATA_SIZE 0x7U
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
/* CDC definitions */
|
/* CDC definitions */
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -166,15 +166,18 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgHSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 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 */
|
|
||||||
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 endpoints used */
|
||||||
@@ -262,8 +265,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -348,15 +355,19 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN
|
|||||||
|
|
||||||
__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 =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
||||||
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: */
|
||||||
0xC0, /* bmAttributes: */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*Interface Descriptor */
|
/*Interface Descriptor */
|
||||||
0x09, /* bLength: Interface Descriptor size */
|
0x09, /* bLength: Interface Descriptor size */
|
||||||
@@ -540,7 +551,6 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
{
|
{
|
||||||
UNUSED(cfgidx);
|
UNUSED(cfgidx);
|
||||||
uint8_t ret = 0U;
|
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
(void)USBD_LL_CloseEP(pdev, CDC_IN_EP);
|
(void)USBD_LL_CloseEP(pdev, CDC_IN_EP);
|
||||||
@@ -563,7 +573,7 @@ static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
pdev->pClassData = NULL;
|
pdev->pClassData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -577,6 +587,7 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_SetupReqTypedef *req)
|
USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||||
|
uint16_t len;
|
||||||
uint8_t ifalt = 0U;
|
uint8_t ifalt = 0U;
|
||||||
uint16_t status_info = 0U;
|
uint16_t status_info = 0U;
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
@@ -592,7 +603,8 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
(uint8_t *)hcdc->data,
|
(uint8_t *)hcdc->data,
|
||||||
req->wLength);
|
req->wLength);
|
||||||
|
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, req->wLength);
|
len = MIN(CDC_REQ_MAX_DATA_SIZE, req->wLength);
|
||||||
|
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -694,8 +706,12 @@ static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
hcdc->TxState = 0U;
|
hcdc->TxState = 0U;
|
||||||
|
|
||||||
|
if (((USBD_CDC_ItfTypeDef *)pdev->pUserData)->TransmitCplt != NULL)
|
||||||
|
{
|
||||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -743,7 +759,6 @@ static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
(uint8_t *)hcdc->data,
|
(uint8_t *)hcdc->data,
|
||||||
(uint16_t)hcdc->CmdLength);
|
(uint16_t)hcdc->CmdLength);
|
||||||
hcdc->CmdOpCode = 0xFFU;
|
hcdc->CmdOpCode = 0xFFU;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
@@ -778,7 +793,7 @@ static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_GetCfgDesc
|
* @brief USBD_CDC_GetOtherSpeedCfgDesc
|
||||||
* Return configuration descriptor
|
* Return configuration descriptor
|
||||||
* @param speed : current device speed
|
* @param speed : current device speed
|
||||||
* @param length : pointer data length
|
* @param length : pointer data length
|
||||||
@@ -792,7 +807,7 @@ static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DeviceQualifierDescriptor
|
* @brief USBD_CDC_GetDeviceQualifierDescriptor
|
||||||
* return Device Qualifier descriptor
|
* return Device Qualifier descriptor
|
||||||
* @param length : pointer data length
|
* @param length : pointer data length
|
||||||
* @retval pointer to descriptor buffer
|
* @retval pointer to descriptor buffer
|
||||||
@@ -840,7 +855,6 @@ uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
|||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_SetRxBuffer
|
* @brief USBD_CDC_SetRxBuffer
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
@@ -889,7 +903,6 @@ uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
|
|||||||
return (uint8_t)ret;
|
return (uint8_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_ReceivePacket
|
* @brief USBD_CDC_ReceivePacket
|
||||||
* prepare OUT Endpoint for reception
|
* prepare OUT Endpoint for reception
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ static int8_t TEMPLATE_Receive(uint8_t *Buf, uint32_t *Len)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TEMPLATE_TransmitCplt
|
* @brief TEMPLATE_TransmitCplt
|
||||||
* Data transmited callback
|
* Data transmitted callback
|
||||||
*
|
*
|
||||||
* @note
|
* @note
|
||||||
* This function is IN transfer complete callback used to inform user that
|
* This function is IN transfer complete callback used to inform user that
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define CDC_ECM_CONFIG_DESC_SIZ 79U
|
#define CDC_ECM_CONFIG_DESC_SIZ 79U
|
||||||
|
|
||||||
|
#define CDC_ECM_DATA_BUFFER_SIZE 2000U
|
||||||
|
|
||||||
#define CDC_ECM_DATA_HS_IN_PACKET_SIZE CDC_ECM_DATA_HS_MAX_PACKET_SIZE
|
#define CDC_ECM_DATA_HS_IN_PACKET_SIZE CDC_ECM_DATA_HS_MAX_PACKET_SIZE
|
||||||
#define CDC_ECM_DATA_HS_OUT_PACKET_SIZE CDC_ECM_DATA_HS_MAX_PACKET_SIZE
|
#define CDC_ECM_DATA_HS_OUT_PACKET_SIZE CDC_ECM_DATA_HS_MAX_PACKET_SIZE
|
||||||
|
|
||||||
@@ -173,7 +175,7 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t data[2000 / 4]; /* Force 32bits alignment */
|
uint32_t data[CDC_ECM_DATA_BUFFER_SIZE / 4]; /* Force 32bits 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 */
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_DeviceQualifierDesc[USB_LEN_DEV_QUALIF
|
|||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t ConnSpeedTab[2] = {CDC_ECM_CONNECT_SPEED_UPSTREAM,
|
static uint32_t ConnSpeedTab[2] = {CDC_ECM_CONNECT_SPEED_UPSTREAM,
|
||||||
CDC_ECM_CONNECT_SPEED_DOWNSTREAM};
|
CDC_ECM_CONNECT_SPEED_DOWNSTREAM
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
@@ -157,8 +158,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgHSDesc[] __ALIGN_END =
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -265,8 +270,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_CfgFSDesc[] __ALIGN_END =
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* IAD descriptor */
|
/* IAD descriptor */
|
||||||
@@ -371,8 +380,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_ECM_OtherSpeedCfgDesc[] __ALIGN_END =
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*--------------------------------------- ------------------------------------*/
|
/*--------------------------------------- ------------------------------------*/
|
||||||
/* IAD descriptor */
|
/* IAD descriptor */
|
||||||
@@ -602,8 +615,9 @@ static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *) pdev->pClassData;
|
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *) pdev->pClassData;
|
||||||
USBD_CDC_ECM_ItfTypeDef *EcmInterface = (USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData;
|
USBD_CDC_ECM_ItfTypeDef *EcmInterface = (USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData;
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
uint8_t ifalt = 0U;
|
uint16_t len;
|
||||||
uint16_t status_info = 0U;
|
uint16_t status_info = 0U;
|
||||||
|
uint8_t ifalt = 0U;
|
||||||
|
|
||||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||||
{
|
{
|
||||||
@@ -615,7 +629,8 @@ static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
EcmInterface->Control(req->bRequest,
|
EcmInterface->Control(req->bRequest,
|
||||||
(uint8_t *)hcdc->data, req->wLength);
|
(uint8_t *)hcdc->data, req->wLength);
|
||||||
|
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, req->wLength);
|
len = MIN(CDC_ECM_DATA_BUFFER_SIZE, req->wLength);
|
||||||
|
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -716,9 +731,12 @@ static uint8_t USBD_CDC_ECM_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
hcdc->TxState = 0U;
|
hcdc->TxState = 0U;
|
||||||
|
if (((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->TransmitCplt != NULL)
|
||||||
|
{
|
||||||
((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (epnum == (CDC_ECM_CMD_EP & 0x7FU))
|
else if (epnum == (CDC_ECM_CMD_EP & 0x7FU))
|
||||||
{
|
{
|
||||||
if (hcdc->NotificationStatus != 0U)
|
if (hcdc->NotificationStatus != 0U)
|
||||||
@@ -766,7 +784,7 @@ static uint8_t USBD_CDC_ECM_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
if ((CurrPcktLen < hcdc->MaxPcktLen) || (hcdc->RxLength >= CDC_ECM_ETH_MAX_SEGSZE))
|
if ((CurrPcktLen < hcdc->MaxPcktLen) || (hcdc->RxLength >= CDC_ECM_ETH_MAX_SEGSZE))
|
||||||
{
|
{
|
||||||
/* USB data will be immediately processed, this allow next USB traffic being
|
/* USB data will be immediately processed, this allow next USB traffic being
|
||||||
NACKed till the end of the application Xfer */
|
NAKed till the end of the application Xfer */
|
||||||
|
|
||||||
/* Process data by application (ie. copy to app buffer or notify user)
|
/* Process data by application (ie. copy to app buffer or notify user)
|
||||||
hcdc->RxLength must be reset to zero at the end of the call of this function */
|
hcdc->RxLength must be reset to zero at the end of the call of this function */
|
||||||
@@ -1020,7 +1038,7 @@ uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev,
|
|||||||
(hcdc->Req).bmRequest = CDC_ECM_BMREQUEST_TYPE_ECM;
|
(hcdc->Req).bmRequest = CDC_ECM_BMREQUEST_TYPE_ECM;
|
||||||
(hcdc->Req).bRequest = (uint8_t)Notif;
|
(hcdc->Req).bRequest = (uint8_t)Notif;
|
||||||
|
|
||||||
switch (Notif)
|
switch ((hcdc->Req).bRequest)
|
||||||
{
|
{
|
||||||
case NETWORK_CONNECTION:
|
case NETWORK_CONNECTION:
|
||||||
(hcdc->Req).wValue = bVal;
|
(hcdc->Req).wValue = bVal;
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ static int8_t CDC_ECM_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CDC_ECM_Itf_TransmitCplt
|
* @brief CDC_ECM_Itf_TransmitCplt
|
||||||
* Data transmited callback
|
* Data transmitted callback
|
||||||
*
|
*
|
||||||
* @note
|
* @note
|
||||||
* This function is IN transfer complete callback used to inform user that
|
* This function is IN transfer complete callback used to inform user that
|
||||||
|
|||||||
@@ -144,10 +144,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_DeviceQualifierDesc[USB_LEN_DEV_QUAL
|
|||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t MAC_StrDesc[6] = {CDC_RNDIS_MAC_ADDR0, CDC_RNDIS_MAC_ADDR1, CDC_RNDIS_MAC_ADDR2,
|
static uint8_t MAC_StrDesc[6] = {CDC_RNDIS_MAC_ADDR0, CDC_RNDIS_MAC_ADDR1, CDC_RNDIS_MAC_ADDR2,
|
||||||
CDC_RNDIS_MAC_ADDR3, CDC_RNDIS_MAC_ADDR4, CDC_RNDIS_MAC_ADDR5};
|
CDC_RNDIS_MAC_ADDR3, CDC_RNDIS_MAC_ADDR4, CDC_RNDIS_MAC_ADDR5
|
||||||
|
};
|
||||||
|
|
||||||
static uint32_t ConnSpeedTab[2] = {CDC_RNDIS_CONNECT_SPEED_UPSTREAM,
|
static uint32_t ConnSpeedTab[2] = {CDC_RNDIS_CONNECT_SPEED_UPSTREAM,
|
||||||
CDC_RNDIS_CONNECT_SPEED_DOWNSTREAM};
|
CDC_RNDIS_CONNECT_SPEED_DOWNSTREAM
|
||||||
|
};
|
||||||
|
|
||||||
static uint8_t EmptyResponse = 0x00U;
|
static uint8_t EmptyResponse = 0x00U;
|
||||||
|
|
||||||
@@ -193,8 +195,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* IAD descriptor */
|
/* IAD descriptor */
|
||||||
@@ -298,8 +304,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgFSDesc[] __ALIGN_END =
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* IAD descriptor */
|
/* IAD descriptor */
|
||||||
@@ -401,8 +411,12 @@ __ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_OtherSpeedCfgDesc[] __ALIGN_END =
|
|||||||
0x02, /* bNumInterfaces: 2 interface */
|
0x02, /* bNumInterfaces: 2 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: self powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 0 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* IAD descriptor */
|
/* IAD descriptor */
|
||||||
@@ -657,7 +671,7 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_SetupReqTypedef *req)
|
USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
||||||
USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)hcdc->data;
|
USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)(void *)hcdc->data;
|
||||||
uint8_t ifalt = 0U;
|
uint8_t ifalt = 0U;
|
||||||
uint16_t status_info = 0U;
|
uint16_t status_info = 0U;
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
@@ -810,9 +824,13 @@ static uint8_t USBD_CDC_RNDIS_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
hcdc->TxState = 0U;
|
hcdc->TxState = 0U;
|
||||||
|
|
||||||
|
if (((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData)->TransmitCplt != NULL)
|
||||||
|
{
|
||||||
((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (epnum == (CDC_RNDIS_CMD_EP & 0x7FU))
|
else if (epnum == (CDC_RNDIS_CMD_EP & 0x7FU))
|
||||||
{
|
{
|
||||||
if (hcdc->NotificationStatus != 0U)
|
if (hcdc->NotificationStatus != 0U)
|
||||||
@@ -863,10 +881,10 @@ static uint8_t USBD_CDC_RNDIS_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
(hcdc->RxLength >= (CDC_RNDIS_ETH_MAX_SEGSZE + sizeof(USBD_CDC_RNDIS_PacketMsgTypeDef))))
|
(hcdc->RxLength >= (CDC_RNDIS_ETH_MAX_SEGSZE + sizeof(USBD_CDC_RNDIS_PacketMsgTypeDef))))
|
||||||
{
|
{
|
||||||
/* USB data will be immediately processed, this allow next USB traffic being
|
/* USB data will be immediately processed, this allow next USB traffic being
|
||||||
NACKed till the end of the application Xfer */
|
NAKed till the end of the application Xfer */
|
||||||
|
|
||||||
/* Call data packet message parsing and processing function */
|
/* Call data packet message parsing and processing function */
|
||||||
(void)USBD_CDC_RNDIS_ProcessPacketMsg(pdev, (USBD_CDC_RNDIS_PacketMsgTypeDef *)hcdc->RxBuffer);
|
(void)USBD_CDC_RNDIS_ProcessPacketMsg(pdev, (USBD_CDC_RNDIS_PacketMsgTypeDef *)(void *)hcdc->RxBuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1071,7 +1089,7 @@ uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
||||||
PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef *)hcdc->TxBuffer;
|
PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef *)(void *)hcdc->TxBuffer;
|
||||||
|
|
||||||
if (hcdc->TxState == 0U)
|
if (hcdc->TxState == 0U)
|
||||||
{
|
{
|
||||||
@@ -1160,10 +1178,12 @@ uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
|
|||||||
(hcdc->Req).wValue = 0U;
|
(hcdc->Req).wValue = 0U;
|
||||||
(hcdc->Req).wIndex = CDC_RNDIS_CMD_ITF_NBR;
|
(hcdc->Req).wIndex = CDC_RNDIS_CMD_ITF_NBR;
|
||||||
(hcdc->Req).wLength = 0U;
|
(hcdc->Req).wLength = 0U;
|
||||||
|
|
||||||
for (Idx = 0U; Idx < 8U; Idx++)
|
for (Idx = 0U; Idx < 8U; Idx++)
|
||||||
{
|
{
|
||||||
(hcdc->Req).data[Idx] = 0U;
|
(hcdc->Req).data[Idx] = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReqSize = 8U;
|
ReqSize = 8U;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1192,7 +1212,7 @@ uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
|
|||||||
*/
|
*/
|
||||||
static uint8_t USBD_CDC_RNDIS_MsgParsing(USBD_HandleTypeDef *pdev, uint8_t *RxBuff)
|
static uint8_t USBD_CDC_RNDIS_MsgParsing(USBD_HandleTypeDef *pdev, uint8_t *RxBuff)
|
||||||
{
|
{
|
||||||
USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)RxBuff;
|
USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)(void *)RxBuff;
|
||||||
static uint8_t ret = (uint8_t)USBD_OK;
|
static uint8_t ret = (uint8_t)USBD_OK;
|
||||||
|
|
||||||
/* Check message type */
|
/* Check message type */
|
||||||
@@ -1200,37 +1220,37 @@ static uint8_t USBD_CDC_RNDIS_MsgParsing(USBD_HandleTypeDef *pdev, uint8_t *RxBu
|
|||||||
{
|
{
|
||||||
/* CDC_RNDIS Initialize message */
|
/* CDC_RNDIS Initialize message */
|
||||||
case CDC_RNDIS_INITIALIZE_MSG_ID:
|
case CDC_RNDIS_INITIALIZE_MSG_ID:
|
||||||
ret = USBD_CDC_RNDIS_ProcessInitMsg(pdev, (USBD_CDC_RNDIS_InitMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessInitMsg(pdev, (USBD_CDC_RNDIS_InitMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* CDC_RNDIS Halt message */
|
/* CDC_RNDIS Halt message */
|
||||||
case CDC_RNDIS_HALT_MSG_ID:
|
case CDC_RNDIS_HALT_MSG_ID:
|
||||||
ret = USBD_CDC_RNDIS_ProcessHaltMsg(pdev, (USBD_CDC_RNDIS_HaltMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessHaltMsg(pdev, (USBD_CDC_RNDIS_HaltMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* CDC_RNDIS Query message */
|
/* CDC_RNDIS Query message */
|
||||||
case CDC_RNDIS_QUERY_MSG_ID:
|
case CDC_RNDIS_QUERY_MSG_ID:
|
||||||
ret = USBD_CDC_RNDIS_ProcessQueryMsg(pdev, (USBD_CDC_RNDIS_QueryMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessQueryMsg(pdev, (USBD_CDC_RNDIS_QueryMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* CDC_RNDIS Set message */
|
/* CDC_RNDIS Set message */
|
||||||
case CDC_RNDIS_SET_MSG_ID:
|
case CDC_RNDIS_SET_MSG_ID:
|
||||||
ret = USBD_CDC_RNDIS_ProcessSetMsg(pdev, (USBD_CDC_RNDIS_SetMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessSetMsg(pdev, (USBD_CDC_RNDIS_SetMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* CDC_RNDIS Reset message */
|
/* CDC_RNDIS Reset message */
|
||||||
case CDC_RNDIS_RESET_MSG_ID:
|
case CDC_RNDIS_RESET_MSG_ID:
|
||||||
ret = USBD_CDC_RNDIS_ProcessResetMsg(pdev, (USBD_CDC_RNDIS_ResetMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessResetMsg(pdev, (USBD_CDC_RNDIS_ResetMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* CDC_RNDIS Keep-Alive message */
|
/* CDC_RNDIS Keep-Alive message */
|
||||||
case CDC_RNDIS_KEEPALIVE_MSG_ID:
|
case CDC_RNDIS_KEEPALIVE_MSG_ID:
|
||||||
ret = USBD_CDC_RNDIS_ProcessKeepAliveMsg(pdev, (USBD_CDC_RNDIS_KpAliveMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessKeepAliveMsg(pdev, (USBD_CDC_RNDIS_KpAliveMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* CDC_RNDIS unsupported message */
|
/* CDC_RNDIS unsupported message */
|
||||||
default:
|
default:
|
||||||
ret = USBD_CDC_RNDIS_ProcessUnsupportedMsg(pdev, (USBD_CDC_RNDIS_CtrlMsgTypeDef *)Msg);
|
ret = USBD_CDC_RNDIS_ProcessUnsupportedMsg(pdev, (USBD_CDC_RNDIS_CtrlMsgTypeDef *)(void *)Msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1255,7 +1275,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessInitMsg(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_CDC_RNDIS_InitMsgTypeDef *InitMessage = (USBD_CDC_RNDIS_InitMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_InitMsgTypeDef *InitMessage = (USBD_CDC_RNDIS_InitMsgTypeDef *)Msg;
|
||||||
|
|
||||||
/* Use same Msg input buffer as response buffer */
|
/* Use same Msg input buffer as response buffer */
|
||||||
USBD_CDC_RNDIS_InitCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_InitCpltMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_InitCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_InitCpltMsgTypeDef *)(void *)Msg;
|
||||||
|
|
||||||
/* Store the Message Request ID */
|
/* Store the Message Request ID */
|
||||||
uint32_t ReqId = InitMessage->ReqId;
|
uint32_t ReqId = InitMessage->ReqId;
|
||||||
@@ -1314,7 +1334,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessHaltMsg(USBD_HandleTypeDef *pdev,
|
|||||||
/* Set CDC_RNDIS state to INITIALIZED */
|
/* Set CDC_RNDIS state to INITIALIZED */
|
||||||
hcdc->State = CDC_RNDIS_STATE_UNINITIALIZED;
|
hcdc->State = CDC_RNDIS_STATE_UNINITIALIZED;
|
||||||
|
|
||||||
/* No response required for this message, so no notification (RESPNSE_AVAILABLE) is sent */
|
/* No response required for this message, so no notification (RESPONSE_AVAILABLE) is sent */
|
||||||
|
|
||||||
UNUSED(Msg);
|
UNUSED(Msg);
|
||||||
|
|
||||||
@@ -1336,7 +1356,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessKeepAliveMsg(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
||||||
|
|
||||||
/* Use same Msg input buffer as response buffer */
|
/* Use same Msg input buffer as response buffer */
|
||||||
USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *)(void *)Msg;
|
||||||
|
|
||||||
/* Store the Message Request ID */
|
/* Store the Message Request ID */
|
||||||
uint32_t ReqId = Msg->ReqId;
|
uint32_t ReqId = Msg->ReqId;
|
||||||
@@ -1381,7 +1401,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
||||||
|
|
||||||
/* Use same Msg input buffer as response buffer */
|
/* Use same Msg input buffer as response buffer */
|
||||||
USBD_CDC_RNDIS_QueryCpltMsgTypeDef *QueryResponse = (USBD_CDC_RNDIS_QueryCpltMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_QueryCpltMsgTypeDef *QueryResponse = (USBD_CDC_RNDIS_QueryCpltMsgTypeDef *)(void *)Msg;
|
||||||
|
|
||||||
/* Store the Message Request ID */
|
/* Store the Message Request ID */
|
||||||
uint32_t ReqId = Msg->RequestId;
|
uint32_t ReqId = Msg->RequestId;
|
||||||
@@ -1524,7 +1544,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessSetMsg(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_CDC_RNDIS_SetMsgTypeDef *SetMessage = (USBD_CDC_RNDIS_SetMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_SetMsgTypeDef *SetMessage = (USBD_CDC_RNDIS_SetMsgTypeDef *)Msg;
|
||||||
|
|
||||||
/* Use same Msg input buffer as response buffer */
|
/* Use same Msg input buffer as response buffer */
|
||||||
USBD_CDC_RNDIS_SetCpltMsgTypeDef *SetResponse = (USBD_CDC_RNDIS_SetCpltMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_SetCpltMsgTypeDef *SetResponse = (USBD_CDC_RNDIS_SetCpltMsgTypeDef *)(void *)Msg;
|
||||||
|
|
||||||
/* Store the Message Request ID */
|
/* Store the Message Request ID */
|
||||||
uint32_t ReqId = SetMessage->ReqId;
|
uint32_t ReqId = SetMessage->ReqId;
|
||||||
@@ -1578,7 +1598,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessResetMsg(USBD_HandleTypeDef *pdev,
|
|||||||
/* Get the CDC_RNDIS handle pointer */
|
/* Get the CDC_RNDIS handle pointer */
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
||||||
/* Use same Msg input buffer as response buffer */
|
/* Use same Msg input buffer as response buffer */
|
||||||
USBD_CDC_RNDIS_ResetCpltMsgTypeDef *ResetResponse = (USBD_CDC_RNDIS_ResetCpltMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_ResetCpltMsgTypeDef *ResetResponse = (USBD_CDC_RNDIS_ResetCpltMsgTypeDef *)(void *)Msg;
|
||||||
|
|
||||||
if ((ResetMessage->MsgLength != sizeof(USBD_CDC_RNDIS_ResetMsgTypeDef)) || \
|
if ((ResetMessage->MsgLength != sizeof(USBD_CDC_RNDIS_ResetMsgTypeDef)) || \
|
||||||
(ResetMessage->Reserved != 0U))
|
(ResetMessage->Reserved != 0U))
|
||||||
@@ -1633,7 +1653,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessPacketMsg(USBD_HandleTypeDef *pdev,
|
|||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Point to the payload and udpate the message length */
|
/* Point to the payload and update the message length */
|
||||||
|
|
||||||
/* Use temporary storage variables to comply with MISRA-C 2012 rule of (+) operand allowed types */
|
/* Use temporary storage variables to comply with MISRA-C 2012 rule of (+) operand allowed types */
|
||||||
tmp1 = (uint32_t)PacketMsg;
|
tmp1 = (uint32_t)PacketMsg;
|
||||||
@@ -1662,7 +1682,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessUnsupportedMsg(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData;
|
||||||
|
|
||||||
/* Use same Msg input buffer as response buffer */
|
/* Use same Msg input buffer as response buffer */
|
||||||
USBD_CDC_RNDIS_StsChangeMsgTypeDef *Response = (USBD_CDC_RNDIS_StsChangeMsgTypeDef *)Msg;
|
USBD_CDC_RNDIS_StsChangeMsgTypeDef *Response = (USBD_CDC_RNDIS_StsChangeMsgTypeDef *)(void *)Msg;
|
||||||
|
|
||||||
/* Setup the response buffer content */
|
/* Setup the response buffer content */
|
||||||
Response->MsgType = CDC_RNDIS_INDICATE_STATUS_MSG_ID;
|
Response->MsgType = CDC_RNDIS_INDICATE_STATUS_MSG_ID;
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ static int8_t CDC_RNDIS_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CDC_RNDIS_Itf_TransmitCplt
|
* @brief CDC_RNDIS_Itf_TransmitCplt
|
||||||
* Data transmited callback
|
* Data transmitted callback
|
||||||
*
|
*
|
||||||
* @note
|
* @note
|
||||||
* This function is IN transfer complete callback used to inform user that
|
* This function is IN transfer complete callback used to inform user that
|
||||||
|
|||||||
@@ -42,10 +42,16 @@ extern "C" {
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define CUSTOM_HID_EPIN_ADDR 0x81U
|
#define CUSTOM_HID_EPIN_ADDR 0x81U
|
||||||
|
|
||||||
|
#ifndef CUSTOM_HID_EPIN_SIZE
|
||||||
#define CUSTOM_HID_EPIN_SIZE 0x02U
|
#define CUSTOM_HID_EPIN_SIZE 0x02U
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CUSTOM_HID_EPOUT_ADDR 0x01U
|
#define CUSTOM_HID_EPOUT_ADDR 0x01U
|
||||||
|
|
||||||
|
#ifndef CUSTOM_HID_EPOUT_SIZE
|
||||||
#define CUSTOM_HID_EPOUT_SIZE 0x02U
|
#define CUSTOM_HID_EPOUT_SIZE 0x02U
|
||||||
|
#endif
|
||||||
|
|
||||||
#define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41U
|
#define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41U
|
||||||
#define USB_CUSTOM_HID_DESC_SIZ 9U
|
#define USB_CUSTOM_HID_DESC_SIZ 9U
|
||||||
|
|||||||
@@ -128,14 +128,17 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgFSDesc[USB_CUSTOM_HID_CONFIG_DES
|
|||||||
{
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_CUSTOM_HID_CONFIG_DESC_SIZ,
|
USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: bus powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
|
|
||||||
/************** Descriptor of CUSTOM HID interface ****************/
|
/************** Descriptor of CUSTOM HID interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -186,14 +189,17 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc[USB_CUSTOM_HID_CONFIG_DES
|
|||||||
{
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_CUSTOM_HID_CONFIG_DESC_SIZ,
|
USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: bus powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
|
|
||||||
/************** Descriptor of CUSTOM HID interface ****************/
|
/************** Descriptor of CUSTOM HID interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -244,14 +250,17 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_OtherSpeedCfgDesc[USB_CUSTOM_HID_CO
|
|||||||
{
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_CUSTOM_HID_CONFIG_DESC_SIZ,
|
USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
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 */
|
||||||
0xC0, /* bmAttributes: bus powered */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
|
|
||||||
/************** Descriptor of CUSTOM HID interface ****************/
|
/************** Descriptor of CUSTOM HID interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -282,7 +291,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_OtherSpeedCfgDesc[USB_CUSTOM_HID_CO
|
|||||||
|
|
||||||
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 */
|
||||||
@@ -412,7 +421,7 @@ static uint8_t USBD_CUSTOM_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].is_used = 0U;
|
pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].is_used = 0U;
|
||||||
pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].bInterval = 0U;
|
pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].bInterval = 0U;
|
||||||
|
|
||||||
/* FRee allocated memory */
|
/* Free allocated memory */
|
||||||
if (pdev->pClassData != NULL)
|
if (pdev->pClassData != NULL)
|
||||||
{
|
{
|
||||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->DeInit();
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->DeInit();
|
||||||
|
|||||||
@@ -153,16 +153,19 @@ USBD_ClassTypeDef USBD_DFU =
|
|||||||
/* USB DFU device Configuration Descriptor */
|
/* USB DFU device Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_DFU_CfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_END =
|
__ALIGN_BEGIN static uint8_t USBD_DFU_CfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_DFU_CONFIG_DESC_SIZ,
|
USB_DFU_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: Configuration value */
|
0x01, /* bConfigurationValue: Configuration value */
|
||||||
0x02, /* iConfiguration: Index of string descriptor describing the configuration */
|
0x02, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||||
0xC0, /* bmAttributes: bus powered and Supprts Remote Wakeup */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
/* 09 */
|
/* 09 */
|
||||||
|
|
||||||
/********** Descriptor of DFU interface 0 Alternate setting 0 **************/
|
/********** Descriptor of DFU interface 0 Alternate setting 0 **************/
|
||||||
@@ -405,7 +408,7 @@ static uint8_t USBD_DFU_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||||||
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 *)hdfu->alt_setting, 1U);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)&hdfu->alt_setting, 1U);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -429,7 +432,7 @@ static uint8_t USBD_DFU_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Call the error management function (command will be nacked */
|
/* Call the error management function (command will be NAKed */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
ret = USBD_FAIL;
|
ret = USBD_FAIL;
|
||||||
}
|
}
|
||||||
@@ -504,7 +507,7 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
if (hdfu->buffer.d8[0] == DFU_CMD_GETCOMMANDS)
|
if (hdfu->buffer.d8[0] == DFU_CMD_GETCOMMANDS)
|
||||||
{
|
{
|
||||||
/* nothink to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (hdfu->wlength == 5U)
|
else if (hdfu->wlength == 5U)
|
||||||
@@ -530,7 +533,7 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* .. */
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -538,7 +541,7 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
/* Reset the global length and block number */
|
/* Reset the global length and block number */
|
||||||
hdfu->wlength = 0U;
|
hdfu->wlength = 0U;
|
||||||
hdfu->wblock_num = 0U;
|
hdfu->wblock_num = 0U;
|
||||||
/* Call the error management function (command will be nacked) */
|
/* Call the error management function (command will be NAKed) */
|
||||||
req.bmRequest = 0U;
|
req.bmRequest = 0U;
|
||||||
req.wLength = 1U;
|
req.wLength = 1U;
|
||||||
USBD_CtlError(pdev, &req);
|
USBD_CtlError(pdev, &req);
|
||||||
@@ -552,7 +555,7 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
/* Decode the required address */
|
/* Decode the required address */
|
||||||
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
||||||
|
|
||||||
/* Preform the write operation */
|
/* Perform the write operation */
|
||||||
if (DfuInterface->Write(hdfu->buffer.d8, (uint8_t *)addr, hdfu->wlength) != USBD_OK)
|
if (DfuInterface->Write(hdfu->buffer.d8, (uint8_t *)addr, hdfu->wlength) != USBD_OK)
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
@@ -579,7 +582,7 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* .. */
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
@@ -615,7 +618,7 @@ static uint8_t *USBD_DFU_GetDeviceQualifierDesc(uint16_t *length)
|
|||||||
* @brief USBD_DFU_GetUsrStringDesc
|
* @brief USBD_DFU_GetUsrStringDesc
|
||||||
* Manages the transfer of memory interfaces string descriptors.
|
* Manages the transfer of memory interfaces string descriptors.
|
||||||
* @param speed : current device speed
|
* @param speed : current device speed
|
||||||
* @param index: desciptor index
|
* @param index: descriptor index
|
||||||
* @param length : pointer data length
|
* @param length : pointer data length
|
||||||
* @retval pointer to the descriptor table or NULL if the descriptor is not supported.
|
* @retval pointer to the descriptor table or NULL if the descriptor is not supported.
|
||||||
*/
|
*/
|
||||||
@@ -733,7 +736,7 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
/* Unsupported state */
|
/* Unsupported state */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Call the error management function (command will be nacked */
|
/* Call the error management function (command will be NAKed */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -752,7 +755,7 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Call the error management function (command will be nacked */
|
/* Call the error management function (command will be NAKed */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -826,7 +829,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
/* Call the error management function (command will be nacked */
|
/* Call the error management function (command will be NAKed */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -836,7 +839,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->wlength = 0U;
|
hdfu->wlength = 0U;
|
||||||
hdfu->wblock_num = 0U;
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
/* Call the error management function (command will be nacked */
|
/* Call the error management function (command will be NAKed */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ static uint8_t *USBD_HID_GetDeviceQualifierDesc(uint16_t *length);
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_ClassTypeDef USBD_HID = {
|
USBD_ClassTypeDef USBD_HID =
|
||||||
|
{
|
||||||
USBD_HID_Init,
|
USBD_HID_Init,
|
||||||
USBD_HID_DeInit,
|
USBD_HID_DeInit,
|
||||||
USBD_HID_Setup,
|
USBD_HID_Setup,
|
||||||
@@ -123,17 +124,21 @@ USBD_ClassTypeDef USBD_HID = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* USB HID device FS Configuration Descriptor */
|
/* USB HID device FS Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_HID_CfgFSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END = {
|
__ALIGN_BEGIN static uint8_t USBD_HID_CfgFSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_HID_CONFIG_DESC_SIZ,
|
USB_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
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 */
|
||||||
0xE0, /* bmAttributes: bus powered and Support Remote Wake-up */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xE0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0xA0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
|
|
||||||
/************** Descriptor of Joystick Mouse interface ****************/
|
/************** Descriptor of Joystick Mouse interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -171,17 +176,21 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgFSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* USB HID device HS Configuration Descriptor */
|
/* USB HID device HS Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_HID_CfgHSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END = {
|
__ALIGN_BEGIN static uint8_t USBD_HID_CfgHSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_HID_CONFIG_DESC_SIZ,
|
USB_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
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 */
|
||||||
0xE0, /* bmAttributes: bus powered and Support Remote Wake-up */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xE0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0xA0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
|
|
||||||
/************** Descriptor of Joystick Mouse interface ****************/
|
/************** Descriptor of Joystick Mouse interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -219,17 +228,21 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgHSDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* USB HID device Other Speed Configuration Descriptor */
|
/* USB HID device Other Speed Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END = {
|
__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_HID_CONFIG_DESC_SIZ,
|
USB_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
||||||
/* wTotalLength: Bytes returned */
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
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 */
|
||||||
0xE0, /* bmAttributes: bus powered and Support Remote Wake-up */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
0xE0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0xA0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||||
|
|
||||||
/************** Descriptor of Joystick Mouse interface ****************/
|
/************** Descriptor of Joystick Mouse interface ****************/
|
||||||
/* 09 */
|
/* 09 */
|
||||||
@@ -268,7 +281,8 @@ __ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[USB_HID_CONFIG_DESC_SIZ]
|
|||||||
|
|
||||||
|
|
||||||
/* USB HID device Configuration Descriptor */
|
/* USB HID device Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END = {
|
__ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END =
|
||||||
|
{
|
||||||
/* 18 */
|
/* 18 */
|
||||||
0x09, /* bLength: HID Descriptor size */
|
0x09, /* bLength: HID Descriptor size */
|
||||||
HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
|
HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
|
||||||
@@ -282,7 +296,8 @@ __ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* USB Standard Device Descriptor */
|
/* USB Standard Device Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = {
|
__ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
|
||||||
|
{
|
||||||
USB_LEN_DEV_QUALIFIER_DESC,
|
USB_LEN_DEV_QUALIFIER_DESC,
|
||||||
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
||||||
0x00,
|
0x00,
|
||||||
@@ -295,7 +310,8 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_
|
|||||||
0x00,
|
0x00,
|
||||||
};
|
};
|
||||||
|
|
||||||
__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,
|
||||||
0x09, 0x02,
|
0x09, 0x02,
|
||||||
0xA1, 0x01,
|
0xA1, 0x01,
|
||||||
@@ -409,7 +425,7 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
pdev->ep_in[HID_EPIN_ADDR & 0xFU].is_used = 0U;
|
pdev->ep_in[HID_EPIN_ADDR & 0xFU].is_used = 0U;
|
||||||
pdev->ep_in[HID_EPIN_ADDR & 0xFU].bInterval = 0U;
|
pdev->ep_in[HID_EPIN_ADDR & 0xFU].bInterval = 0U;
|
||||||
|
|
||||||
/* FRee allocated memory */
|
/* Free allocated memory */
|
||||||
if (pdev->pClassData != NULL)
|
if (pdev->pClassData != NULL)
|
||||||
{
|
{
|
||||||
(void)USBD_free(pdev->pClassData);
|
(void)USBD_free(pdev->pClassData);
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ USBD_ClassTypeDef USBD_MSC =
|
|||||||
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_MSC_CONFIG_DESC_SIZ,
|
USB_MSC_CONFIG_DESC_SIZ,
|
||||||
|
|
||||||
@@ -131,8 +131,12 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG
|
|||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: */
|
0x01, /* bConfigurationValue: */
|
||||||
0x04, /* iConfiguration: */
|
0x04, /* iConfiguration: */
|
||||||
0xC0, /* bmAttributes: */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/******************** Mass Storage interface ********************/
|
/******************** Mass Storage interface ********************/
|
||||||
0x09, /* bLength: Interface Descriptor size */
|
0x09, /* bLength: Interface Descriptor size */
|
||||||
@@ -166,7 +170,7 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG
|
|||||||
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_MSC_CONFIG_DESC_SIZ,
|
USB_MSC_CONFIG_DESC_SIZ,
|
||||||
|
|
||||||
@@ -174,8 +178,12 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG
|
|||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: */
|
0x01, /* bConfigurationValue: */
|
||||||
0x04, /* iConfiguration: */
|
0x04, /* iConfiguration: */
|
||||||
0xC0, /* bmAttributes: */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/******************** Mass Storage interface ********************/
|
/******************** Mass Storage interface ********************/
|
||||||
0x09, /* bLength: Interface Descriptor size */
|
0x09, /* bLength: Interface Descriptor size */
|
||||||
@@ -207,7 +215,7 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIG
|
|||||||
|
|
||||||
__ALIGN_BEGIN static uint8_t USBD_MSC_OtherSpeedCfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
__ALIGN_BEGIN static uint8_t USBD_MSC_OtherSpeedCfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
||||||
USB_MSC_CONFIG_DESC_SIZ,
|
USB_MSC_CONFIG_DESC_SIZ,
|
||||||
|
|
||||||
@@ -215,8 +223,12 @@ __ALIGN_BEGIN static uint8_t USBD_MSC_OtherSpeedCfgDesc[USB_MSC_CONFIG_DESC_SIZ]
|
|||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: */
|
0x01, /* bConfigurationValue: */
|
||||||
0x04, /* iConfiguration: */
|
0x04, /* iConfiguration: */
|
||||||
0xC0, /* bmAttributes: */
|
#if (USBD_SELF_POWERED == 1U)
|
||||||
0x32, /* MaxPower 100 mA */
|
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#else
|
||||||
|
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||||
|
#endif
|
||||||
|
USBD_MAX_POWER, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/******************** Mass Storage interface ********************/
|
/******************** Mass Storage interface ********************/
|
||||||
0x09, /* bLength: Interface Descriptor size */
|
0x09, /* bLength: Interface Descriptor size */
|
||||||
@@ -320,7 +332,7 @@ uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_MSC_DeInit
|
* @brief USBD_MSC_DeInit
|
||||||
* DeInitilaize the mass storage configuration
|
* DeInitialize the mass storage configuration
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param cfgidx: configuration index
|
* @param cfgidx: configuration index
|
||||||
* @retval status
|
* @retval status
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ void MSC_BOT_Init(USBD_HandleTypeDef *pdev)
|
|||||||
(void)USBD_LL_FlushEP(pdev, MSC_EPOUT_ADDR);
|
(void)USBD_LL_FlushEP(pdev, MSC_EPOUT_ADDR);
|
||||||
(void)USBD_LL_FlushEP(pdev, MSC_EPIN_ADDR);
|
(void)USBD_LL_FlushEP(pdev, MSC_EPIN_ADDR);
|
||||||
|
|
||||||
/* Prapare EP to Receive First BOT Cmd */
|
/* Prepare EP to Receive First BOT Cmd */
|
||||||
(void)USBD_LL_PrepareReceive(pdev, MSC_EPOUT_ADDR, (uint8_t *)&hmsc->cbw,
|
(void)USBD_LL_PrepareReceive(pdev, MSC_EPOUT_ADDR, (uint8_t *)&hmsc->cbw,
|
||||||
USBD_BOT_CBW_LENGTH);
|
USBD_BOT_CBW_LENGTH);
|
||||||
}
|
}
|
||||||
@@ -132,14 +132,14 @@ void MSC_BOT_Reset(USBD_HandleTypeDef *pdev)
|
|||||||
(void)USBD_LL_ClearStallEP(pdev, MSC_EPIN_ADDR);
|
(void)USBD_LL_ClearStallEP(pdev, MSC_EPIN_ADDR);
|
||||||
(void)USBD_LL_ClearStallEP(pdev, MSC_EPOUT_ADDR);
|
(void)USBD_LL_ClearStallEP(pdev, MSC_EPOUT_ADDR);
|
||||||
|
|
||||||
/* Prapare EP to Receive First BOT Cmd */
|
/* Prepare EP to Receive First BOT Cmd */
|
||||||
(void)USBD_LL_PrepareReceive(pdev, MSC_EPOUT_ADDR, (uint8_t *)&hmsc->cbw,
|
(void)USBD_LL_PrepareReceive(pdev, MSC_EPOUT_ADDR, (uint8_t *)&hmsc->cbw,
|
||||||
USBD_BOT_CBW_LENGTH);
|
USBD_BOT_CBW_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MSC_BOT_DeInit
|
* @brief MSC_BOT_DeInit
|
||||||
* Deinitialize the BOT Machine
|
* DeInitialize the BOT Machine
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1039,7 +1039,7 @@ static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
* @brief SCSI_UpdateBotData
|
* @brief SCSI_UpdateBotData
|
||||||
* fill the requested Data to transmit buffer
|
* fill the requested Data to transmit buffer
|
||||||
* @param hmsc handler
|
* @param hmsc handler
|
||||||
* @param params: Data buffer
|
* @param pBuff: Data buffer
|
||||||
* @param length: Data length
|
* @param length: Data length
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ USBD_ClassTypeDef USBD_TEMPLATE_ClassDriver =
|
|||||||
/* USB TEMPLATE device Configuration Descriptor */
|
/* USB TEMPLATE device Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_TEMPLATE_CfgDesc[USB_TEMPLATE_CONFIG_DESC_SIZ] __ALIGN_END =
|
__ALIGN_BEGIN static uint8_t USBD_TEMPLATE_CfgDesc[USB_TEMPLATE_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||||
{
|
{
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_TEMPLATE_CONFIG_DESC_SIZ,
|
USB_TEMPLATE_CONFIG_DESC_SIZ,
|
||||||
/* wTotalLength: Bytes returned */
|
/* wTotalLength: Bytes returned */
|
||||||
@@ -239,7 +239,6 @@ static uint8_t USBD_TEMPLATE_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
return (uint8_t)ret;
|
return (uint8_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_TEMPLATE_GetCfgDesc
|
* @brief USBD_TEMPLATE_GetCfgDesc
|
||||||
* return configuration descriptor
|
* return configuration descriptor
|
||||||
@@ -264,7 +263,6 @@ uint8_t *USBD_TEMPLATE_DeviceQualifierDescriptor(uint16_t *length)
|
|||||||
return USBD_TEMPLATE_DeviceQualifierDesc;
|
return USBD_TEMPLATE_DeviceQualifierDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_TEMPLATE_DataIn
|
* @brief USBD_TEMPLATE_DataIn
|
||||||
* handle data IN Stage
|
* handle data IN Stage
|
||||||
@@ -289,6 +287,7 @@ static uint8_t USBD_TEMPLATE_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_TEMPLATE_EP0_TxReady
|
* @brief USBD_TEMPLATE_EP0_TxReady
|
||||||
* handle EP0 TRx Ready event
|
* handle EP0 TRx Ready event
|
||||||
@@ -300,6 +299,7 @@ static uint8_t USBD_TEMPLATE_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_TEMPLATE_SOF
|
* @brief USBD_TEMPLATE_SOF
|
||||||
* handle SOF event
|
* handle SOF event
|
||||||
@@ -311,6 +311,7 @@ static uint8_t USBD_TEMPLATE_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_TEMPLATE_IsoINIncomplete
|
* @brief USBD_TEMPLATE_IsoINIncomplete
|
||||||
* handle data ISO IN Incomplete event
|
* handle data ISO IN Incomplete event
|
||||||
@@ -323,6 +324,7 @@ static uint8_t USBD_TEMPLATE_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t e
|
|||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_TEMPLATE_IsoOutIncomplete
|
* @brief USBD_TEMPLATE_IsoOutIncomplete
|
||||||
* handle data ISO OUT Incomplete event
|
* handle data ISO OUT Incomplete event
|
||||||
|
|||||||
457
Class/VIDEO/Inc/usbd_video.h
Normal file
457
Class/VIDEO/Inc/usbd_video.h
Normal file
@@ -0,0 +1,457 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usbd_video.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief header file for the usbd_video.c file.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 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 __USBD_VIDEO_H
|
||||||
|
#define __USBD_VIDEO_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "usbd_ioreq.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO
|
||||||
|
* @brief This file is the Header file for usbd_video.c
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @defgroup usbd_VIDEO_Exported_Defines
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USB Video device class specification version 1.10 */
|
||||||
|
#ifdef UVC_1_0
|
||||||
|
#define UVC_VERSION 0x0100U /* UVC 1.0 */
|
||||||
|
#else
|
||||||
|
#define UVC_VERSION 0x0110U /* UVC 1.1 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* bEndpointAddress in Endpoint Descriptor */
|
||||||
|
#ifndef UVC_IN_EP
|
||||||
|
#define UVC_IN_EP 0x81U
|
||||||
|
#endif /* VIDEO_IN_EP */
|
||||||
|
|
||||||
|
/* These defines shall be updated in the usbd_conf.h file */
|
||||||
|
#ifndef UVC_WIDTH
|
||||||
|
#define UVC_WIDTH 400U
|
||||||
|
#endif /* UVC_WIDTH */
|
||||||
|
|
||||||
|
#ifndef UVC_HEIGHT
|
||||||
|
#define UVC_HEIGHT 240U
|
||||||
|
#endif /* UVC_HEIGHT */
|
||||||
|
|
||||||
|
#ifndef UVC_CAM_FPS_FS
|
||||||
|
#define UVC_CAM_FPS_FS 10U
|
||||||
|
#endif /* UVC_CAM_FPS_FS */
|
||||||
|
|
||||||
|
#ifndef UVC_CAM_FPS_HS
|
||||||
|
#define UVC_CAM_FPS_HS 5U
|
||||||
|
#endif /* UVC_CAM_FPS_HS */
|
||||||
|
|
||||||
|
#ifndef UVC_PACKET_SIZE
|
||||||
|
#define UVC_PACKET_SIZE 512U
|
||||||
|
#endif /* UVC_PACKET_SIZE */
|
||||||
|
|
||||||
|
#ifndef UVC_MAX_FRAME_SIZE
|
||||||
|
#define UVC_MAX_FRAME_SIZE (UVC_WIDTH * UVC_HEIGHT * 16U / 2U)
|
||||||
|
#endif /* UVC_MAX_FRAME_SIZE */
|
||||||
|
|
||||||
|
#ifndef UVC_COLOR_PRIMARIE
|
||||||
|
#define UVC_COLOR_PRIMARIE 0x01U
|
||||||
|
#endif /* UVC_COLOR_PRIMARIE */
|
||||||
|
|
||||||
|
#ifndef UVC_TFR_CHARACTERISTICS
|
||||||
|
#define UVC_TFR_CHARACTERISTICS 0x01U
|
||||||
|
#endif /* UVC_TFR_CHARACTERISTICS */
|
||||||
|
|
||||||
|
#ifndef UVC_MATRIX_COEFFICIENTS
|
||||||
|
#define UVC_MATRIX_COEFFICIENTS 0x04U
|
||||||
|
#endif /* UVC_MATRIX_COEFFICIENTS */
|
||||||
|
|
||||||
|
#ifndef UVC_BITS_PER_PIXEL
|
||||||
|
#define UVC_BITS_PER_PIXEL 12U
|
||||||
|
#endif /* UVC_BITS_PER_PIXEL */
|
||||||
|
|
||||||
|
#define UVC_GUID_YUY2 0x32595559U
|
||||||
|
#define UVC_GUID_NV12 0x3231564EU
|
||||||
|
|
||||||
|
#ifndef UVC_UNCOMPRESSED_GUID
|
||||||
|
#define UVC_UNCOMPRESSED_GUID UVC_GUID_NV12
|
||||||
|
#endif /* UVC_UNCOMPRESSED_GUID */
|
||||||
|
|
||||||
|
#define UVC_INTERVAL(n) (10000000U/(n))
|
||||||
|
|
||||||
|
#define UVC_MIN_BIT_RATE(n) (UVC_WIDTH * UVC_HEIGHT * 16U * (n)) /* 16 bit */
|
||||||
|
#define UVC_MAX_BIT_RATE(n) (UVC_WIDTH * UVC_HEIGHT * 16U * (n)) /* 16 bit */
|
||||||
|
|
||||||
|
#define UVC_PACKETS_IN_FRAME(n) (UVC_MAX_FRAME_SIZE / (n))
|
||||||
|
|
||||||
|
#ifndef UVC_ISO_FS_MPS
|
||||||
|
#define UVC_ISO_FS_MPS 256U
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UVC_ISO_HS_MPS
|
||||||
|
#define UVC_ISO_HS_MPS 512U
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UVC_HEADER_PACKET_CNT
|
||||||
|
#define UVC_HEADER_PACKET_CNT 0x01U
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define UVC_REQ_READ_MASK 0x80U
|
||||||
|
#define UVC_VC_IF_NUM 0x00U
|
||||||
|
#define UVC_VS_IF_NUM 0x01U
|
||||||
|
#define UVC_TOTAL_IF_NUM 0x02U
|
||||||
|
|
||||||
|
#ifdef USBD_UVC_FORMAT_UNCOMPRESSED
|
||||||
|
#define UVC_CONFIG_DESC_SIZ (0x88U + 0x16U)
|
||||||
|
#else
|
||||||
|
#define UVC_CONFIG_DESC_SIZ 0x88U
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define UVC_TOTAL_BUF_SIZE 0x04U
|
||||||
|
|
||||||
|
#define UVC_VC_EP_DESC_SIZE 0x05U
|
||||||
|
#define UVC_STREAMING_EP_DESC_SIZE 0x07U
|
||||||
|
#define UVC_EP_DESC_TYPE 0x25U
|
||||||
|
|
||||||
|
/* Video Interface Class Codes*/
|
||||||
|
#define UVC_CC_VIDEO 0x0EU
|
||||||
|
|
||||||
|
#define UVC_PLAY_STATUS_STOP 0x00U
|
||||||
|
#define UVC_PLAY_STATUS_READY 0x01U
|
||||||
|
#define UVC_PLAY_STATUS_STREAMING 0x02U
|
||||||
|
|
||||||
|
#ifndef WBVAL
|
||||||
|
#define WBVAL(x) ((x) & 0xFFU),(((x) >> 8) & 0xFFU)
|
||||||
|
#endif
|
||||||
|
#ifndef DBVAL
|
||||||
|
#define DBVAL(x) ((x)& 0xFFU),(((x) >> 8) & 0xFFU),(((x)>> 16) & 0xFFU),(((x) >> 24) & 0xFFU)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Video Interface Protocol Codes */
|
||||||
|
#define PC_PROTOCOL_UNDEFINED 0x00U
|
||||||
|
|
||||||
|
#define VIDEO_VC_IF_HEADER_DESC_SIZE 0x0DU
|
||||||
|
#define VIDEO_IN_TERMINAL_DESC_SIZE 0x08U
|
||||||
|
#define VIDEO_OUT_TERMINAL_DESC_SIZE 0x09U
|
||||||
|
#define VIDEO_VS_IF_IN_HEADER_DESC_SIZE 0x0EU
|
||||||
|
|
||||||
|
#define VS_FORMAT_UNCOMPRESSED_DESC_SIZE 0x1BU
|
||||||
|
#define VS_FORMAT_MJPEG_DESC_SIZE 0x0BU
|
||||||
|
#define VS_FRAME_DESC_SIZE 0x1EU
|
||||||
|
#define VS_COLOR_MATCHING_DESC_SIZE 0x06U
|
||||||
|
|
||||||
|
#ifdef USBD_UVC_FORMAT_UNCOMPRESSED
|
||||||
|
#define VS_FORMAT_DESC_SIZE VS_FORMAT_UNCOMPRESSED_DESC_SIZE
|
||||||
|
#define VS_FORMAT_SUBTYPE VS_FORMAT_UNCOMPRESSED
|
||||||
|
#define VS_FRAME_SUBTYPE VS_FRAME_UNCOMPRESSED
|
||||||
|
|
||||||
|
#define VC_HEADER_SIZE (VIDEO_VS_IF_IN_HEADER_DESC_SIZE + \
|
||||||
|
VS_FORMAT_UNCOMPRESSED_DESC_SIZE + \
|
||||||
|
VS_FRAME_DESC_SIZE + \
|
||||||
|
VS_COLOR_MATCHING_DESC_SIZE)
|
||||||
|
#else
|
||||||
|
#define VS_FORMAT_DESC_SIZE VS_FORMAT_MJPEG_DESC_SIZE
|
||||||
|
#define VS_FORMAT_SUBTYPE VS_FORMAT_MJPEG
|
||||||
|
#define VS_FRAME_SUBTYPE VS_FRAME_MJPEG
|
||||||
|
|
||||||
|
#define VC_HEADER_SIZE (VIDEO_VS_IF_IN_HEADER_DESC_SIZE + \
|
||||||
|
VS_FORMAT_DESC_SIZE + \
|
||||||
|
VS_FRAME_DESC_SIZE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Video Class specification release 1.1
|
||||||
|
* Appendix A. Video Device Class Codes defines
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Video Interface Subclass values */
|
||||||
|
#define SC_UNDEFINED 0x00U
|
||||||
|
#define SC_VIDEOCONTROL 0x01U
|
||||||
|
#define SC_VIDEOSTREAMING 0x02U
|
||||||
|
#define SC_VIDEO_INTERFACE_COLLECTION 0x03U
|
||||||
|
|
||||||
|
/* Video Class-Specific Descriptor Types */
|
||||||
|
#define CS_UNDEFINED 0x20U
|
||||||
|
#define CS_DEVICE 0x21U
|
||||||
|
#define CS_CONFIGURATION 0x22U
|
||||||
|
#define CS_STRING 0x23U
|
||||||
|
#define CS_INTERFACE 0x24U
|
||||||
|
#define CS_ENDPOINT 0x25U
|
||||||
|
|
||||||
|
/* Video Class-Specific VideoControl Interface Descriptor Subtypes */
|
||||||
|
#define VC_DESCRIPTOR_UNDEFINED 0x00U
|
||||||
|
#define VC_HEADER 0x01U
|
||||||
|
#define VC_INPUT_TERMINAL 0x02U
|
||||||
|
#define VC_OUTPUT_TERMINAL 0x03U
|
||||||
|
#define VC_SELECTOR_UNIT 0x04U
|
||||||
|
#define VC_PROCESSING_UNIT 0x05U
|
||||||
|
#define VC_EXTENSION_UNIT 0x06U
|
||||||
|
|
||||||
|
/* Video Class-Specific VideoStreaming Interface Descriptor Subtypes */
|
||||||
|
#define VS_UNDEFINED 0x00U
|
||||||
|
#define VS_INPUT_HEADER 0x01U
|
||||||
|
#define VS_OUTPUT_HEADER 0x02U
|
||||||
|
#define VS_STILL_IMAGE_FRAME 0x03U
|
||||||
|
#define VS_FORMAT_UNCOMPRESSED 0x04U
|
||||||
|
#define VS_FRAME_UNCOMPRESSED 0x05U
|
||||||
|
#define VS_FORMAT_MJPEG 0x06U
|
||||||
|
#define VS_FRAME_MJPEG 0x07U
|
||||||
|
#define VS_FORMAT_MPEG2TS 0x0AU
|
||||||
|
#define VS_FORMAT_DV 0x0CU
|
||||||
|
#define VS_COLORFORMAT 0x0DU
|
||||||
|
#define VS_FORMAT_FRAME_BASED 0x10U
|
||||||
|
#define VS_FRAME_FRAME_BASED 0x11U
|
||||||
|
#define VS_FORMAT_STREAM_BASED 0x12U
|
||||||
|
|
||||||
|
/* Video Class-Specific Request values */
|
||||||
|
#define UVC_RQ_UNDEFINED 0x00U
|
||||||
|
#define UVC_SET_CUR 0x01U
|
||||||
|
#define UVC_GET_CUR 0x81U
|
||||||
|
#define UVC_GET_MIN 0x82U
|
||||||
|
#define UVC_GET_MAX 0x83U
|
||||||
|
#define UVC_GET_RES 0x84U
|
||||||
|
#define UVC_GET_LEN 0x85U
|
||||||
|
#define UVC_GET_INFO 0x86U
|
||||||
|
#define UVC_GET_DEF 0x87U
|
||||||
|
|
||||||
|
/* VideoControl Interface Control Selectors */
|
||||||
|
#define VC_CONTROL_UNDEFINED 0x00U
|
||||||
|
#define VC_VIDEO_POWER_MODE_CONTROL 0x01U
|
||||||
|
#define VC_REQUEST_ERROR_CODE_CONTROL 0x02U
|
||||||
|
|
||||||
|
/* Request Error Code Control */
|
||||||
|
#define UVC_NO_ERROR_ERR 0x00U
|
||||||
|
#define UVC_NOT_READY_ERR 0x01U
|
||||||
|
#define UVC_WRONG_STATE_ERR 0x02U
|
||||||
|
#define UVC_POWER_ERR 0x03U
|
||||||
|
#define UVC_OUT_OF_RANGE_ERR 0x04U
|
||||||
|
#define UVC_INVALID_UNIT_ERR 0x05U
|
||||||
|
#define UVC_INVALID_CONTROL_ERR 0x06U
|
||||||
|
#define UVC_INVALID_REQUEST_ERR 0x07U
|
||||||
|
#define UVC_UNKNOWN_ERR 0xFFU
|
||||||
|
|
||||||
|
/*Terminal Control Selectors*/
|
||||||
|
#define TE_CONTROL_UNDEFINED 0x00U
|
||||||
|
|
||||||
|
/* Selector Unit Control Selectors */
|
||||||
|
#define SU_CONTROL_UNDEFINED 0x00U
|
||||||
|
#define SU_INPUT_SELECT_CONTROL 0x01U
|
||||||
|
|
||||||
|
/* Camera Terminal Control Selectors */
|
||||||
|
#define CT_CONTROL_UNDEFINED 0x00U
|
||||||
|
#define CT_SCANNING_MODE_CONTROL 0x01U
|
||||||
|
#define CT_AE_MODE_CONTROL 0x02U
|
||||||
|
#define CT_AE_PRIORITY_CONTROL 0x03U
|
||||||
|
#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04U
|
||||||
|
#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05U
|
||||||
|
#define CT_FOCUS_ABSOLUTE_CONTROL 0x06U
|
||||||
|
#define CT_FOCUS_RELATIVE_CONTROL 0x07U
|
||||||
|
#define CT_FOCUS_AUTO_CONTROL 0x08U
|
||||||
|
#define CT_IRIS_ABSOLUTE_CONTROL 0x09U
|
||||||
|
#define CT_IRIS_RELATIVE_CONTROL 0x0AU
|
||||||
|
#define CT_ZOOM_ABSOLUTE_CONTROL 0x0BU
|
||||||
|
#define CT_ZOOM_RELATIVE_CONTROL 0x0CU
|
||||||
|
#define CT_PANTILT_ABSOLUTE_CONTROL 0x0DU
|
||||||
|
#define CT_PANTILT_RELATIVE_CONTROL 0x0EU
|
||||||
|
#define CT_ROLL_ABSOLUTE_CONTROL 0x0FU
|
||||||
|
#define CT_ROLL_RELATIVE_CONTROL 0x10U
|
||||||
|
#define CT_PRIVACY_CONTROL 0x11U
|
||||||
|
|
||||||
|
/* Processing Unit Control Selectors */
|
||||||
|
#define PU_CONTROL_UNDEFINED 0x00U
|
||||||
|
#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01U
|
||||||
|
#define PU_BRIGHTNESS_CONTROL 0x02U
|
||||||
|
#define PU_CONTRAST_CONTROL 0x03U
|
||||||
|
#define PU_GAIN_CONTROL 0x04U
|
||||||
|
#define PU_POWER_LINE_FREQUENCY_CONTROL 0x05U
|
||||||
|
#define PU_HUE_CONTROL 0x06U
|
||||||
|
#define PU_SATURATION_CONTROL 0x07U
|
||||||
|
#define PU_SHARPNESS_CONTROL 0x08U
|
||||||
|
#define PU_GAMMA_CONTROL 0x09U
|
||||||
|
#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0AU
|
||||||
|
#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0BU
|
||||||
|
#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0CU
|
||||||
|
#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0DU
|
||||||
|
#define PU_DIGITAL_MULTIPLIER_CONTROL 0x0EU
|
||||||
|
#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0FU
|
||||||
|
#define PU_HUE_AUTO_CONTROL 0x10U
|
||||||
|
#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11U
|
||||||
|
#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12U
|
||||||
|
|
||||||
|
/*Extension Unit Control Selectors */
|
||||||
|
#define XU_CONTROL_UNDEFINED 0x00U
|
||||||
|
|
||||||
|
/* VideoStreaming Interface Control Selectors */
|
||||||
|
#define VS_CONTROL_UNDEFINED 0x00U
|
||||||
|
#define VS_PROBE_CONTROL 0x100U
|
||||||
|
#define VS_COMMIT_CONTROL 0x200U
|
||||||
|
#define VS_STILL_PROBE_CONTROL 0x03U
|
||||||
|
#define VS_STILL_COMMIT_CONTROL 0x04U
|
||||||
|
#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05U
|
||||||
|
#define VS_STREAM_ERROR_CODE_CONTROL 0x06U
|
||||||
|
#define VS_GENERATE_KEY_FRAME_CONTROL 0x07U
|
||||||
|
#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08U
|
||||||
|
#define VS_SYNC_DELAY_CONTROL 0x09U
|
||||||
|
|
||||||
|
|
||||||
|
/* Control Capabilities */
|
||||||
|
#define UVC_SUPPORTS_GET 0x01U
|
||||||
|
#define UVC_SUPPORTS_SET 0x02U
|
||||||
|
#define UVC_STATE_DISABLED 0x04U
|
||||||
|
#define UVC_AUTOUPDATE_CONTROL 0x08U
|
||||||
|
#define UVC_ASYNCHRONOUS_CONTROL 0x10U
|
||||||
|
|
||||||
|
/* USB Terminal Types */
|
||||||
|
#define TT_VENDOR_SPECIFIC 0x0100U
|
||||||
|
#define TT_STREAMING 0x0101U
|
||||||
|
|
||||||
|
/* Input Terminal Types */
|
||||||
|
#define ITT_VENDOR_SPECIFIC 0x0200U
|
||||||
|
#define ITT_CAMERA 0x0201U
|
||||||
|
#define ITT_MEDIA_TRANSPORT_INPUT 0x0202U
|
||||||
|
|
||||||
|
/*Output Terminal Types */
|
||||||
|
#define OTT_VENDOR_SPECIFIC 0x0300U
|
||||||
|
#define OTT_DISPLAY 0x0301U
|
||||||
|
#define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302U
|
||||||
|
|
||||||
|
/* External Terminal Types */
|
||||||
|
#define EXTERNAL_VENDOR_SPECIFIC 0x0400U
|
||||||
|
#define COMPOSITE_CONNECTOR 0x0401U
|
||||||
|
#define SVIDEO_CONNECTOR 0x0402U
|
||||||
|
#define COMPONENT_CONNECTOR 0x0403U
|
||||||
|
|
||||||
|
|
||||||
|
/* VIDEO Commands enumeration */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
VIDEO_CMD_START = 1U,
|
||||||
|
VIDEO_CMD_PLAY,
|
||||||
|
VIDEO_CMD_STOP,
|
||||||
|
} VIDEO_CMD_TypeDef;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
VIDEO_OFFSET_NONE = 0U,
|
||||||
|
VIDEO_OFFSET_HALF,
|
||||||
|
VIDEO_OFFSET_FULL,
|
||||||
|
VIDEO_OFFSET_UNKNOWN,
|
||||||
|
} VIDEO_OffsetTypeDef;
|
||||||
|
|
||||||
|
typedef struct _VIDEO_DescHeader
|
||||||
|
{
|
||||||
|
uint8_t bLength;
|
||||||
|
uint8_t bDescriptorType;
|
||||||
|
uint8_t bDescriptorSubType;
|
||||||
|
} USBD_VIDEO_DescHeader_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t bLength;
|
||||||
|
uint8_t bDescriptorType;
|
||||||
|
uint8_t bDescriptorSubType;
|
||||||
|
uint8_t bFrameIndex;
|
||||||
|
uint8_t bmCapabilities;
|
||||||
|
uint16_t wWidth;
|
||||||
|
uint16_t wHeight;
|
||||||
|
uint32_t dwMinBitRate;
|
||||||
|
uint32_t dwMaxBitRate;
|
||||||
|
uint32_t dwMaxVideoFrameBufSize;
|
||||||
|
uint32_t dwDefaultFrameInterval;
|
||||||
|
uint8_t bFrameIntervalType;
|
||||||
|
uint32_t dwMinFrameInterval;
|
||||||
|
uint32_t dwMaxFrameInterval;
|
||||||
|
uint32_t dwFrameIntervalStep;
|
||||||
|
} __PACKED USBD_VIDEO_VSFrameDescTypeDef;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t cmd;
|
||||||
|
uint8_t data[USB_MAX_EP0_SIZE];
|
||||||
|
uint8_t len;
|
||||||
|
uint8_t unit;
|
||||||
|
} USBD_VIDEO_ControlTypeDef;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t interface;
|
||||||
|
uint32_t uvc_state;
|
||||||
|
uint8_t buffer[UVC_TOTAL_BUF_SIZE];
|
||||||
|
VIDEO_OffsetTypeDef offset;
|
||||||
|
USBD_VIDEO_ControlTypeDef control;
|
||||||
|
} USBD_VIDEO_HandleTypeDef;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int8_t (* Init)(void);
|
||||||
|
int8_t (* DeInit)(void);
|
||||||
|
int8_t (* Control)(uint8_t, uint8_t *, uint16_t);
|
||||||
|
int8_t (* Data)(uint8_t **, uint16_t *, uint16_t *);
|
||||||
|
uint8_t *pStrDesc;
|
||||||
|
} USBD_VIDEO_ItfTypeDef;
|
||||||
|
|
||||||
|
/* UVC uses only 26 first bytes */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t bmHint;
|
||||||
|
uint8_t bFormatIndex;
|
||||||
|
uint8_t bFrameIndex;
|
||||||
|
uint32_t dwFrameInterval;
|
||||||
|
uint16_t wKeyFrameRate;
|
||||||
|
uint16_t wPFrameRate;
|
||||||
|
uint16_t wCompQuality;
|
||||||
|
uint16_t wCompWindowSize;
|
||||||
|
uint16_t wDelay;
|
||||||
|
uint32_t dwMaxVideoFrameSize;
|
||||||
|
uint32_t dwMaxPayloadTransferSize;
|
||||||
|
uint32_t dwClockFrequency;
|
||||||
|
uint8_t bmFramingInfo;
|
||||||
|
uint8_t bPreferedVersion;
|
||||||
|
uint8_t bMinVersion;
|
||||||
|
uint8_t bMaxVersion;
|
||||||
|
} __PACKED USBD_VideoControlTypeDef;
|
||||||
|
|
||||||
|
extern USBD_ClassTypeDef USBD_VIDEO;
|
||||||
|
#define USBD_VIDEO_CLASS &USBD_VIDEO
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USB_CORE_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint8_t USBD_VIDEO_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_VIDEO_ItfTypeDef *fops);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _USBD_VIDEO_H_ */
|
||||||
142
Class/VIDEO/Inc/usbd_video_if_template.h
Normal file
142
Class/VIDEO/Inc/usbd_video_if_template.h
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usbd_video_if_template.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Template Header file for the video Interface application layer functions
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 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 __USBD_VIDEO_IF_H__
|
||||||
|
#define __USBD_VIDEO_IF_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "usbd_video.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN INCLUDE */
|
||||||
|
|
||||||
|
/* USER CODE END INCLUDE */
|
||||||
|
|
||||||
|
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||||
|
* @brief For Usb device.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF
|
||||||
|
* @brief Usb VIDEO interface device module.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Exported_Defines
|
||||||
|
* @brief Defines.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EXPORTED_DEFINES */
|
||||||
|
|
||||||
|
/* USER CODE END EXPORTED_DEFINES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Exported_Types
|
||||||
|
* @brief Types.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EXPORTED_TYPES */
|
||||||
|
|
||||||
|
/* USER CODE END EXPORTED_TYPES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Exported_Macros
|
||||||
|
* @brief Aliases.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EXPORTED_MACRO */
|
||||||
|
|
||||||
|
/* USER CODE END EXPORTED_MACRO */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Exported_Variables
|
||||||
|
* @brief Public variables.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** VIDEO_IF Interface callback. */
|
||||||
|
extern USBD_VIDEO_ItfTypeDef USBD_VIDEO_fops_FS;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EXPORTED_VARIABLES */
|
||||||
|
|
||||||
|
/* USER CODE END EXPORTED_VARIABLES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Exported_FunctionsPrototype
|
||||||
|
* @brief Public functions declaration.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Manages the DMA full transfer complete event.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void TransferComplete_CallBack_FS(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Manages the DMA half transfer complete event.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HalfTransfer_CallBack_FS(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
|
||||||
|
|
||||||
|
/* USER CODE END EXPORTED_FUNCTIONS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* USBD_VIDEO_IF_H_ */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1040
Class/VIDEO/Src/usbd_video.c
Normal file
1040
Class/VIDEO/Src/usbd_video.c
Normal file
File diff suppressed because it is too large
Load Diff
296
Class/VIDEO/Src/usbd_video_if_template.c
Normal file
296
Class/VIDEO/Src/usbd_video_if_template.c
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usbd_video_if_template.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Template file for Video Interface application layer functions
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 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
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "usbd_video_if.h"
|
||||||
|
|
||||||
|
/* Include you image binary file here
|
||||||
|
Binary image template shall provide:
|
||||||
|
- tImagesList: table containing pointers to all images
|
||||||
|
- tImagesSizes: table containing sizes of each image respectively
|
||||||
|
- img_count: global image counter variable
|
||||||
|
- IMG_NBR: Total image number
|
||||||
|
|
||||||
|
To generate such file, it is possible to use tools converting video to MJPEG then to JPEG images.
|
||||||
|
*/
|
||||||
|
/* #include "img_bin.h" */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN INCLUDE */
|
||||||
|
|
||||||
|
/* USER CODE END INCLUDE */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||||
|
* @brief Usb device library.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup USBD_VIDEO_IF
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Private_TypesDefinitions
|
||||||
|
* @brief Private types.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PRIVATE_TYPES */
|
||||||
|
|
||||||
|
/* USER CODE END PRIVATE_TYPES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Private_Defines
|
||||||
|
* @brief Private defines.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PRIVATE_DEFINES */
|
||||||
|
|
||||||
|
/* USER CODE END PRIVATE_DEFINES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Private_Macros
|
||||||
|
* @brief Private macros.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PRIVATE_MACRO */
|
||||||
|
|
||||||
|
/* USER CODE END PRIVATE_MACRO */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Private_Variables
|
||||||
|
* @brief Private variables.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PRIVATE_VARIABLES */
|
||||||
|
|
||||||
|
/* USER CODE END PRIVATE_VARIABLES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Exported_Variables
|
||||||
|
* @brief Public variables.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EXPORTED_VARIABLES */
|
||||||
|
|
||||||
|
/* USER CODE END EXPORTED_VARIABLES */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup USBD_VIDEO_IF_Private_FunctionPrototypes
|
||||||
|
* @brief Private functions declaration.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int8_t VIDEO_Itf_Init(void);
|
||||||
|
static int8_t VIDEO_Itf_DeInit(void);
|
||||||
|
static int8_t VIDEO_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length);
|
||||||
|
static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx);
|
||||||
|
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
|
||||||
|
|
||||||
|
/* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
USBD_VIDEO_ItfTypeDef USBD_VIDEO_fops_FS =
|
||||||
|
{
|
||||||
|
VIDEO_Itf_Init,
|
||||||
|
VIDEO_Itf_DeInit,
|
||||||
|
VIDEO_Itf_Control,
|
||||||
|
VIDEO_Itf_Data,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief Initializes the VIDEO media low layer over USB FS IP
|
||||||
|
* @param VIDEOFreq: VIDEO frequency used to play the VIDEO stream.
|
||||||
|
* @param Volume: Initial volume level (from 0 (Mute) to 100 (Max))
|
||||||
|
* @param options: Reserved for future use
|
||||||
|
* @retval USBD_OK if all operations are OK else USBD_FAIL
|
||||||
|
*/
|
||||||
|
static int8_t VIDEO_Itf_Init(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Add your initialization code here
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TEMPLATE_DeInit
|
||||||
|
* DeInitializes the UVC media low layer
|
||||||
|
* @param None
|
||||||
|
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||||
|
*/
|
||||||
|
static int8_t VIDEO_Itf_DeInit(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Add your deinitialization code here
|
||||||
|
*/
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TEMPLATE_Control
|
||||||
|
* Manage the UVC class requests
|
||||||
|
* @param Cmd: Command code
|
||||||
|
* @param Buf: Buffer containing command data (request parameters)
|
||||||
|
* @param Len: 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 VIDEO_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TEMPLATE_Data
|
||||||
|
* Manage the UVC data packets
|
||||||
|
* @param pbuf: pointer to the buffer data to be filled
|
||||||
|
* @param psize: pointer tot he current packet size to be filled
|
||||||
|
* @param pcktidx: pointer to the current packet index in the current image
|
||||||
|
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||||
|
*/
|
||||||
|
static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Implementation of this function is mandatory to provide the video data to the USB video class
|
||||||
|
This function shall parse the MJPEG images and provide each time the buffer packet relative to
|
||||||
|
current packet index and its size.
|
||||||
|
If the packet is the first packet in the current MJPEG image, then packet size shall be zero and
|
||||||
|
the pbuf is ignored and pcktidx shall be zero.
|
||||||
|
Below is typical implementation of this function based on a binary image template.
|
||||||
|
|
||||||
|
Binary image template shall provide:
|
||||||
|
- tImagesList: table containing pointers to all images
|
||||||
|
- tImagesSizes: table containing sizes of each image respectively
|
||||||
|
- img_count: global image counter variable
|
||||||
|
- IMG_NBR: Total image number
|
||||||
|
|
||||||
|
To generate such file, it is possible to use tools converting video to MJPEG then to JPEG images.
|
||||||
|
|
||||||
|
*/
|
||||||
|
const uint8_t *(*ImagePtr) = tImagesList;
|
||||||
|
uint32_t packet_count = (tImagesSizes[img_count]) / ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)));
|
||||||
|
uint32_t packet_remainder = (tImagesSizes[img_count]) % ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)));
|
||||||
|
static uint8_t packet_index = 0;
|
||||||
|
|
||||||
|
/* Check if end of current image has been reached */
|
||||||
|
if (packet_index < packet_count)
|
||||||
|
{
|
||||||
|
/* Set the current packet size */
|
||||||
|
*psize = (uint16_t)UVC_PACKET_SIZE;
|
||||||
|
|
||||||
|
/* Get the pointer to the next packet to be transmitted */
|
||||||
|
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U))));
|
||||||
|
}
|
||||||
|
else if ((packet_index == packet_count))
|
||||||
|
{
|
||||||
|
if (packet_remainder != 0U)
|
||||||
|
{
|
||||||
|
/* Get the pointer to the next packet to be transmitted */
|
||||||
|
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U))));
|
||||||
|
|
||||||
|
/* Set the current packet size */
|
||||||
|
*psize = packet_remainder + (UVC_HEADER_PACKET_CNT * 2U);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packet_index++;
|
||||||
|
|
||||||
|
/* New image to be started, send only the packet header */
|
||||||
|
*psize = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* New image to be started, send only the packet header */
|
||||||
|
*psize = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update the packet index */
|
||||||
|
*pcktidx = packet_index;
|
||||||
|
|
||||||
|
/* Increment the packet count and check if it reached the end of current image buffer */
|
||||||
|
if (packet_index++ >= (packet_count + 1))
|
||||||
|
{
|
||||||
|
/* Reset the packet count to zero */
|
||||||
|
packet_index = 0U;
|
||||||
|
|
||||||
|
/* Move to the next image in the images table */
|
||||||
|
|
||||||
|
img_count++;
|
||||||
|
HAL_Delay(USBD_VIDEO_IMAGE_LAPS);
|
||||||
|
/* Check if images count has been reached, then reset to zero (go back to first image in circular loop) */
|
||||||
|
if (img_count == IMG_NBR)
|
||||||
|
{
|
||||||
|
img_count = 0U;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
|
||||||
|
|
||||||
|
/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
@@ -71,15 +71,66 @@ extern "C" {
|
|||||||
/* AUDIO Class Config */
|
/* AUDIO Class Config */
|
||||||
#define USBD_AUDIO_FREQ 22100U
|
#define USBD_AUDIO_FREQ 22100U
|
||||||
|
|
||||||
|
/* CustomHID Class Config */
|
||||||
|
#define CUSTOM_HID_HS_BINTERVAL 0x05U
|
||||||
|
#define CUSTOM_HID_FS_BINTERVAL 0x05U
|
||||||
|
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
|
||||||
|
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
|
||||||
|
|
||||||
|
/* VIDEO Class Config */
|
||||||
|
#define UVC_1_1 /* #define UVC_1_0 */
|
||||||
|
|
||||||
|
/* To be used only with YUY2 and NV12 Video format, shouldn't be defined for MJPEG format */
|
||||||
|
#define USBD_UVC_FORMAT_UNCOMPRESSED
|
||||||
|
|
||||||
|
#ifdef USBD_UVC_FORMAT_UNCOMPRESSED
|
||||||
|
#define UVC_BITS_PER_PIXEL 12U
|
||||||
|
#define UVC_UNCOMPRESSED_GUID UVC_GUID_NV12 /* UVC_GUID_YUY2 */
|
||||||
|
|
||||||
|
/* refer to Table 3-18 Color Matching Descriptor video class v1.1 */
|
||||||
|
#define UVC_COLOR_PRIMARIE 0x01U
|
||||||
|
#define UVC_TFR_CHARACTERISTICS 0x01U
|
||||||
|
#define UVC_MATRIX_COEFFICIENTS 0x04U
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Video Stream frame width and height */
|
||||||
|
#define UVC_WIDTH 176U
|
||||||
|
#define UVC_HEIGHT 144U
|
||||||
|
|
||||||
|
/* bEndpointAddress in Endpoint Descriptor */
|
||||||
|
#define UVC_IN_EP 0x81U
|
||||||
|
|
||||||
|
#define UVC_CAM_FPS_FS 10U
|
||||||
|
#define UVC_CAM_FPS_HS 5U
|
||||||
|
|
||||||
|
#define UVC_ISO_FS_MPS 512U
|
||||||
|
#define UVC_ISO_HS_MPS 512U
|
||||||
|
|
||||||
|
#define UVC_PACKET_SIZE UVC_ISO_FS_MPS
|
||||||
|
/* To be used with Device Only IP supporting double buffer mode */
|
||||||
|
/* #define UVC_HEADER_PACKET_CNT 0x02U */
|
||||||
|
/* #define UVC_PACKET_SIZE (UVC_ISO_FS_MPS * UVC_HEADER_PACKET_CNT) */
|
||||||
|
|
||||||
|
#define UVC_MAX_FRAME_SIZE (UVC_WIDTH * UVC_HEIGHT * 16U / 8U)
|
||||||
|
|
||||||
/** @defgroup USBD_Exported_Macros
|
/** @defgroup USBD_Exported_Macros
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Memory management macros */
|
/* Memory management macros make sure to use static memory allocation */
|
||||||
#define USBD_malloc malloc
|
/** Alias for memory allocation. */
|
||||||
#define USBD_free free
|
#define USBD_malloc (void *)USBD_static_malloc
|
||||||
|
|
||||||
|
/** Alias for memory release. */
|
||||||
|
#define USBD_free USBD_static_free
|
||||||
|
|
||||||
|
/** Alias for memory set. */
|
||||||
#define USBD_memset memset
|
#define USBD_memset memset
|
||||||
|
|
||||||
|
/** Alias for memory copy. */
|
||||||
#define USBD_memcpy memcpy
|
#define USBD_memcpy memcpy
|
||||||
|
|
||||||
|
/** Alias for delay. */
|
||||||
#define USBD_Delay HAL_Delay
|
#define USBD_Delay HAL_Delay
|
||||||
|
|
||||||
/* DEBUG macros */
|
/* DEBUG macros */
|
||||||
@@ -149,6 +200,9 @@ extern "C" {
|
|||||||
/** @defgroup USBD_CONF_Exported_FunctionsPrototype
|
/** @defgroup USBD_CONF_Exported_FunctionsPrototype
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
/* Exported functions -------------------------------------------------------*/
|
||||||
|
void *USBD_static_malloc(uint32_t size);
|
||||||
|
void USBD_static_free(void *p);
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ extern "C" {
|
|||||||
#define USBD_SELF_POWERED 1U
|
#define USBD_SELF_POWERED 1U
|
||||||
#endif /*USBD_SELF_POWERED */
|
#endif /*USBD_SELF_POWERED */
|
||||||
|
|
||||||
|
#ifndef USBD_MAX_POWER
|
||||||
|
#define USBD_MAX_POWER 0x32U /* 100 mA */
|
||||||
|
#endif /* USBD_MAX_POWER */
|
||||||
|
|
||||||
#ifndef USBD_SUPPORT_USER_STRING_DESC
|
#ifndef USBD_SUPPORT_USER_STRING_DESC
|
||||||
#define USBD_SUPPORT_USER_STRING_DESC 0U
|
#define USBD_SUPPORT_USER_STRING_DESC 0U
|
||||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
@@ -114,6 +118,7 @@ extern "C" {
|
|||||||
#define USB_DESC_TYPE_ENDPOINT 0x05U
|
#define USB_DESC_TYPE_ENDPOINT 0x05U
|
||||||
#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
|
#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
|
||||||
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
|
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
|
||||||
|
#define USB_DESC_TYPE_IAD 0x0BU
|
||||||
#define USB_DESC_TYPE_BOS 0x0FU
|
#define USB_DESC_TYPE_BOS 0x0FU
|
||||||
|
|
||||||
#define USB_CONFIG_REMOTE_WAKEUP 0x02U
|
#define USB_CONFIG_REMOTE_WAKEUP 0x02U
|
||||||
@@ -125,6 +130,11 @@ extern "C" {
|
|||||||
|
|
||||||
#define USB_DEVICE_CAPABITY_TYPE 0x10U
|
#define USB_DEVICE_CAPABITY_TYPE 0x10U
|
||||||
|
|
||||||
|
#define USB_CONF_DESC_SIZE 0x09U
|
||||||
|
#define USB_IF_DESC_SIZE 0x09U
|
||||||
|
#define USB_EP_DESC_SIZE 0x07U
|
||||||
|
#define USB_IAD_DESC_SIZE 0x08U
|
||||||
|
|
||||||
#define USB_HS_MAX_PACKET_SIZE 512U
|
#define USB_HS_MAX_PACKET_SIZE 512U
|
||||||
#define USB_FS_MAX_PACKET_SIZE 64U
|
#define USB_FS_MAX_PACKET_SIZE 64U
|
||||||
#define USB_MAX_EP0_SIZE 64U
|
#define USB_MAX_EP0_SIZE 64U
|
||||||
@@ -150,7 +160,6 @@ extern "C" {
|
|||||||
#define USBD_EP_TYPE_BULK 0x02U
|
#define USBD_EP_TYPE_BULK 0x02U
|
||||||
#define USBD_EP_TYPE_INTR 0x03U
|
#define USBD_EP_TYPE_INTR 0x03U
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@@ -173,8 +182,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint8_t wDescriptorLengthLow;
|
uint16_t wTotalLength;
|
||||||
uint8_t wDescriptorLengthHigh;
|
|
||||||
uint8_t bNumInterfaces;
|
uint8_t bNumInterfaces;
|
||||||
uint8_t bConfigurationValue;
|
uint8_t bConfigurationValue;
|
||||||
uint8_t iConfiguration;
|
uint8_t iConfiguration;
|
||||||
@@ -190,6 +198,15 @@ typedef struct
|
|||||||
uint8_t bNumDeviceCaps;
|
uint8_t bNumDeviceCaps;
|
||||||
} USBD_BosDescTypedef;
|
} USBD_BosDescTypedef;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t bLength;
|
||||||
|
uint8_t bDescriptorType;
|
||||||
|
uint8_t bEndpointAddress;
|
||||||
|
uint8_t bmAttributes;
|
||||||
|
uint16_t wMaxPacketSize;
|
||||||
|
uint8_t bInterval;
|
||||||
|
} USBD_EpDescTypedef;
|
||||||
|
|
||||||
struct _USBD_HandleTypeDef;
|
struct _USBD_HandleTypeDef;
|
||||||
|
|
||||||
@@ -274,10 +291,10 @@ typedef struct _USBD_HandleTypeDef
|
|||||||
USBD_SpeedTypeDef dev_speed;
|
USBD_SpeedTypeDef dev_speed;
|
||||||
USBD_EndpointTypeDef ep_in[16];
|
USBD_EndpointTypeDef ep_in[16];
|
||||||
USBD_EndpointTypeDef ep_out[16];
|
USBD_EndpointTypeDef ep_out[16];
|
||||||
uint32_t ep0_state;
|
__IO uint32_t ep0_state;
|
||||||
uint32_t ep0_data_len;
|
uint32_t ep0_data_len;
|
||||||
uint8_t dev_state;
|
__IO uint8_t dev_state;
|
||||||
uint8_t dev_old_state;
|
__IO uint8_t dev_old_state;
|
||||||
uint8_t dev_address;
|
uint8_t dev_address;
|
||||||
uint8_t dev_connection_status;
|
uint8_t dev_connection_status;
|
||||||
uint8_t dev_test_mode;
|
uint8_t dev_test_mode;
|
||||||
@@ -317,11 +334,21 @@ __STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
|
|||||||
return _SwapVal;
|
return _SwapVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef LOBYTE
|
||||||
#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
|
#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
|
||||||
#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
|
#endif
|
||||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
||||||
|
|
||||||
|
#ifndef HIBYTE
|
||||||
|
#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined ( __GNUC__ )
|
#if defined ( __GNUC__ )
|
||||||
#ifndef __weak
|
#ifndef __weak
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "usbd_core.h"
|
#include "usbd_core.h"
|
||||||
|
#include "usbd_hid.h" /* Include class header file */
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@@ -223,7 +224,7 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev,
|
|||||||
* @brief Returns the last transferred packet size.
|
* @brief Returns the last transferred packet size.
|
||||||
* @param pdev: Device handle
|
* @param pdev: Device handle
|
||||||
* @param ep_addr: Endpoint Number
|
* @param ep_addr: Endpoint Number
|
||||||
* @retval Recived Data Size
|
* @retval Received Data Size
|
||||||
*/
|
*/
|
||||||
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
@@ -233,6 +234,27 @@ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Static single allocation.
|
||||||
|
* @param size: Size of allocated memory
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void *USBD_static_malloc(uint32_t size)
|
||||||
|
{
|
||||||
|
static uint32_t mem[(sizeof(USBD_HID_HandleTypeDef) / 4) + 1]; /* On 32-bit boundary */
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dummy memory free
|
||||||
|
* @param p: Pointer to allocated memory address
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void USBD_static_free(void *p)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delays routine for the USB Device Library.
|
* @brief Delays routine for the USB Device Library.
|
||||||
* @param Delay: Delay in ms
|
* @param Delay: Delay in ms
|
||||||
|
|||||||
@@ -100,16 +100,10 @@ USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
|||||||
return USBD_FAIL;
|
return USBD_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unlink previous class */
|
/* Unlink previous class resources */
|
||||||
if (pdev->pClass != NULL)
|
|
||||||
{
|
|
||||||
pdev->pClass = NULL;
|
pdev->pClass = NULL;
|
||||||
}
|
pdev->pUserData = NULL;
|
||||||
|
|
||||||
if (pdev->pConfDesc != NULL)
|
|
||||||
{
|
|
||||||
pdev->pConfDesc = NULL;
|
pdev->pConfDesc = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* Assign USBD Descriptors */
|
/* Assign USBD Descriptors */
|
||||||
if (pdesc != NULL)
|
if (pdesc != NULL)
|
||||||
@@ -129,7 +123,7 @@ USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DeInit
|
* @brief USBD_DeInit
|
||||||
* Re-Initialize th device library
|
* Re-Initialize the device library
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status: status
|
* @retval status: status
|
||||||
*/
|
*/
|
||||||
@@ -137,6 +131,9 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
USBD_StatusTypeDef ret;
|
USBD_StatusTypeDef ret;
|
||||||
|
|
||||||
|
/* Disconnect the USB Device */
|
||||||
|
(void)USBD_LL_Stop(pdev);
|
||||||
|
|
||||||
/* Set Default State */
|
/* Set Default State */
|
||||||
pdev->dev_state = USBD_STATE_DEFAULT;
|
pdev->dev_state = USBD_STATE_DEFAULT;
|
||||||
|
|
||||||
@@ -144,22 +141,15 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
|||||||
if (pdev->pClass != NULL)
|
if (pdev->pClass != NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
||||||
|
pdev->pClass = NULL;
|
||||||
|
pdev->pUserData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdev->pConfDesc != NULL)
|
/* Free Device descriptors resources */
|
||||||
{
|
pdev->pDesc = NULL;
|
||||||
pdev->pConfDesc = NULL;
|
pdev->pConfDesc = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* Stop the low level driver */
|
/* DeInitialize low level driver */
|
||||||
ret = USBD_LL_Stop(pdev);
|
|
||||||
|
|
||||||
if (ret != USBD_OK)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize low level driver */
|
|
||||||
ret = USBD_LL_DeInit(pdev);
|
ret = USBD_LL_DeInit(pdev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -188,13 +178,18 @@ USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDe
|
|||||||
pdev->pClass = pclass;
|
pdev->pClass = pclass;
|
||||||
|
|
||||||
/* Get Device Configuration Descriptor */
|
/* Get Device Configuration Descriptor */
|
||||||
#ifdef USE_USB_FS
|
#ifdef USE_USB_HS
|
||||||
pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len);
|
if (pdev->pClass->GetHSConfigDescriptor != NULL)
|
||||||
#else /* USE_USB_HS */
|
{
|
||||||
pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len);
|
pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len);
|
||||||
|
}
|
||||||
|
#else /* Default USE_USB_FS */
|
||||||
|
if (pdev->pClass->GetFSConfigDescriptor != NULL)
|
||||||
|
{
|
||||||
|
pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len);
|
||||||
|
}
|
||||||
#endif /* USE_USB_FS */
|
#endif /* USE_USB_FS */
|
||||||
|
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,23 +213,16 @@ USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev)
|
|||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_StatusTypeDef ret;
|
/* Disconnect USB Device */
|
||||||
|
(void)USBD_LL_Stop(pdev);
|
||||||
|
|
||||||
/* Free Class Resources */
|
/* Free Class Resources */
|
||||||
if (pdev->pClass != NULL)
|
if (pdev->pClass != NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
(void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdev->pConfDesc != NULL)
|
return USBD_OK;
|
||||||
{
|
|
||||||
pdev->pConfDesc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Stop the low level driver */
|
|
||||||
ret = USBD_LL_Stop(pdev);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -292,7 +280,7 @@ USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_SetupStage
|
* @brief USBD_LL_SetupStage
|
||||||
* Handle the setup stage
|
* Handle the setup stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -330,10 +318,11 @@ USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DataOutStage
|
* @brief USBD_LL_DataOutStage
|
||||||
* Handle data OUT stage
|
* Handle data OUT stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param epnum: endpoint index
|
* @param epnum: endpoint index
|
||||||
|
* @param pdata: data pointer
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
||||||
@@ -356,11 +345,14 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((pdev->pClass->EP0_RxReady != NULL) &&
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
(pdev->dev_state == USBD_STATE_CONFIGURED))
|
{
|
||||||
|
if (pdev->pClass->EP0_RxReady != NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->EP0_RxReady(pdev);
|
pdev->pClass->EP0_RxReady(pdev);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,8 +370,11 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((pdev->pClass->DataOut != NULL) &&
|
else
|
||||||
(pdev->dev_state == USBD_STATE_CONFIGURED))
|
{
|
||||||
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
|
{
|
||||||
|
if (pdev->pClass->DataOut != NULL)
|
||||||
{
|
{
|
||||||
ret = (USBD_StatusTypeDef)pdev->pClass->DataOut(pdev, epnum);
|
ret = (USBD_StatusTypeDef)pdev->pClass->DataOut(pdev, epnum);
|
||||||
|
|
||||||
@@ -388,17 +383,14 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
/* should never be in this condition */
|
|
||||||
return USBD_FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DataInStage
|
* @brief USBD_LL_DataInStage
|
||||||
* Handle data in stage
|
* Handle data in stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param epnum: endpoint index
|
* @param epnum: endpoint index
|
||||||
@@ -440,11 +432,13 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((pdev->pClass->EP0_TxSent != NULL) &&
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
(pdev->dev_state == USBD_STATE_CONFIGURED))
|
{
|
||||||
|
if (pdev->pClass->EP0_TxSent != NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->EP0_TxSent(pdev);
|
pdev->pClass->EP0_TxSent(pdev);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
(void)USBD_LL_StallEP(pdev, 0x80U);
|
(void)USBD_LL_StallEP(pdev, 0x80U);
|
||||||
(void)USBD_CtlReceiveStatus(pdev);
|
(void)USBD_CtlReceiveStatus(pdev);
|
||||||
}
|
}
|
||||||
@@ -467,8 +461,11 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
pdev->dev_test_mode = 0U;
|
pdev->dev_test_mode = 0U;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((pdev->pClass->DataIn != NULL) &&
|
else
|
||||||
(pdev->dev_state == USBD_STATE_CONFIGURED))
|
{
|
||||||
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
|
{
|
||||||
|
if (pdev->pClass->DataIn != NULL)
|
||||||
{
|
{
|
||||||
ret = (USBD_StatusTypeDef)pdev->pClass->DataIn(pdev, epnum);
|
ret = (USBD_StatusTypeDef)pdev->pClass->DataIn(pdev, epnum);
|
||||||
|
|
||||||
@@ -477,10 +474,7 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
/* should never be in this condition */
|
|
||||||
return USBD_FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
@@ -501,9 +495,14 @@ USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
|||||||
pdev->dev_config = 0U;
|
pdev->dev_config = 0U;
|
||||||
pdev->dev_remote_wakeup = 0U;
|
pdev->dev_remote_wakeup = 0U;
|
||||||
|
|
||||||
if (pdev->pClassData != NULL)
|
if (pdev->pClass == NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
return USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdev->pClass->DeInit != NULL)
|
||||||
|
{
|
||||||
|
(void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open EP0 OUT */
|
/* Open EP0 OUT */
|
||||||
@@ -522,7 +521,7 @@ USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_LL_Reset
|
* @brief USBD_LL_SetSpeed
|
||||||
* Handle Reset event
|
* Handle Reset event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -536,7 +535,7 @@ USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_Suspend
|
* @brief USBD_LL_Suspend
|
||||||
* Handle Suspend event
|
* Handle Suspend event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -551,7 +550,7 @@ USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_Resume
|
* @brief USBD_LL_Resume
|
||||||
* Handle Resume event
|
* Handle Resume event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -568,7 +567,7 @@ USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_SOF
|
* @brief USBD_LL_SOF
|
||||||
* Handle SOF event
|
* Handle SOF event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -576,11 +575,16 @@ USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
|
if (pdev->pClass == NULL)
|
||||||
|
{
|
||||||
|
return USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
{
|
{
|
||||||
if (pdev->pClass->SOF != NULL)
|
if (pdev->pClass->SOF != NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->SOF(pdev);
|
(void)pdev->pClass->SOF(pdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +592,7 @@ USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_IsoINIncomplete
|
* @brief USBD_LL_IsoINIncomplete
|
||||||
* Handle iso in incomplete event
|
* Handle iso in incomplete event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -596,15 +600,24 @@ USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
||||||
uint8_t epnum)
|
uint8_t epnum)
|
||||||
{
|
{
|
||||||
/* Prevent unused arguments compilation warning */
|
if (pdev->pClass == NULL)
|
||||||
UNUSED(pdev);
|
{
|
||||||
UNUSED(epnum);
|
return USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
|
{
|
||||||
|
if (pdev->pClass->IsoINIncomplete != NULL)
|
||||||
|
{
|
||||||
|
(void)pdev->pClass->IsoINIncomplete(pdev, epnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_IsoOUTIncomplete
|
* @brief USBD_LL_IsoOUTIncomplete
|
||||||
* Handle iso out incomplete event
|
* Handle iso out incomplete event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -612,15 +625,24 @@ USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
|
||||||
uint8_t epnum)
|
uint8_t epnum)
|
||||||
{
|
{
|
||||||
/* Prevent unused arguments compilation warning */
|
if (pdev->pClass == NULL)
|
||||||
UNUSED(pdev);
|
{
|
||||||
UNUSED(epnum);
|
return USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
|
{
|
||||||
|
if (pdev->pClass->IsoOUTIncomplete != NULL)
|
||||||
|
{
|
||||||
|
(void)pdev->pClass->IsoOUTIncomplete(pdev, epnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DevConnected
|
* @brief USBD_LL_DevConnected
|
||||||
* Handle device connection event
|
* Handle device connection event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -634,7 +656,7 @@ USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DevDisconnected
|
* @brief USBD_LL_DevDisconnected
|
||||||
* Handle device disconnection event
|
* Handle device disconnection event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
@@ -646,7 +668,7 @@ USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
if (pdev->pClass != NULL)
|
if (pdev->pClass != NULL)
|
||||||
{
|
{
|
||||||
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
(void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
|||||||
(void)USBD_LL_ClearStallEP(pdev, ep_addr);
|
(void)USBD_LL_ClearStallEP(pdev, ep_addr);
|
||||||
}
|
}
|
||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
(USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req);
|
ret = (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -501,7 +501,9 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
err++;
|
err++;
|
||||||
}
|
}
|
||||||
#elif (USBD_CLASS_USER_STRING_DESC == 1U)
|
#endif
|
||||||
|
|
||||||
|
#if (USBD_CLASS_USER_STRING_DESC == 1U)
|
||||||
if (pdev->pDesc->GetUserStrDescriptor != NULL)
|
if (pdev->pDesc->GetUserStrDescriptor != NULL)
|
||||||
{
|
{
|
||||||
pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, (req->wValue), &len);
|
pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, (req->wValue), &len);
|
||||||
@@ -511,7 +513,9 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
err++;
|
err++;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
#if ((USBD_CLASS_USER_STRING_DESC == 0U) && (USBD_SUPPORT_USER_STRING_DESC == 0U))
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
err++;
|
err++;
|
||||||
#endif
|
#endif
|
||||||
@@ -554,8 +558,7 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (req->wLength != 0U)
|
if (req->wLength != 0U)
|
||||||
{
|
{
|
||||||
if (len != 0U)
|
if (len != 0U)
|
||||||
@@ -573,7 +576,7 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_SetAddress
|
* @brief USBD_SetAddress
|
||||||
@@ -825,6 +828,7 @@ static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_ParseSetupRequest
|
* @brief USBD_ParseSetupRequest
|
||||||
* Copy buffer into setup structure
|
* Copy buffer into setup structure
|
||||||
@@ -832,7 +836,6 @@ static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
||||||
{
|
{
|
||||||
uint8_t *pbuff = pdata;
|
uint8_t *pbuff = pdata;
|
||||||
@@ -854,6 +857,7 @@ void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
|||||||
req->wLength = SWAPBYTE(pbuff);
|
req->wLength = SWAPBYTE(pbuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CtlError
|
* @brief USBD_CtlError
|
||||||
* Handle USB low level Error
|
* Handle USB low level Error
|
||||||
@@ -861,7 +865,6 @@ void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
|||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
UNUSED(req);
|
UNUSED(req);
|
||||||
@@ -908,6 +911,7 @@ void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_GetLen
|
* @brief USBD_GetLen
|
||||||
* return the string length
|
* return the string length
|
||||||
|
|||||||
@@ -90,7 +90,12 @@ USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
|
|||||||
/* Set EP0 State */
|
/* Set EP0 State */
|
||||||
pdev->ep0_state = USBD_EP0_DATA_IN;
|
pdev->ep0_state = USBD_EP0_DATA_IN;
|
||||||
pdev->ep_in[0].total_length = len;
|
pdev->ep_in[0].total_length = len;
|
||||||
|
|
||||||
|
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
||||||
|
pdev->ep_in[0].rem_length = 0U;
|
||||||
|
#else
|
||||||
pdev->ep_in[0].rem_length = len;
|
pdev->ep_in[0].rem_length = len;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Start the transfer */
|
/* Start the transfer */
|
||||||
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
|
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
|
||||||
@@ -129,7 +134,12 @@ USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
|
|||||||
/* Set EP0 State */
|
/* Set EP0 State */
|
||||||
pdev->ep0_state = USBD_EP0_DATA_OUT;
|
pdev->ep0_state = USBD_EP0_DATA_OUT;
|
||||||
pdev->ep_out[0].total_length = len;
|
pdev->ep_out[0].total_length = len;
|
||||||
|
|
||||||
|
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
||||||
|
pdev->ep_out[0].rem_length = 0U;
|
||||||
|
#else
|
||||||
pdev->ep_out[0].rem_length = len;
|
pdev->ep_out[0].rem_length = len;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Start the transfer */
|
/* Start the transfer */
|
||||||
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
|
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -29,21 +29,6 @@ This software component is licensed by ST under Ultimate Liberty license SLA004
|
|||||||
|
|
||||||
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32_mw_usb_device/blob/master/Release_Notes.html).
|
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32_mw_usb_device/blob/master/Release_Notes.html).
|
||||||
|
|
||||||
## Compatibility information
|
|
||||||
|
|
||||||
This table shows the correspondence between the USB Device MW version and the corresponding HAL version of the targeted series. It is **crucial** that you use a consistent set of versions for the MW - HAL, as mentioned in this table.
|
|
||||||
|
|
||||||
Note that:
|
|
||||||
* in case a series does not support a particular tag, it is not mentioned in front of it.
|
|
||||||
* in case a series supports a recent tag, it is not mentioned in front of older ones.
|
|
||||||
|
|
||||||
USB Device | HAL |
|
|
||||||
---------- | ---------- |
|
|
||||||
Tag v2.5.1 | Tag v1.10.2 ([stm32l0xx_hal_driver](https://github.com/STMicroelectronics/stm32l0xx_hal_driver))
|
|
||||||
Tag v2.5.2 | Tag v1.4.0 ([stm32l1xx_hal_driver](https://github.com/STMicroelectronics/stm32l1xx_hal_driver))
|
|
||||||
Tag v2.5.3 | Tag v1.7.3 ([stm32f0xx_hal_driver](https://github.com/STMicroelectronics/stm32f0xx_hal_driver))<br>Tag v1.1.4 ([stm32f1xx_hal_driver](https://github.com/STMicroelectronics/stm32f1xx_hal_driver))<br>Tag v1.2.4 ([stm32f2xx_hal_driver](https://github.com/STMicroelectronics/stm32f2xx_hal_driver))<br>Tag v1.5.3 ([stm32f3xx_hal_driver](https://github.com/STMicroelectronics/stm32f3xx_hal_driver))
|
|
||||||
Tag v2.6.0 | Tag v1.7.8 ([stm32f4xx_hal_driver](https://github.com/STMicroelectronics/stm32f4xx_hal_driver))<br>Tag v1.2.8 ([stm32f7xx_hal_driver](https://github.com/STMicroelectronics/stm32f7xx_hal_driver))<br>Tag v1.9.0 ([stm32h7xx_hal_driver](https://github.com/STMicroelectronics/stm32h7xx_hal_driver))<br>Tag v1.12.0 ([stm32l4xx_hal_driver](https://github.com/STMicroelectronics/stm32l4xx_hal_driver))<br>Tag v1.6.0 ([stm32wbxx_hal_driver](https://github.com/STMicroelectronics/stm32wbxx_hal_driver))
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If you have any issue with the **software content** of this repository, you can file an issue [here](https://github.com/STMicroelectronics/stm32_mw_usb_device/issues/new/choose).
|
If you have any issue with the **software content** of this repository, you can file an issue [here](https://github.com/STMicroelectronics/stm32_mw_usb_device/issues/new/choose).
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||||
<link rel="File-List" href="Release_Notes_for_STM32F2xx_StdPeriph_Driver_files/filelist.xml">
|
<link rel="File-List" href="Release_Notes_for_STM32F2xx_StdPeriph_Driver_files/filelist.xml">
|
||||||
<link rel="Edit-Time-Data" href="Release_Notes_for_STM32F2xx_StdPeriph_Driver_files/editdata.mso"><!--[if !mso]>
|
<link rel="Edit-Time-Data" href="Release_Notes_for_STM32F2xx_StdPeriph_Driver_files/editdata.mso"><!--[if !mso]>
|
||||||
@@ -920,10 +921,42 @@ ul
|
|||||||
</tbody></table>
|
</tbody></table>
|
||||||
<p class="MsoNormal"><span style="font-family: "Arial","sans-serif"; display: none;"><o:p> </o:p></span></p>
|
<p class="MsoNormal"><span style="font-family: "Arial","sans-serif"; display: none;"><o:p> </o:p></span></p>
|
||||||
<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 style="">
|
<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: 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>
|
<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: 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
|
<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
|
||||||
|
Changes</span></u></b></p><ul style="margin-top: 0cm;" type="square"><li>Integration of 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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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
|
||||||
|
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: 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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
@@ -946,7 +979,30 @@ 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 mondatory 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 </li><li>Improve APIs error management and prevent accessing NULL pointers</li></ul><li>USB MSC Class:</li><ul><li>Fix USBCV specific class tests</li><li>Fix mutliple 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 automaticly re-enabling the OUT EP </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
|
|
||||||
|
|
||||||
|
<ul style="margin-top: 0cm;" type="square">
|
||||||
|
<li>USB Core:</li>
|
||||||
|
<ul>
|
||||||
|
<li>minor rework on USBD_Init() USBD_DeInit()</li>
|
||||||
|
<li>Fix warning issue with Keil due to missing return value of setup API<br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<li>USB CDC Class:</li>
|
||||||
|
<ul>
|
||||||
|
<li>Fix file indentation</li>
|
||||||
|
<li>Avoid accessing to NULL pointer in case
|
||||||
|
TransmitCplt() user fops is not defined to allow application
|
||||||
|
compatibility with device library version below v2.6.0<br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
<ul style="margin-top: 0cm;" type="square">
|
||||||
|
<li>Fix minor misra-c 2012 violations</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.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
|
||||||
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>
|
||||||
|
|
||||||
|
|
||||||
@@ -969,7 +1025,30 @@ 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 USBD_SUPPORT_USER_STRING_DESC insead of USBD_SUPPORT_USER_STRING</li><li> prevent accessing to NULL pointer if the get descriptor functions are not defined</li><li>Update on USBD_LL_Resume(), 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
|
<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 </li><li>Improve APIs error 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 </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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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 USBD_SUPPORT_USER_STRING_DESC instead of USBD_SUPPORT_USER_STRING</li><li> prevent accessing to NULL pointer if the get descriptor functions are not defined</li><li>Update on USBD_LL_Resume(), 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>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user