cores
cores copied to clipboard
Recommend renaming NUM_ENDPOINTS to LAST_ENDPOINT
Here is the relevant line that uses the #define:
https://github.com/PaulStoffregen/cores/blob/fcece8099baf1081f77d36628f2ac7de5fd70cf4/teensy4/usb.c#L65
The most common problem of NUM_ENDPOINTS is that one has to guess what EPs to include in the count. Should I include EP0 (yes), should I include EP1 (no)? An even more serious problem is if the user decides to skip some EPs and say only use EP3 (IN) and EP4 (OUT). They think they have 2 EPs and based on other definitions they set NUM_ENDPOINTS to 3 to include EP0. But they should have set it to 4 because the skipped EP2 although isn't initialized, MUST be allocated endpoint_t queue heads because how the rest of the code is written: using EP2 or EP2+1 to address the queue heads as if all EPs before the EP were present.
Three files use this #define, usb_desc.c, usb_desc_h, and usb.c