cancel
Showing results for 
Search instead for 
Did you mean: 

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

Dvan .8
Associate II

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;
}

1 REPLY 1
Dvan .8
Associate II

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