atsamd: USB methods disable interrupts for too long
I’m working on a SAMD21 based USB device, which does the USB work in the USB ISR, along the lines of the usb_echo example. The USB interrupt is set to a lower priority (higher number) than another interrupt which needs to be serviced fairly quickly, but sometimes that doesn’t happen quickly enough. The issue seems to be that UsbBus
’s methods do all their work in interrupt free contexts. For example, these.
Might it make sense for UsbBus
to have an “in use” flag in the mutex rather than the RefCell, so that the interrupts only need to be disabled for setting/checking that flag?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 20 (20 by maintainers)
dirbaio on Matrix suggested that the stm32-usbd doesn’t have this particular issue, perhaps it’s possible to make UsbBus and/or Inner not by Sync, so that the user either picks their own mutex or only accesses the USB from one particular context.
I think it was just to prevent us being interrupted by a different USB interrupt while servicing a USB interrupt. I don’t think there is anything wrong with being preempted by a higher priority interrupt as long as its not USB-related, but theres only one way to find out xD
Something like this maybe: