aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/CDC.cpp
diff options
context:
space:
mode:
authorZach Eveland <zeveland@blacklabel-development.com>2012-02-13 00:56:06 -0500
committerZach Eveland <zeveland@blacklabel-development.com>2012-02-13 00:56:06 -0500
commit924e5a48465cf8a9ba3af38e6cf4c2e1a2c0733c (patch)
treee879b9041bf5e9bb37be75eb44d00b311d9d6d0c /cores/arduino/CDC.cpp
parentac3aca0acf45f459c2c55e8e0894621aaaa4b4dd (diff)
Leonardo auto-reset-and-upload changes for Windows (explanation below)
On Windows COM port changes when board switched between bootloader and sketch. No way to prevent this so now Windows users have to select the upload port separate from the comm port. Also, handling of reset into bootloader was broken on Windows. Would occasionally leave the original COM port completely unusable. Changed the way this reset is initiated. Finally, had to add upload.disable.flushing=true flag to boards.txt so IDE wouldn't try to flush the original COM port after it disappeared.
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r--cores/arduino/CDC.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index 6dd1cbe..deda5c0 100644
--- a/cores/arduino/CDC.cpp
+++ b/cores/arduino/CDC.cpp
@@ -23,20 +23,6 @@
#if defined(USBCON)
#ifdef CDC_ENABLED
-void Reboot()
-{
- USB.detach();
- cli();
-
- // Reset the microcontroller to run the bootloader
- wdt_enable(WDTO_15MS);
- for (;;);
-}
-
-// Define constants and variables for buffering incoming serial data. We're
-// using a ring buffer (I think), in which head is the index of the location
-// to which to write the next incoming character and tail is the index of the
-// location from which to read.
#if (RAMEND < 1000)
#define SERIAL_BUFFER_SIZE 16
#else
@@ -114,9 +100,14 @@ bool WEAK CDC_Setup(Setup& setup)
if (CDC_SET_CONTROL_LINE_STATE == r)
{
- if (0 != _usbLineInfo.lineState && 1200 == _usbLineInfo.dwDTERate) // auto-reset is triggered when the port, already open at 1200 bps, is closed
- Reboot();
_usbLineInfo.lineState = setup.wValueL;
+ // auto-reset into the bootloader is triggered when the port, already
+ // 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
+ if (0 != _usbLineInfo.lineState && 1200 == _usbLineInfo.dwDTERate) {
+ wdt_enable(WDTO_2S);
+ }
return true;
}
}