KINETIS/LLD/USBHSv1: Fix USB_USE_WAIT
support
#342
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 KINETIS 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
.Tested on Teensy 3.2 (MK20DX256) in QMK. 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); however, on Teensy 3.2 that change resulted in a lockup immediately after sending a single keyboard event, because the main thread waiting for the USB transfer completion was not getting resumed when thein_cb
pointer was NULL.