|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
AGT pulse-output / output-compare demo for EK-RA8D2. More...
#include <stdint.h>#include "ra8_agt.h"#include "ra8_agt_regs.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_time.h"Go to the source code of this file.
Enumerations | |
| enum | agt_pulse_const_t : uint32_t { k_agt_pulse_baud = 115200U , k_agt_pulse_poll_ms = 10U } |
| Demo tunables. More... | |
| enum | agt_pulse_timer_t : uint16_t { k_agt_pulse_channel = 0U , k_agt_pulse_period = 0x7FFFU , k_agt_pulse_duty = 0x3FFFU } |
| AGT channel + pulse-output settings. More... | |
| enum | agt_pulse_fmt_t : uint32_t { k_agt_pulse_hex_digits = 8U , k_agt_pulse_hex_shift = 4U , k_agt_pulse_hex_mask = 0xFU } |
| Hex-digit width + mask for the per-tick banner formatter. More... | |
Functions | |
| static void | internal_panic_halt (void) |
| Spin-halt the core if any init step fails. | |
| static void | internal_setup_or_halt (void) |
| Bring up CGC, SysTick, SCI8 and LED1. | |
| static ra8_err_t | internal_arm (void) |
| Arm AGT0 in pulse-output / output-compare mode. | |
| static void | internal_format_tick (uint32_t tick, uint8_t *digits) |
| Render the 32-bit tick counter into an 8-byte ASCII-hex buf. | |
| static ra8_err_t | internal_emit_tick (uint32_t tick) |
| Emit one tick banner over SCI8. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const char | s_agt_pulse_hex_chars [] = "0123456789ABCDEF" |
| Hex print map for the tick counter. | |
| static const uint8_t | s_agt_pulse_msg_head [] = "agt_pulse: tick=" |
| Tick-line prefix and CR/LF tail. | |
| static const uint8_t | s_agt_pulse_msg_tail [] = "\r\n" |
AGT pulse-output / output-compare demo for EK-RA8D2.
Brings up CGC + SysTick + UART (SCI8 on PD_02 / PD_03) and arms AGT0 in pulse-output mode via the new ra8_agt_start_pulse_output HAL surface. The HAL programmes TMOD = 001b in AGTMR1 (HUM Ch 24.3.4 "Pulse Output Mode" p 1177), wires AGTCMA as the duty target so the AGTOAn pin toggles on compare-match A, and sets AGTIOC.TOE so the AGTOn pin tracks counter underflows.
The demo polls AGTCR.TUNDF in the foreground loop. Each underflow:
The HIL gate scrapes agt_pulse: tick= to confirm bring-up.
Definition in file main.c.
| enum agt_pulse_const_t : uint32_t |
| enum agt_pulse_fmt_t : uint32_t |
| enum agt_pulse_timer_t : uint16_t |
|
staticnodiscard |
Arm AGT0 in pulse-output / output-compare mode.
Definition at line 146 of file main.c.
References k_agt_pulse_channel, k_agt_pulse_duty, k_agt_pulse_period, k_ra8_agt_output_polarity_active_high, k_ra8_agt_pulse_compare_a, k_ra8_agt_pulse_mode_continuous, ra8_agt_start_pulse_output(), and RA8_INTERNAL.
|
staticnodiscard |
Emit one tick banner over SCI8.
Format: agt_pulse: tick=XXXXXXXX\r\n. The HIL probe matches on the agt_pulse: tick= prefix so any non-zero tick passes.
| [in] | tick | Current tick counter value. |
Definition at line 207 of file main.c.
References internal_format_tick(), k_agt_pulse_hex_digits, k_ra8_ok, ra8_board_uart_console_write(), RA8_INTERNAL, s_agt_pulse_msg_head, and s_agt_pulse_msg_tail.
|
static |
Render the 32-bit tick counter into an 8-byte ASCII-hex buf.
Big-endian hex render: digits[0] = most-significant nibble. Caller passes a buffer >= 8 bytes long.
| [in] | tick | Tick counter value to render. |
| [out] | digits | Destination buffer (>= 8 bytes). |
Definition at line 177 of file main.c.
References k_agt_pulse_hex_digits, k_agt_pulse_hex_mask, k_agt_pulse_hex_shift, RA8_INTERNAL, and s_agt_pulse_hex_chars.
|
static |
Spin-halt the core if any init step fails.
Boot helper. Uses wfi so an attached debugger can break in and inspect the failed init.
Definition at line 83 of file main.c.
References RA8_INTERNAL.
|
static |
Bring up CGC, SysTick, SCI8 and LED1.
Sequence: ra8_cgc_init -> ra8_time_init -> ra8_board_uart_console_init -> ra8_board_led_init. Any failure goes straight to panic-halt so the HIL gate sees no agt_pulse: banner.
Definition at line 107 of file main.c.
References internal_panic_halt(), k_agt_pulse_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, and ra8_time_init().
| 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.
The application entry point Reset_Handler hands control to.
Initializes and arms ADC_B, formats each successful channel sample without variadic I/O, emits the verdict, toggles LED1, and delays.
Definition at line 224 of file main.c.
References internal_arm(), internal_emit_tick(), internal_panic_halt(), internal_setup_or_halt(), k_agt_pulse_channel, k_agt_pulse_poll_ms, k_ra8_agt_agtcr_tundf_msk, k_ra8_board_led1, k_ra8_ok, ra8_agt_get_status(), ra8_agt_stop(), ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
Hex print map for the tick counter.
Definition at line 61 of file main.c.
Referenced by internal_format_tick().
|
static |
Tick-line prefix and CR/LF tail.
Definition at line 64 of file main.c.
Referenced by internal_emit_tick().
|
static |
Definition at line 65 of file main.c.
Referenced by internal_emit_tick().