summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/chibios/usb_driver.c
AgeCommit message (Collapse)Author
2022-05-14Check for ongoing transfers on the OUT endpoint (#16974)Stefan Kerkmann
...when attempting to start a receiving USB transfer. Previously, we would check on the IN endpoint which is the transmitting part of the USB endpoint. This is wrong and lead to two USB transfers being started immediately after each other in case of e.g. RAW HID endpoints: 1. When finishing an OUT transfer the low level USB driver calls the out_cb callback, which in turn initiates another OUT transfer by calling qmkusbDataReceived. 2. When the raw hid receive channel runs empty inside the raw_hid task, another OUT transfer is started to potentially fill the channel again. This happens by calling ibnotify. Both events occur directly after each other, thus triggering the bug.
2022-02-12Format code according to conventions (#16322)QMK Bot
2021-04-25Fix how USB queue overflow is handled in chibios. (#12576)Purdea Andrei
* Fix how USB queue overflow is handled in chibios. This commit reverts PR 12472 (commit c823fe2d3f23ed090e36ce39beed4c448298bd2f), and it implements the original intent of the commit in a better way. The original intent of the above mentioned commit was to not deadlock the keyboard when console is enabled, and hid_listen is not started. The above mentioned commit had a few drawbacks: 1) When a lot of data was printed to the console, the queue would get full, and drop data, even if hid_listen was running. (For example having matrix debug enabled just didn't work right at all) 2) I believe the function in which this was implemented is used by all other USB endpoints, so with the above change, overflow, and data loss could happen in other important functions of QMK as well. This commit implements deadlock prevention in a slightly similar way to how it's done on AVR. There is an additional static local variable, that memorizes whether the console has timeouted before. If we are in the timeouted=false state, then we send the character normally with a 5ms timeout. If it does time out, then hid_listen is likely not running, and future characters should not be sent with a timeout, but those characters should still be sent if there is space in the queue. The difference between the AVR implementation and this one is that the AVR implementation checks the queue state directly, but this implementation instead attempts to write the character with a zero timeout. If it fails, then we remain in the timeouted=true state, if it succeeds, then hid_listen started removing data from the queue, so we can go out of the timeouted=true state. * Added comment explaining the timeouted logic to console flow control. * Console flow control: refactor chibios flowcontrol code to make it more readable, and rename the timeouted variable to timed_out on both chibios and lufa. Changed comments to says timed_out is an approximation of listener_disconnected, to make it clear that it's not the same thing * fix typo
2021-04-10Format code according to conventions (#12540)github-actions[bot]
Co-authored-by: QMK Bot <hello@qmk.fm>
2021-04-10ChibiOS USB driver: prevent deadlock with CONSOLE_ENABLE = yes (#12472)Michael Stapelberg
Before this commit, attaching an ARM-based (i.e. ChibiOS-based) keyboard that uses CONSOLE_ENABLE = yes and produces debug messages would deadlock the keyboard unless one was running hid_listen. With this commit, dead-locking writes to the queue are detected and prevented. fixes #5631
2020-12-11Normalise include statements in core code (#11153)Ryan
* Normalise include statements in core code * Missed one
2020-02-292020 February 29 Breaking Changes Update (#8064)James Young
2019-08-30clang-format changesskullY
2018-04-15Add a custom USB driver for ARM (#2750)fredizzimo
* Copy Chibios serial_usb_driver into the chibios/protocol It's renamed to usb_driver to avoid name conflicts * Make the usb driver compile * Disable ChibiOS serial usb driver for all keyboards * Change usb_main to use QMKUSBDriver * Initialize the usb driver buffers * Add support for fixed size queues * Fix USB driver initialization * Don't transfer an empty packet for fixed size streams