From b8a2daf8bcda528be820eb0b76e6b15961cd71c0 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Sun, 14 Aug 2011 16:02:16 -0400 Subject: LEDs for D13, TX, and RX are more in line with Uno-like behavior during sketch uploading. D13 flashes on reboot, TX and RX flash with USB data transfer. --- bootloaders/diskloader/src/DiskLoader.cpp | 4 ++++ bootloaders/diskloader/src/Platform.h | 8 ++++---- bootloaders/diskloader/src/USBCore.cpp | 13 +++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'bootloaders/diskloader/src') diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp index 3cb5caa..bc1e026 100644 --- a/bootloaders/diskloader/src/DiskLoader.cpp +++ b/bootloaders/diskloader/src/DiskLoader.cpp @@ -119,6 +119,9 @@ int main(void) __attribute__ ((naked)); // STK500v1 main loop, very similar to optiboot in protocol and implementation int main() { + TXLED0; + RXLED0; + LED0; BOARD_INIT(); USBInit(); @@ -236,6 +239,7 @@ void LEDPulse() void Reboot() { + /* TODO - ZE - this should probably be a WDT reset instead, right? */ UDCON = 1; // Detatch USB UDIEN = 0; asm volatile ( // Reset vector to run firmware diff --git a/bootloaders/diskloader/src/Platform.h b/bootloaders/diskloader/src/Platform.h index 3f55c68..004933e 100644 --- a/bootloaders/diskloader/src/Platform.h +++ b/bootloaders/diskloader/src/Platform.h @@ -33,10 +33,10 @@ typedef unsigned long u32; #define BOARD_INIT() DDRC |= (1<<7); DDRB |= (1<<0); DDRE |= (1<<6); CPU_PRESCALE(0); DISABLE_JTAG(); #define LED0 PORTC &= ~(1<<7) #define LED1 PORTC |= (1<<7) -#define TXLED0 PORTE &= ~(1<<6) -#define TXLED1 PORTE |= (1<<6) -#define RXLED0 PORTB &= ~(1<<0) -#define RXLED1 PORTB |= (1<<0) +#define TXLED0 PORTE |= (1<<6) +#define TXLED1 PORTE &= ~(1<<6) +#define RXLED0 PORTB |= (1<<0) +#define RXLED1 PORTB &= ~(1<<0) #define TRANSFER_PGM 0x80 #define TRANSFER_RELEASE 0x40 diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp index fbfad0e..52b960a 100644 --- a/bootloaders/diskloader/src/USBCore.cpp +++ b/bootloaders/diskloader/src/USBCore.cpp @@ -86,23 +86,27 @@ static inline void ClearOUT(void) static void Send(volatile const u8* data, u8 count) { + TXLED1; // light the TX LED while (count--) UEDATX = *data++; } void Recv(volatile u8* data, u8 count) { + RXLED1; // light the RX LED while (count--) *data++ = UEDATX; } static inline u8 Recv8() { + RXLED1; // light the RX LED return UEDATX; } static inline void Send8(u8 d) { + TXLED1; // light the TX LED UEDATX = d; } @@ -506,12 +510,17 @@ int USBGetChar() u8 temp = 0; for (temp=100; temp; temp--) asm volatile("nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t"::); + RXLED0; // we turn the RX and TX LEDs on in the relevant Send or Recv instruction + TXLED0; // we turn them off here after some time has passed to ensure a minimum on time. } - if (!--_timeout) + if (!--_timeout) { + TXLED0; // switch off the RX and TX LEDs before starting the user sketch + RXLED0; Reboot(); // USB not connected, run firmware + } - LEDPulse(); +// LEDPulse(); } return -1; } -- cgit v1.2.3-18-g5258