67static const char*
s_tag =
"poeg_demo";
70typedef enum : uint32_t {
79typedef enum : uint8_t {
146 __asm__
volatile(
"wfi");
163 uint32_t cpuclk0_hz = 0U;
250 .enable_osc_stop =
false,
251 .invert_input =
false,
292 uint32_t before = 0U;
303 uint32_t asserted = 0U;
320 uint32_t cleared = 0U;
333 const uint8_t running = (after != before) ? 1U : 0U;
335 *out_ok = (shutoff != 0U && reenabled != 0U && running != 0U) ? 1U : 0U;
356 const uint8_t good = (err ==
k_ra8_ok && ok != 0U) ? 1U : 0U;
void main(void)
Secure fallback main entry point.
static ra8_err_t internal_poeg_demo_arm_gpt(void)
Configure GPT0 for saw-wave PWM with auto_start = true.
volatile uint32_t g_poeg_last_status
Last POEGG snapshot latched immediately after the shutoff assert.
poeg_demo_config_t
Compile-time settings.
@ k_poeg_demo_gpt_duty
Mid-scale PWM duty (50%).
@ k_poeg_demo_gpt_prd
16-bit GPT period (saw PWM).
@ k_poeg_demo_period_ms
Delay between shutoff cycles.
@ k_poeg_demo_baud
SCI console baud rate.
@ k_poeg_demo_settle_ms
High-Z hold while the PWM runs.
poeg_demo_unit_t
GPT channel + POEG group the demo pairs.
@ k_poeg_demo_group
POEG group gating GPT0.
@ k_poeg_demo_gpt_channel
GPT channel driving the PWM.
static void internal_poeg_demo_panic_halt(void)
Park forever after a fatal initialization failure.
volatile uint32_t g_poeg_heartbeat
Bumps once per main-loop pass – liveness for headless probes.
volatile uint32_t g_poeg_mismatch
Latches the count of cycles whose verdict was not healthy.
volatile uint32_t g_poeg_shutoffs
Count of healthy safe-shutoff cycles completed (assert + re-enable).
static ra8_err_t internal_poeg_demo_cycle(uint8_t *out_ok)
Run one safe-shutoff cycle and fold the result into the verdict.
static const uint8_t s_poeg_demo_ok_msg[]
Success banner for a complete safe-shutoff and re-enable cycle.
static void internal_poeg_demo_setup_or_halt(void)
Bring CGC + SysTick + MSTP + SCI console + LEDs up.
static const uint8_t s_poeg_demo_bad_msg[]
Failure banner for an incomplete POEG safety cycle.
static ra8_err_t internal_poeg_demo_arm_poeg(void)
Arm POEG group 0 to accept an output-disable request.
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).
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.
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.
Full-featured General PWM Timer (GPT) driver.
@ k_ra8_gpt_mode_saw_pwm
Saw-wave PWM (up-count).
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_read(uint8_t channel, uint32_t *out)
Read the current counter value.
@ k_ra8_gpt_ps_div_4
PCLKD / 4.
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.
Port Output Enable for GPT (POEG) driver.
ra8_err_t ra8_poeg_trigger_stop(uint8_t group)
Trigger an emergency stop via POEGG.SSF (software).
ra8_err_t ra8_poeg_get_status(uint8_t group, uint32_t *out_mask)
Read POEGG status flag bits.
ra8_err_t ra8_poeg_init(uint8_t group, const ra8_poeg_cfg_t *cfg)
Initialise a POEG group with a configuration descriptor.
ra8_err_t ra8_poeg_clear_status(uint8_t group, uint32_t mask)
Clear one or more POEGG status flag bits.
@ k_ra8_poeg_status_st
POEGG.ST state.
@ k_ra8_poeg_status_ssf
POEGG.SSF Software.
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.
Configuration descriptor for ra8_poeg_init.