Skip to content

Commit ca616c8

Browse files
authored
Move "send ZLP write start" after last alignment packet sent
1 parent e2aed18 commit ca616c8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/usb/source/USBCDC.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ void USBCDC::send_nb(uint8_t *buffer, uint32_t size, uint32_t *actual, bool now)
391391
if ((CDC_MAX_PACKET_SIZE == size) && (CDC_MAX_PACKET_SIZE == write_size)) {
392392
_trans_zlp = true;
393393
}
394+
394395
if (now) {
395396
_send_isr_start();
396397
}
@@ -407,11 +408,6 @@ void USBCDC::_send_isr_start()
407408
if (USBDevice::write_start(_bulk_in, _tx_buffer, _tx_size)) {
408409
_tx_in_progress = true;
409410
}
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-
}
415411
}
416412
}
417413

@@ -423,6 +419,11 @@ void USBCDC::_send_isr()
423419
{
424420
assert_locked();
425421

422+
/* Send ZLP write start after last alignment packet sent */
423+
if (_trans_zlp && USBDevice::write_start(_bulk_in, _tx_buffer, 0)) {
424+
_trans_zlp = false;
425+
}
426+
426427
write_finish(_bulk_in);
427428
_tx_buf = _tx_buffer;
428429
_tx_size = 0;

0 commit comments

Comments
 (0)