70static const char*
s_tag =
"dtc_demo";
73typedef enum : uint32_t {
82typedef enum : uint8_t {
97typedef enum : uint16_t {
102typedef enum : uint8_t {
114typedef enum : uint8_t {
128typedef enum : uint8_t {
145typedef enum : uint16_t {
160typedef enum : uint32_t {
167typedef enum : uint32_t {
172 "CRA=0x0000 encodes a 256-unit block; buffer must be 256 words");
243 __asm__
volatile(
"wfi");
287 uint32_t cpuclk0_hz = 0U;
386 if (slot_reg ==
nullptr) {
391 const uint32_t cur = *slot_reg;
520 const uint8_t good = (err ==
k_ra8_ok && ok != 0U) ? 1U : 0U;
void main(void)
Secure fallback main entry point.
volatile uint32_t g_dtc_isr_count
Count of DTC-complete callbacks fanned through the HAL dispatch.
static uint32_t s_dtc_vt[k_dtc_arm_vt_entries]
DTC vector table – one 4-byte TI start address per IELSR slot.
static r_dtc_xfer_info_t s_dtc_ti
The 16-byte Transfer Information block the DTC reads each pass.
volatile uint32_t g_dtc_heartbeat
Bumps once per main-loop pass – liveness for headless probes.
static uint32_t s_src[k_dtc_arm_buf_words]
Source / destination buffers (32-bit aligned by element type).
static uint16_t s_dtc_slot
IELSR slot allocated for the DTC activation = DTC vector number.
volatile uint32_t g_dtc_activations
Count of ELC software-event triggers issued (armed + disarmed).
static uint32_t s_dst[k_dtc_arm_buf_words]
dtc_demo_byte_t
Single-byte constants.
@ k_dtc_demo_byte_sh
Source-pattern shift (i ^ (i >> 8)).
@ k_dtc_demo_isr_prio
NVIC priority for the DTC-complete slot.
static const uint8_t k_dtc_demo_ok_msg[]
Output line tags.
dtc_mr_field_t
DTC Transfer-Information mode-bit field values.
@ k_dtc_sm_inc
MRA.SM[3:2] = 10b: increment SAR.
@ k_dtc_md_block
MRA.MD[7:6] = 10b: block transfer mode.
@ k_dtc_sz_word
MRA.SZ[5:4] = 10b: 32-bit word units.
@ k_dtc_dm_inc
MRB.DM[3:2] = 10b: increment DAR.
dtc_demo_config_t
Compile-time settings.
@ k_dtc_demo_poll_limit
Bounded wait for the block to land.
@ k_dtc_demo_buf_words
32-bit words per buffer / block.
@ k_dtc_demo_period_ms
Delay between copy passes.
@ k_dtc_demo_buf_bytes
Bytes copied per pass (256 x 4).
@ k_dtc_demo_baud
SCI8 baud rate.
dtc_vt_geom_t
DTC vector-table geometry.
@ k_dtc_ti_align
TI start address multiple of 16.
@ k_dtc_vt_entries
One pointer per IELSR slot 0..95.
@ k_dtc_vt_align
DTCVBR 1 KB alignment (HUM 18.2.11).
static uint8_t dtc_demo_verify(void)
Verify that s_dst matches s_src element-by-element.
static void dtc_demo_setup_or_halt(void)
Bring CGC + SysTick + ISR + ELC + SCI8 + LEDs + MSTP up.
static void dtc_demo_swevt_isr(void *ctx)
IELSR-slot ISR for the DTC-complete interrupt.
static void dtc_demo_program_ti(void)
Write the 16-byte TI block describing the block copy.
static const uint8_t k_dtc_demo_bad_msg[]
dtc_demo_event_t
ELC software event 0 -> ICU event number.
@ k_dtc_demo_event_swevt0
ELC software event 0 (HUM Table 19.3).
dtc_count_t
DTC count-register values for one 256-word block.
@ k_dtc_cra_block_256
CRAH = CRAL = 0 => 256-unit block.
@ k_dtc_crb_one_block
CRB = 1 => one block per pass.
volatile uint32_t g_dtc_match
1 when the destination matched the source after the last pass.
static void dtc_demo_complete_cb(void *ctx, uint16_t status)
DTC completion callback (fanned out by ra8_dtc_dispatch).
static ra8_err_t dtc_demo_arm_slot(void)
Re-arm DTC activation on the slot and clear any latched IR.
volatile uint32_t g_dtc_bytes
Bytes the DTC moved on the last successful pass (0 on failure).
static void dtc_demo_bringup_or_halt(void)
Initialise the DTC, allocate its activation slot, and enable it.
static ra8_err_t dtc_demo_run_once(uint8_t *out_ok)
Program + activate one DTC block copy and wait for completion.
dtc_mr_pos_t
Bit positions inside the DTC TI MR word.
@ k_dtc_mra_sz_pos
MRA.SZ field position.
@ k_dtc_mrb_byte_pos
MRB byte offset within MR.
@ k_dtc_mra_sm_pos
MRA.SM field position.
@ k_dtc_mra_md_pos
MRA.MD field position.
@ k_dtc_mrb_dm_pos
MRB.DM field position.
@ k_dtc_mra_byte_pos
MRA byte offset within MR.
static void dtc_demo_fill_buffers(void)
Fill s_src with a deterministic pattern and clear s_dst.
dtc_cra_t
CRA=0x0000 encodes a full 256-unit block.
@ k_dtc_cra_block_units
Units per block when CRAH/CRAL = 0.
static void dtc_demo_panic_halt(void)
Park forever after a fatal init failure.
dtc_demo_swevt_t
ELSEGRn index fired by ra8_elc_software_trigger.
@ k_dtc_demo_swevt_index
ELSEGR0 -> ELC_SWEVT0 (0x0CC).
static const char * s_tag
Logging / check tag.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
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.
Data Transfer Controller (DTC) driver.
void ra8_dtc_dispatch(void)
Fire the attached activation callback with current DTCSTS.
ra8_err_t ra8_dtc_attach_handler(ra8_dtc_event_fn_t fn, void *ctx)
Attach a shared activation-complete callback.
ra8_err_t ra8_dtc_enable(void)
Start the DTC module.
ra8_err_t ra8_dtc_init(void *vector_base)
Initialise the DTC and install its vector table base.
DTC (Data Transfer Controller) register layout for the RA8D2.
Event Link Controller driver.
ra8_err_t ra8_elc_init(void)
Reset the ELC register block and enable the controller.
ra8_err_t ra8_elc_software_trigger(uint8_t event_index)
Fire a software event via one of the ELSEGRn registers.
ra8_elc_event_t
Partial list of ELC events (populate as drivers need them).
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Interrupt Control Unit (ICU) register layout for the Renesas RA8D2.
static volatile uint32_t * ra8_icu_ielsr(uint16_t index)
Get pointer to IELSR register N.
@ k_ra8_ielsr_dtce_mask
DTCE bit mask.
NVIC + ICU IELSR allocator.
ra8_err_t ra8_isr_init(void)
Initialise the ra8_isr table.
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.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
One 16-byte Transfer Information (TI) block referenced by the DTC vector table.