buserror / simavr

simavr is a lean, mean and hackable AVR simulator for linux & OSX
GNU General Public License v3.0
1.56k stars 365 forks source link

Incorrect maximum number of USB endpoints #467

Open vintagepc opened 2 years ago

vintagepc commented 2 years ago

The AVR USB code hard-caps the number of endpoints at 5.

https://github.com/buserror/simavr/blob/ea4c4504d15117223a23e2dd6edb745fea61ceae/simavr/sim/avr_usb.c#L151

https://github.com/buserror/simavr/blob/ea4c4504d15117223a23e2dd6edb745fea61ceae/simavr/sim/avr_usb.c#L156

This is as expected for the AT90 example part but is too small for parts like the 32u4 which have USB defined and up to 7 configurable endpoints.

leptun commented 2 years ago

Also, is ENDPOINT_EPNUM_MASK correct? Right now it is 0x0F, but the AVR MCUs that support USB only ever use 3 bits, not 4. This could potentially result in writing a reserved bit in UENUM.