From: asterix Date: Wed, 11 Jan 2012 14:40:24 +0000 (+0000) Subject: Add watchdog driver. X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=705e92ca3e6a5bd0223f21a8fd9ac714f3253a5f;p=bertos.git Add watchdog driver. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5245 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/arm/drv/wdt_arm.h b/bertos/cpu/arm/drv/wdt_arm.h index 2e631bd6..64f21eef 100644 --- a/bertos/cpu/arm/drv/wdt_arm.h +++ b/bertos/cpu/arm/drv/wdt_arm.h @@ -40,11 +40,21 @@ #define DRV_WDT_ARM_H #include // INLINE +#include // BV -#warning TODO: This module is not implemented for at91 CPUs +#if CPU_ARM_AT91 + #include -INLINE void wdt_start(uint32_t _timeout) { (void) _timeout; /* implement me */ } -INLINE void wdt_stop(void) { /*implement me */ } -INLINE void wdt_reset(void) { /* implement me */ } + INLINE void wdt_start(uint32_t _timeout) { (void) _timeout; /* implement me */ } + INLINE void wdt_stop(void) { WDT_MR = BV(WDT_WDDIS); } + INLINE void wdt_reset(void) + { + #if (ARCH & ARCH_BOOT) + WDT_CR = WDT_KEY | BV(WDT_WDRSTT); + #endif + } +#else + #error "Missing watchdog support for yout CPU" +#endif #endif //DRV_WDT_ARM_H diff --git a/bertos/cpu/arm/hw/init_at91.c b/bertos/cpu/arm/hw/init_at91.c index fc7ffaf4..f803c595 100644 --- a/bertos/cpu/arm/hw/init_at91.c +++ b/bertos/cpu/arm/hw/init_at91.c @@ -39,6 +39,8 @@ #include #include +#include "cfg/cfg_wdt.h" + #define USE_FIXED_PLL 1 #define XTAL_FREQ 18432000UL @@ -171,8 +173,10 @@ void __init1(void) AIC_EOICR = 0xFFFFFFFF; AIC_IDCR = 0xFFFFFFFF; - /* The watchdog is enabled after processor reset. Disable it. */ - WDT_MR = BV(WDT_WDDIS); + #if CONFIG_WATCHDOG == 0 + /* The watchdog is enabled after processor reset. Disable it. */ + WDT_MR = BV(WDT_WDDIS); + #endif /* * Enable the main oscillator. Set startup time of 6 * 8 slow