aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/CDC.cpp
diff options
context:
space:
mode:
authorZach Eveland <zeveland@blacklabel-development.com>2012-02-14 12:17:30 -0500
committerZach Eveland <zeveland@blacklabel-development.com>2012-02-14 12:17:30 -0500
commit79481252081da0bdc4501cf039c060efcdf85c95 (patch)
treead6915f694dbfdcab4196da2ca3b98bbcc0f4365 /cores/arduino/CDC.cpp
parent19c44dd5fd671823610f6b6277874c956cced90e (diff)
Leonardo now checks whether bootloader should be run after a WDT event.
Before the sketch initiates an auto-reset for upload it pokes a magic word into a specific RAM address. On starting the bootloader checks this address. If it finds the magic word it knows the bootloader code should run. If not it jumps straight back to sketch. Test in a sketch by adding to setup(): wdt_enable(WDTO_2S); Sketch should upload, start, run for two seconds, WDT, and sketch should restart (not bootloader). Had to cut out unused descriptor code to make the bootloader still fit in 4k.
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r--cores/arduino/CDC.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index deda5c0..0fa06bc 100644
--- a/cores/arduino/CDC.cpp
+++ b/cores/arduino/CDC.cpp
@@ -105,7 +105,8 @@ 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
- if (0 != _usbLineInfo.lineState && 1200 == _usbLineInfo.dwDTERate) {
+ if (0 != _usbLineInfo.lineState && 1200 == _usbLineInfo.dwDTERate) {
+ *(uint16_t *)0x0A00 = 0x7777;
wdt_enable(WDTO_2S);
}
return true;