aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generic/usb_cdc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/generic/usb_cdc.c b/src/generic/usb_cdc.c
index 143c213f..961c6330 100644
--- a/src/generic/usb_cdc.c
+++ b/src/generic/usb_cdc.c
@@ -44,11 +44,13 @@ usb_bulk_in_task(void)
{
if (!sched_check_wake(&usb_bulk_in_wake))
return;
- uint_fast8_t tpos = transmit_pos;
+ uint_fast8_t tpos = transmit_pos, max_tpos = tpos;
if (!tpos)
return;
- uint_fast8_t max_tpos = (tpos > USB_CDC_EP_BULK_IN_SIZE
- ? USB_CDC_EP_BULK_IN_SIZE : tpos);
+ if (max_tpos > USB_CDC_EP_BULK_IN_SIZE)
+ max_tpos = USB_CDC_EP_BULK_IN_SIZE;
+ else if (max_tpos == USB_CDC_EP_BULK_IN_SIZE)
+ max_tpos = USB_CDC_EP_BULK_IN_SIZE-1; // Avoid zero-length-packets
int_fast8_t ret = usb_send_bulk_in(transmit_buf, max_tpos);
if (ret <= 0)
return;