From c748023ede9e7d8bdbf81ce8c8be2a437607a9e4 Mon Sep 17 00:00:00 2001 From: Leo C Date: Wed, 21 Jan 2015 04:07:19 +0100 Subject: Support for Peter Danneggers fboot. --- avr/main.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'avr/main.c') diff --git a/avr/main.c b/avr/main.c index 8bffef9..f4d4c6f 100644 --- a/avr/main.c +++ b/avr/main.c @@ -7,6 +7,7 @@ #include "common.h" #include +#include #include #include @@ -24,11 +25,9 @@ #include "time.h" #include "rtc.h" -static uint8_t mcusr; +uint8_t mcusr __attribute__ ((section (".noinit"))); -/*--------------------------------------------------------------------------*/ #if DEBUG - __attribute__ ((naked)) __attribute__ ((section (".init3"))) void preset_ram (void) { @@ -36,6 +35,21 @@ void preset_ram (void) *p = 0xdd; } +#endif + +__attribute__ ((naked)) __attribute__ ((section (".init3"))) +void get_mcusr (void) +{ + /* save and clear reset reason(s) */ + /* TODO: move to init section? */ + mcusr = MCUSR; + MCUSR = 0; + + wdt_disable(); +} + +/*--------------------------------------------------------------------------*/ +#if DEBUG static const FLASH char * const FLASH rreasons[] = { FSTR("Power on"), @@ -77,13 +91,6 @@ ISR(INT6_vect) static void setup_avr(void) { - /* save and clear reset reason(s) */ - /* TODO: move to init section? */ - mcusr = MCUSR; - MCUSR = 0; - - /* WD */ - /* CPU */ /* Disable JTAG Interface regardless of the JTAGEN fuse setting. */ -- cgit v1.2.3