Skip to content

Commit

Permalink
Move "send ZLP write start" after last alignment packet sent
Browse files Browse the repository at this point in the history
  • Loading branch information
cyliangtw authored Dec 5, 2023
1 parent e2aed18 commit ca616c8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/usb/source/USBCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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;
}
}
}

Expand All @@ -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;
Expand Down

0 comments on commit ca616c8

Please sign in to comment.