summaryrefslogtreecommitdiff
path: root/avr/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'avr/main.c')
-rw-r--r--avr/main.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/avr/main.c b/avr/main.c
index 5a0d792..3852e75 100644
--- a/avr/main.c
+++ b/avr/main.c
@@ -7,6 +7,7 @@
#include "common.h"
#include <avr/interrupt.h>
+#include <avr/wdt.h>
#include <stdlib.h>
#include <stdio.h>
@@ -25,11 +26,9 @@
#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. */