![]() |
MT2523 API Reference
LinkIt SDK v4
|
This section introduces the Watchdog Timer (WDT) APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, enums, structures and functions. More...
This section introduces the Watchdog Timer (WDT) APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, enums, structures and functions.
| Terms | Details |
|---|---|
| NVIC | Nested Vectored Interrupt Controller. NVIC is the interrupt controller of ARM Cortex-M4. For more details, please refer to NVIC introduction in ARM Cortex-M4 Processor Technical Reference Manual. |
| WDT | Watchdog Timer. A watchdog timer is an electronic timer that is used to detect and recover from computer malfunctions. For an introduction to Watchdog timer, please refer to Watchdog timer in Wikipedia. |
The software architecture of WDT driver is shown in the below diagrams.
Functions | |
| hal_wdt_status_t | hal_wdt_init (hal_wdt_config_t *wdt_config) |
| This function is mainly used to initialize the watchdog hardware. More... | |
| hal_wdt_status_t | hal_wdt_deinit (void) |
| De-initialize the watchdog. More... | |
| hal_wdt_status_t | hal_wdt_enable (uint32_t magic) |
| Enable the watchdog timer. More... | |
| hal_wdt_status_t | hal_wdt_disable (uint32_t magic) |
| Disable the watchdog timer. More... | |
| hal_wdt_status_t | hal_wdt_software_reset (void) |
| This function is used to trigger a watchdog reset manually. More... | |
| hal_wdt_status_t | hal_wdt_feed (uint32_t magic) |
| This function is used to feed the watchdog(restart the watchdog timer). More... | |
| hal_wdt_callback_t | hal_wdt_register_callback (hal_wdt_callback_t wdt_callback) |
| Register a callback function while using interrupt mode. More... | |
| hal_wdt_reset_status_t | hal_wdt_get_reset_status (void) |
| Get the status of last watchdog reset/interrupt. More... | |
| bool | hal_wdt_get_enable_status (void) |
| Get the enable status of the WDT. More... | |
| hal_wdt_mode_t | hal_wdt_get_mode (void) |
| Get the current mode of the WDT. More... | |
Modules | |
| Define | |
| Enum | |
| Struct | |
| Typedef | |
| hal_wdt_status_t hal_wdt_deinit | ( | void | ) |
De-initialize the watchdog.
After this function is called, the callback will be cleared and the WDT will be disabled.
| hal_wdt_status_t hal_wdt_disable | ( | uint32_t | magic | ) |
Disable the watchdog timer.
After this function, the watchdog timer will stop counting.
| [in] | magic | is the magic number of this function. Please always use HAL_WDT_DISABLE_MAGIC. |
| hal_wdt_status_t hal_wdt_enable | ( | uint32_t | magic | ) |
Enable the watchdog timer.
After this function call, the watchdog timer will start counting down.
| [in] | magic | is the magic number of this function. Please always use HAL_WDT_ENABLE_MAGIC. |
| hal_wdt_status_t hal_wdt_feed | ( | uint32_t | magic | ) |
This function is used to feed the watchdog(restart the watchdog timer).
To avoid the WDT from expiring, this function should be called regularly.
| [in] | magic | is the magic number of this function. Please always use HAL_WDT_FEED_MAGIC. |
| bool hal_wdt_get_enable_status | ( | void | ) |
Get the enable status of the WDT.
| hal_wdt_mode_t hal_wdt_get_mode | ( | void | ) |
Get the current mode of the WDT.
For more information on reset and interrupt modes, please refer to Supported features in overview.
| hal_wdt_reset_status_t hal_wdt_get_reset_status | ( | void | ) |
Get the status of last watchdog reset/interrupt.
If the WDT failed to be fed in time and has expired, the status will be HAL_WDT_TIMEOUT_RESET. If the software register is set by hal_wdt_software_reset() function, the status will be HAL_WDT_SOFTWARE_RESET. Note that the reset status can be cleared by hal_wdt_init(), hal_wdt_enable() and hal_wdt_disable() functions. It is advised to call this function to get the reset status before hal_wdt_init(), hal_wdt_enable() and hal_wdt_disable() function calls. If you want to preserve the reset status of the last reset, you should call this function to get the reset status before calling hal_wdt_init() and hal_wdt_enable() and hal_wdt_disable().
| hal_wdt_status_t hal_wdt_init | ( | hal_wdt_config_t * | wdt_config | ) |
This function is mainly used to initialize the watchdog hardware.
It is used to set the WDT to either reset or interrupt modes. For more details on reset and interrupt modes, please refer to overview in Supported features. It’s also used to set the timeout value of the watchdog timer. This function will not enable the WDT. To enable WDT, the hal_wdt_enable() must be called.
| [in] | wdt_config | is the init configuration parameter. For more details about this parameter, please refer to hal_wdt_config_t. |
| hal_wdt_callback_t hal_wdt_register_callback | ( | hal_wdt_callback_t | wdt_callback | ) |
Register a callback function while using interrupt mode.
| [in] | wdt_callback | is the function pointer to the callback. This callback is called once the WDT triggers an interrupt in the ISR routine. WDT driver will only keep the last registered wdt_callback. It means if user1 registers callback func1, later, user2 registers callback func2, the driver will only keep callback func2 and return func1 to user2. |
| hal_wdt_status_t hal_wdt_software_reset | ( | void | ) |
This function is used to trigger a watchdog reset manually.
After this function is called, the software reset bit of the hardware status register will be set, you can get this status by using hal_wdt_get_reset_status().