2020-04-10 03:13 AM
Firmware package v1.25.0 introduced new define for USB stack called USE_USB_FS. This isn't generated anywhere even when USB speed in CubeMX is set to "Device Full Speed 12MBit/s". Previously, the following defines have been used (and they still are!):
DEVICE_FS=0
DEVICE_HS=1
So you could pass to USBD_Init as last argument either DEVICE_FS (0) or DEVICE_HS (1) which worked fine. However, USBD_RegisterClass now has the following code block:
#ifdef USE_USB_FS
pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len);
#else /* USE_USB_HS */
pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len);
#endif /* USE_USB_FS */
Since I define my own ConfigDescriptors, I've set HS descriptor to NULL. Now, guess what happens since USE_USB_FS isn't defined anywhere? The program crashes - null pointer is accessed obviously.
Solution: If "Device Full Speed 12MBit/s" is checked in CubeMX, CubeMX should add USE_USB_FS to the list of defines.
2020-07-02 08:59 PM
Hi. I have the same problem with custom MIDI class. I tried adding the #define manually in several places and it didn't work. Could you make it run?
2020-10-30 03:36 AM
Hello, I have the same problem with custom HID class. And #define doesn't work but if I comment #ifdef USE_USB_FS and keep only pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len); for example in my case It seems to be work.
2020-10-30 05:23 AM
You need to add USE_USB_FS Define symbols in your project.