|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Exercise the WUPEN0 / WUPEN1 wake-source enable matrix. 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_time.h"Go to the source code of this file.
Enumerations | |
| enum | lpm_wupen_mask_t : uint32_t { k_lpm_wupen_all_mask = 0xFFFFFFFFUL } |
| Wake-up enable register masks. More... | |
| enum | lpm_wake_const_t : uint32_t { k_lpm_wake_baud = 115200U } |
Functions | |
| static void | internal_lpm_wake_panic_halt (void) |
| Park the processor after a fatal setup or wake-matrix failure. | |
| static void | internal_lpm_wake_setup_or_halt (void) |
| Bring CGC + SysTick + SCI8 + LED1 + LPM block up. | |
| static ra8_err_t | internal_lpm_wake_arm0 (uint32_t bits) |
| Arm a WUPEN0 source mask and update the in-RAM snapshot. | |
| static ra8_err_t | internal_lpm_wake_arm1 (uint32_t bits) |
| Arm a WUPEN1 source mask and update the in-RAM snapshot. | |
| static ra8_err_t | internal_lpm_wake_walk_wupen0 (void) |
| Walk the WUPEN0 internal-peripheral wake sources. | |
| static ra8_err_t | internal_lpm_wake_walk_wupen1 (void) |
| Walk the WUPEN1 internal-peripheral wake sources. | |
| static ra8_err_t | internal_lpm_wake_disarm_all (void) |
| Disarm every WUPEN bit the demo set and confirm zero. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | s_lpm_wake_boot_msg [] = "lpm_wake_matrix: boot\r\n" |
| Boot banner – HIL gate string. | |
| static const uint8_t | s_lpm_wake_done_msg [] = "lpm_wake_matrix: done\r\n" |
| Per-step completion banner emitted after each arm/disarm. | |
| volatile uint64_t | g_lpm_wake_matrix_armed = 0U |
| Snapshot of which WUPEN sources the demo has armed so far. | |
Exercise the WUPEN0 / WUPEN1 wake-source enable matrix.
Walks every wake-source bit the LPM HAL exposes through ra8_lpm_arm_wupen0_bits / ra8_lpm_arm_wupen1_bits and verifies the matrix is reachable from the application layer. The demo does NOT attempt to enter Software Standby / Deep Standby because most of these sources need additional peripheral wiring (USB device attached, IRQ pin driven, ULPT armed, etc) that the bare EK-RA8D2 cannot synthesise without external hardware.
Instead, the demo:
The demo proves that the HAL helpers actually mutate the WUPEN registers as expected – equivalent to the host unit test in tests/mocks/src/test_app_lpm_wake_matrix_demo.c but running on real silicon so the chip's read-as-written semantics are exercised.
Definition in file main.c.
| enum lpm_wake_const_t : uint32_t |
| enum lpm_wupen_mask_t : uint32_t |
|
staticnodiscard |
Arm a WUPEN0 source mask and update the in-RAM snapshot.
Applies the requested low-bank mask, then samples the combined exit cause into the externally visible progression snapshot.
| [in] | bits | k_ra8_lpm_wupen0_* mask to OR into WUPEN0. |
| k_ra8_ok | The mask was armed and the resulting snapshot was captured. |
Definition at line 169 of file main.c.
References g_lpm_wake_matrix_armed, k_ra8_ok, RA8_INTERNAL, ra8_lpm_arm_wupen0_bits(), and ra8_lpm_get_exit_cause().
Referenced by internal_lpm_wake_walk_wupen0().
|
staticnodiscard |
Arm a WUPEN1 source mask and update the in-RAM snapshot.
Applies the requested high-bank mask, then samples the combined exit cause into the externally visible progression snapshot.
| [in] | bits | k_ra8_lpm_wupen1_* mask to OR into WUPEN1. |
| k_ra8_ok | The mask was armed and the resulting snapshot was captured. |
Definition at line 204 of file main.c.
References g_lpm_wake_matrix_armed, k_ra8_ok, RA8_INTERNAL, ra8_lpm_arm_wupen1_bits(), and ra8_lpm_get_exit_cause().
Referenced by internal_lpm_wake_walk_wupen1().
|
staticnodiscard |
Disarm every WUPEN bit the demo set and confirm zero.
Clears both complete WUPEN banks in order and refreshes the combined externally visible snapshot only after both clears succeed.
| k_ra8_ok | Both banks were cleared and the zero snapshot was captured. |
Definition at line 340 of file main.c.
References g_lpm_wake_matrix_armed, k_lpm_wupen_all_mask, k_ra8_ok, RA8_INTERNAL, ra8_lpm_clear_wupen0_bits(), ra8_lpm_clear_wupen1_bits(), and ra8_lpm_get_exit_cause().
Referenced by main().
|
static |
Park the processor after a fatal setup or wake-matrix failure.
Executes wait-for-interrupt indefinitely so a partial matrix walk cannot be mistaken for a completed diagnostic.
Definition at line 96 of file main.c.
References RA8_INTERNAL.
Referenced by internal_lpm_wake_setup_or_halt(), and main().
|
static |
Bring CGC + SysTick + SCI8 + LED1 + LPM block up.
Initializes clocks, timing, the HIL console, LED1, and LPM configuration in dependency order, halting at the first required failure.
Definition at line 118 of file main.c.
References internal_lpm_wake_panic_halt(), k_lpm_wake_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_lpm_dcssmode_128us, k_ra8_lpm_ss2lp_default, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_lpm_init(), and ra8_time_init().
Referenced by main().
|
staticnodiscard |
Walk the WUPEN0 internal-peripheral wake sources.
Arms each supported low-bank source in a fixed diagnostic order and stops immediately if any individual update or snapshot read fails.
| k_ra8_ok | All six WUPEN0 source bits were armed successfully. |
Definition at line 243 of file main.c.
References internal_lpm_wake_arm0(), k_ra8_lpm_wupen0_iwdt, k_ra8_lpm_wupen0_pvd1, k_ra8_lpm_wupen0_pvd2, k_ra8_lpm_wupen0_rtcalm, k_ra8_lpm_wupen0_rtcprd, k_ra8_lpm_wupen0_vbatt, k_ra8_ok, and RA8_INTERNAL.
Referenced by main().
|
staticnodiscard |
Walk the WUPEN1 internal-peripheral wake sources.
Arms each supported high-bank source in a fixed diagnostic order and stops immediately if any individual update or snapshot read fails.
| k_ra8_ok | All six WUPEN1 source bits were armed successfully. |
Definition at line 293 of file main.c.
References internal_lpm_wake_arm1(), k_ra8_lpm_wupen1_comphs0, k_ra8_lpm_wupen1_i3c0, k_ra8_lpm_wupen1_sosc, k_ra8_lpm_wupen1_ulpt0a, k_ra8_lpm_wupen1_ulpt0b, k_ra8_lpm_wupen1_ulpt0u, k_ra8_ok, and RA8_INTERNAL.
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 358 of file main.c.
References internal_lpm_wake_disarm_all(), internal_lpm_wake_panic_halt(), internal_lpm_wake_setup_or_halt(), internal_lpm_wake_walk_wupen0(), internal_lpm_wake_walk_wupen1(), k_ra8_board_led1, k_ra8_ok, ra8_board_led_on(), ra8_board_uart_console_write(), ra8_isr_globals_enable(), s_lpm_wake_boot_msg, and s_lpm_wake_done_msg.
| volatile uint64_t g_lpm_wake_matrix_armed = 0U |
Snapshot of which WUPEN sources the demo has armed so far.
Updated after each successful ra8_lpm_arm_wupen0_bits / ra8_lpm_arm_wupen1_bits call. Exposed for SWD inspection so an operator can confirm matrix progression without a UART.
Definition at line 81 of file main.c.
Referenced by internal_lpm_wake_arm0(), internal_lpm_wake_arm1(), and internal_lpm_wake_disarm_all().
|
static |