![]() |
RAFW Flexible Software Package Documentation
Release v2.0.1
|
|
Functions | |
| fsp_err_t | R_WDOG_W_Open (wdt_ctrl_t *const p_ctrl, wdt_cfg_t const *const p_cfg) |
| fsp_err_t | R_WDOG_W_TimeoutGet (wdt_ctrl_t *const p_ctrl, wdt_timeout_values_t *const p_timeout) |
| fsp_err_t | R_WDOG_W_TimeoutSet (wdt_ctrl_t *p_ctrl, uint32_t timeout) |
| fsp_err_t | R_WDOG_W_Refresh (wdt_ctrl_t *const p_ctrl) |
| fsp_err_t | R_WDOG_W_StatusGet (wdt_ctrl_t *const p_ctrl, wdt_status_t *const p_status) |
| fsp_err_t | R_WDOG_W_StatusClear (wdt_ctrl_t *const p_ctrl, const wdt_status_t status) |
| fsp_err_t | R_WDOG_W_CounterGet (wdt_ctrl_t *const p_ctrl, uint32_t *const p_count) |
| fsp_err_t | R_WDOG_W_CallbackSet (wdt_ctrl_t *const p_ctrl, void(*p_callback)(wdt_callback_args_t *), void *const p_context, wdt_callback_args_t *const p_callback_memory) |
| fsp_err_t | R_WDOG_W_Freeze (wdt_ctrl_t *const p_ctrl, bool freeze) |
Driver for the WDOG peripheral on RA for Wireless (RAFW) MCUs. This module implements the WDT Interface.
The watchdog timer is used to recover from unexpected errors in an application. The watchdog timer must be refreshed periodically before underflow. If the watchdog timer count is allowed to underflow, the WDOG resets the device. The WDT also provides a option to generate NMI prior to reset.
The WDT HAL module has the following key features:
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| NMI Support |
| Enabled | If enabled, code for NMI support is included in the build. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| Name | Name must be a valid C symbol | g_wdog_w0 | Module name. |
| Timeout | Timeout value in cycles, must be a non-negative integer greater than 1. | 8191 | Select the watchdog timeout in cycles. |
| Window start | Value must be a non-negative integer. | ${enum.driver.watchdog.window_start_default} | Select the watchdog window start in cycles. |
| Window end | Value must be a non-negative integer. | 0 | Select the watchdog window end in cycles (0-(window_start-1)). |
| Reset Control |
| Reset Output | Select what happens when the watchdog timer expires. |
| NMI Callback | Name must be a valid C symbol | NULL | A user callback function must be provided if the WDOG_W is configured to generate an NMI when the timer underflows or a refresh error occurs. If this callback function is provided, it will be called from the NMI handler each time the watchdog triggers. |
The WDOG clock is based on a MCU-specific 32KHz clock. The frequency is divided by 320 (fixed). Therefore, the WDOG is clocked at 100 Hz.
This module does not use I/O pins.
The watchdog timer uses the NMI, which is enabled by default. No special configuration is required. When the NMI is triggered, the callback function registered during open is called.
The WDOG will be expired in 81.91 sec in default as detailed below.
WDOG clock frequency = 100 Hz Timeout period = 8191 cycles(default) Cycle time = 1 / 100 Hz = 10 ms Timeout = 10 ms x 8191 cycles = 81.91 sec
Developers should be aware of the following limitations when using the WDOG:
This is a basic example of minimal use of the WDOG in an application.
This example gives an example callback to handle an NMI generated by an underflow.
Data Structures | |
| struct | wdog_w_instance_ctrl_t |
| struct | wdog_w_extended_cfg_t |
Enumerations | |
| enum | wdog_w_clk_src_t |
| struct wdog_w_instance_ctrl_t |
WDOG_W private control block. DO NOT MODIFY. Initialization occurs when wdt_api_t::open is called.
| struct wdog_w_extended_cfg_t |
WATCHDOG extended Configuration
| Data Fields | ||
|---|---|---|
| wdog_w_clk_src_t | wdt_clk_src | CLock source setting for WDT. |
| enum wdog_w_clk_src_t |
| fsp_err_t R_WDOG_W_Open | ( | wdt_ctrl_t *const | p_ctrl, |
| wdt_cfg_t const *const | p_cfg | ||
| ) |
Configure the watchdog timer. Implements wdt_api_t::open.
This function should only be called once. Subsequent calls will have no effect.
Example:
| FSP_SUCCESS | WDT successfully configured. |
| FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
| FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
| FSP_ERR_INVALID_STATE | The security state of the NMI and the module do not match. |
| fsp_err_t R_WDOG_W_TimeoutGet | ( | wdt_ctrl_t *const | p_ctrl, |
| wdt_timeout_values_t *const | p_timeout | ||
| ) |
Read timeout information for the watchdog timer. Implements wdt_api_t::timeoutGet.
| FSP_SUCCESS | WDT timeout information retrieved successfully. |
| FSP_ERR_ASSERTION | Null Pointer. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| fsp_err_t R_WDOG_W_TimeoutSet | ( | wdt_ctrl_t * | p_ctrl, |
| uint32_t | timeout | ||
| ) |
Set timeout value.
| FSP_SUCCESS | WDT timeout value is set successfully. |
| FSP_ERR_ASSERTION | Null Pointer. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| FSP_ERR_INVALID_SIZE | WDT timeout value is out of range. |
| fsp_err_t R_WDOG_W_Refresh | ( | wdt_ctrl_t *const | p_ctrl | ) |
Refresh the watchdog timer. Implements wdt_api_t::refresh.
In addition to refreshing the watchdog counter this function can be used to start the counter.
Example:
| FSP_SUCCESS | WDT successfully refreshed. |
| FSP_ERR_ASSERTION | p_ctrl is NULL. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| FSP_ERR_IN_USE | The watchdog is busy writing and the count value cannot be refreshed. |
| fsp_err_t R_WDOG_W_StatusGet | ( | wdt_ctrl_t *const | p_ctrl, |
| wdt_status_t *const | p_status | ||
| ) |
Read the WDT status flags. Implements wdt_api_t::statusGet.
Indicates both status and error conditions.
Example:
| FSP_SUCCESS | WDT status successfully read. |
| FSP_ERR_ASSERTION | Null pointer as a parameter. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| FSP_ERR_UNSUPPORTED | This function is only valid if the watchdog generates an NMI when an error occurs. |
| fsp_err_t R_WDOG_W_StatusClear | ( | wdt_ctrl_t *const | p_ctrl, |
| const wdt_status_t | status | ||
| ) |
Clear the WDT status and error flags. Implements wdt_api_t::statusClear.
| FSP_ERR_UNSUPPORTED | This function is not supported. |
| fsp_err_t R_WDOG_W_CounterGet | ( | wdt_ctrl_t *const | p_ctrl, |
| uint32_t *const | p_count | ||
| ) |
Read the current count value of the WDT. Implements wdt_api_t::counterGet.
Example:
| FSP_SUCCESS | WDT current count successfully read. |
| FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| FSP_ERR_IN_USE | The watchdog is busy writing and the count value cannot be read. |
| fsp_err_t R_WDOG_W_CallbackSet | ( | wdt_ctrl_t *const | p_ctrl, |
| void(*)(wdt_callback_args_t *) | p_callback, | ||
| void *const | p_context, | ||
| wdt_callback_args_t *const | p_callback_memory | ||
| ) |
Updates the user callback and has option of providing memory for callback structure. Implements wdt_api_t::callbackSet
| FSP_SUCCESS | Callback updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
| fsp_err_t R_WDOG_W_Freeze | ( | wdt_ctrl_t *const | p_ctrl, |
| bool | freeze | ||
| ) |
Freeze/unfreeze the watchdog timer.
Example:
| FSP_SUCCESS | Freeze watchdog timer successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_NOT_ENABLED | Freezing watchdog timer is not allowed. |