Once in a while the device would just stop responding to host requests (I was using CDC at the time).
Poking around I found that the K50 was sending a STALL response to the host DATA_IN packet (which typ indicates an error), and everything just stops.
Reading through the K50 datasheet there's a note that caught my eye:
Code: Select all
The firmware should not set the UOWN bit in the same instruction cycles as any other
modifications to the BDnSTAT soft register. The UOWN bit should only be set
in a separate instruction cycle, only after all other bits in BDnSTAT (and
address/count registers) have been fully updated.
The SF USB code is based on an old version of the MLA stack and doesn't follow the note's recommendations.
Looking at newer versions of the stack C code I see they've changed it to meet the above (quite a while ago, actually).
I made that change and bingo, things started working like normal.
I don't know if this is something that only affects some devices, but the change is included for all of them...
maybe it's just not in the older datasheets.
Anyway, here's a modified USBSystem.bas file that incorporates the change. It's just knocked together, but it changes both HID and CDC to follow the recommendation above.