|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Event Link Controller driver. More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_elc_dim_t : uint8_t { k_ra8_elc_elsr_count = 53U , k_ra8_elc_segr_count = 4U } |
| ELC register-array dimensions. More... | |
Functions | |
| ra8_err_t | ra8_elc_init (void) |
| Reset the ELC register block and enable the controller. | |
| ra8_err_t | ra8_elc_deinit (void) |
| Disable the ELC globally (ELCR.ELCON = 0) and stop the module. | |
| ra8_err_t | ra8_elc_link (uint8_t elsr_index, ra8_elc_event_t event) |
| Route an ELC event to an ELSR slot so the destination peripheral triggers on it. | |
| ra8_err_t | ra8_elc_unlink (uint8_t elsr_index) |
| Clear one ELSR slot so it stops routing any event. | |
| ra8_err_t | ra8_elc_software_trigger (uint8_t event_index) |
| Fire a software event via one of the ELSEGRn registers. | |
| ra8_err_t | ra8_elc_is_enabled (bool *out_enabled) |
| Read ELCR.ELCON to verify the global enable state. | |
Event Link Controller driver.
Owns every write to the ELC register block (ELCR, ELSEGR0..3, ELSR0..52, ELCSAR{A,B,C}, ELCPAR{A,B,C}) at 0x40201000 (HUM Ch 19, p 817..836). Layout cross-verified against FSP R_ELC_Type in R7KA8D2KF_core0.h.
The ELC lets one peripheral's event directly trigger another peripheral's input without CPU involvement. The driver exposes the following operation-named helpers:
Drivers call these helpers; they never touch the ELC registers directly. The NSC veneer surface is ra8_elc_*.
HUM Ch 19.2.3 (p 817) / FSP R_ELC_Type assign 53 ELSR slots (ELSR0..ELSR52), each a 16-bit register at a 4-byte stride that stores one ELC event number (the ELS field is 10 bits wide). The mapping of slot to destination peripheral is fixed and lives in HUM Table 19.2; callers learn it from the peripheral datasheets.
Single-threaded init context only.
Definition in file ra8_elc.h.
| enum ra8_elc_dim_t : uint8_t |
|
nodiscard |
Disable the ELC globally (ELCR.ELCON = 0) and stop the module.
Definition at line 120 of file ra8_elc.c.
References internal_elcr(), k_ra8_mstp_elc, and ra8_mstp_disable().
|
nodiscard |
Reset the ELC register block and enable the controller.
Powers the ELC module via MSTPCRC, clears every ELSR slot (ELSR0..ELSR52), clears ELSEGR0..3, then sets ELCR.ELCON = 1 so the hardware routes events.
Definition at line 91 of file ra8_elc.c.
References internal_elcr(), internal_elsegr(), internal_elsr(), k_ra8_elc_elsegr_step_unlock, k_ra8_elc_elsr_count, k_ra8_elc_segr_count, k_ra8_elcr_bit_elcon, k_ra8_mstp_elc, k_ra8_ok, ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by dtc_arm_setup_or_halt(), dtc_coh_setup_or_halt(), dtc_demo_setup_or_halt(), and internal_setup_or_halt().
|
nodiscard |
Read ELCR.ELCON to verify the global enable state.
| [out] | out_enabled | On success, true if ELCON is set. |
| k_ra8_ok | Value returned. |
| k_ra8_err_null_ptr | out_enabled was NULL. |
Definition at line 164 of file ra8_elc.c.
References internal_elcr(), k_ra8_elcr_bit_elcon, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by main().
|
nodiscard |
Route an ELC event to an ELSR slot so the destination peripheral triggers on it.
| [in] | elsr_index | Slot number 0..k_ra8_elc_elsr_count - 1. |
| [in] | event | ELC event number from ra8_elc_event_t. |
| k_ra8_ok | Slot programmed. |
| k_ra8_err_out_of_range | elsr_index out of range. |
Definition at line 127 of file ra8_elc.c.
References internal_elsr(), k_ra8_elc_elsr_count, k_ra8_err_out_of_range, and k_ra8_ok.
Referenced by internal_setup_or_halt().
|
nodiscard |
Fire a software event via one of the ELSEGRn registers.
Per HUM Ch 19.2.2 "ELSEGRn : Event Link Software Event Generation Register n" (p 817) and FSP R_ELC_SoftwareEventGenerate, the SEG bit is write-protected by WI/WE and must be set with a three-step sequence:
The hardware fires the event exactly once. Useful for testing event-driven paths without waiting for a real peripheral edge.
| [in] | event_index | Software event 0..3 (selects ELSEGR0..3). |
| k_ra8_ok | Three-step sequence written. |
| k_ra8_err_invalid_arg | event_index out of range. |
Definition at line 147 of file ra8_elc.c.
References internal_elsegr(), k_ra8_elc_elsegr_step_arm, k_ra8_elc_elsegr_step_trigger, k_ra8_elc_elsegr_step_unlock, k_ra8_elc_segr_count, k_ra8_err_invalid_arg, and k_ra8_ok.
Referenced by dtc_arm_run_armed(), dtc_arm_run_disarmed(), dtc_coh_run_once(), dtc_demo_run_once(), and main().
|
nodiscard |
Clear one ELSR slot so it stops routing any event.
| [in] | elsr_index | Slot number 0..k_ra8_elc_elsr_count - 1. |
| k_ra8_ok | Slot cleared. |
| k_ra8_err_out_of_range | elsr_index out of range. |
Definition at line 137 of file ra8_elc.c.
References internal_elsr(), k_ra8_elc_elsr_count, k_ra8_err_out_of_range, and k_ra8_ok.