]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/main.c
Merge branch 'master' into cmdline_edit
[z180-stamp.git] / avr / main.c
index 5a0d7928ea4b45aa9c7822d04dc84c1cd7ed1fe4..3852e754a5ba59477cf813421ebfcc36fea0f3c2 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. */