|
STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
|
Window watchdog start, refresh, early wakeup and debug freeze. More...
Macros | |
| #define | WWDG_COUNTER_MIN (0x40U) |
| Lowest counter or window value: 0x3F is the reset point. | |
| #define | WWDG_COUNTER_MAX (0x7FU) |
| Highest counter or window value (7 bits). | |
Functions | |
| DRIVER_MUST_CHECK DriverStatus_e | wwdgStart (WwdgRegisters_t *wwdg, uint32_t prescaler, uint32_t window, uint32_t counter) |
Set the window and timer base, then start the watchdog counting from counter. | |
| DRIVER_MUST_CHECK DriverStatus_e | wwdgRefresh (WwdgRegisters_t *wwdg, uint32_t counter) |
Reload the counter with counter (CR = WDGA | counter). | |
| void | wwdgEnableEarlyWakeup (WwdgRegisters_t *wwdg) |
| Raise WWDG_IRQn when the counter reaches 0x40, one count before reset. | |
| void | wwdgClearEarlyWakeup (WwdgRegisters_t *wwdg) |
| Clear the early-wakeup flag (SR.EWIF, write 0 to clear). | |
| void | wwdgFreezeInDebug (DbgmcuRegisters_t *dbgmcu) |
| Stop the WWDG counter whenever the core is halted by a debugger. | |
| static DriverStatus_e | wwdgValidateCount (uint32_t value) |
| Accept a counter or window value: 0x40 to 0x7F. | |
Window watchdog start, refresh, early wakeup and debug freeze.
| #define WWDG_COUNTER_MIN (0x40U) |
Lowest counter or window value: 0x3F is the reset point.
Definition at line 37 of file wwdg.h.
Referenced by wwdgValidateCount().
| #define WWDG_COUNTER_MAX (0x7FU) |
Highest counter or window value (7 bits).
Definition at line 38 of file wwdg.h.
Referenced by wwdgValidateCount().
| DriverStatus_e wwdgStart | ( | WwdgRegisters_t * | wwdg, |
| uint32_t | prescaler, | ||
| uint32_t | window, | ||
| uint32_t | counter ) |
Set the window and timer base, then start the watchdog counting from counter.
Writes CFR, then CR with WDGA and counter in one store, so the window and timer base are in place before the counter starts. CFR.EWI is kept.
It then clears SR.EWIF. The counter runs from the moment its clock is enabled, even before WDGA is set, and sets EWIF each time it passes 0x40, enabled or not. Left set, that stale flag would raise the early wakeup at once, above the window.
| wwdg | WWDG block (e.g. WWDG). |
| prescaler | A WWDG_CFR_WDGTB_DIV* value. |
| window | 0x40 to 0x7F. A refresh while the counter is above it resets the chip; 0x7F allows a refresh at any time. |
| counter | 0x40 to 0x7F, the start value. Timeout = (counter - 0x3F) counts. |
| DRIVER_STATUS_OK | Running. |
| DRIVER_STATUS_ERR_INVALID_PARAM | A parameter is out of range. Nothing written. |
Definition at line 30 of file wwdg.c.
References WwdgRegisters_t::CFR, WwdgRegisters_t::CR, DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, WwdgRegisters_t::SR, WWDG_CFR_EWI, WWDG_CFR_W_Pos, WWDG_CFR_WDGTB_DIV8, WWDG_CFR_WDGTB_Pos, WWDG_CR_T_Pos, WWDG_CR_WDGA, wwdgStart(), and wwdgValidateCount().
Referenced by wwdgStart().
| DriverStatus_e wwdgRefresh | ( | WwdgRegisters_t * | wwdg, |
| uint32_t | counter ) |
Reload the counter with counter (CR = WDGA | counter).
A single store, so it is safe from any context.
| wwdg | WWDG block (e.g. WWDG). |
| counter | 0x40 to 0x7F. |
| DRIVER_STATUS_OK | Reloaded. |
| DRIVER_STATUS_ERR_INVALID_PARAM | counter is out of range. Nothing written. |
Definition at line 63 of file wwdg.c.
References WwdgRegisters_t::CR, DRIVER_STATUS_OK, WWDG_CR_T_Pos, WWDG_CR_WDGA, wwdgRefresh(), and wwdgValidateCount().
Referenced by wwdgRefresh().
| void wwdgEnableEarlyWakeup | ( | WwdgRegisters_t * | wwdg | ) |
Raise WWDG_IRQn when the counter reaches 0x40, one count before reset.
CFR.EWI can only be set; a reset clears it.
| wwdg | WWDG block (e.g. WWDG). |
Definition at line 75 of file wwdg.c.
References WwdgRegisters_t::CFR, WWDG_CFR_EWI, and wwdgEnableEarlyWakeup().
Referenced by wwdgEnableEarlyWakeup().
| void wwdgClearEarlyWakeup | ( | WwdgRegisters_t * | wwdg | ) |
Clear the early-wakeup flag (SR.EWIF, write 0 to clear).
Call it in WWDG_IRQHandler, or the interrupt is taken again at once.
| wwdg | WWDG block (e.g. WWDG). |
Definition at line 80 of file wwdg.c.
References WwdgRegisters_t::SR, and wwdgClearEarlyWakeup().
Referenced by wwdgClearEarlyWakeup().
| void wwdgFreezeInDebug | ( | DbgmcuRegisters_t * | dbgmcu | ) |
Stop the WWDG counter whenever the core is halted by a debugger.
As iwdgFreezeInDebug(), for the WWDG's bit.
| dbgmcu | DBGMCU block (e.g. DBGMCU). |
Definition at line 86 of file wwdg.c.
References DbgmcuRegisters_t::APB1_FZ, DBGMCU_APB1_FZ_DBG_WWDG_STOP, and wwdgFreezeInDebug().
Referenced by wwdgFreezeInDebug().
|
static |
Accept a counter or window value: 0x40 to 0x7F.
| value | Candidate value. |
| DRIVER_STATUS_OK | In range. |
| DRIVER_STATUS_ERR_INVALID_PARAM | Otherwise. |
Definition at line 18 of file wwdg.c.
References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, WWDG_COUNTER_MAX, WWDG_COUNTER_MIN, and wwdgValidateCount().
Referenced by wwdgRefresh(), wwdgStart(), and wwdgValidateCount().