- add (currently inactive) code for the watch dog timer

git-svn-id: https://svn.openpcd.org:2342/trunk@240 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
This commit is contained in:
laforge 2006-09-30 22:37:48 +00:00
parent 0a3534e799
commit 48afc6a1d1
3 changed files with 23 additions and 5 deletions

View File

@ -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

View File

@ -17,21 +17,31 @@
*
*/
#include <lib_AT91SAM7.h>
#include <AT91SAM7.h>
#include <os/dbgu.h>
#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

5
firmware/src/os/wdt.h Normal file
View File

@ -0,0 +1,5 @@
#ifndef _WDT_H
extern void wdt_init(void);
extern void wdt_restart(void);
#endif