]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/main.c
Bufix mstep command: take the right arg for parameter count.
[z180-stamp.git] / avr / main.c
index 5a0d7928ea4b45aa9c7822d04dc84c1cd7ed1fe4..113b4f24310f2cea292503f9e274d7b6fbdba42a 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "common.h"
 #include <avr/interrupt.h>
+#include <avr/wdt.h>
 #include <stdlib.h>
 #include <stdio.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)
 {
@@ -37,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"),
@@ -78,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. */
@@ -217,7 +224,7 @@ const char *bootdelay_process(void)
        debug("### main_loop entered: bootdelay=%d\n\n", bootdelay);
        _delay_ms(20);
 
-       s = getenv(PSTR(ENV_BOOTCMD));
+       s = getenv_char(PSTR(ENV_BOOTCMD));
        stored_bootdelay = bootdelay;
        return s;
 }
@@ -270,7 +277,7 @@ int main(void)
        setup_system_time();
        setup_fatfs();
 
-       printf_P(PSTR("\nATMEGA1281+Z8S180 Stamp Monitor\n\n"));
+       printf_P(PSTR("\n" MCU_STRING "+Z8S180 Stamp Monitor\n\n"));
 
        setup_z180_serv();