diff options
author | Zach Eveland <zeveland@blacklabel-development.com> | 2012-03-08 14:20:12 -0500 |
---|---|---|
committer | Zach Eveland <zeveland@blacklabel-development.com> | 2012-03-08 14:20:12 -0500 |
commit | 75da79ad7602d1a73e46155a5630f41d91f9bd83 (patch) | |
tree | d84ec7bc47cb72016f1f21a5a0acbd476c93c9d1 /bootloaders/caterina/Caterina.c | |
parent | 53e51de832189a30a2a6e9fae77d0f58a3616ccc (diff) |
give Leonardo bootloader 250 ms to finish housekeeping before leaving self-programming mode
Earlier approach had bootloader end as soon as it was told to. On Linux this caused problems with avrdude because the microcontroller never had a chance to send an acknowledgement.
Diffstat (limited to 'bootloaders/caterina/Caterina.c')
-rwxr-xr-x | bootloaders/caterina/Caterina.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bootloaders/caterina/Caterina.c b/bootloaders/caterina/Caterina.c index c8e82a9..2b50636 100755 --- a/bootloaders/caterina/Caterina.c +++ b/bootloaders/caterina/Caterina.c @@ -62,6 +62,7 @@ uint16_t TxLEDPulse = 0; // time remaining for Tx LED pulse uint16_t RxLEDPulse = 0; // time remaining for Rx LED pulse
/* Bootloader timeout timer */
+#define TIMEOUT_PERIOD 8000
uint16_t Timeout = 0;
uint16_t bootKey = 0x7777;
@@ -133,12 +134,14 @@ int main(void) /* Enable global interrupts so that the USB stack can function */
sei();
+ Timeout = 0;
+
while (RunBootloader)
{
CDC_Task();
USB_USBTask();
/* Time out and start the sketch if one is present */
- if (Timeout > 8000)
+ if (Timeout > TIMEOUT_PERIOD)
RunBootloader = false;
LEDPulse();
@@ -475,7 +478,11 @@ void CDC_Task(void) if (Command == 'E')
{
- RunBootloader = false;
+ /* We nearly run out the bootloader timeout clock,
+ * leaving just a few hundred milliseconds so the
+ * bootloder has time to respond and service any
+ * subsequent requests */
+ Timeout = TIMEOUT_PERIOD - 250;
// Send confirmation byte back to the host
WriteNextResponseByte('\r');
|