diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-03-22 23:33:07 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-03-22 23:33:07 +0100 |
commit | 4c0cf591b03148b9450d4009d2a3e908ec0c87a8 (patch) | |
tree | 3d801e9ebb253dec366184f9b5b21d130ee3d129 /firmware/src | |
parent | 4086f4cf46a8f508766eeaad03450a4d7845f194 (diff) |
wdt: make sure WDT doesn't fire inadvertently
We have to set WDD and WDV to the same value to avoid watchdog errors
Diffstat (limited to 'firmware/src')
-rw-r--r-- | firmware/src/os/wdt.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/firmware/src/os/wdt.c b/firmware/src/os/wdt.c index 8e2b73a..99d86a1 100644 --- a/firmware/src/os/wdt.c +++ b/firmware/src/os/wdt.c @@ -23,13 +23,19 @@ #include <os/dbgu.h> #include <os/system_irq.h> +#define WDT_WDD 0xFF +#define WDT_WDV 0xFF + #ifdef WDT_DEBUG #undef WDT_DEBUG #endif/*WDT_DEBUG*/ - + static void wdt_irq(u_int32_t sr) { - DEBUGPCRF("================> WATCHDOG EXPIRED !!!!!"); + if (sr & 1) + DEBUGPCRF("================> WATCHDOG EXPIRED !!!!!"); + if (sr & 2) + DEBUGPCRF("================> WATCHDOG ERROR !!!!!"); } void wdt_restart(void) @@ -41,11 +47,12 @@ void wdt_init(void) { sysirq_register(AT91SAM7_SYSIRQ_WDT, &wdt_irq); #ifdef WDT_DEBUG - AT91F_WDTSetMode(AT91C_BASE_WDTC, (0xff << 16) | + AT91F_WDTSetMode(AT91C_BASE_WDTC, (WDT_WDD << 16) | AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | - AT91C_WDTC_WDFIEN); + AT91C_WDTC_WDFIEN | WDT_WDV); #else - AT91F_WDTSetMode(AT91C_BASE_WDTC, (0x80 << 16) | - AT91C_WDTC_WDRSTEN | 0x80); + AT91F_WDTSetMode(AT91C_BASE_WDTC, (WDT_WDD << 16) | + AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | + AT91C_WDTC_WDRSTEN | WDT_WDV); #endif } |