70static const char*
s_tag =
"bkup_demo";
73typedef enum : uint32_t {
82typedef enum : uint8_t {
175 __asm__
volatile(
"wfi");
211 uint32_t cpuclk0_hz = 0U;
256 .enable_switch =
false,
257 .enable_backup =
true,
334 uint32_t sentinel = 0U;
380 "survived=Y / survived=N suffixes must be equal length");
400 const uint8_t good = (err ==
k_ra8_ok && rw != 0U) ? 1U : 0U;
void main(void)
Secure fallback main entry point.
static ra8_err_t internal_bkup_demo_survival_check(void)
Detect reset survival and maintain the boot counter.
static void internal_bkup_demo_setup_or_halt(void)
Initialize clocks, time, console, LEDs, and the backup domain.
static const uint8_t s_bkup_demo_crlf[]
Console line terminator for each periodic report.
volatile uint32_t g_bkup_rw_ok
1 when words 0..29 read back exactly what was written.
volatile uint32_t g_bkup_heartbeat
Bumps once per main-loop pass – liveness for headless probes.
static const uint8_t s_bkup_demo_surv_n[]
Cold-start survival suffix.
static void internal_bkup_demo_report_survival(void)
Emit the fixed-width reset-survival suffix over the console.
static const uint8_t s_bkup_demo_surv_y[]
Warm-reset survival suffix.
bkup_demo_layout_t
Backup-word layout (32 words total; 0..29 data, 30/31 reserved).
@ k_bkup_demo_idx_boot
Boot-counter word index.
@ k_bkup_demo_data_words
Count of rw-pattern words (0..29).
@ k_bkup_demo_idx_sentinel
Reset-survival sentinel word index.
static const uint8_t s_bkup_demo_ok_msg[]
Prefix for a successful backup-word read/write report.
static void internal_bkup_demo_panic_halt(void)
Park forever after a fatal initialization failure.
static ra8_err_t internal_bkup_demo_rw_check(uint8_t *out_ok)
Write words 0..29 with the pattern, read them back, and compare.
volatile uint32_t g_bkup_boot_count
Boot counter held in backup word 31 (increments per reset on HW).
static uint32_t internal_bkup_demo_pattern(uint8_t i)
Derive the deterministic pattern for one backup word.
bkup_demo_config_t
Compile-time settings.
@ k_bkup_demo_period_ms
Delay between reports.
@ k_bkup_demo_pat_mult
Per-word pattern multiplier.
@ k_bkup_demo_pat_xor
Per-word pattern XOR mask.
@ k_bkup_demo_sentinel
"good cafe" reset-survival marker.
@ k_bkup_demo_baud
SCI8 console baud rate.
static const uint8_t s_bkup_demo_bad_msg[]
Prefix for a failed backup-word read/write report.
volatile uint32_t g_bkup_survived
1 when the sentinel was found at boot (state retained across reset).
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).
Battery Backup Function (VBATT) HAL driver – public API.
ra8_err_t ra8_bkup_write_word(uint8_t word_index, uint32_t value)
Write one 32-bit word into the VBTBKRn array.
ra8_err_t ra8_bkup_init(const ra8_bkup_config_t *cfg)
Configure the battery-backup block from cfg.
@ k_ra8_bkup_vdet_2p80v
000b: 2.80 V (default after reset).
ra8_err_t ra8_bkup_read_word(uint8_t word_index, uint32_t *out)
Read one 32-bit word from the VBTBKRn array.
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.
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.
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 passed to ra8_bkup_init.