Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Watchdog by
Diff: Watchdog.cpp
- Revision:
- 15:e0e4c2268558
- Parent:
- 14:30665d9afe68
- Child:
- 17:ccd155378a9b
--- a/Watchdog.cpp Fri Feb 03 04:53:54 2017 +0000
+++ b/Watchdog.cpp Fri Feb 23 13:41:54 2018 +0000
@@ -19,7 +19,7 @@
#if defined( TARGET_LPC1768 )
/// Watchdog gets instantiated at the module level
Watchdog::Watchdog() {
- wdreset = (LPC_WDT->WDMOD >> 2) & 1; // capture the cause of the previous reset
+ _wdreset = (LPC_WDT->WDMOD >> 2) & 1; // capture the cause of the previous reset
}
/// Load timeout value in watchdog timer and enable
@@ -48,13 +48,13 @@
/// get the flag to indicate if the watchdog causes the reset
bool Watchdog::WatchdogCausedReset() {
- return wdreset;
+ return _wdreset;
}
#elif defined( TARGET_LPC4088 )
// from Gesotec Gesotec
/// Watchdog gets instantiated at the module level
Watchdog::Watchdog() {
- wdreset = (LPC_WDT->MOD >> 2) & 1; // capture the cause of the previous reset
+ _wdreset = (LPC_WDT->MOD >> 2) & 1; // capture the cause of the previous reset
}
/// Load timeout value in watchdog timer and enable
@@ -83,12 +83,13 @@
/// get the flag to indicate if the watchdog causes the reset
bool Watchdog::WatchdogCausedReset() {
- return wdreset;
+ return _wdreset;
}
#elif defined(TARGET_STM)
Watchdog::Watchdog()
{
- wdreset = (RCC->CSR & (1<<29)) ? true : false; // read the IWDGRSTF (Independent WD, not the windows WD)
+ _rcc_csr = RCC->CSR;
+ RCC->CSR |= RCC_CSR_RMVF; // clear reset flag
}
// 整数Xを含む最小のべき乗指数
@@ -182,10 +183,6 @@
/// get the flag to indicate if the watchdog causes the reset
bool Watchdog::WatchdogCausedReset()
{
- if (wdreset)
- {
- RCC->CSR |= (1<<24); // clear reset flag
- }
- return wdreset;
+ return (_rcc_csr & (RCC_CSR_IWDGRSTF | RCC_CSR_WWDGRSTF)) != 0; // read the IWDGRSTF (Independent WD, not the windows WD)
}
#endif
