libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
SWM050 WDT API. More...
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... | |
SWM050 WDT API.
LGPL License Terms libopencm3 License
void wdt_clear_int | ( | void | ) |
Clears the WDT's interrupt.
Definition at line 101 of file wdt.c.
References WDT_EOI.
void wdt_clock_enable | ( | bool | en | ) |
Enables the WDT's clock.
This only enables the clock to the peripheral.
en | True 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().
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.
en | enable |
Definition at line 55 of file wdt.c.
References WDT_CR.
uint32_t wdt_get_value | ( | void | ) |
bool wdt_int_status | ( | void | ) |
Gets the WDT's interrupt status.
Definition at line 92 of file wdt.c.
References WDT_STAT.
void wdt_mode | ( | enum wdt_modes | mode | ) |
Sets the WDT's mode of operation.
mode | The mode of operation Watchdog mode |
Definition at line 68 of file wdt.c.
References WDT_CR, and WDT_MODE_INT.
Referenced by wdt_setup().
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().
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.
time1 | The 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. |
time2 | The 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().
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.
mode | passed to wdt_mode() |
time1 | passed to wdt_set_time() |
time2 | passed to wdt_set_time() |
Definition at line 38 of file wdt.c.
References wdt_clock_enable(), wdt_mode(), wdt_reset(), and wdt_set_time().