From ca616c865acb59c6f6311952787f242831ced02f Mon Sep 17 00:00:00 2001 From: Chris Liang Date: Tue, 5 Dec 2023 19:31:17 +0800 Subject: [PATCH] Move "send ZLP write start" after last alignment packet sent --- drivers/usb/source/USBCDC.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/usb/source/USBCDC.cpp b/drivers/usb/source/USBCDC.cpp index b32730388b3..3b0f8021f34 100644 --- a/drivers/usb/source/USBCDC.cpp +++ b/drivers/usb/source/USBCDC.cpp @@ -391,6 +391,7 @@ void USBCDC::send_nb(uint8_t *buffer, uint32_t size, uint32_t *actual, bool now) if ((CDC_MAX_PACKET_SIZE == size) && (CDC_MAX_PACKET_SIZE == write_size)) { _trans_zlp = true; } + if (now) { _send_isr_start(); } @@ -407,11 +408,6 @@ void USBCDC::_send_isr_start() if (USBDevice::write_start(_bulk_in, _tx_buffer, _tx_size)) { _tx_in_progress = true; } - } else if (!_tx_in_progress && _trans_zlp) { - if (USBDevice::write_start(_bulk_in, _tx_buffer, 0)) { - _tx_in_progress = true; - _trans_zlp = false; - } } } @@ -423,6 +419,11 @@ void USBCDC::_send_isr() { assert_locked(); + /* Send ZLP write start after last alignment packet sent */ + if (_trans_zlp && USBDevice::write_start(_bulk_in, _tx_buffer, 0)) { + _trans_zlp = false; + } + write_finish(_bulk_in); _tx_buf = _tx_buffer; _tx_size = 0;