28static const char*
s_tag =
"ISR";
40typedef enum : uintptr_t {
51typedef enum : uint16_t {
85 "ra8_isr slot pool must equal the ICU IELSR capacity (see #237)");
112 volatile uint32_t* iser =
114 *iser = (uint32_t)1UL << bit;
133 volatile uint32_t* icer =
135 *icer = (uint32_t)1UL << bit;
154 volatile uint32_t* icpr =
156 *icpr = (uint32_t)1UL << bit;
198 if (ielsr !=
nullptr) {
219 if (ielsr !=
nullptr) {
234 s_slots[slot].handler =
nullptr;
318 s_slots[slot].handler = handler;
321 s_slots[slot].priority = priority;
329 if (out_slot !=
nullptr) {
354 s_slots[slot].handler =
nullptr;
368 void*
const ctx =
s_slots[slot].ctx;
384 if (ielsr !=
nullptr) {
389 if (handler !=
nullptr) {
403 s_slots[slot].priority = priority;
424 if (ielsr ==
nullptr) {
432 const uint32_t cur = *ielsr;
433 const uint32_t next =
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
ra8_elc_event_t
Partial list of ELC events (populate as drivers need them).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_exists
Item already exists – cannot create again.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Shared CPU-intrinsic seam for the HAL drivers (host/target split).
static void ra8_hw_irq_enable(void)
Enable maskable interrupts (clear PRIMASK).
static void ra8_hw_irq_disable(void)
Disable maskable interrupts (set PRIMASK).
Interrupt Control Unit (ICU) register layout for the Renesas RA8D2.
@ k_ra8_icu_num_ielsr
IELSR slot count on RA8D2 (FSP R_ICU_Type).
@ k_ra8_ielsr_ir_bit
IR interrupt status flag (W0C).
static volatile uint32_t * ra8_icu_ielsr(uint16_t index)
Get pointer to IELSR register N.
@ k_ra8_ielsr_dtce_mask
DTCE bit mask.
@ k_ra8_ielsr_iels_mask
IELS field mask (10 bits).
void ra8_isr_globals_disable(void)
Globally mask maskable interrupts (PRIMASK = 1).
ra8_err_t ra8_isr_init(void)
Initialise the ra8_isr table.
ra8_err_t ra8_isr_lookup_slot(ra8_elc_event_t event, uint16_t *out_slot)
Look up the slot allocated to a registered event.
ra8_err_t ra8_isr_set_dtc(uint16_t slot, bool enable)
Enable or disable DTC activation on a registered IELSR slot.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
static void internal_nvic_clear_pending(uint16_t n)
Clear pending flag on NVIC line n.
static uint16_t internal_find_free(void)
Find the first free dispatch-table slot.
static void internal_nvic_set_priority(uint16_t n, uint8_t prio)
Set NVIC priority byte for line n.
static void internal_ielsr_clear(uint16_t slot)
Clear an IELSR slot (set event = 0, IR bit clear).
static void internal_ielsr_write(uint16_t slot, ra8_elc_event_t event)
Write the event number into an IELSR slot.
ra8_err_t ra8_isr_register(ra8_elc_event_t event, ra8_isr_handler_t handler, void *ctx, uint8_t priority, uint16_t *out_slot)
Allocate an IELSR slot for an ELC event + handler.
static ra8_isr_slot_t s_slots[k_ra8_isr_slot_count]
Per-slot dispatch table.
ra8_err_t ra8_isr_set_priority(ra8_elc_event_t event, uint8_t priority)
Change the NVIC priority of a registered slot.
static void internal_nvic_enable(uint16_t n)
Enable NVIC line n.
ra8_err_t ra8_isr_unregister(ra8_elc_event_t event)
Release a previously-allocated IELSR slot.
ra8_isr_nvic_t
NVIC register-base offsets used by the dispatcher.
@ k_ra8_isr_nvic_ipr_base
IPR base: priority bytes.
@ k_ra8_isr_nvic_icer_base
ICER base: disables.
@ k_ra8_isr_nvic_iser_base
ISER base: enables.
@ k_ra8_isr_nvic_icpr_base
ICPR base: clear pending.
static uint16_t internal_find_event(ra8_elc_event_t event)
Search the dispatch table for a previously-registered event.
void ra8_isr_dispatch(uint16_t slot)
Invoke the handler stored in dispatch-table slot slot.
ra8_isr_nvic_layout_t
Bit-per-word geometry of ISER / ICER arrays.
@ k_ra8_isr_nvic_prio_shift
Upper 4 priority bits used.
@ k_ra8_isr_nvic_bits_per_word
32 bits per ISER/ICER entry.
static void internal_nvic_disable(uint16_t n)
Disable NVIC line n.
NVIC + ICU IELSR allocator.
@ k_ra8_isr_slot_none
RA8 ISR slot none.
void(* ra8_isr_handler_t)(void *ctx)
Driver-supplied callback invoked on interrupt entry.
@ k_ra8_isr_prio_max
Lowest priority.
@ k_ra8_isr_slot_count
One slot per ICU IELSR route (= k_ra8_icu_num_ielsr).
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
#define ra8_log_error(tag, message)
RA8 log error.
Dispatch-table entry for one IELSR slot.
ra8_elc_event_t event
Event mapped to this slot.
ra8_isr_handler_t handler
Driver callback, NULL if free.
void * ctx
Context passed to handler.
bool in_use
True when allocated.
uint8_t priority
Last-set NVIC priority.