See Quick start guide for WDT driver.
This is a driver for configuring, enabling, disabling and use of the on-chip WDT.
This driver depends on the following modules:
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the Watchdog Timer (WDT). | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the Watchdog Timer (WDT). | |
Macros | |
#define | MASK_PRESCALE_WPD3 0x08 |
Mask for timeout period setting above WDT_TIMEOUT_PERIOD_256KCLK. More... | |
#define | PRESCALE_MASK (WDP3_bm | WDP2_bm | WDP1_bm | WDP0_bm) |
Mask for timeout period setting register. More... | |
#define | WDCE_bm 0x10 /* WDT change enable bit mask. */ |
#define | WDCE_bp 4 /* WDT change enable bit position. */ |
#define | WDE_bm 0x08 /* WDT enable bit mask. */ |
#define | WDE_bp 3 /* WDT enable bit position. */ |
#define | WDIE_bm 0x40 /* WDT timeout interrupt enable bit mask. */ |
#define | WDIE_bp 6 /* WDT timeout interrupt enable bit position. */ |
#define | WDIF_bm 0x80 /* WDT timeout interrupt flag bit mask. */ |
#define | WDIF_bp 7 /* WDT timeout interrupt flag bit position. */ |
#define | WDP0_bm 0x01 /* WDT prescaler 0 Bit mask. */ |
#define | WDP0_bp 0 /* WDT prescaler 0 bit position. */ |
#define | WDP1_bm 0x02 /* WDT prescaler 1 Bit mask. */ |
#define | WDP1_bp 1 /* WDT prescaler 1 bit position. */ |
#define | WDP2_bm 0x04 /* WDT prescaler 2 Bit mask. */ |
#define | WDP2_bp 2 /* WDT prescaler 2 bit position. */ |
#define | WDP3_bm 0x20 /* WDT prescaler 3 Bit mask. */ |
#define | WDP3_bp 5 /* WDT prescaler 3 bit position. */ |
#define | WDRF_bm 0x08 /* WDT Reset flag Bit mask. */ |
#define | WDRF_bp 3 /* WDT Reset flag bit position. */ |
#define | wdt_reset() __asm__ __volatile__ ("wdr"); |
This macro resets (clears/refreshes) the Watchdog Timer. More... | |
Typedefs | |
typedef void(* | wdt_callback_t )(void) |
Interrupt event callback function type. More... | |
Enumerations | |
enum | wdt_mode_select { INTERRUPT_MODE, SYSTEM_RESET_MODE, INTERRUPT_SYSTEM_RESET_MODE } |
enum | wdt_timeout_period { WDT_TIMEOUT_PERIOD_2KCLK = (0x00), WDT_TIMEOUT_PERIOD_4KCLK = (0x01), WDT_TIMEOUT_PERIOD_8KCLK = (0x02), WDT_TIMEOUT_PERIOD_16KCLK = (0x03), WDT_TIMEOUT_PERIOD_32KCLK = (0x04), WDT_TIMEOUT_PERIOD_64KCLK = (0x05), WDT_TIMEOUT_PERIOD_128KCLK = (0x06), WDT_TIMEOUT_PERIOD_256KCLK = (0x07), WDT_TIMEOUT_PERIOD_512KCLK = (0x08), WDT_TIMEOUT_PERIOD_1024KCLK = (0x09) } |
Functions | |
void | wdt_disable (void) |
Disable Watchdog. More... | |
void | wdt_enable (enum wdt_mode_select mode) |
Enable WDT at different modes. More... | |
static enum wdt_timeout_period | wdt_get_timeout_period (void) |
static bool | wdt_interrupt_mode_enabled (void) |
checks whether the Watchdog is enabled for interrupt mode More... | |
static void | wdt_reset_flag_clear (void) |
static bool | wdt_reset_flag_is_set (void) |
static bool | wdt_reset_interrupt_mode_enabled (void) |
checks whether the Watchdog is enabled for system reset and interrupt mode More... | |
void | wdt_reset_mcu (void) |
void | wdt_set_interrupt_callback (wdt_callback_t callback) |
Set WDT timer overflow interrupt callback function. More... | |
void | wdt_set_timeout_period (enum wdt_timeout_period to_period) |
Set Watchdog timeout period. More... | |
static bool | wdt_system_reset_mode_enabled (void) |
checks whether the Watchdog is enabled for system reset mode More... | |
static void | wdt_timeout_interrupt_flag_clear (void) |
Clear Watchdog timeout interrupt flag. More... | |
static bool | wdt_timeout_interrupt_flag_is_set (void) |
Gets the status of Watchdog timeout interrupt flag. More... | |
#define MASK_PRESCALE_WPD3 0x08 |
Mask for timeout period setting above WDT_TIMEOUT_PERIOD_256KCLK.
Referenced by wdt_set_timeout_period().
Mask for timeout period setting register.
Referenced by wdt_get_timeout_period().
#define WDCE_bm 0x10 /* WDT change enable bit mask. */ |
#define WDCE_bp 4 /* WDT change enable bit position. */ |
#define WDE_bm 0x08 /* WDT enable bit mask. */ |
#define WDE_bp 3 /* WDT enable bit position. */ |
#define WDIE_bm 0x40 /* WDT timeout interrupt enable bit mask. */ |
#define WDIE_bp 6 /* WDT timeout interrupt enable bit position. */ |
#define WDIF_bm 0x80 /* WDT timeout interrupt flag bit mask. */ |
Referenced by wdt_timeout_interrupt_flag_clear(), and wdt_timeout_interrupt_flag_is_set().
#define WDIF_bp 7 /* WDT timeout interrupt flag bit position. */ |
#define WDP0_bm 0x01 /* WDT prescaler 0 Bit mask. */ |
#define WDP0_bp 0 /* WDT prescaler 0 bit position. */ |
#define WDP1_bm 0x02 /* WDT prescaler 1 Bit mask. */ |
#define WDP1_bp 1 /* WDT prescaler 1 bit position. */ |
#define WDP2_bm 0x04 /* WDT prescaler 2 Bit mask. */ |
#define WDP2_bp 2 /* WDT prescaler 2 bit position. */ |
#define WDP3_bm 0x20 /* WDT prescaler 3 Bit mask. */ |
#define WDP3_bp 5 /* WDT prescaler 3 bit position. */ |
#define WDRF_bm 0x08 /* WDT Reset flag Bit mask. */ |
Referenced by wdt_reset_flag_clear(), and wdt_reset_flag_is_set().
#define WDRF_bp 3 /* WDT Reset flag bit position. */ |
#define wdt_reset | ( | ) | __asm__ __volatile__ ("wdr"); |
This macro resets (clears/refreshes) the Watchdog Timer.
Referenced by main(), run_interrupt_reset_test(), wdt_disable(), wdt_enable(), wdt_reset_mcu(), and wdt_set_timeout_period().
typedef void(* wdt_callback_t)(void) |
Interrupt event callback function type.
The interrupt handler can be configured to do a function callback, the callback function must match the wdt_callback_t type.
enum wdt_mode_select |
enum wdt_timeout_period |
void wdt_disable | ( | void | ) |
Disable Watchdog.
This function disables the WDT without changing period settings. This function is written in asm where ever the time is critical
References cpu_irq_restore(), cpu_irq_save(), wdt_reset, and wdt_reset_flag_clear().
Referenced by main(), run_interrupt_reset_test(), run_wdt_interrupt_test(), and wdt_reset_mode_enable().
void wdt_enable | ( | enum wdt_mode_select | mode | ) |
Enable WDT at different modes.
This function allows WDT to enable. Using this function we can select either Interrupt Mode or System reset mode or Interrupt and System reset mode. This function is written in asm where ever the time is critical
mode | WDT timer mode selection |
References cpu_irq_restore(), cpu_irq_save(), INTERRUPT_MODE, INTERRUPT_SYSTEM_RESET_MODE, SYSTEM_RESET_MODE, wdt_reset, and wdt_reset_flag_clear().
Referenced by main(), run_interrupt_reset_test(), run_wdt_interrupt_test(), wdt_reset_mcu(), and wdt_reset_mode_enable().
|
inlinestatic |
Get Watchdog timeout period.
This function gets the coded field of the WDT timeout period.
References PRESCALE_MASK, WDT_TIMEOUT_PERIOD_1024KCLK, and WDT_TIMEOUT_PERIOD_512KCLK.
Referenced by main(), run_interrupt_reset_test(), and run_wdt_interrupt_test().
|
inlinestatic |
checks whether the Watchdog is enabled for interrupt mode
References WDE_bm, and WDIE_bm.
Referenced by run_wdt_interrupt_test().
|
inlinestatic |
Clear Watchdog reset flag.
This function clears the WDT flag.
none |
References WDRF_bm.
Referenced by wdt_disable(), and wdt_enable().
|
inlinestatic |
Gets the status of Watchdog reset flag.
This function checks the WDT reset flag is set
false | WDT reset flag is not set true reset flag is set |
References WDRF_bm.
|
inlinestatic |
checks whether the Watchdog is enabled for system reset and interrupt mode
References WDE_bm, and WDIE_bm.
Referenced by run_interrupt_reset_test().
void wdt_reset_mcu | ( | void | ) |
Reset MCU via Watchdog.
This function generates an hardware microcontroller reset using the WDT.
The function loads enables the WDT in system reset mode.
References SYSTEM_RESET_MODE, wdt_enable(), wdt_reset, wdt_set_timeout_period(), and WDT_TIMEOUT_PERIOD_2KCLK.
Referenced by main().
void wdt_set_interrupt_callback | ( | wdt_callback_t | callback | ) |
Set WDT timer overflow interrupt callback function.
This function allows the caller to set and change the interrupt callback function. Without setting a callback function the interrupt handler in the driver will only clear the interrupt flags.
callback | Reference to a callback function |
References wdt_timer_callback.
Referenced by main(), run_interrupt_reset_test(), and run_wdt_interrupt_test().
void wdt_set_timeout_period | ( | enum wdt_timeout_period | to_period | ) |
Set Watchdog timeout period.
This function sets the coded field of the WDT timeout period. This function is written in asm where ever the time is critical
to_period | WDT timeout period |
References cpu_irq_restore(), cpu_irq_save(), MASK_PRESCALE_WPD3, and wdt_reset.
Referenced by main(), run_interrupt_reset_test(), run_wdt_interrupt_test(), wdt_reset_mcu(), and wdt_reset_mode_enable().
|
inlinestatic |
|
inlinestatic |
Clear Watchdog timeout interrupt flag.
This function clears the WDT interrupt flag.
none |
References WDIF_bm.
Referenced by run_interrupt_reset_test().
|
inlinestatic |
Gets the status of Watchdog timeout interrupt flag.
This function checks whether the Watchdog timeout interrupt flag is set
References WDIF_bm.
Referenced by run_interrupt_reset_test().