diff options
author | Zach Eveland <zeveland@blacklabel-development.com> | 2012-03-01 08:51:16 -0500 |
---|---|---|
committer | Zach Eveland <zeveland@blacklabel-development.com> | 2012-03-01 08:51:16 -0500 |
commit | c8ca7f96366d53b139ded479bcc690332eb8382d (patch) | |
tree | f163ba20621974a2c1756ee8a8093c9b4d8fd5d2 /cores/arduino | |
parent | 569b573d30ad4da2a903fe83d29e85e6b7dc9c8b (diff) |
changed auto-reset logic for Leonardo. only do WDT manipulation if the port is opened at 1200 bps. (Dave Mellis)
Diffstat (limited to 'cores/arduino')
-rw-r--r-- | cores/arduino/CDC.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index 6d3929e..94faf2e 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -106,21 +106,22 @@ bool WEAK CDC_Setup(Setup& setup) // open at 1200 bps, is closed. this is the signal to start the watchdog // with a relatively long period so it can finish housekeeping tasks // like servicing endpoints before the sketch ends - - // We check DTR state to determine if host port is open (bit 0 of lineState). - // Serial1.print(">"); Serial1.println(_usbLineInfo.lineState, HEX); - if ((_usbLineInfo.lineState & 0x01) == 0 && _usbLineInfo.dwDTERate == 1200) { - *(uint16_t *)0x0A00 = 0x7777; - wdt_enable(WDTO_250MS); - } else { - // Most OSs do some intermediate steps when configuring ports and DTR can - // twiggle more than once before stabilizing. - // To avoid spurious resets we set the watchdog to 250ms and eventually - // cancel if DTR goes back high. - - wdt_disable(); - wdt_reset(); - *(uint16_t *)0x0A00 = 0x0; + if (1200 == _usbLineInfo.dwDTERate) { + // We check DTR state to determine if host port is open (bit 0 of lineState). + // Serial1.print(">"); Serial1.println(_usbLineInfo.lineState, HEX); + if ((_usbLineInfo.lineState & 0x01) == 0) { + *(uint16_t *)0x0A00 = 0x7777; + wdt_enable(WDTO_250MS); + } else { + // Most OSs do some intermediate steps when configuring ports and DTR can + // twiggle more than once before stabilizing. + // To avoid spurious resets we set the watchdog to 250ms and eventually + // cancel if DTR goes back high. + + wdt_disable(); + wdt_reset(); + *(uint16_t *)0x0A00 = 0x0; + } } return true; } |