From 2b13fd3b4091049ebdf295986d834de4c9ea3c32 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Thu, 27 Oct 2011 11:27:24 -0400 Subject: bootloader runs sketch after timeout, added bootloader LED breathing --- bootloaders/diskloader/src/DiskLoader.cpp | 48 +++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'bootloaders/diskloader/src') diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp index e984375..30ac1b6 100644 --- a/bootloaders/diskloader/src/DiskLoader.cpp +++ b/bootloaders/diskloader/src/DiskLoader.cpp @@ -23,7 +23,7 @@ u8 _flashbuf[128]; u8 _inSync; u8 _ok; u16 do_reset = 0; -volatile u16 _timeout; +volatile u16 _timeout = 0; void Program(u8 ep, u16 page, u8 count) { @@ -49,6 +49,20 @@ void Program(u8 ep, u16 page, u8 count) boot_rww_enable (); } +u16 _pulse; +void LEDPulse() +{ + _pulse += 1; + u8 p = _pulse >> 9; + if (p > 63) + p = 127-p; + p += p; + if (((u8)_pulse) > p) + L_LED_OFF(); + else + L_LED_ON(); +} + #define HW_VER 0x02 #define SW_MAJOR 0x01 #define SW_MINOR 0x10 @@ -95,6 +109,19 @@ const u8 _consts[] = void start_sketch() { + L_LED_OFF(); + RX_LED_OFF(); + TX_LED_OFF(); + /* move interrupts to application section: + * uses inline assembly because the procedure must be completed in four cycles. + */ + cli(); // disable interrupts first + asm volatile ( + "ldi r16, 0x01\n" // (1<