diff options
author | Keith Packard <keithp@keithp.com> | 2011-05-18 00:17:04 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-05-18 00:17:04 -0700 |
commit | f2c9234341b18d94c6056d72a496753c64619f08 (patch) | |
tree | ebe604a5bc1b15034634735e63ff02e4a3a200a7 | |
parent | e7e2fdf45dfbf6393ee0a0ec22e1e5ea49d6cfd5 (diff) |
src-avr: Trap accidental restart
Use the LED output pin to notice when avr-demo accidentally restarts
and print out an error message in that case.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | src-avr/ao_demo.c | 3 | ||||
-rw-r--r-- | src-avr/ao_led.c | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src-avr/ao_demo.c b/src-avr/ao_demo.c index cb7ad786..d905cec6 100644 --- a/src-avr/ao_demo.c +++ b/src-avr/ao_demo.c @@ -35,10 +35,11 @@ main(void) ao_clock_init(); ao_serial_init(); + + ao_led_init(LEDS_AVAILABLE); ao_stdio_init(); printf ("stdio initialized\n"); // ao_debug_init(); - ao_led_init(LEDS_AVAILABLE); ao_timer_init(); ao_cmd_init(); ao_usb_init(); diff --git a/src-avr/ao_led.c b/src-avr/ao_led.c index 0e69ee3a..5183140b 100644 --- a/src-avr/ao_led.c +++ b/src-avr/ao_led.c @@ -63,6 +63,10 @@ ao_led_init(uint8_t enable) { ao_led_enable = enable; #ifdef AVR + if ((LED_DDR & enable)) { + printf ("oops! restarted\n"); + ao_panic(AO_PANIC_REBOOT); + } LED_PORT &= ~enable; LED_DDR |= enable; #else |