Skip to main content
Visitor II
May 5, 2023
Question

I'm trying to use CUSTOM_HID_SendReport but pdev->pClassDataCmsit[pdev->classId] is always NULL

  • May 5, 2023
  • 1 reply
  • 891 views

I'm trying to implement a custom hid on STM32F4. I'm able to init USB and enumerate the device. but when i try to use the CUSTOM_HID_SendReport It always exits on the ClassId check.

uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len) {
 USBD_CUSTOM_HID_HandleTypeDef *hhid;
 
 if (pdev->pClassDataCmsit[pdev->classId] == NULL) {
 return (uint8_t)USBD_FAIL;
 }
 
 #ifdef USE_USBD_COMPOSITE
 /* Get Endpoint IN address allocated for this class instance */
 CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
 #endif
 
 hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
 
 if (pdev->dev_state == USBD_STATE_CONFIGURED) {
 if (hhid->state == CUSTOM_HID_IDLE) {
 hhid->state = CUSTOM_HID_BUSY;
 (void)USBD_LL_Transmit(pdev, CUSTOMHIDInEpAdd, report, len);
 }
 else {
 return (uint8_t)USBD_BUSY;
 }
 }
 return (uint8_t)USBD_OK;
}

    This topic has been closed for replies.

    1 reply

    Dvan .8Author
    Visitor II
    May 5, 2023

    I regenerated the code and copied it over to my platformio project again and now this problem is gone.