|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
High-Speed Analog Comparator (ACMPHS) channel-0 polling demo. More...
#include <stdint.h>#include "ra8_acmphs.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_port_constants.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | acmphs_demo_const_t : uint32_t { k_acmphs_demo_period_ms = 1000U } |
| Demo tunables. More... | |
| enum | acmphs_demo_chan_t : uint8_t { k_acmphs_demo_channel = 0U , k_acmphs_demo_ivpsel = 0U , k_acmphs_demo_ivrefsel = 0U } |
| Channel + register-field selectors. More... | |
Functions | |
| static void | internal_acmphs_demo_panic_halt (void) |
| Park the CPU forever after a fatal comparator-demo failure. | |
| static ra8_err_t | internal_acmphs_demo_setup (void) |
| Bring CGC + SysTick + LEDs + ACMPHS channel 0 up. | |
| static ra8_err_t | internal_acmphs_demo_one_iter (void) |
| Read the comparator output and route to the matching LED. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| volatile uint32_t | g_acmphs_compare_tick = 0U |
| HIL liveness counter – incremented each comparator read iteration. | |
High-Speed Analog Comparator (ACMPHS) channel-0 polling demo.
Brings up the on-chip ACMPHS unit, configures channel 0 with the default plus-input / internal-Vref minus-input pair (no edge IRQ, polling only), and reads CMPMON once per second via ra8_acmphs_read_output. LED1 toggles each time the comparator output is HIGH; LED2 toggles each time the output is LOW. LED3 latches if a HAL error is ever returned.
Bare EK-RA8D2 only – no expansion board. The default plus-input pin is left floating; the comparator simply tracks whatever rail the analogue front-end happens to settle at, so the goal is to exercise the bring-up + readback path, not to validate a known threshold.
Definition in file main.c.
| enum acmphs_demo_chan_t : uint8_t |
| enum acmphs_demo_const_t : uint32_t |
|
staticnodiscard |
Read the comparator output and route to the matching LED.
Polls channel 0 once, toggling LED1 for a high result and LED2 for a low result while preserving the first HAL or BSP error.
| k_ra8_ok | The sample was read and the selected LED toggled. |
| (other) | The comparator read or selected LED update failed. |
Definition at line 182 of file main.c.
References k_acmphs_demo_channel, k_ra8_board_led1, k_ra8_board_led2, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, ra8_acmphs_read_output(), ra8_board_led_toggle(), and RA8_INTERNAL.
Referenced by main().
|
static |
Park the CPU forever after a fatal comparator-demo failure.
Enters a permanent wait-for-interrupt loop so the comparator and LED state at the point of failure remain available to a debugger.
Definition at line 87 of file main.c.
References RA8_INTERNAL.
Referenced by main().
|
staticnodiscard |
Bring CGC + SysTick + LEDs + ACMPHS channel 0 up.
Initializes the clock and time base, configures all three board LEDs, enables the comparator block, and binds channel 0 to the demo's selected input and reference without edge interrupts or filtering.
| k_ra8_ok | All clocks, LEDs, and comparator state were initialized. |
| (other) | The first error reported by a board or HAL dependency. |
Definition at line 118 of file main.c.
References k_acmphs_demo_channel, k_acmphs_demo_ivpsel, k_acmphs_demo_ivrefsel, k_ra8_acmphs_edge_none, k_ra8_board_led1, k_ra8_board_led2, k_ra8_board_led3, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_acmphs_channel_init(), ra8_acmphs_init(), ra8_board_led_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, 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.
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.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
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.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
The application entry point Reset_Handler hands control to.
Brings up logging and the clock tree, releases the Cortex-M33 (which then blinks LED1 via ra8_pcntr_set_output()), and idles. See the file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the cacheable-SRAM round-trip with the D-cache that SystemInit() enabled through ra8_cache_dcache_enable(), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU + RA8_BOOT_CACHE_VIA_HAL).
The application entry point Reset_Handler hands control to.
Publishes the mailbox, releases the Cortex-M33 into the emitter, yields until it signals done, validates the blob the M33 built, then logs the PASS/FAIL verdict and the chapter count read back from the blob. See the file header for the offload narrative.
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.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Publishes the mailbox, arms the IPC0 wake and configures the LPM block, releases the Cortex-M33 into the reader, waits for the first held page, logs the page-0 verdict, then runs the #150 mode-switch cycle – parking in low-power WFI and waking on the M33's page-turn pokes – before logging the handoff verdict and parking for good. See the file header for the narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the timebase then measures forever.
The application entry point Reset_Handler hands control to.
Arms the RIIC1 target and polls the dispatcher.
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.
Brings up the LIN commander then drives frames.
The application entry point Reset_Handler hands control to.
Brings up logging, "renders" page 0 into the shared mailbox, releases the Cortex-M33 into its hold loop, and parks the M85 in low-power WFI sleep. See the file header for the power-saving narrative.
The application entry point Reset_Handler hands control to.
The USB clock, pins, console, and the SD card all come up before the kernel so the worker only deals with USB stack bring-up.
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.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (MPU enabled, canonical boot map, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the wear-levelling + power-cycle-survival flow, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the program/erase round-trip, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then runs the full ra8_io VFS round-trip over the native-SDHI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Brings up the console and both stdio sinks, retargets the engine's stdio to the in-RAM capture sink, runs the two-backend swap, replays the RAM capture out of the UART, and prints a single PASS/FAIL verdict per abstraction before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then writes + reads + compares one raw 512-byte block straight against ra8_sdcard. On success it prints the exact PASS banner; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII + RSIP, then ThreadX.
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.
The application entry point Reset_Handler hands control to.
Definition at line 195 of file main.c.
References g_acmphs_compare_tick, internal_acmphs_demo_one_iter(), internal_acmphs_demo_panic_halt(), internal_acmphs_demo_setup(), k_acmphs_demo_period_ms, k_ra8_board_led3, k_ra8_ok, ra8_board_led_on(), ra8_delay_ms(), and ra8_isr_globals_enable().
| volatile uint32_t g_acmphs_compare_tick = 0U |
HIL liveness counter – incremented each comparator read iteration.
Read externally by scripts/hil/jlink_memprobe.sh via SWD; the script halts the chip, samples this value, lets the chip run for N seconds, halts again, and asserts the delta >= HIL_PROBE_MIN_ADVANCE. Catches the "PC is in MRAM but main loop never iterated" failure mode that the plain HIL_MODE=alive check misses.
volatile keeps the increment alive under optimization; the global (non-static) keeps the symbol linker-visible without –gc-sections culling.
Definition at line 69 of file main.c.
Referenced by main().