Skip to content

Send a ZLP if data size is multiple of the endpoint size for USB sends in SAM core #4172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions hardware/arduino/sam/cores/arduino/USB/USBCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ uint32_t USBD_Send(uint32_t ep, const void* d, uint32_t len)
{
uint32_t n;
int r = len;
uint32_t epSize = (ep==0) ? EP0_SIZE : EPX_SIZE;
const uint8_t* data = (const uint8_t*)d;

if (!_usbConfiguration)
Expand All @@ -205,15 +206,18 @@ uint32_t USBD_Send(uint32_t ep, const void* d, uint32_t len)

while (len)
{
if(ep==0) n = EP0_SIZE;
else n = EPX_SIZE;
n = epSize;
if (n > len)
n = len;
len -= n;

UDD_Send(ep & 0xF, data, n);
data += n;
}

if ((r != 0) && (r % epSize) == 0)
UDD_Send(ep & 0xF, NULL, 0);

//TXLED1; // light the TX LED
//TxLEDPulse = TX_RX_LED_PULSE_MS;
return r;
Expand Down