Skip to content

Commit

Permalink
correct blocking of usb report transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossless committed Dec 22, 2024
1 parent c234722 commit a569ef5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/platform/sh68f90a/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,26 @@ void usb_init()

void usb_send_report(report_keyboard_t *report)
{
uint8_t timeout = 0;
while (timeout < 255 && EP1CON & _IEP1RDY) {
delay_us(40);
timeout++;
}

set_ep1_in_buffer(report->raw, KEYBOARD_REPORT_SIZE);

SET_EP1_CNT(KEYBOARD_REPORT_SIZE);
SET_EP1_IN_RDY;

// TODO: this function should be blocking until transaction is finished, instead of a delay
delay_ms(10);
}

void usb_send_extra(report_extra_t *report)
{
uint8_t timeout = 0;
while (timeout < 255 && EP2CON & _IEP2RDY) {
delay_us(40);
timeout++;
}

set_ep2_in_buffer((uint8_t *)report, sizeof(report_extra_t));

SET_EP2_CNT(sizeof(report_extra_t));
Expand Down

0 comments on commit a569ef5

Please sign in to comment.