ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
Loading...
Searching...
No Matches
iwdg.h File Reference
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define IWDG_PRESCALER_4   0u
 
#define IWDG_PRESCALER_8   1u
 
#define IWDG_PRESCALER_16   2u
 
#define IWDG_PRESCALER_32   3u
 
#define IWDG_PRESCALER_64   4u
 
#define IWDG_PRESCALER_128   5u
 
#define IWDG_PRESCALER_256   6u
 

Functions

void IWDG_Init (uint8_t prescaler, uint16_t reload)
 Configure and start the independent watchdog.
 
void IWDG_Refresh (void)
 Reload the watchdog counter ("kick" / "feed").
 
bool IWDG_WasReset (void)
 Was the most recent reset caused by the IWDG?
 
void IWDG_ClearResetFlag (void)
 Clear the IWDG reset flag in RCC->RSR.
 

Macro Definition Documentation

◆ IWDG_PRESCALER_128

#define IWDG_PRESCALER_128   5u

Definition at line 52 of file iwdg.h.

◆ IWDG_PRESCALER_16

#define IWDG_PRESCALER_16   2u

Definition at line 49 of file iwdg.h.

◆ IWDG_PRESCALER_256

#define IWDG_PRESCALER_256   6u

Definition at line 53 of file iwdg.h.

◆ IWDG_PRESCALER_32

#define IWDG_PRESCALER_32   3u

Definition at line 50 of file iwdg.h.

◆ IWDG_PRESCALER_4

#define IWDG_PRESCALER_4   0u

Definition at line 47 of file iwdg.h.

◆ IWDG_PRESCALER_64

#define IWDG_PRESCALER_64   4u

Definition at line 51 of file iwdg.h.

◆ IWDG_PRESCALER_8

#define IWDG_PRESCALER_8   1u

Definition at line 48 of file iwdg.h.

Function Documentation

◆ IWDG_ClearResetFlag()

void IWDG_ClearResetFlag ( void  )

Clear the IWDG reset flag in RCC->RSR.

Note
Safe to call unconditionally; clears the flag even if it was not set. Typically called once at boot after the application has logged the reset reason.

Definition at line 78 of file iwdg.c.

◆ IWDG_Init()

void IWDG_Init ( uint8_t  prescaler,
uint16_t  reload 
)

Configure and start the independent watchdog.

Parameters
prescalerOne of the IWDG_PRESCALER_* values (3-bit PR field).
reload12-bit reload value (1..4095). Total timeout is (reload + 1) × prescaler_div / LSI.
Note
Once started the IWDG cannot be stopped without a system reset. The function is idempotent — calling it twice with the same arguments is safe.

Definition at line 44 of file iwdg.c.

References IWDG_KEY_ENABLE, IWDG_KEY_REFRESH, IWDG_KEY_UNLOCK, and IWDG_PRESCALER_256.

◆ IWDG_Refresh()

void IWDG_Refresh ( void  )

Reload the watchdog counter ("kick" / "feed").

Note
Must be called periodically — at least once per timeout window — or the chip will reset.

Definition at line 70 of file iwdg.c.

References IWDG_KEY_REFRESH.

◆ IWDG_WasReset()

bool IWDG_WasReset ( void  )

Was the most recent reset caused by the IWDG?

Returns
true if the IWDGRST flag in RCC->RSR was set on this boot, false otherwise. The flag is sticky until cleared with IWDG_ClearResetFlag(), so this query is safe to call any number of times.

Definition at line 74 of file iwdg.c.