56typedef enum : uint32_t {
64typedef enum : uint8_t {
85 __asm__
volatile(
"wfi");
108 uint32_t cpuclk0_hz = 0U;
130 .io_port_keep =
false,
131 .opa_bus_keep =
true,
132 .sscr_fast_return =
true,
142 .user_ctx_gpio =
nullptr,
143 .user_ctx_time =
nullptr,
235 for (uint8_t i = 0U; i < n; i++) {
236 buf[i] = tmp[(uint8_t)(n - 1U - i)];
255static uint32_t
pp_demo_append(uint8_t* buf, uint32_t off,
const char* tag, uint64_t val)
258 while (tag[i] !=
'\0') {
259 buf[off++] = (uint8_t)tag[i];
295 const uint8_t suffix[] =
" us\r\n";
296 for (uint32_t i = 0U; i <
sizeof(suffix) - 1U; i++) {
297 out[off++] = suffix[i];
319 bool profile_ok =
true;
327 const uint8_t fail_banner[] =
"pp: FAIL cycle_modes\r\n";
334 const uint8_t stats_fail[] =
"pp: FAIL get_stats\r\n";
void main(void)
Secure fallback main entry point.
pp_demo_const_t
App-wide tunables.
@ k_pp_demo_baud
Pp demo baud.
@ k_pp_demo_us_per_ms
Pp demo us per ms.
@ k_pp_demo_busy_iters
Pp demo busy iters.
@ k_pp_demo_period_ms
Pp demo period ms.
static void pp_demo_panic_halt(void)
Park forever after a fatal init failure.
static bool pp_demo_cycle_modes(void)
Cycle through ACTIVE -> SLEEP -> DEEP_SLEEP -> SOFTWARE_STANDBY, marking entry/exit on each.
static void pp_demo_setup_or_halt(void)
static uint64_t pp_demo_now_us(void *ctx)
Time-base hook for the profiler – wraps ra8_time_ms to us.
static uint8_t pp_demo_uint_to_dec(uint8_t *buf, uint64_t v)
Write a decimal uint64 (low 32 bits) into buf.
static const uint8_t k_pp_demo_pass_msg[]
Success verdict line emitted only when a full mode cycle and the stats read both returned k_ra8_ok (n...
static uint32_t pp_demo_append(uint8_t *buf, uint32_t off, const char *tag, uint64_t val)
Append tag then the decimal of val to buf at off.
static void pp_demo_clocks_or_halt(void)
Bring CGC + SysTick + MSTP + UART console up.
pp_demo_byte_t
Single-byte ASCII conversion constants.
@ k_pp_demo_dec_base
Pp demo dec base.
@ k_pp_demo_ascii_zero
Pp demo ascii zero.
@ k_pp_demo_uint_dec_max
Max digits in a uint32 base-10.
@ k_pp_demo_print_buf
Max bytes in one print line.
static void pp_demo_modules_or_halt(void)
Bring LPM + power profiler + LEDs up; panic-halts on fail.
static uint32_t pp_demo_format_line(uint8_t *out, const ra8_power_profile_stats_t *stats)
Format the per-cycle stats line into out.
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).
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ 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.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Low Power Mode (LPM) HAL driver – public API.
ra8_err_t ra8_lpm_init(const ra8_lpm_config_t *cfg)
Initialise the LPM block from a config descriptor.
ra8_err_t ra8_lpm_enter_sleep(ra8_sleep_mode_t mode)
Programme LPSCR for mode and enter the requested sleep.
@ k_ra8_lpm_ss2lp_default
SS2LP_0 – default mode.
@ k_ra8_sleep_mode_sleep
CPU sleep, peripherals run.
@ k_ra8_lpm_dcssmode_128us
128 us soft-start (cold-reset default).
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.
Power-profiling helper – public API.
ra8_err_t ra8_power_profile_get_stats(ra8_power_profile_stats_t *out_stats)
Copy the current statistics snapshot to the caller.
ra8_err_t ra8_power_profile_mark_enter(ra8_power_profile_region_id_t region_id)
Mark entry into a tracked region.
ra8_err_t ra8_power_profile_mark_exit(ra8_power_profile_region_id_t region_id)
Mark exit from a tracked region.
@ k_ra8_power_profile_region_deep_standby
Deep-software-standby mode.
@ k_ra8_power_profile_region_active
CPU active / running mode.
@ k_ra8_power_profile_region_sleep
Sleep mode (CPU clock stopped).
@ k_ra8_power_profile_region_software_standby
Software-standby mode.
ra8_err_t ra8_power_profile_init(const ra8_power_profile_config_t *cfg)
Initialise the power profiler.
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.
uint32_t ra8_time_ms(void)
Get the current 1 kHz tick count.
Configuration descriptor for ra8_lpm_init.
Initialisation configuration.
uint64_t total_time_us
Sum of (exit - enter) over all closed pairs, microseconds.
Aggregate snapshot of all per-region accumulators.
ra8_power_profile_region_stats_t regions[k_ra8_power_profile_max_regions]
Per-region accumulators.