|
|
@ -118,20 +118,26 @@ static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum); |
|
|
|
|
|
|
|
|
|
|
|
USBD_ClassTypeDef USBD_HID = |
|
|
|
USBD_ClassTypeDef USBD_HID = |
|
|
|
{ |
|
|
|
{ |
|
|
|
USBD_HID_Init, |
|
|
|
.Init = USBD_HID_Init, |
|
|
|
USBD_HID_DeInit, |
|
|
|
.DeInit = USBD_HID_DeInit, |
|
|
|
USBD_HID_Setup, |
|
|
|
|
|
|
|
NULL, /*EP0_TxSent*/ |
|
|
|
/* Control Endpoints*/ |
|
|
|
NULL, /*EP0_RxReady*/ |
|
|
|
.Setup = USBD_HID_Setup, |
|
|
|
USBD_HID_DataIn, /*DataIn*/ |
|
|
|
.EP0_TxSent = NULL, |
|
|
|
NULL, /*DataOut*/ |
|
|
|
.EP0_RxReady = NULL, |
|
|
|
NULL, /*SOF */ |
|
|
|
|
|
|
|
NULL, |
|
|
|
/* Class Specific Endpoints*/ |
|
|
|
NULL, |
|
|
|
.DataIn = USBD_HID_DataIn, |
|
|
|
USBD_HID_GetCfgDesc, |
|
|
|
.DataOut = NULL, |
|
|
|
USBD_HID_GetCfgDesc, |
|
|
|
.SOF = NULL, |
|
|
|
USBD_HID_GetCfgDesc, |
|
|
|
.IsoINIncomplete = NULL, // unused
|
|
|
|
USBD_HID_GetDeviceQualifierDesc, |
|
|
|
.IsoOUTIncomplete = NULL, // unused
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Descriptor getters */ |
|
|
|
|
|
|
|
.GetHSConfigDescriptor = USBD_HID_GetCfgDesc, |
|
|
|
|
|
|
|
.GetFSConfigDescriptor = USBD_HID_GetCfgDesc, |
|
|
|
|
|
|
|
.GetOtherSpeedConfigDescriptor = USBD_HID_GetCfgDesc, |
|
|
|
|
|
|
|
.GetDeviceQualifierDescriptor = USBD_HID_GetDeviceQualifierDesc, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/* USB HID device Configuration Descriptor */ |
|
|
|
/* USB HID device Configuration Descriptor */ |
|
|
@ -139,8 +145,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ |
|
|
|
{ |
|
|
|
{ |
|
|
|
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*/ |
|
|
@ -279,8 +284,7 @@ __ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] _ |
|
|
|
* @param cfgidx: Configuration index |
|
|
|
* @param cfgidx: Configuration index |
|
|
|
* @retval status |
|
|
|
* @retval status |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, |
|
|
|
static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) |
|
|
|
uint8_t cfgidx) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t ret = 0; |
|
|
|
uint8_t ret = 0; |
|
|
|
|
|
|
|
|
|
|
@ -308,8 +312,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, |
|
|
|
* @param cfgidx: Configuration index |
|
|
|
* @param cfgidx: Configuration index |
|
|
|
* @retval status |
|
|
|
* @retval status |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, |
|
|
|
static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx) |
|
|
|
uint8_t cfgidx) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
/* Close HID EPs */ |
|
|
|
/* Close HID EPs */ |
|
|
|
USBD_LL_CloseEP(pdev, |
|
|
|
USBD_LL_CloseEP(pdev, |
|
|
@ -331,8 +334,7 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, |
|
|
|
* @param req: usb requests |
|
|
|
* @param req: usb requests |
|
|
|
* @retval status |
|
|
|
* @retval status |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, |
|
|
|
static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) |
|
|
|
USBD_SetupReqTypedef *req) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
uint16_t len = 0; |
|
|
|
uint16_t len = 0; |
|
|
|
uint8_t *pbuf = NULL; |
|
|
|
uint8_t *pbuf = NULL; |
|
|
@ -408,9 +410,7 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, |
|
|
|
* @param buff: pointer to report |
|
|
|
* @param buff: pointer to report |
|
|
|
* @retval status |
|
|
|
* @retval status |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, |
|
|
|
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len) |
|
|
|
uint8_t *report, |
|
|
|
|
|
|
|
uint16_t len) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *) pdev->pClassData; |
|
|
|
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *) pdev->pClassData; |
|
|
|
|
|
|
|
|
|
|
@ -474,8 +474,7 @@ static uint8_t *USBD_HID_GetCfgDesc(uint16_t *length) |
|
|
|
* @param epnum: endpoint index |
|
|
|
* @param epnum: endpoint index |
|
|
|
* @retval status |
|
|
|
* @retval status |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, |
|
|
|
static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum) |
|
|
|
uint8_t epnum) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
/* Ensure that the FIFO is empty before a new transfer, this condition could
|
|
|
|
/* Ensure that the FIFO is empty before a new transfer, this condition could
|
|
|
|