STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
WWDG

Window watchdog start, refresh, early wakeup and debug freeze. More...

Collaboration diagram for WWDG:

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.

Detailed Description

Window watchdog start, refresh, early wakeup and debug freeze.

Macro Definition Documentation

◆ WWDG_COUNTER_MIN

#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().

◆ WWDG_COUNTER_MAX

#define WWDG_COUNTER_MAX   (0x7FU)

Highest counter or window value (7 bits).

Definition at line 38 of file wwdg.h.

Referenced by wwdgValidateCount().

Function Documentation

◆ wwdgStart()

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.

Parameters
wwdgWWDG block (e.g. WWDG).
prescalerA WWDG_CFR_WDGTB_DIV* value.
window0x40 to 0x7F. A refresh while the counter is above it resets the chip; 0x7F allows a refresh at any time.
counter0x40 to 0x7F, the start value. Timeout = (counter - 0x3F) counts.
Precondition
The WWDG clock is on (rccWwdgClockEnable()).
Return values
DRIVER_STATUS_OKRunning.
DRIVER_STATUS_ERR_INVALID_PARAMA parameter is out of range. Nothing written.
Warning
Once started, only a reset stops it. Refresh it with wwdgRefresh() below the window and before the counter reaches 0x3F.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wwdgRefresh()

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.

Parameters
wwdgWWDG block (e.g. WWDG).
counter0x40 to 0x7F.
Return values
DRIVER_STATUS_OKReloaded.
DRIVER_STATUS_ERR_INVALID_PARAMcounter is out of range. Nothing written.
Warning
A refresh while the counter is above the window resets the chip at once.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wwdgEnableEarlyWakeup()

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.

Parameters
wwdgWWDG block (e.g. WWDG).

Definition at line 75 of file wwdg.c.

References WwdgRegisters_t::CFR, WWDG_CFR_EWI, and wwdgEnableEarlyWakeup().

Referenced by wwdgEnableEarlyWakeup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wwdgClearEarlyWakeup()

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.

Parameters
wwdgWWDG block (e.g. WWDG).

Definition at line 80 of file wwdg.c.

References WwdgRegisters_t::SR, and wwdgClearEarlyWakeup().

Referenced by wwdgClearEarlyWakeup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wwdgFreezeInDebug()

void wwdgFreezeInDebug ( DbgmcuRegisters_t * dbgmcu)

Stop the WWDG counter whenever the core is halted by a debugger.

As iwdgFreezeInDebug(), for the WWDG's bit.

Parameters
dbgmcuDBGMCU 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wwdgValidateCount()

DriverStatus_e wwdgValidateCount ( uint32_t value)
static

Accept a counter or window value: 0x40 to 0x7F.

Parameters
valueCandidate value.
Return values
DRIVER_STATUS_OKIn range.
DRIVER_STATUS_ERR_INVALID_PARAMOtherwise.

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().

Here is the call graph for this function:
Here is the caller graph for this function: