Skip to content

Commit 1cccc7e

Browse files
authored
Update USBCDC.cpp to support ZLP
1 parent 794ee97 commit 1cccc7e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/usb/source/USBCDC.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ void USBCDC::_init()
186186
_rx_in_progress = false;
187187
_rx_buf = _rx_buffer;
188188
_rx_size = 0;
189+
_trans_zlp = false;
189190
}
190191

191192
void USBCDC::callback_reset()
@@ -387,6 +388,9 @@ void USBCDC::send_nb(uint8_t *buffer, uint32_t size, uint32_t *actual, bool now)
387388
}
388389
_tx_size += write_size;
389390
*actual = write_size;
391+
if((CDC_MAX_PACKET_SIZE == size) && (CDC_MAX_PACKET_SIZE == write_size)) {
392+
_trans_zlp = true;
393+
}
390394
if (now) {
391395
_send_isr_start();
392396
}
@@ -403,6 +407,11 @@ void USBCDC::_send_isr_start()
403407
if (USBDevice::write_start(_bulk_in, _tx_buffer, _tx_size)) {
404408
_tx_in_progress = true;
405409
}
410+
} else if(!_tx_in_progress && _trans_zlp) {
411+
if (USBDevice::write_start(_bulk_in, _tx_buffer, 0)) {
412+
_tx_in_progress = true;
413+
_trans_zlp = false;
414+
}
406415
}
407416
}
408417

0 commit comments

Comments
 (0)