diff options
author | Cristian Maglie <c.maglie@bug.st> | 2014-09-01 12:16:41 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2014-09-01 12:16:41 +0200 |
commit | 1d0f3510f68d2a4edcdadc31ecd5883b5dc3a4a1 (patch) | |
tree | e1660603f66a5bc61dd3d8d2782a803dfa3e63e3 /cores/arduino/CDC.cpp | |
parent | 5d87f9e8e2ee8e0a2028aec93dfe6951bd1c0c45 (diff) |
Fix for upload problems on Arduino Leonardo (and derivatives) with OSX 10.9.4
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r-- | cores/arduino/CDC.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index bf3d076..7e32d04 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -80,35 +80,39 @@ bool WEAK CDC_Setup(Setup& setup) if (CDC_SET_LINE_CODING == r) { USB_RecvControl((void*)&_usbLineInfo,7); - return true; } if (CDC_SET_CONTROL_LINE_STATE == r) { _usbLineInfo.lineState = setup.wValueL; + } + if (CDC_SET_LINE_CODING == r || CDC_SET_CONTROL_LINE_STATE == r) + { // 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 (1200 == _usbLineInfo.dwDTERate) { - // We check DTR state to determine if host port is open (bit 0 of lineState). - if ((_usbLineInfo.lineState & 0x01) == 0) { - *(uint16_t *)0x0800 = 0x7777; - wdt_enable(WDTO_120MS); - } 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 *)0x0800 = 0x0; - } + + // We check DTR state to determine if host port is open (bit 0 of lineState). + if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0) + { + *(uint16_t *)0x0800 = 0x7777; + wdt_enable(WDTO_120MS); + } + 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 *)0x0800 = 0x0; } - return true; } + return true; } return false; } |