|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RTC alarm + UART log demo for EK-RA8D2. 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_rtc.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | rtc_demo_const_t : uint32_t { k_rtc_demo_baud = 115200U , k_rtc_demo_poll_ms = 100U , k_rtc_demo_advance_secs = 10U , k_rtc_demo_ms_per_sec = 1000U } |
| Demo tunables. More... | |
| enum | rtc_demo_calendar_t : uint8_t { k_rtc_demo_secs_per_min = 60U , k_rtc_demo_mins_per_hour = 60U , k_rtc_demo_hours_per_day = 24U } |
| Calendar-arithmetic moduli for the +5 s alarm calc. More... | |
| enum | rtc_demo_seed_t : uint16_t { k_rtc_demo_alarm_offset_s = 5U , k_rtc_demo_seed_year_lo = 26U , k_rtc_demo_year_base = 2000U , k_rtc_demo_seed_month = 1U , k_rtc_demo_seed_day = 1U } |
| Alarm offset from the current RTC reading. More... | |
Functions | |
| static void | internal_rtc_demo_panic_halt (void) |
| Park the processor after an unrecoverable periodic-RTC failure. | |
| static void | internal_rtc_demo_setup_or_halt (void) |
| Initialize clocks, console, and the periodic demo's RTC seed. | |
| static ra8_err_t | internal_rtc_demo_arm_alarm (const ra8_rtc_datetime_t *now) |
| Program a +5 s alarm relative to now and enable AIE. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | s_rtc_demo_log_msg [] = "rtc_per: tick\r\n" |
| Fixed UART diagnostics for boot and periodic RTC events. | |
| static const uint8_t | s_rtc_demo_boot_msg [] = "rtc_per: boot\r\n" |
RTC alarm + UART log demo for EK-RA8D2.
Sets the on-chip RTC to a known seed time (2026-01-01 00:00:00), schedules an alarm 5 seconds in the future via the new ra8_rtc_set_alarm API, enables RCR1.AIE, and polls ra8_rtc_get_status for the alarm-fired flag (no NVIC needed in this minimal demo). When the alarm fires, the demo logs the wall time over SCI8 (115200 8N1, on the J-Link OB CDC port), clears the status bit, advances the seed by ten seconds, and re-arms.
Sequence:
Definition in file main.c.
| enum rtc_demo_calendar_t : uint8_t |
| enum rtc_demo_const_t : uint32_t |
| enum rtc_demo_seed_t : uint16_t |
|
staticnodiscard |
Program a +5 s alarm relative to now and enable AIE.
Carries the five-second offset through seconds, minutes, and hours, programs that calendar alarm, then enables both alarm and periodic RTC status sources used by the polling loop.
| [in] | now | Current RTC calendar value used as the alarm origin. |
| k_ra8_ok | The alarm and both requested status sources were enabled. |
| (other) | The first RTC driver error. |
now points to a valid initialized calendar value. now is active. Definition at line 170 of file main.c.
References ra8_rtc_datetime_t::hour, k_ra8_ok, k_ra8_rtc_irq_alarm, k_ra8_rtc_irq_periodic, k_rtc_demo_alarm_offset_s, k_rtc_demo_hours_per_day, k_rtc_demo_mins_per_hour, k_rtc_demo_secs_per_min, ra8_rtc_datetime_t::minute, ra8_rtc_set_alarm(), ra8_rtc_set_irq_enable(), and ra8_rtc_datetime_t::second.
|
static |
Park the processor after an unrecoverable periodic-RTC failure.
Repeats wait-for-interrupt forever, preserving the RTC and console state at the failure point for an attached debugger.
Definition at line 84 of file main.c.
References RA8_INTERNAL.
|
static |
Initialize clocks, console, and the periodic demo's RTC seed.
Starts the clock tree and millisecond time base, opens the board UART console, initializes the RTC, and installs the fixed 2026-01-01 calendar value. Any dependency error enters the fatal halt rather than returning partially initialized state.
Definition at line 109 of file main.c.
References internal_rtc_demo_panic_halt(), k_ra8_clock_id_cpuclk0, k_ra8_ok, k_rtc_demo_baud, k_rtc_demo_seed_day, k_rtc_demo_seed_month, k_rtc_demo_seed_year_lo, k_rtc_demo_year_base, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_rtc_init(), ra8_rtc_set(), 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.
Definition at line 193 of file main.c.
References internal_rtc_demo_arm_alarm(), internal_rtc_demo_panic_halt(), internal_rtc_demo_setup_or_halt(), k_ra8_ok, k_ra8_rtc_irq_alarm, k_ra8_rtc_irq_periodic, k_rtc_demo_advance_secs, k_rtc_demo_ms_per_sec, k_rtc_demo_poll_ms, ra8_board_uart_console_write(), ra8_delay_ms(), ra8_isr_globals_enable(), ra8_rtc_clear_status(), ra8_rtc_get(), ra8_rtc_get_status(), s_rtc_demo_boot_msg, and s_rtc_demo_log_msg.
|
static |