Skip to content
Open
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
12 changes: 11 additions & 1 deletion hardware/arduino/avr/cores/arduino/USBCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ static inline u8 FifoFree()
return UEINTX & (1<<FIFOCON);
}

static inline u8 HasOUT()
{
return UEINTX & (1<<RXOUTI);
}

static inline void ReleaseRX()
{
UEINTX = 0x6B; // FIFOCON=0 NAKINI=1 RWAL=1 NAKOUTI=0 RXSTPI=1 RXOUTI=0 STALLEDI=1 TXINI=1
Expand Down Expand Up @@ -214,7 +219,12 @@ class LockEP
u8 USB_Available(u8 ep)
{
LockEP lock(ep);
return FifoByteCount();
u8 n = FifoByteCount();

if (!n && HasOUT())
ReleaseRX(); // handle ZLP

return n;
}

// Non Blocking receive
Expand Down