From 874cacf143330bf156d44102faba83ade270029d Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Thu, 8 Sep 2011 16:23:29 -0400 Subject: misc. bootloader fixes: increased wait time after receiving avrdude 'Q', increased bootloader timeout, and fixed LED one-shot timing --- bootloaders/diskloader/src/DiskLoader.cpp | 5 +++-- bootloaders/diskloader/src/USBCore.cpp | 31 +++++++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'bootloaders/diskloader/src') diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp index 34a9c94..da57e75 100644 --- a/bootloaders/diskloader/src/DiskLoader.cpp +++ b/bootloaders/diskloader/src/DiskLoader.cpp @@ -210,7 +210,7 @@ int main() if (cmd == 'Q') break; } - _timeout = 1; // signal to exit the bootloader + _timeout = 1000; // wait a moment before exiting the bootloader - may need to finish responding to 'Q' for example _ejected = 1; } } @@ -232,7 +232,8 @@ void LEDPulse() void Reboot() { - /* TODO - ZE - this should probably be a WDT reset instead, right? */ + TXLED0; // switch off the RX and TX LEDs before starting the user sketch + RXLED0; UDCON = 1; // Detatch USB UDIEN = 0; asm volatile ( // Reset vector to run firmware diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp index 142fc79..1a8f2d0 100644 --- a/bootloaders/diskloader/src/USBCore.cpp +++ b/bootloaders/diskloader/src/USBCore.cpp @@ -29,6 +29,11 @@ #define EP_TYPE_ISOCHRONOUS_IN 0x41 #define EP_TYPE_ISOCHRONOUS_OUT 0x40 +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +#define TX_RX_LED_PULSE_MS 100 +u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ +u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + void Reboot(); //================================================================== @@ -85,6 +90,7 @@ static void Send(volatile const u8* data, u8 count) { TXLED1; // light the TX LED + TxLEDPulse = TX_RX_LED_PULSE_MS; while (count--) UEDATX = *data++; } @@ -92,6 +98,7 @@ void Send(volatile const u8* data, u8 count) void Recv(volatile u8* data, u8 count) { RXLED1; // light the RX LED + RxLEDPulse = TX_RX_LED_PULSE_MS; while (count--) *data++ = UEDATX; } @@ -99,12 +106,14 @@ void Recv(volatile u8* data, u8 count) static inline u8 Recv8() { RXLED1; // light the RX LED + RxLEDPulse = TX_RX_LED_PULSE_MS; return UEDATX; } static inline void Send8(u8 d) { TXLED1; // light the TX LED + TxLEDPulse = TX_RX_LED_PULSE_MS; UEDATX = d; } @@ -451,12 +460,17 @@ void USBGeneralInterrupt() { InitEP(0,EP_TYPE_CONTROL,EP_SINGLE_64); // init ep0 _usbConfiguration = 0; // not configured yet - //UEIENX = 1 << RXSTPE; } - // Start of Frame + // Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too if (udint & (1<