|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Software Standby (LPSCR.LPMD = 0x5) + RTC periodic wake demo. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_lpm.h"#include "ra8_lpm_regs.h"#include "ra8_rtc.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | lpm_swstd_const_t : uint32_t { k_lpm_swstd_baud = 115200U } |
| Demo tunables. More... | |
| enum | lpm_swstd_byte_t : uint16_t { k_lpm_swstd_alarm_offset_s = 5U , k_lpm_swstd_seed_year_lo = 26U , k_lpm_swstd_year_base = 2000U , k_lpm_swstd_seed_month = 1U , k_lpm_swstd_seed_day = 1U , k_lpm_swstd_secs_per_min = 60U , k_lpm_swstd_mins_per_hour = 60U , k_lpm_swstd_hours_per_day = 24U } |
| Single-byte demo constants. More... | |
Functions | |
| static void | internal_lpm_swstd_panic_halt (void) |
| Park the processor after a fatal setup or standby-path failure. | |
| static void | internal_lpm_swstd_setup_or_halt (void) |
| Bring CGC + SysTick + SCI8 + RTC + LPM block up. | |
| static void | internal_lpm_swstd_add_offset (const ra8_rtc_datetime_t *now, ra8_rtc_datetime_t *out) |
Compute now + 5 s wrapping over seconds/minutes/hours. | |
| static ra8_err_t | internal_lpm_swstd_arm_wake (const ra8_rtc_datetime_t *now) |
| Arm the +5 s RTC alarm and the WUPEN0.RTCALM wake source. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | s_lpm_swstd_boot_msg [] = "lpm_swstd: boot\r\n" |
| Boot banner – this is the HIL gate string. | |
| volatile uint32_t | g_lpm_swstd_wake_count = 0U |
| Liveness counter – bumped after each Software-Standby wake. | |
Software Standby (LPSCR.LPMD = 0x5) + RTC periodic wake demo.
Demonstrates Software Standby mode on the EK-RA8D2. Software Standby gates almost every clock domain except the sub-clock oscillator (SOSC) and a small set of always-on wake-up detectors – including the RTC. The demo wires the RTC alarm onto WUPEN0.RTCALMWUPEN so a +5 s RTC alarm wakes the CPU out of LPMD = 0x5.
Boot flow:
Definition in file main.c.
| enum lpm_swstd_byte_t : uint16_t |
Single-byte demo constants.
| enum lpm_swstd_const_t : uint32_t |
|
static |
Compute now + 5 s wrapping over seconds/minutes/hours.
Copies the complete calendar value, then advances the time-of-day fields with explicit carry propagation through seconds, minutes, and hours.
| [in] | now | Current datetime. |
| [out] | out | Receives the +5 s alarm datetime. |
Definition at line 185 of file main.c.
References ra8_rtc_datetime_t::hour, k_lpm_swstd_alarm_offset_s, k_lpm_swstd_hours_per_day, k_lpm_swstd_mins_per_hour, k_lpm_swstd_secs_per_min, ra8_rtc_datetime_t::minute, RA8_INTERNAL, and ra8_rtc_datetime_t::second.
Referenced by internal_lpm_swstd_arm_wake().
|
staticnodiscard |
Arm the +5 s RTC alarm and the WUPEN0.RTCALM wake source.
Builds the future alarm, enables the RTC alarm interrupt, and then enables the corresponding software-standby wake bit.
| [in] | now | Current RTC calendar value used as the alarm base. |
| k_ra8_ok | The alarm and wake-source bit were armed. |
now.Definition at line 227 of file main.c.
References internal_lpm_swstd_add_offset(), k_ra8_lpm_wupen0_rtcalm, k_ra8_ok, k_ra8_rtc_irq_alarm, ra8_lpm_arm_wupen0_bits(), ra8_rtc_set_alarm(), and ra8_rtc_set_irq_enable().
Referenced by main().
|
static |
Park the processor after a fatal setup or standby-path failure.
Executes wait-for-interrupt indefinitely so a failed software- standby sequence cannot continue into application code with partial state.
Definition at line 98 of file main.c.
References RA8_INTERNAL.
Referenced by internal_lpm_swstd_setup_or_halt(), and main().
|
static |
Bring CGC + SysTick + SCI8 + RTC + LPM block up.
Same shape as lpm_idle_demo but adds RTC init + alarm seed. The J-Link console (SCI8 + PD02/PD03 routing + baud) is brought up via the EK-RA8D2 board-support package.
Definition at line 125 of file main.c.
References internal_lpm_swstd_panic_halt(), k_lpm_swstd_baud, k_lpm_swstd_seed_day, k_lpm_swstd_seed_month, k_lpm_swstd_seed_year_lo, k_lpm_swstd_year_base, k_ra8_clock_id_cpuclk0, k_ra8_lpm_dcssmode_128us, k_ra8_lpm_ss2lp_default, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_lpm_init(), ra8_rtc_init(), ra8_rtc_set(), and ra8_time_init().
Referenced by main().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Definition at line 242 of file main.c.
References g_lpm_swstd_wake_count, internal_lpm_swstd_arm_wake(), internal_lpm_swstd_panic_halt(), internal_lpm_swstd_setup_or_halt(), k_ra8_ok, k_ra8_rtc_irq_alarm, k_ra8_sleep_mode_software_std, ra8_board_uart_console_write(), ra8_isr_globals_enable(), ra8_lpm_enter_sleep(), ra8_rtc_clear_status(), ra8_rtc_get(), and s_lpm_swstd_boot_msg.
| volatile uint32_t g_lpm_swstd_wake_count = 0U |