aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generic/usb_cdc.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/generic/usb_cdc.c b/src/generic/usb_cdc.c
index 96bd01c6..7f6b2f34 100644
--- a/src/generic/usb_cdc.c
+++ b/src/generic/usb_cdc.c
@@ -92,8 +92,19 @@ usb_bulk_out_task(void)
{
if (!sched_check_wake(&usb_bulk_out_wake))
return;
- // Process any existing message blocks
+ // Read data
uint_fast8_t rpos = receive_pos, pop_count;
+ if (rpos + USB_CDC_EP_BULK_OUT_SIZE <= sizeof(receive_buf)) {
+ int_fast8_t ret = usb_read_bulk_out(
+ &receive_buf[rpos], USB_CDC_EP_BULK_OUT_SIZE);
+ if (ret > 0) {
+ rpos += ret;
+ usb_notify_bulk_out();
+ }
+ } else {
+ usb_notify_bulk_out();
+ }
+ // Process a message block
int_fast8_t ret = command_find_and_dispatch(receive_buf, rpos, &pop_count);
if (ret) {
// Move buffer
@@ -104,14 +115,6 @@ usb_bulk_out_task(void)
}
rpos = needcopy;
}
- // Read more data
- if (rpos + USB_CDC_EP_BULK_OUT_SIZE <= sizeof(receive_buf)) {
- ret = usb_read_bulk_out(&receive_buf[rpos], USB_CDC_EP_BULK_OUT_SIZE);
- if (ret > 0) {
- rpos += ret;
- usb_notify_bulk_out();
- }
- }
receive_pos = rpos;
}
DECL_TASK(usb_bulk_out_task);