/*--------------------------------------------------------------------------*/
+static uint8_t mcusr;
+
+static
void setup_avr(void)
{
+ /* save and clear reset reason(s) */
+ mcusr = MCUSR;
+ MCUSR = 0;
+
/* WD */
/* CPU */
TIMSK1 = _BV(OCIE1A); // Enable TC1.oca interrupt
}
+static const FLASH char * const FLASH rreasons[] = {
+ FSTR("Power on"),
+ FSTR("External"),
+ FSTR("Brown out"),
+ FSTR("Watchdog"),
+ FSTR("JTAG"),
+ };
+
+static
+void print_reset_reason(void)
+{
+ uint8_t r = mcusr & 0x1f;
+ const FLASH char * const FLASH *p = rreasons;
+
+ printf_P(PSTR("Reset reason(s): "));
+ for ( ; r; p++, r >>= 1) {
+ if (r & 1) {
+ my_puts_P(*p);
+ if (r & ~1)
+ printf_P(PSTR(", "));
+ }
+ }
+ printf_P(PSTR(".\n"));
+}
/*******************************************************************************/
return abort;
}
+static
const char *bootdelay_process(void)
{
char *s;
return s;
}
+static
void autoboot_command(const char *s)
{
debug("### main_loop: bootcmd=\"%s\"\n", s ? s : PSTR("<UNDEFINED>"));
}
+static
void main_loop(void)
{
const char *s;
serial_setup();
sei();
-
- if (env_check() == 0)
- set_default_env();
+
+ debug("\n=========================< (RE)START DEBUG >=========================\n");
+#if DEBUG
+ print_reset_reason();
+#endif
+
env_init();
printf_P(PSTR("\n(ATMEGA1281+HD64180)_stamp Tester\n"));