summaryrefslogtreecommitdiff
path: root/lightctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'lightctrl.c')
-rw-r--r--lightctrl.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lightctrl.c b/lightctrl.c
index 9e8d234..659ac26 100644
--- a/lightctrl.c
+++ b/lightctrl.c
@@ -5,6 +5,7 @@
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
+#include <avr/wdt.h>
#include <util/delay.h>
const uint8_t __signature[3] __attribute__((section (".signature"), used)) =
@@ -27,6 +28,7 @@ const uint8_t __signature[3] __attribute__((section (".signature"), used)) =
#include "dali_ctl.c"
#include "dim.c"
#include "can.c"
+#include "wdt.c"
static void can_rx_exec(void)
{
@@ -65,6 +67,8 @@ static void can_rx_exec(void)
int main(void)
{
+ wdt_init();
+
DDRD |= (1 << D_LED1) | (1 << D_LED2 ) | (1 << D_TXD) | (1 << D_DALIO);
PORTD |= (1 << D_LED1) | (1 << D_TAST);
PORTD &= ~(1 << D_LED1);
@@ -76,8 +80,24 @@ int main(void)
sei();
+ uart_puts("\nreset from");
+ if (MCUSR & (1 << WDRF))
+ uart_puts(" WDT");
+ if (MCUSR & (1 << BORF))
+ uart_puts(" BO");
+ if (MCUSR & (1 << EXTRF))
+ uart_puts(" EXT");
+ if (MCUSR & (1 << PORF))
+ uart_puts(" POR");
+ MCUSR = 0;
+
+ uart_puts("\nwdt_generation ");
+ uart_puthex(wdt_generation);
+
uart_puts("\ndelay...\n");
+ wdt_reset();
_delay_ms(1000);
+ wdt_reset();
uart_puts("\ninit done\n");
can_init();
@@ -88,6 +108,7 @@ int main(void)
uint16_t ctr = 0;
while (1) {
+ wdt_reset();
if (canint) {
canint = false;
can_int();