forked from stm/stm32-mw-usb-device
Release v2.11.4
This commit is contained in:
@@ -103,9 +103,16 @@ typedef enum
|
||||
typedef struct _USBD_CUSTOM_HID_Itf
|
||||
{
|
||||
uint8_t *pReport;
|
||||
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
|
||||
uint16_t wReportDescLen;
|
||||
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
|
||||
int8_t (* Init)(void);
|
||||
int8_t (* DeInit)(void);
|
||||
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||
int8_t (* OutEvent)(uint8_t *report_buffer);
|
||||
#else
|
||||
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
|
||||
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||
int8_t (* CtrlReqComplete)(uint8_t request, uint16_t wLength);
|
||||
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||
|
||||
@@ -284,6 +284,11 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
|
||||
pdev->ep_in[CUSTOMHIDInEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
if (USBD_CUSTOMHID_OUTREPORT_BUF_SIZE < CUSTOM_HID_EPOUT_SIZE)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
/* Open EP OUT */
|
||||
(void)USBD_LL_OpenEP(pdev, CUSTOMHIDOutEpAdd, USBD_EP_TYPE_INTR,
|
||||
CUSTOM_HID_EPOUT_SIZE);
|
||||
@@ -397,9 +402,17 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
||||
}
|
||||
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||
#ifndef USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED
|
||||
|
||||
if (req->wLength > USBD_CUSTOMHID_OUTREPORT_BUF_SIZE)
|
||||
{
|
||||
/* Stall EP0 */
|
||||
USBD_CtlError(pdev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
|
||||
hhid->IsReportAvailable = 1U;
|
||||
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf,
|
||||
MIN(req->wLength, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE));
|
||||
|
||||
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf, req->wLength);
|
||||
#endif /* USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
||||
break;
|
||||
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||
@@ -701,8 +714,13 @@ static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
|
||||
/* USB data will be immediately processed, this allow next USB traffic being
|
||||
NAKed till the end of the application processing */
|
||||
|
||||
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf);
|
||||
#else
|
||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
|
||||
hhid->Report_buf[1]);
|
||||
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
@@ -755,8 +773,12 @@ static uint8_t USBD_CUSTOM_HID_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
||||
|
||||
if (hhid->IsReportAvailable == 1U)
|
||||
{
|
||||
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf);
|
||||
#else
|
||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
|
||||
hhid->Report_buf[1]);
|
||||
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||
hhid->IsReportAvailable = 0U;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,11 @@ EndBSPDependencies */
|
||||
|
||||
static int8_t TEMPLATE_CUSTOM_HID_Init(void);
|
||||
static int8_t TEMPLATE_CUSTOM_HID_DeInit(void);
|
||||
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t *report_buffer);
|
||||
#else
|
||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state);
|
||||
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||
|
||||
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||
static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLength);
|
||||
@@ -49,6 +53,9 @@ __ALIGN_BEGIN static uint8_t TEMPLATE_CUSTOM_HID_ReportDesc[USBD_CUSTOM_HID_REPO
|
||||
USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_template_fops =
|
||||
{
|
||||
TEMPLATE_CUSTOM_HID_ReportDesc,
|
||||
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
|
||||
USBD_CUSTOM_HID_REPORT_DESC_SIZE,
|
||||
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
|
||||
TEMPLATE_CUSTOM_HID_Init,
|
||||
TEMPLATE_CUSTOM_HID_DeInit,
|
||||
TEMPLATE_CUSTOM_HID_OutEvent,
|
||||
@@ -95,10 +102,17 @@ static int8_t TEMPLATE_CUSTOM_HID_DeInit(void)
|
||||
* @param state: event state
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
|
||||
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t *report_buffer)
|
||||
{
|
||||
UNUSED(report_buffer);
|
||||
#else
|
||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state)
|
||||
{
|
||||
UNUSED(event_idx);
|
||||
UNUSED(state);
|
||||
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||
|
||||
/* Start next USB packet transfer once data processing is completed */
|
||||
if (USBD_CUSTOM_HID_ReceivePacket(&USBD_Device) != (uint8_t)USBD_OK)
|
||||
@@ -151,7 +165,7 @@ static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLen
|
||||
static uint8_t *TEMPLATE_CUSTOM_HID_GetReport(uint16_t *ReportLength)
|
||||
{
|
||||
UNUSED(ReportLength);
|
||||
uint8_t *pbuff;
|
||||
uint8_t *pbuff = NULL;
|
||||
|
||||
return (pbuff);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user