a
Fork of Watchdog by
Revision 7:098b53d90b3d, committed 2017-09-26
- Comitter:
- suads
- Date:
- Tue Sep 26 20:47:06 2017 +0000
- Parent:
- 6:40f189c7795b
- Commit message:
- xx
Changed in this revision
Watchdog.cpp | Show annotated file Show diff for this revision Revisions of this file |
Watchdog.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 40f189c7795b -r 098b53d90b3d Watchdog.cpp --- a/Watchdog.cpp Mon Mar 02 21:36:00 2015 +0000 +++ b/Watchdog.cpp Tue Sep 26 20:47:06 2017 +0000 @@ -21,8 +21,8 @@ /// @author Bernaérd Remond /// -#define LPC -//#define ST_NUCLEO +//#define LPC +#define ST_NUCLEO #include "mbed.h" @@ -31,20 +31,23 @@ /// Watchdog gets instantiated at the module level Watchdog::Watchdog() { +/* #ifdef LPC wdreset = (LPC_WDT->WDMOD >> 2) & 1; // capture the cause of the previous reset #endif +*/ #ifdef ST_NUCLEO // capture the cause of the previous reset /* Check if the system has resumed from IWDG reset */ -/* + printf("Watchdog()\n"); + if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) { wdreset = true; } else { wdreset = false; } -*/ + wdreset = false; #endif @@ -52,16 +55,18 @@ /// Load timeout value in watchdog timer and enable void Watchdog::Configure(float timeout) { +/* #ifdef LPC LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 LPC_WDT->WDTC = (uint32_t)(timeout * (float)clk); LPC_WDT->WDMOD = 0x3; // Enabled and Reset -#endif +#endif +*/ #ifdef ST_NUCLEO // see http://embedded-lab.com/blog/?p=9662 #define LsiFreq (45000) - + printf("Configure\n"); uint16_t PrescalerCode; uint16_t Prescaler; uint16_t ReloadValue; @@ -100,7 +105,7 @@ ReloadValue = (uint32_t)(timeout * (LsiFreq/Prescaler)); Calculated_timeout = ((float)(Prescaler * ReloadValue)) / LsiFreq; - printf("WATCHDOG set with prescaler:%d reload value: 0x%X - timeout:%f\n",Prescaler, ReloadValue, Calculated_timeout); + printf("WATCHDOG set with prescaler:%d reload value Nucleo: 0x%X - timeout:%f\n",Prescaler, ReloadValue, Calculated_timeout); IWDG->KR = 0x5555; //Disable write protection of IWDG registers IWDG->PR = PrescalerCode; //Set PR value @@ -115,18 +120,26 @@ /// "Service", "kick" or "feed" the dog - reset the watchdog timer /// by writing this required bit pattern void Watchdog::Service() { +/* #ifdef LPC LPC_WDT->WDFEED = 0xAA; LPC_WDT->WDFEED = 0x55; -#endif +#endif +*/ #ifdef ST_NUCLEO +// printf("Service\n"); IWDG->KR = 0xAAAA; //Reload IWDG - See more at: http://embedded-lab.com/blog/?p=9662#sthash.6VNxVSn0.dpuf #endif } /// get the flag to indicate if the watchdog causes the reset bool Watchdog::WatchdogCausedReset() { + printf("WatchdogCausedReset\n"); return wdreset; } +bool Watchdog::dsable(){ + + } +
diff -r 40f189c7795b -r 098b53d90b3d Watchdog.h --- a/Watchdog.h Mon Mar 02 21:36:00 2015 +0000 +++ b/Watchdog.h Tue Sep 26 20:47:06 2017 +0000 @@ -94,6 +94,7 @@ /// /// @returns true if the Watchdog was the cause of the reset bool WatchdogCausedReset(); + bool dsable(); private: bool wdreset; };