libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
Watchdog Defines

Defined Constants and Types for the SWM050 Watchdog More...

Collaboration diagram for Watchdog Defines:

Modules

 Watchdog mode
 
 Watchdog Registers
 

Functions

void wdt_setup (enum wdt_modes mode, uint8_t time1, uint8_t time2)
 Sets up the WDT before the call to wdt_enable(). More...
 
void wdt_enable (bool en)
 Enables the WDT. More...
 
void wdt_mode (enum wdt_modes mode)
 Sets the WDT's mode of operation. More...
 
void wdt_reset (void)
 Reset the WDT's counter. More...
 
bool wdt_int_status (void)
 Gets the WDT's interrupt status. More...
 
void wdt_clear_int (void)
 Clears the WDT's interrupt. More...
 
void wdt_clock_enable (bool en)
 Enables the WDT's clock. More...
 
uint32_t wdt_get_value (void)
 Gets the current WDT counter value. More...
 
void wdt_set_time (uint8_t time1, uint8_t time2)
 Sets the WDT's initial counter values. More...
 

Detailed Description

Defined Constants and Types for the SWM050 Watchdog

LGPL License Terms libopencm3 License

Function Documentation

◆ wdt_clear_int()

void wdt_clear_int ( void  )

Clears the WDT's interrupt.

Note
Only useful with WDT_MODE_INT

Definition at line 101 of file wdt.c.

References WDT_EOI.

◆ wdt_clock_enable()

void wdt_clock_enable ( bool  en)

Enables the WDT's clock.

This only enables the clock to the peripheral.

See also
wdt_setup
Parameters
enTrue to enable, false to disable

Definition at line 115 of file wdt.c.

References SYSCTL_SYS_CFG_1, and SYSCTL_SYS_CFG_1_WDT.

Referenced by wdt_setup().

Here is the caller graph for this function:

◆ wdt_enable()

void wdt_enable ( bool  en)

Enables the WDT.

This actually starts the watchdog, you should have already selected modes and set timeouts. If WDT_MODE_INT is used, the interrupt should also be enabled using the NVIC before enabling the WDT.

See also
wdt_setup
Parameters
enenable

Definition at line 55 of file wdt.c.

References WDT_CR.

◆ wdt_get_value()

uint32_t wdt_get_value ( void  )

Gets the current WDT counter value.

The vendor-supplied documentation for the WDT_CCVR register appears to be incorrect, and does not seem to be 1 bit wide, which would make no sense.

Returns
The current WDT counter value

Definition at line 130 of file wdt.c.

References WDT_CCVR.

◆ wdt_int_status()

bool wdt_int_status ( void  )

Gets the WDT's interrupt status.

Note
Only useful with WDT_MODE_INT
Returns
The WDT's interrupt status. True if an interrupt has not been cleared.

Definition at line 92 of file wdt.c.

References WDT_STAT.

◆ wdt_mode()

void wdt_mode ( enum wdt_modes  mode)

Sets the WDT's mode of operation.

Parameters
modeThe mode of operation Watchdog mode

Definition at line 68 of file wdt.c.

References WDT_CR, and WDT_MODE_INT.

Referenced by wdt_setup().

Here is the caller graph for this function:

◆ wdt_reset()

void wdt_reset ( void  )

Reset the WDT's counter.

The "feed the dog" operation. Must be called periodically to avoid a timeout. Calling this also clears any WDT interrupts.

Definition at line 82 of file wdt.c.

References WDT_CRR.

Referenced by wdt_setup().

Here is the caller graph for this function:

◆ wdt_set_time()

void wdt_set_time ( uint8_t  time1,
uint8_t  time2 
)

Sets the WDT's initial counter values.

Both time1 and time2 follow the equation 2^(8 + i), where i is a value from 0 to 15, and where the result is in clock cycles. For example: time1 = 15 2^(8 + time1) / 18Mhz = 0.466s The majority of the vendor-supplied documentation appears to be completely incorrect about the equation used for these counters.

Only the least significant 4 bits are used for both values, eg 0 to 15.

Parameters
time1The timer value used in both modes. In WDT_MODE_RESET, this value counts down to 0 and resets the system. In WDT_MODE_INT, this value counts down to 0, generates a WDT interrupt, loads time2 into the counter, and counts down.
time2The timer value used after time1 in mode WDT_MODE_INT. If this counts down to 0, and the WDT interrupt has not been cleared, the system resets. This has no use in mode WDT_MODE_RESET.

Definition at line 155 of file wdt.c.

References WDT_TORR.

Referenced by wdt_setup().

Here is the caller graph for this function:

◆ wdt_setup()

void wdt_setup ( enum wdt_modes  mode,
uint8_t  time1,
uint8_t  time2 
)

Sets up the WDT before the call to wdt_enable().

This only prepares the watchdog, it will not start counting until it is enabled.

Parameters
modepassed to wdt_mode()
time1passed to wdt_set_time()
time2passed to wdt_set_time()

Definition at line 38 of file wdt.c.

References wdt_clock_enable(), wdt_mode(), wdt_reset(), and wdt_set_time().

Here is the call graph for this function: