AnsweredAssumed Answered

STM32F40X: Problem getting CUSTOMHID work on endpoint other than 1

Question asked by Kok.Henk on Feb 4, 2016
Latest reply on Feb 8, 2016 by Kok.Henk
I am in the process of making a USB device that is both a mass storage device (with SD card on SDIO) and a custom HID device. Eventually it will run on an STM32F405RGTx, but for now we're running it on an STM32F4DISCOVERY board (so a 407, should not matter that much).

I have already come a long way. The MSC device works flawlessly, albeit slow (but what do you expect on FS? :) ) and I have managed to integrate a custom HID into it. I did this by making my own instance of a USBD_ClassTypeDef and distribute the function calls to either USBD_MSC or USBD_CUSTOM_HID where appropriate.

The thing that does NOT work yet, is the IN transfers from the HID device (receiving OUT works). The debugger tells me that when I try to send a report, the PDC ISR is constantly called. Apparently the reason for the IRQ is not lifted.

To be able to investigate, I also took the CUSTOM HID part in isolation, which worked,.... until I changed the endpoints to 0x82/0x02 or basically any other value than 0x81/0x01. In the composite device, the MSC has endpoints 0x81/0x01 and the CUSTOM HID has 0x82/0x02, so there is the difference that apparently broke the functioning of CUSTOM HID.

Now, I have seen quite a number of projects with multiple endpoints on this site, so apparently I missed something. Perhaps just changing the defines for the endpoint numbers is not enough, and the endpoint number is defined somewhere else as well, for instance.

Another thing that struck me was the bit assignment in the OTG_FS_DAINT register: bit16=ep0, bit18=ep3, where I would expect bit16-31 = ep0-15, but apparently not. This discrepancy only exists for OUT endpoints, so it seems irrelevant, but I still find it strange.

Does this problem make sense to anyone? :)