|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Independent Watchdog Timer driver implementation. More...
#include "ra8_iwdt.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_iwdt_regs.h"#include "ra8_log.h"Go to the source code of this file.
Data Structures | |
| struct | ra8_iwdt_state_t |
| Driver-wide runtime state. More... | |
Enumerations | |
| enum | ra8_iwdt_mask_t : uint16_t { k_ra8_iwdt_status_all } |
| Combined IWDTSR flag mask (UNDFF | REFEF). More... | |
Functions | |
| ra8_err_t | ra8_iwdt_init (void) |
| Prepare the IWDT driver layer. | |
| void | ra8_iwdt_refresh_deferred (void) |
| Refresh the IWDT counter. | |
| ra8_err_t | ra8_iwdt_get_status (uint16_t *out_mask) |
| Read the IWDTSR status bits (UNDFF / REFEF only). | |
| ra8_err_t | ra8_iwdt_clear_status (void) |
| Clear the underflow / refresh-error flags via IWDTSR write. | |
| ra8_err_t | ra8_iwdt_get_counter (uint16_t *out_counter) |
| Read the live 14-bit IWDT down-counter (CNTVAL). | |
| ra8_err_t | ra8_iwdt_attach_handler (ra8_iwdt_event_fn_t fn, void *ctx) |
| Attach a handler for the IWDT NMI event. | |
| void | ra8_iwdt_dispatch (void) |
| Dispatch an IWDT NMI event – snapshot status + fire callback. | |
Variables | |
| static const char * | s_tag = "IWDT" |
| static ra8_iwdt_state_t | s_iwdt_state |
Independent Watchdog Timer driver implementation.
The IWDT configuration (period, window, reset-vs-interrupt output) lives in the OFS0 option-setting register, which is programmed at flash time and locked once the boot ROM hands off. RA8D2 supports auto-start mode only (FSP IWDT_PRV_REGISTER_START_MODE is never set on this part), so this driver covers only the runtime surface: refresh, status read/clear, live counter readout, and NMI dispatch. Every register touch below carries a HUM Ch 28 citation.
Mapping to FSP r_iwdt API:
Definition in file ra8_iwdt.c.
| enum ra8_iwdt_mask_t : uint16_t |
Combined IWDTSR flag mask (UNDFF | REFEF).
| Enumerator | |
|---|---|
| k_ra8_iwdt_status_all | RA8 iwdt status all. |
Definition at line 55 of file ra8_iwdt.c.
|
nodiscard |
Attach a handler for the IWDT NMI event.
| [in] | fn | Callback fired on dispatch. |
| [in] | ctx | Context forwarded to the callback. |
Definition at line 133 of file ra8_iwdt.c.
References k_ra8_ok, and s_iwdt_state.
|
nodiscard |
Clear the underflow / refresh-error flags via IWDTSR write.
Mirrors FSP R_IWDT_StatusClear – writes a 0 to the relevant bit and re-reads until the bit clears (the silicon takes one IWDTCLK cycle to drop the flag).
Definition at line 110 of file ra8_iwdt.c.
References r_iwdt_regs_t::IWDTSR, k_ra8_iwdt_status_all, k_ra8_ok, and ra8_iwdt().
Referenced by main().
| void ra8_iwdt_dispatch | ( | void | ) |
Dispatch an IWDT NMI event – snapshot status + fire callback.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
Definition at line 141 of file ra8_iwdt.c.
References r_iwdt_regs_t::IWDTSR, k_ra8_iwdt_status_all, ra8_iwdt(), and s_iwdt_state.
|
nodiscard |
Read the live 14-bit IWDT down-counter (CNTVAL).
Mirrors FSP R_IWDT_CounterGet – reads IWDTSR & 0x3FFF.
| [out] | out_counter | Receives the 14-bit counter value (0..0x3FFF). |
| k_ra8_ok | *out_counter populated. |
| k_ra8_err_null_ptr | out_counter == NULL. |
Definition at line 124 of file ra8_iwdt.c.
References k_ra8_iwdt_sr_cnt_mask, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_iwdt(), and s_tag.
Referenced by main().
|
nodiscard |
Read the IWDTSR status bits (UNDFF / REFEF only).
| [out] | out_mask | Receives OR of k_ra8_iwdt_status_*. |
Definition at line 100 of file ra8_iwdt.c.
References k_ra8_iwdt_status_all, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_iwdt(), and s_tag.
|
nodiscard |
Prepare the IWDT driver layer.
Initialise the IWDT driver layer.
No-op in v0.x: the IWDT is armed by OFS0 at reset, so there is nothing for the driver to programme. We just log that we are alive.
Definition at line 69 of file ra8_iwdt.c.
References k_ra8_ok, ra8_log_info, and s_tag.
Referenced by internal_wdt_demo_setup_or_halt(), and main().
| void ra8_iwdt_refresh_deferred | ( | void | ) |
Refresh the IWDT counter.
Refresh the IWDT counter via a wrapper function.
Thin wrapper around the inline ra8_iwdt_refresh() helper in the register header. Provided as an extern so other compilation units do not have to pull in ra8_iwdt_regs.h. Mirrors FSP R_IWDT_Refresh (which writes 0x00 then 0xFF to IWDTRR).
Definition at line 94 of file ra8_iwdt.c.
References ra8_iwdt_refresh().
Referenced by main().
|
static |
Definition at line 49 of file ra8_iwdt.c.
Referenced by ra8_iwdt_attach_handler(), and ra8_iwdt_dispatch().
|
static |
Definition at line 38 of file ra8_iwdt.c.