diff options
| -rw-r--r-- | boards.txt | 3 | ||||
| -rw-r--r-- | cores/arduino/CDC.cpp | 23 | 
2 files changed, 9 insertions, 17 deletions
| @@ -149,7 +149,8 @@ mega.build.variant=mega  leonardo.name=Arduino Leonardo  leonardo.upload.protocol=avr109  leonardo.upload.maximum_size=28672 -leonardo.upload.speed=1200 +leonardo.upload.speed=57600 +leonardo.upload.disable_flushing=true  leonardo.bootloader.low_fuses=0xde  leonardo.bootloader.high_fuses=0xd8  leonardo.bootloader.extended_fuses=0xcb 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;  		}  	} | 
