|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Independent Watchdog driver header. More...
Go to the source code of this file.
Typedefs | |
| typedef void(* | ra8_iwdt_event_fn_t) (void *ctx, uint16_t status_mask) |
| IWDT NMI underflow event callback. | |
Enumerations | |
| enum | ra8_iwdt_status_mask_t : uint16_t { k_ra8_iwdt_status_none = 0x0000U , k_ra8_iwdt_status_underflow = 0x4000U , k_ra8_iwdt_status_refresh = 0x8000U } |
| IWDTSR status bits exposed to callers. More... | |
Functions | |
| ra8_err_t | ra8_iwdt_init (void) |
| Initialise the IWDT driver layer. | |
| void | ra8_iwdt_refresh_deferred (void) |
| Refresh the IWDT counter via a wrapper function. | |
| 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. | |
Independent Watchdog driver header.
Extends the refresh stub with: status reporting, live counter read, and NMI underflow attach / dispatch. Period + window + reset-vs-NMI choice still come from the OFS0 option-setting register at flash- write time; the IWDT cannot be reconfigured at runtime on the RA8D2 (auto-start only – the FSP IWDT_PRV_REGISTER_START_MODE path is not supported on this part).
The driver mirrors the runtime surface of the FSP r_iwdt driver:
Definition in file ra8_iwdt.h.
| typedef void(* ra8_iwdt_event_fn_t) (void *ctx, uint16_t status_mask) |
IWDT NMI underflow event callback.
| [in] | ctx | Caller context. |
| [in] | status_mask | Latched IWDTSR bits (UNDFF / REFEF). |
Definition at line 59 of file ra8_iwdt.h.
| enum ra8_iwdt_status_mask_t : uint16_t |
IWDTSR status bits exposed to callers.
Mirrors HUM Ch 28.2.2 "IWDTSR" bit layout (UNDFF bit 14, REFEF bit 15) and FSP IWDT_PRV_STATUS_START_BIT semantics. The CNTVAL counter occupies the lower 14 bits and is exposed through ra8_iwdt_get_counter instead.
| Enumerator | |
|---|---|
| k_ra8_iwdt_status_none | RA8 iwdt status none. |
| k_ra8_iwdt_status_underflow | IWDTSR.UNDFF bit 14. |
| k_ra8_iwdt_status_refresh | IWDTSR.REFEF bit 15. |
Definition at line 47 of file ra8_iwdt.h.
|
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 |
Initialise 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 via a wrapper function.
Equivalent to FSP R_IWDT_Refresh: writes the mandatory 0x00 then 0xFF sequence to IWDTRR. A single write does NOT refresh – both bytes are required.
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().