ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
38
39#include <stdint.h>
40
41#include "ra8_attributes.h"
42#include "ra8_boot_entry.h"
43#include "ra8_err.h"
44#include "ra8_isr.h"
45#include "ra8_log.h"
46#include "ra8_reset.h"
47#include "ra8_time.h"
48
58
73volatile uint32_t g_reset_cause_loop = 0U;
74
88volatile uint32_t g_reset_cause_initial = 0U;
89
106{
107 while (1) {
108 __asm__ volatile("wfi");
109 }
110}
111
112void main(void)
113{
116 }
118
119 if (ra8_reset_init() != k_ra8_ok) {
121 }
122
124 if (ra8_reset_get_cause(&cause) != k_ra8_ok) {
126 }
127 g_reset_cause_initial = (uint32_t)cause;
128 ra8_log_info_val("reset_cause_demo", "boot cause", (uint32_t)cause);
129
130 if (cause != k_ra8_reset_cause_software) {
131 /* Cold boot (POR or other) -- trigger the SW-reset path that the HIL
132 * gate validates. ra8_reset_software_reset does not return on target. */
136 }
137
138 /* Post-reset boot: cause == software. Advance the HIL counter so
139 * jlink_memprobe sees movement and the gate passes. */
140 while (1) {
141 g_reset_cause_loop += 1U;
143 }
144}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static void internal_reset_cause_panic_halt(void)
Park the CPU forever in WFI – used after the SW reset write or if HAL init fails.
Definition main.c:105
reset_cause_demo_const_t
Internal constants for the reset-cause demo.
Definition main.c:53
@ k_reset_cause_loop_period_ms
20 Hz advance for HIL probe.
Definition main.c:56
@ k_reset_cause_cpu_hz_at_reset
MOCO ~8.4 MHz before CGC bring-up.
Definition main.c:54
@ k_reset_cause_settle_ms
Pause before triggering SW reset.
Definition main.c:55
volatile uint32_t g_reset_cause_loop
HIL-probed counter – advances only after the second (software-cause) boot.
Definition main.c:73
volatile uint32_t g_reset_cause_initial
Decoded reset cause observed on this boot, captured as soon as ra8_reset_init returns.
Definition main.c:88
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Boot entry points shared between a vector table and its startup code.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Definition ra8_isr.c:439
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Definition ra8_log.h:366
Reset cause introspection + software reset trigger.
ra8_err_t ra8_reset_get_cause(ra8_reset_cause_t *out)
Decode the latched RSTSRn flags into a single primary cause.
Definition ra8_reset.c:326
ra8_err_t ra8_reset_init(void)
Snapshot the reset cause at boot.
Definition ra8_reset.c:310
ra8_reset_cause_t
Decoded reset-cause taxonomy.
Definition ra8_reset.h:93
@ k_ra8_reset_cause_software
RSTSR1.SWRF.
Definition ra8_reset.h:107
@ k_ra8_reset_cause_unknown
No flag latched.
Definition ra8_reset.h:94
void ra8_reset_software_reset(void)
Trigger a software-initiated system reset.
Definition ra8_reset.c:394
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.
Definition ra8_time.c:59
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Definition ra8_time.c:129