Skip to content

Commit

Permalink
Check usb transmit status in send_extra() (qmk#14643)
Browse files Browse the repository at this point in the history
  • Loading branch information
daskygit committed Oct 23, 2021
1 parent 1e13d07 commit 1953a96
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tmk_core/protocol/chibios/usb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,17 @@ static void send_extra(uint8_t report_id, uint16_t data) {
return;
}

if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) {
/* Need to either suspend, or loop and call unlock/lock during
* every iteration - otherwise the system will remain locked,
* no interrupts served, so USB not going through as well.
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
osalSysUnlock();
return;
}
}

static report_extra_t report;
report = (report_extra_t){.report_id = report_id, .usage = data};

Expand Down

0 comments on commit 1953a96

Please sign in to comment.