mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
parent
a707f0ba4d
commit
3c0f26d6a8
@ -273,7 +273,9 @@ int USB_Send(u8 ep, const void* d, int len)
|
|||||||
int r = len;
|
int r = len;
|
||||||
const u8* data = (const u8*)d;
|
const u8* data = (const u8*)d;
|
||||||
u8 timeout = 250; // 250ms timeout on send? TODO
|
u8 timeout = 250; // 250ms timeout on send? TODO
|
||||||
while (len)
|
bool sendZlp = false;
|
||||||
|
|
||||||
|
while (len || sendZlp)
|
||||||
{
|
{
|
||||||
u8 n = USB_SendSpace(ep);
|
u8 n = USB_SendSpace(ep);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
@ -284,13 +286,16 @@ int USB_Send(u8 ep, const void* d, int len)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > len)
|
if (n > len) {
|
||||||
n = len;
|
n = len;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
LockEP lock(ep);
|
LockEP lock(ep);
|
||||||
// Frame may have been released by the SOF interrupt handler
|
// Frame may have been released by the SOF interrupt handler
|
||||||
if (!ReadWriteAllowed())
|
if (!ReadWriteAllowed())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
len -= n;
|
len -= n;
|
||||||
if (ep & TRANSFER_ZERO)
|
if (ep & TRANSFER_ZERO)
|
||||||
{
|
{
|
||||||
@ -307,8 +312,17 @@ int USB_Send(u8 ep, const void* d, int len)
|
|||||||
while (n--)
|
while (n--)
|
||||||
Send8(*data++);
|
Send8(*data++);
|
||||||
}
|
}
|
||||||
if (!ReadWriteAllowed() || ((len == 0) && (ep & TRANSFER_RELEASE))) // Release full buffer
|
|
||||||
|
if (sendZlp) {
|
||||||
ReleaseTX();
|
ReleaseTX();
|
||||||
|
sendZlp = false;
|
||||||
|
} else if (!ReadWriteAllowed()) { // ...release if buffer is full...
|
||||||
|
ReleaseTX();
|
||||||
|
if (len == 0) sendZlp = true;
|
||||||
|
} else if ((len == 0) && (ep & TRANSFER_RELEASE)) { // ...or if forced with TRANSFER_RELEASE
|
||||||
|
// XXX: TRANSFER_RELEASE is never used can be removed?
|
||||||
|
ReleaseTX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TXLED1; // light the TX LED
|
TXLED1; // light the TX LED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user