76typedef enum : uint32_t {
86typedef enum : uint16_t {
94typedef enum : uint8_t {
189 __asm__
volatile(
"wfi");
238 uint32_t cpuclk0_hz = 0U;
347 uint32_t status = 0U;
357 const uint32_t delta = latch - *prev_latch;
376 uint32_t prev_latch = 0U;
377 uint32_t prev_free = 0U;
378 bool have_prev =
false;
385 uint32_t pulses = 0U;
391 uint32_t now_free = 0U;
394 if (now_free != prev_free) {
398 prev_free = now_free;
void main(void)
Secure fallback main entry point.
gpt_ecc_layout_t
GPT channel + LED selection for the demo.
@ k_gpt_ecc_capture_channel
GPT0: input-capture channel.
@ k_gpt_ecc_count_channel
GPT1: event-count channel.
static void gpt_ecc_clocks_or_halt(void)
Bring up the core clocks, SysTick, and LED1.
static const ra8_port_pin_t k_gpt_ecc_pin_capture
GTIOC0A input pad for the capture channel (placeholder).
volatile uint32_t g_gpt_ecc_last_period
Most recent valid input-capture delta, in GPT counter ticks.
static void gpt_ecc_panic_halt(void)
Park the CPU after a fatal init failure.
volatile uint32_t g_gpt_ecc_capture_events
Count of valid input-capture edges observed so far.
volatile uint32_t g_gpt_ecc_tick
Pin-independent liveness counter.
static bool gpt_ecc_period_valid(uint32_t delta_ticks)
Classify a captured delta as a genuine signal period.
volatile uint32_t g_gpt_ecc_pulse_count
Latest accumulated external pulse count (GPT1 GTCNT).
static bool gpt_ecc_service_capture(uint32_t *prev_latch)
Service one input-capture poll: latch delta -> globals.
gpt_ecc_poll_const_t
Main-loop poll cadence in milliseconds.
@ k_gpt_ecc_poll_period_ms
Sample GTST / GTCNT every 5 ms.
static void gpt_ecc_timers_or_halt(void)
Configure the capture (GPT0) and count (GPT1) timer channels.
gpt_ecc_period_const_t
32-bit counter tunables (free-run period + capture window).
@ k_gpt_ecc_period
GTPR full-scale.
@ k_gpt_ecc_min_valid_ticks
100: glitch-reject floor.
@ k_gpt_ecc_max_valid_ticks
Wrap / stale-latch ceiling.
static const ra8_port_pin_t k_gpt_ecc_pin_count
GTIOC1A input pad for the event-count channel (placeholder).
static void gpt_ecc_route_pins_or_halt(void)
Route the two GTIOCnA edge-input pins to the GPT peripheral.
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_led1
LED1, BLUE, P600 (jumper E27).
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.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
PSEL codes for peripheral pin routing on the RA8D2.
@ k_ra8_psel_gpt0
00011b: GPT timer I/O (GTIOCnA/B).
Full-featured General PWM Timer (GPT) driver.
@ k_ra8_gpt_status_ccra
GTST.TCFA (bit 0).
@ k_ra8_gpt_mode_saw_pwm
Saw-wave PWM (up-count).
ra8_err_t ra8_gpt_clear_status(uint8_t channel, uint32_t mask)
Clear GTST flag bits (write-0 to clear).
ra8_err_t ra8_gpt_init(uint8_t channel, const ra8_gpt_cfg_t *cfg)
Initialise a GPT channel with a full config descriptor.
ra8_err_t ra8_gpt_get_status(uint8_t channel, uint32_t *out_mask)
Read GTST overflow / underflow / compare flags.
ra8_err_t ra8_gpt_read(uint8_t channel, uint32_t *out)
Read the current counter value.
@ k_ra8_gpt_ps_div_1
PCLKD / 1.
GPT input-capture + external event / pulse-count extension.
ra8_err_t ra8_gpt_capture_read(uint8_t channel, ra8_gpt_ccr_sel_t which, uint32_t *out_value)
Read the value latched by the last input capture.
@ k_ra8_gpt_cnt_src_ioca_rising
bits 8,9 GTIOCnA rising.
@ k_ra8_gpt_cnt_src_none
No count source (disable).
ra8_err_t ra8_gpt_capture_configure(uint8_t channel, ra8_gpt_ccr_sel_t which, uint32_t source_mask)
Arm a GPT channel for input capture on GTCCRA or GTCCRB.
@ k_ra8_gpt_cap_src_ioca_rising
bits 8,9 GTIOCnA rising.
ra8_err_t ra8_gpt_event_count_configure(uint8_t channel, uint32_t up_source, uint32_t down_source)
Configure external event (edge) counting on GTCNT.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
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.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_port_4
RA8 port 4.
#define RA8_PIN(port, pin)
Build a ra8_port_pin_t from explicit port / pin indices.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
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.
Configuration descriptor for ra8_gpt_init.