Driver for the WDT (Watchdog Timer).
This driver provides access to the main features of the WDT controller. The Watchdog Timer can be used to prevent system lock-up if the software becomes trapped in a deadlock. It can generate a general reset or a processor reset only.
See Quickstart guide for SAM4L watchdog driver.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the WDT_SAM4L - SAM4L Watchdog Timer. | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the WDT_SAM4L - SAM4L Watchdog Timer. | |
Data Structures | |
struct | wdt_config |
Watchdog Timer configuration structure. More... | |
struct | wdt_dev_inst |
Watchdog Timer driver software instance structure. More... | |
Enumerations | |
enum | wdt_period { WDT_PERIOD_NONE = 0, WDT_PERIOD_MIN_CLK = 7, WDT_PERIOD_256_CLK = 7, WDT_PERIOD_512_CLK = 8, WDT_PERIOD_1024_CLK = 9, WDT_PERIOD_2048_CLK = 10, WDT_PERIOD_4096_CLK = 11, WDT_PERIOD_8192_CLK = 12, WDT_PERIOD_16384_CLK = 13, WDT_PERIOD_32768_CLK = 14, WDT_PERIOD_65536_CLK = 15, WDT_PERIOD_131072_CLK = 16, WDT_PERIOD_262144_CLK = 17, WDT_PERIOD_524288_CLK = 18, WDT_PERIOD_1048576_CLK = 19, WDT_PERIOD_2097152_CLK = 20, WDT_PERIOD_4194304_CLK = 21, WDT_PERIOD_8388608_CLK = 22, WDT_PERIOD_16777216_CLK = 23, WDT_PERIOD_33554432_CLK = 24, WDT_PERIOD_67108864_CLK = 25, WDT_PERIOD_134217728_CLK = 26, WDT_PERIOD_268435456_CLK = 27, WDT_PERIOD_536870912_CLK = 28, WDT_PERIOD_1073741824_CLK = 29, WDT_PERIOD_2147483648_CLK = 30, WDT_PERIOD_4294967296_CLK = 31, WDT_PERIOD_MAX_CLK = 31 } |
Watchdog Timer period configuration enum. More... | |
Functions | |
void | wdt_clear (struct wdt_dev_inst *const dev_inst) |
Restart the watchdog timer. More... | |
static void | wdt_clear_interrupt (struct wdt_dev_inst *const dev_inst) |
Clear the WDT module interrupt status. More... | |
void | wdt_disable (struct wdt_dev_inst *const dev_inst) |
Disable the WDT module. More... | |
static void | wdt_disable_interrupt (struct wdt_dev_inst *const dev_inst) |
Disable the WDT module interrupt. More... | |
void | wdt_enable (struct wdt_dev_inst *const dev_inst) |
Enable the WDT module. More... | |
static void | wdt_enable_interrupt (struct wdt_dev_inst *const dev_inst) |
Enable the WDT module interrupt. More... | |
void | wdt_get_config_defaults (struct wdt_config *const cfg) |
Initializes a Watchdog Timer configuration structure to defaults. More... | |
static uint32_t | wdt_get_interrupt_mask (struct wdt_dev_inst *const dev_inst) |
Get the watchdog interrupt mask. More... | |
static uint32_t | wdt_get_interrupt_status (struct wdt_dev_inst *const dev_inst) |
Get the watchdog interrupt status. More... | |
static uint32_t | wdt_get_status (struct wdt_dev_inst *const dev_inst) |
Get the watchdog timer status. More... | |
bool | wdt_init (struct wdt_dev_inst *const dev_inst, Wdt *const wdt, struct wdt_config *const cfg) |
Initialize the WDT module. More... | |
bool | wdt_reset_mcu (void) |
Reset MCU by generating a WDT reset as soon as possible. More... | |
static void | wdt_set_ctrl (uint32_t ctrl) |
Sets the WatchDog Timer Control register to the ctrl value thanks to the WatchDog Timer key. More... | |
#define | WDT_FIRST_KEY 0x55ul |
Watchdog control register first write keys. More... | |
#define | WDT_SECOND_KEY 0xAAul |
Watchdog control register second write keys. More... | |
#define WDT_FIRST_KEY 0x55ul |
Watchdog control register first write keys.
Referenced by wdt_clear(), and wdt_set_ctrl().
#define WDT_SECOND_KEY 0xAAul |
Watchdog control register second write keys.
Referenced by wdt_clear(), and wdt_set_ctrl().
enum wdt_period |
Watchdog Timer period configuration enum.
Enum for the possible period settings of the Watchdog timer module, for values requiring a period as a number of Watchdog timer clock ticks.
Formula for Ttimeout = 2pow(PSEL+1) / Fclk_cnt Formula for Ttimeban = 2pow(TBAN+1) / Fclk_cnt
void wdt_clear | ( | struct wdt_dev_inst *const | dev_inst | ) |
Restart the watchdog timer.
dev_inst | Device structure pointer. |
References wdt_dev_inst::hw_dev, WDT_FIRST_KEY, and WDT_SECOND_KEY.
|
inlinestatic |
Clear the WDT module interrupt status.
dev_inst | Device structure pointer. |
References wdt_dev_inst::hw_dev.
void wdt_disable | ( | struct wdt_dev_inst *const | dev_inst | ) |
Disable the WDT module.
dev_inst | Device structure pointer. |
References wdt_dev_inst::hw_dev, sysclk_disable_peripheral_clock(), and wdt_set_ctrl().
Referenced by run_wdt_test_all().
|
inlinestatic |
Disable the WDT module interrupt.
dev_inst | Device structure pointer. |
References wdt_dev_inst::hw_dev.
void wdt_enable | ( | struct wdt_dev_inst *const | dev_inst | ) |
Enable the WDT module.
dev_inst | Device structure pointer. |
References wdt_config::always_on, wdt_dev_inst::hw_dev, sysclk_enable_peripheral_clock(), wdt_dev_inst::wdt_cfg, and wdt_set_ctrl().
Referenced by main(), run_wdt_test_all(), and wdt_reset_mcu().
|
inlinestatic |
Enable the WDT module interrupt.
dev_inst | Device structure pointer. |
References wdt_dev_inst::hw_dev.
void wdt_get_config_defaults | ( | struct wdt_config *const | cfg | ) |
Initializes a Watchdog Timer configuration structure to defaults.
Initializes a given Watchdog Timer configuration structure to a set of known default values. This function should be called on all new instances of these configuration structures before being modified by the user application.
The default configuration is as follows:
cfg | Configuration structure to initialize to default values. |
References wdt_config::always_on, Assert, wdt_config::clk_src, wdt_config::disable_flash_cali, wdt_config::disable_wdt_after_reset, wdt_config::timeout_period, WDT_CLK_SRC_RCSYS, wdt_config::wdt_int, WDT_INT_DIS, wdt_config::wdt_mode, WDT_MODE_BASIC, WDT_PERIOD_131072_CLK, WDT_PERIOD_NONE, and wdt_config::window_period.
Referenced by main(), run_wdt_test_all(), and wdt_reset_mcu().
|
inlinestatic |
Get the watchdog interrupt mask.
References wdt_dev_inst::hw_dev.
|
inlinestatic |
Get the watchdog interrupt status.
References wdt_dev_inst::hw_dev.
|
inlinestatic |
Get the watchdog timer status.
References wdt_dev_inst::hw_dev.
bool wdt_init | ( | struct wdt_dev_inst *const | dev_inst, |
Wdt *const | wdt, | ||
struct wdt_config *const | cfg | ||
) |
Initialize the WDT module.
dev_inst | Device structure pointer. |
wdt | Base address of the WDT instance. |
cfg | Pointer to WDT configuration. |
true | if the initialization was successful. |
false | if initialization failed. |
References Assert, wdt_config::clk_src, wdt_config::disable_flash_cali, wdt_config::disable_wdt_after_reset, wdt_dev_inst::hw_dev, sysclk_disable_peripheral_clock(), sysclk_enable_peripheral_clock(), wdt_config::timeout_period, wdt_dev_inst::wdt_cfg, wdt_config::wdt_int, wdt_config::wdt_mode, wdt_set_ctrl(), and wdt_config::window_period.
Referenced by main(), run_wdt_test_all(), and wdt_reset_mcu().
bool wdt_reset_mcu | ( | void | ) |
Reset MCU by generating a WDT reset as soon as possible.
References Disable_global_interrupt, wdt_config::disable_wdt_after_reset, wdt_config::timeout_period, wdt_enable(), wdt_get_config_defaults(), wdt_init(), and WDT_PERIOD_MIN_CLK.
Referenced by main(), and run_wdt_test_all().
|
static |
Sets the WatchDog Timer Control register to the ctrl value thanks to the WatchDog Timer key.
ctrl | Value to set the WatchDog Timer Control register to. |
References div_ceil, OSC_RC32K_NOMINAL_HZ, OSC_RCSYS_NOMINAL_HZ, sysclk_get_cpu_hz(), WDT_CLK_SRC_RCSYS, WDT_FIRST_KEY, and WDT_SECOND_KEY.
Referenced by wdt_disable(), wdt_enable(), and wdt_init().