From 48afc6a1d1a9166508304cc01b2cfc1899d2b163 Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 30 Sep 2006 22:37:48 +0000 Subject: - add (currently inactive) code for the watch dog timer git-svn-id: https://svn.openpcd.org:2342/trunk@240 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- firmware/src/os/main.c | 7 +++++-- firmware/src/os/wdt.c | 16 +++++++++++++--- firmware/src/os/wdt.h | 5 +++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 firmware/src/os/wdt.h diff --git a/firmware/src/os/main.c b/firmware/src/os/main.c index 973488b..b9ed4dc 100644 --- a/firmware/src/os/main.c +++ b/firmware/src/os/main.c @@ -45,14 +45,16 @@ int main(void) AT91F_PIOA_CfgPMC(); - /* call application specific init function */ - _init_func(); + wdt_init(); /* initialize USB */ req_ctx_init(); usbcmd_gen_init(); udp_open(); + /* call application specific init function */ + _init_func(); + // Enable User Reset and set its minimal assertion to 960 us AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4 << 8) | (unsigned int)(0xA5 << 24); @@ -70,6 +72,7 @@ int main(void) /* Call application specific main idle function */ _main_func(); dbgu_rb_flush(); + wdt_restart(); #ifdef CONFIG_IDLE //cpu_idle(); #endif diff --git a/firmware/src/os/wdt.c b/firmware/src/os/wdt.c index 579d15d..5a3c809 100644 --- a/firmware/src/os/wdt.c +++ b/firmware/src/os/wdt.c @@ -17,21 +17,31 @@ * */ +#include +#include + +#include + #define WDT_DEBUG -void wdt_irq(void) +static void wdt_irq(void) { DEBUGPCRF("================> WATCHDOG EXPIRED !!!!!"); } +void wdt_restart(void) +{ + AT91F_WDTRestart(AT91C_BASE_WDTC); +} + void wdt_init(void) { #ifdef WDT_DEBUG - AT91F_WDTSetMode(AT91C_BASE_WDT, (0xfff << 16) | + AT91F_WDTSetMode(AT91C_BASE_WDTC, (0xfff << 16) | AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | AT91C_WDTC_WDFIEN); #else - AT91F_WDTSetMode(AT91C_BASE_WDT, (0xfff << 16) | + AT91F_WDTSetMode(AT91C_BASE_WDTC, (0xfff << 16) | AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | AT91C_WDTC_WDRSTEN); #endif diff --git a/firmware/src/os/wdt.h b/firmware/src/os/wdt.h new file mode 100644 index 0000000..35ea721 --- /dev/null +++ b/firmware/src/os/wdt.h @@ -0,0 +1,5 @@ +#ifndef _WDT_H +extern void wdt_init(void); +extern void wdt_restart(void); + +#endif -- cgit v1.2.3