Skip to content

Commit 0a35327

Browse files
ThomasKuehnepfeerick
authored andcommitted
chore(radio) catchup remaining Class/HID
1 parent 6b32fd3 commit 0a35327

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

radio/src/targets/common/arm/stm32/usbd_hid_joystick.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
312312
(void)USBD_LL_OpenEP(pdev, HIDInEpAdd, USBD_EP_TYPE_INTR, hid_in_pkt_size);
313313
pdev->ep_in[HIDInEpAdd & 0xFU].is_used = 1U;
314314

315-
hhid->state = HID_IDLE;
315+
hhid->state = USBD_HID_IDLE;
316316

317317
return (uint8_t)USBD_OK;
318318
}
@@ -373,19 +373,19 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
373373
case USB_REQ_TYPE_CLASS :
374374
switch (req->bRequest)
375375
{
376-
case HID_REQ_SET_PROTOCOL:
376+
case USBD_HID_REQ_SET_PROTOCOL:
377377
hhid->Protocol = (uint8_t)(req->wValue);
378378
break;
379379

380-
case HID_REQ_GET_PROTOCOL:
380+
case USBD_HID_REQ_GET_PROTOCOL:
381381
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->Protocol, 1U);
382382
break;
383383

384-
case HID_REQ_SET_IDLE:
384+
case USBD_HID_REQ_SET_IDLE:
385385
hhid->IdleState = (uint8_t)(req->wValue >> 8);
386386
break;
387387

388-
case HID_REQ_GET_IDLE:
388+
case USBD_HID_REQ_GET_IDLE:
389389
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->IdleState, 1U);
390390
break;
391391

@@ -507,9 +507,9 @@ uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t
507507

508508
if (pdev->dev_state == USBD_STATE_CONFIGURED)
509509
{
510-
if (hhid->state == HID_IDLE)
510+
if (hhid->state == USBD_HID_IDLE)
511511
{
512-
hhid->state = HID_BUSY;
512+
hhid->state = USBD_HID_BUSY;
513513
(void)USBD_LL_Transmit(pdev, HIDInEpAdd, report, len);
514514
} else {
515515
return (uint8_t)USBD_BUSY;
@@ -625,7 +625,7 @@ static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
625625
UNUSED(epnum);
626626
/* Ensure that the FIFO is empty before a new transfer, this condition could
627627
be caused by a new transfer before the end of the previous transfer */
628-
((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = HID_IDLE;
628+
((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = USBD_HID_IDLE;
629629

630630
return (uint8_t)USBD_OK;
631631
}

radio/src/thirdparty/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h

+14-10
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ extern "C" {
6060
#define HID_FS_BINTERVAL 0x0AU
6161
#endif /* HID_FS_BINTERVAL */
6262

63-
#define HID_REQ_SET_PROTOCOL 0x0BU
64-
#define HID_REQ_GET_PROTOCOL 0x03U
63+
#define USBD_HID_REQ_SET_PROTOCOL 0x0BU
64+
#define USBD_HID_REQ_GET_PROTOCOL 0x03U
6565

66-
#define HID_REQ_SET_IDLE 0x0AU
67-
#define HID_REQ_GET_IDLE 0x02U
66+
#define USBD_HID_REQ_SET_IDLE 0x0AU
67+
#define USBD_HID_REQ_GET_IDLE 0x02U
6868

69-
#define HID_REQ_SET_REPORT 0x09U
70-
#define HID_REQ_GET_REPORT 0x01U
69+
#define USBD_HID_REQ_SET_REPORT 0x09U
70+
#define USBD_HID_REQ_GET_REPORT 0x01U
7171
/**
7272
* @}
7373
*/
@@ -78,17 +78,17 @@ extern "C" {
7878
*/
7979
typedef enum
8080
{
81-
HID_IDLE = 0,
82-
HID_BUSY,
83-
} HID_StateTypeDef;
81+
USBD_HID_IDLE = 0,
82+
USBD_HID_BUSY,
83+
} USBD_HID_StateTypeDef;
8484

8585

8686
typedef struct
8787
{
8888
uint32_t Protocol;
8989
uint32_t IdleState;
9090
uint32_t AltSetting;
91-
HID_StateTypeDef state;
91+
USBD_HID_StateTypeDef state;
9292
} USBD_HID_HandleTypeDef;
9393

9494
/*
@@ -134,7 +134,11 @@ extern USBD_ClassTypeDef USBD_HID;
134134
/** @defgroup USB_CORE_Exported_Functions
135135
* @{
136136
*/
137+
#ifdef USE_USBD_COMPOSITE
138+
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len, uint8_t ClassId);
139+
#else
137140
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len);
141+
#endif /* USE_USBD_COMPOSITE */
138142
uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev);
139143

140144
/**

radio/src/thirdparty/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c

+19-11
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
295295

296296
#ifdef USE_USBD_COMPOSITE
297297
/* Get the Endpoints addresses allocated for this class instance */
298-
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
298+
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
299299
#endif /* USE_USBD_COMPOSITE */
300300

301301
if (pdev->dev_speed == USBD_SPEED_HIGH)
@@ -311,7 +311,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
311311
(void)USBD_LL_OpenEP(pdev, HIDInEpAdd, USBD_EP_TYPE_INTR, HID_EPIN_SIZE);
312312
pdev->ep_in[HIDInEpAdd & 0xFU].is_used = 1U;
313313

314-
hhid->state = HID_IDLE;
314+
hhid->state = USBD_HID_IDLE;
315315

316316
return (uint8_t)USBD_OK;
317317
}
@@ -329,7 +329,7 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
329329

330330
#ifdef USE_USBD_COMPOSITE
331331
/* Get the Endpoints addresses allocated for this class instance */
332-
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
332+
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
333333
#endif /* USE_USBD_COMPOSITE */
334334

335335
/* Close HID EPs */
@@ -372,19 +372,19 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
372372
case USB_REQ_TYPE_CLASS :
373373
switch (req->bRequest)
374374
{
375-
case HID_REQ_SET_PROTOCOL:
375+
case USBD_HID_REQ_SET_PROTOCOL:
376376
hhid->Protocol = (uint8_t)(req->wValue);
377377
break;
378378

379-
case HID_REQ_GET_PROTOCOL:
379+
case USBD_HID_REQ_GET_PROTOCOL:
380380
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->Protocol, 1U);
381381
break;
382382

383-
case HID_REQ_SET_IDLE:
383+
case USBD_HID_REQ_SET_IDLE:
384384
hhid->IdleState = (uint8_t)(req->wValue >> 8);
385385
break;
386386

387-
case HID_REQ_GET_IDLE:
387+
case USBD_HID_REQ_GET_IDLE:
388388
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->IdleState, 1U);
389389
break;
390390

@@ -472,16 +472,24 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
472472
return (uint8_t)ret;
473473
}
474474

475+
475476
/**
476477
* @brief USBD_HID_SendReport
477478
* Send HID Report
478479
* @param pdev: device instance
479480
* @param buff: pointer to report
481+
* @param ClassId: The Class ID
480482
* @retval status
481483
*/
484+
#ifdef USE_USBD_COMPOSITE
485+
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len, uint8_t ClassId)
486+
{
487+
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
488+
#else
482489
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len)
483490
{
484491
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
492+
#endif /* USE_USBD_COMPOSITE */
485493

486494
if (hhid == NULL)
487495
{
@@ -490,14 +498,14 @@ uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t
490498

491499
#ifdef USE_USBD_COMPOSITE
492500
/* Get the Endpoints addresses allocated for this class instance */
493-
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
501+
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, ClassId);
494502
#endif /* USE_USBD_COMPOSITE */
495503

496504
if (pdev->dev_state == USBD_STATE_CONFIGURED)
497505
{
498-
if (hhid->state == HID_IDLE)
506+
if (hhid->state == USBD_HID_IDLE)
499507
{
500-
hhid->state = HID_BUSY;
508+
hhid->state = USBD_HID_BUSY;
501509
(void)USBD_LL_Transmit(pdev, HIDInEpAdd, report, len);
502510
}
503511
}
@@ -607,7 +615,7 @@ static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
607615
UNUSED(epnum);
608616
/* Ensure that the FIFO is empty before a new transfer, this condition could
609617
be caused by a new transfer before the end of the previous transfer */
610-
((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = HID_IDLE;
618+
((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = USBD_HID_IDLE;
611619

612620
return (uint8_t)USBD_OK;
613621
}

0 commit comments

Comments
 (0)