MIMXRT1062/LLD/USBHSv1: Fix USB_USE_WAIT
support
#343
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The USBHSv1 LLD for MIMXRT1062 was checking
epc->in_cb
andepc->out_cb
to be non-NULL before calling_usb_isr_invoke_in_cb()
and_usb_isr_invoke_out_cb()
. This is not correct, because if theUSB_USE_WAIT
option is enabled, those ChibiOS macros do more than just invoking the callback - they also resume the thread that may be waiting for the transfer completion, and omitting the call results in that thread never getting resumed. The macros also perform the same pointer check internally before invoking the callback.Remove the unneeded checks to make the driver work properly with any APIs enabled by
USB_USE_WAIT
. Also remove the manipulation of(usbp)->receiving
and(usbp)->transmitting
, because the_usb_isr_invoke_in_cb()
and_usb_isr_invoke_out_cb()
macros handle that part too.This change is NOT tested yet (I don't have the corresponding hardware); maybe @jtojnar (the reporter of qmk/qmk_firmware#18805) could test whether it fixes their problem instead of using a workaround which puts a dummy function pointer into
in_cb
(qmk/qmk_firmware#18811).The error was uncovered by qmk/qmk_firmware#18631 — the cleanup part of that PR removed some
in_cb
callback functions that were doing nothing, and the resulting code worked fine on most supported chips (e.g, various STM32 and RP2040), but broke on Arm-based Teensy boards (#342 fixes the same problem in the KINETIS driver).Cc: @stapelberg