X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/7f552300815ccadd45ebb3e7f0ae72a3b2e0c4e5..refs/tags/hexrel-6.4:/avr/main.c diff --git a/avr/main.c b/avr/main.c index af082a3..3852e75 100644 --- a/avr/main.c +++ b/avr/main.c @@ -1,15 +1,18 @@ /* + * (C) Copyright 2014 Leo C. + * + * SPDX-License-Identifier: GPL-2.0+ */ #include "common.h" - #include +#include #include #include #include "config.h" -#include "debug.h" +#include "ff.h" #include "z80-if.h" #include "i2c.h" #include "con-utils.h" @@ -18,13 +21,14 @@ #include "cli.h" #include "env.h" #include "z180-serv.h" -#include "spi.h" +#include "gpio.h" +#include "time.h" +#include "rtc.h" +#include "debug.h" -static uint8_t mcusr; +uint8_t mcusr __attribute__ ((section (".noinit"))); -/*--------------------------------------------------------------------------*/ #if DEBUG - __attribute__ ((naked)) __attribute__ ((section (".init3"))) void preset_ram (void) { @@ -32,6 +36,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"), @@ -73,13 +92,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. */ @@ -109,13 +121,6 @@ void setup_avr(void) TCCR3B = (0b01<