70static const char*
s_tag =
"dtc_arm";
73typedef enum : uint32_t {
84typedef enum : uint8_t {
99typedef enum : uint16_t {
104typedef enum : uint8_t {
116typedef enum : uint8_t {
130typedef enum : uint8_t {
147typedef enum : uint16_t {
162typedef enum : uint32_t {
169typedef enum : uint32_t {
174 "CRA=0x0000 encodes a 256-unit block; buffer must be 256 words");
245 __asm__
volatile(
"wfi");
289 uint32_t cpuclk0_hz = 0U;
452 if (
s_dst[i] != expect) {
562 uint8_t armed_ok = 0U;
563 uint8_t disarmed_ok = 0U;
void main(void)
Secure fallback main entry point.
static void dtc_arm_program_ti(void)
Write the 16-byte TI block describing the block copy.
volatile uint32_t g_dtc_isr_count
Count of DTC-complete callbacks fanned through the HAL dispatch.
dtc_arm_vt_geom_t
DTC vector-table geometry.
@ k_dtc_arm_vt_entries
One pointer per IELSR slot 0..95.
@ k_dtc_arm_ti_align
TI start address multiple of 16.
@ k_dtc_arm_vt_align
DTCVBR 1 KB alignment (HUM 18.2.11).
static void dtc_arm_setup_or_halt(void)
Bring CGC + SysTick + ISR + ELC + SCI8 + LEDs + MSTP up.
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.
dtc_arm_event_t
ELC software event 0 -> ICU event number.
@ k_dtc_arm_event_swevt0
ELC software event 0 (HUM Table 19.3).
volatile uint32_t g_dtc_heartbeat
Bumps once per main-loop pass – liveness for headless probes.
dtc_arm_cra_t
CRA=0x0000 encodes a full 256-unit block.
@ k_dtc_arm_cra_block_units
Units per block when CRAH/CRAL = 0.
static uint8_t dtc_arm_all_match_src(void)
Verify s_dst matches s_src element-by-element.
static void dtc_arm_fill(uint32_t dst_init)
Fill s_src with a deterministic pattern and s_dst with a value.
static uint32_t s_src[k_dtc_arm_buf_words]
Source / destination buffers (32-bit aligned by element type).
dtc_arm_count_t
DTC count-register values for one 256-word block.
@ k_dtc_arm_cra_block_256
CRAH = CRAL = 0 => 256-unit block.
@ k_dtc_arm_crb_one_block
CRB = 1 => one block per pass.
dtc_arm_config_t
Compile-time settings.
@ k_dtc_arm_poll_limit
Bounded wait for the block to land.
@ k_dtc_arm_buf_bytes
Bytes copied per armed pass.
@ k_dtc_arm_baud
SCI8 baud rate.
@ k_dtc_arm_buf_words
32-bit words per buffer / block.
@ k_dtc_arm_period_ms
Delay between passes.
@ k_dtc_arm_settle
Bounded settle for the disarmed pass.
@ k_dtc_arm_dst_sentinel
Disarmed-phase destination fill.
static uint16_t s_dtc_slot
IELSR slot allocated for the DTC activation = DTC vector number.
static uint8_t dtc_arm_all_equal(uint32_t expect)
Verify every word of s_dst still holds expect.
static ra8_err_t dtc_arm_run_disarmed(uint8_t *out_ok)
Run one DISARMED pass: DTCE = 0, fire the event, expect NO copy.
volatile uint32_t g_dtc_armed_ok
1 when the armed pass copied the block correctly.
dtc_arm_mr_field_t
DTC Transfer-Information mode-bit field values.
@ k_dtc_arm_md_block
MRA.MD[7:6] = 10b: block transfer mode.
@ k_dtc_arm_dm_inc
MRB.DM[3:2] = 10b: increment DAR.
@ k_dtc_arm_sz_word
MRA.SZ[5:4] = 10b: 32-bit word units.
@ k_dtc_arm_sm_inc
MRA.SM[3:2] = 10b: increment SAR.
dtc_arm_byte_t
Single-byte constants.
@ k_dtc_arm_isr_prio
NVIC priority for the DTC-complete slot.
@ k_dtc_arm_byte_sh
Source-pattern shift (i ^ (i >> 8)).
static ra8_err_t dtc_arm_run_armed(uint8_t *out_ok)
Run one ARMED pass: DTCE = 1, fire the event, expect a full copy.
dtc_arm_mr_pos_t
Bit positions inside the DTC TI MR word.
@ k_dtc_arm_mra_byte_pos
MRA byte offset within MR.
@ k_dtc_arm_mra_md_pos
MRA.MD field position.
@ k_dtc_arm_mrb_byte_pos
MRB byte offset within MR.
@ k_dtc_arm_mrb_dm_pos
MRB.DM field position.
@ k_dtc_arm_mra_sm_pos
MRA.SM field position.
@ k_dtc_arm_mra_sz_pos
MRA.SZ field position.
static void dtc_arm_complete_cb(void *ctx, uint16_t status)
DTC completion callback (fanned out by ra8_dtc_dispatch).
static void dtc_arm_panic_halt(void)
Park forever after a fatal init failure.
static void dtc_arm_bringup_or_halt(void)
Initialise the DTC, allocate its activation slot, and enable it.
volatile uint32_t g_dtc_disarmed_ok
1 when the disarmed pass left the destination untouched.
static void dtc_arm_swevt_isr(void *ctx)
IELSR-slot ISR for the DTC-complete interrupt.
static const uint8_t k_dtc_arm_ok_msg[]
Output line tags.
dtc_arm_swevt_t
ELSEGRn index fired by ra8_elc_software_trigger.
@ k_dtc_arm_swevt_index
ELSEGR0 -> ELC_SWEVT0 (0x0CC).
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]
static const uint8_t k_dtc_arm_bad_msg[]
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.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
NVIC + ICU IELSR allocator.
ra8_err_t ra8_isr_init(void)
Initialise the ra8_isr table.
ra8_err_t ra8_isr_set_dtc(uint16_t slot, bool enable)
Enable or disable DTC activation on a registered 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.
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.