Skip to content
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
6 changes: 4 additions & 2 deletions hardware/arduino/sam/cores/arduino/USB/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#define CDC_LINESTATE_READY (CDC_LINESTATE_RTS | CDC_LINESTATE_DTR)

uint32_t lineStateChangeTime = 0;

struct ring_buffer
{
uint8_t buffer[CDC_SERIAL_BUFFER_SIZE];
Expand Down Expand Up @@ -128,6 +130,7 @@ bool WEAK CDC_Setup(Setup& setup)
if (CDC_SET_CONTROL_LINE_STATE == r)
{
_usbLineInfo.lineState = setup.wValueL;
lineStateChangeTime = millis();
// auto-reset into the bootloader is triggered when the port, already
// open at 1200 bps, is closed.
if (1200 == _usbLineInfo.dwDTERate)
Expand Down Expand Up @@ -290,12 +293,11 @@ Serial_::operator bool()

bool result = false;

if (_usbLineInfo.lineState > 0)
if (_usbLineInfo.lineState > 0 && ((millis() - lineStateChangeTime) >= 10))
{
result = true;
}

delay(10);
return result;
}

Expand Down