ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

E-reader device chrome – Library + Reading screens. More...

#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "er_pageturn.h"
#include "ereader_ui_steps.h"
#include "literata_latin1.h"
#include "ra8_app.h"
#include "ra8_batt.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_board_ek_ra8d2_touch.h"
#include "ra8_boot_entry.h"
#include "ra8_box.h"
#include "ra8_cgc.h"
#include "ra8_display_pal.h"
#include "ra8_display_pal_lcd.h"
#include "ra8_display_pal_policy.h"
#include "ra8_err.h"
#include "ra8_gfx.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_panel_timing.h"
#include "ra8_port_constants.h"
#include "ra8_port_utils.h"
#include "ra8_sdfont.h"
#include "ra8_sdramc.h"
#include "ra8_time.h"
#include "ra8_touch.h"
#include "ra8_ui.h"
#include "reflow.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  : uint16_t { k_er_clean_every = 8U }
 Default clean-refresh cadence: a GC16 every N fast turns. More...

Functions

 RA8_BOARD_PANEL_FRAMEBUFFER (s_framebuffer)
static void app_panic_halt (void)
 Halt forever with the red board LED on.
static void app_bringup_clocks (void)
 Bring up clocks, MSTP, system tick, and the two board LEDs.
static void app_bringup_panel (void)
 Bring up external SDRAM and the GLCDC panel, then cache the FB.
static void app_bringup_gfx (void)
 Bind ra8_gfx to the panel framebuffer.
static void app_bringup_touch (void)
 Open the GT911 touch controller (best-effort, polled).
static void er_try_load_font (void)
 Best-effort: load FONT.OTF off the Pmod2 SD card into s_font_buf.
static void er_app_render (const ra8_app_t *a)
 App render trampoline: dispatch to the screen render by app id.
static void er_apps_init (void)
 Register the e-reader screen-apps into s_app_reg.
void er_render_current (void)
 Render whichever screen is on top of the navigation stack.
void er_render_nag_region (void)
 Repaint only the low-battery banner rect (dirty-region update).
void er_flush_event (display_turn_event_t event)
 Flush the panel for a refresh event through the cadence policy (#78).
void main (void)
 The application entry point Reset_Handler hands control to.

Variables

const char k_er_wordmark [6] = "PAPYR"
 Wordmark / status text.
const char k_er_lib_heading [] = "PAPYR Library"
 Library heading text.
const char k_er_status_right [] = "10:24 98%"
 Status-bar right text.
const char k_er_search_hint [] = "Search"
 Search placeholder.
const char k_er_count_text [] = "6 books"
 Book-count chip text.
const char k_er_book_title [] = "The Time Machine"
 Reading title text.
const char k_er_page_label [] = "Page 12 of 248"
 Reading page label.
const char k_er_chapter [] = "I"
 Bitmap-fallback heading.
const char *const k_er_nav_items [] = {"Library", "Store", "Notes", "Settings"}
 Bottom-nav destinations.
const er_book_t k_er_books []
 Demo shelf (public-domain works).
const char *const k_er_body_lines []
 Reading-view body paragraph lines (pre-wrapped for the font).
static const char k_er_chapter_xhtml []
 Reading-view chapter as XHTML, reflowed by reflow when an SD font is present (the same prose as k_er_body_lines, but laid out live at the proportional type scale instead of pre-wrapped bitmap lines).
static const char k_er_chapter2_xhtml []
 Reading-view chapter two (cross-chapter <a href> link target).
const er_chapter_t k_er_spine []
 Two-chapter mock spine for in-content cross-chapter navigation (#110).
uint32_t s_chapter_idx
 Index of the chapter currently shown in the Reading view.
static const ra8_port_pin_t k_er_pin_sck = (ra8_port_pin_t)k_ra8_board_pmod2_spi_sck
 Pmod2 SPI pins (J25) – SCI0 Simple-SPI, per sd_font_render.
static const ra8_port_pin_t k_er_pin_cipo = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cipo
static const ra8_port_pin_t k_er_pin_copi = (ra8_port_pin_t)k_ra8_board_pmod2_spi_copi
static const ra8_port_pin_t k_er_pin_cs = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cs
static const display_cfg_t k_er_display_cfg
 Display PAL config – LCD/GLCDC backend over the SDRAM buffer.
static display_handle_ts_display = nullptr
 PAL handle returned by display_init.
display_fb_t s_fb
 Mutable copy of the FB descriptor; populated at boot.
ra8_ui_nav_t s_nav
 Navigation stack (which screen is shown).
ra8_ui_target_t s_targets [k_er_max_targets]
 Tap targets for the current screen (rect + action id).
uint16_t s_target_count
 Number of tap targets currently populated.
ra8_kbd_layout_t s_kb
 On-screen keyboard grid (built by er_render_keyboard, read on tap).
ra8_kbd_text_t s_query
 Live search query typed on the keyboard; filters the Library shelf.
uint32_t s_reading_page
 Reading view: current reflow page index (0-based).
uint32_t s_reading_pages = 1U
 Reading view: total reflow pages from the last layout (>= 1).
ra8_batt_monitor_t s_batt_mon
 Low-battery nag policy state (edge-triggered, see ra8_batt).
ra8_batt_nag_t s_batt_nag = k_ra8_batt_nag_none
 Nag currently shown over the chrome (none = no banner).
uint8_t s_batt_soc = 0U
 Last fuel-gauge SOC percent (for the banner text).
bool s_nag_region_only = false
 Set by er_handle_tap when a tap only toggled the nag (incremental repaint).
static display_policy_t s_policy
 Refresh-cadence policy driving e-ink page-turn waveforms (#78).
display_turn_event_t s_pending_event = k_display_event_chapter
 Pending refresh event for the next flush (set by a tap/button handler).
volatile uint32_t g_er_cur_page
 SWD / --dump-sym telemetry for the headless page-turn HIL (#78).
volatile uint32_t g_er_turns
 Count of page turns applied since boot.
volatile uint32_t g_er_last_hint
 Last display_refresh_hint_t flushed.
volatile uint32_t g_er_loop_ticks
 Free-running main-loop counter – HIL liveness.
er_loc_t s_loc_back [k_er_page_back_cap]
 Reading back-stack for link round-trips (footnote + chapter) (#110).
uint32_t s_loc_back_count
 Entries used in s_loc_back.
uint8_t s_font_buf [k_er_font_cap]
 Font blob read off the SD card – lives in SDRAM (hundreds of KiB).
uint8_t s_img_arena_buf [k_er_img_arena]
 Image-decode bump arena in SDRAM (covers / figures are megabytes).
reflow_t s_reflow_engine
 reflow engine for the Reading body (page / glyph / token pools).
bool s_reflow_open = false
 True while s_reflow_engine holds a laid-out chapter (cache valid).
uint32_t s_reflow_chapter = (uint32_t)k_er_chapter_none
 Chapter index currently laid out in s_reflow_engine (cache key).
int32_t s_reflow_w = 0
 Body geometry the cached layout was paginated for (cache key).
int32_t s_reflow_h = 0
 Body height the layout used.
uint32_t s_font_len
 Bytes of font read off the card (0 if none).
bool s_have_font
 True once an SD font is loaded; gates the reflow body render.
static uint32_t s_pclka_hz
 Cached PCLKA rate (Hz) for the SD SPI clock shim.
static const ra8_widget_vtable_t k_er_nag_vt = {.render = er_nag_render}
 Nag banner overlay widget vtable (renderer lives in the input TU).
static ra8_app_t s_app_library
 Library / Reading / Keyboard (+ optional Settings) app instances.
static ra8_app_t s_app_reader
static ra8_app_t s_app_keyboard
static ra8_app_ts_app_slots [4]
 App registry storage (4 slots: 3 core + an optional Settings).
static ra8_app_registry_t s_app_reg
static const ra8_app_vtable_t k_er_app_vt
 Vtable shared by every screen-app (render-only; nav owns transitions).

Detailed Description

E-reader device chrome – Library + Reading screens.

Tag
[Ring 6 / APP] {World: S}

E-reader UI chrome (issue #80). The application shell is laid out by the bounded box-model engine libs/ra8_box (the #80 box model: stacks, a fixed-column grid, padding/gap, fixed vs flex sizing), rendered into the GLCDC framebuffer through libs/ra8_gfx in the flat 16-level-grayscale language of the verified "PAPYR" proof-of-concept, and navigated through the libs/ra8_ui screen stack. The Reading body renders real reflowed book text through apps/shared_libs/reflow when a font is present on the microSD (FONT.OTF); with no card it falls back to the bundled ra8_gfx bitmap font (#83).

Two screens:

  • Library: status bar, toolbar (search + count), a 2-column grid of book cards (cover + title + author + reading-progress bar), and a bottom navigation strip – all laid out by ra8_box.
  • Reading: status bar, body text at the reading margin, footer with page label + progress bar.

Boot: clocks/MSTP/SysTick/LEDs, then SDRAM + GLCDC (the 1024x600 RGB565 framebuffer lives in external SDRAM), then ra8_gfx bound to it. Layout is resolution-adaptive from the framebuffer the backend reports.

The screen rendering, in-content navigation, on-screen keyboard, battery nag and input polling live in the per-aspect helper translation units under src/ (ereader_ui_screens.c + ereader_ui_input.c); this file keeps boot, the app-framework screen dispatch, and the main loop. See src/ereader_ui_steps.h for the shared contract.

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : uint16_t

Default clean-refresh cadence: a GC16 every N fast turns.

Enumerator
k_er_clean_every 

Er clean every.

Definition at line 260 of file main.c.

Function Documentation

◆ app_bringup_clocks()

void app_bringup_clocks ( void )
static

Bring up clocks, MSTP, system tick, and the two board LEDs.

Same boot order the other full-panel manual demos use.

Precondition
Reset_Handler ran .data/.bss init.
IRQs are still globally disabled.
Postcondition
Clocks, MSTP, ra8_time and both board LEDs are initialised.
Global IRQs are enabled.
Note
Not thread-safe; single-shot helper.
Since
0.1.0

Definition at line 337 of file main.c.

References app_panic_halt(), k_ra8_board_led_blue, k_ra8_board_led_red, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_isr_globals_enable(), ra8_mstp_init(), and ra8_time_init().

◆ app_bringup_gfx()

void app_bringup_gfx ( void )
static

Bind ra8_gfx to the panel framebuffer.

After this, all chrome drawing goes through ra8_gfx primitives.

Precondition
app_bringup_panel has run; s_fb.pixels is reachable.
The framebuffer is RGB565.
Postcondition
ra8_gfx draw calls operate on s_framebuffer.
On failure the app panic-halts.
Note
Not thread-safe; single-shot helper.
Since
0.1.0

Definition at line 403 of file main.c.

References app_panic_halt(), k_ra8_gfx_format_rgb565, k_ra8_ok, ra8_gfx_init(), and s_fb.

◆ app_bringup_panel()

void app_bringup_panel ( void )
static

Bring up external SDRAM and the GLCDC panel, then cache the FB.

Settle delay, ra8_sdramc_init (the framebuffer lives at 0x68000000), then display_init (panel power + GLCDC routing). Caches the FB.

Precondition
app_bringup_clocks has run; IRQs are enabled.
s_framebuffer is reachable.
Postcondition
SDRAM is up; GLCDC scans out s_framebuffer.
s_display non-NULL and s_fb mirrors the backend FB.
Note
Not thread-safe; single-shot helper.
Since
0.1.0

Definition at line 376 of file main.c.

References app_panic_halt(), display_get_framebuffer(), display_init(), k_er_display_cfg, k_er_settle_ms, k_ra8_ok, ra8_delay_ms(), ra8_sdramc_init(), s_display, and s_fb.

◆ app_bringup_touch()

void app_bringup_touch ( void )
static

Open the GT911 touch controller (best-effort, polled).

Brings the app-owned IIC_B peripheral up in I2C-compat mode, binds it through the ra8_io facade into the driver's injected seam, then opens the driver. The fuel-gauge reads in ereader_ui_input.c share this bus bring-up. Boards / emulator runs without the GT911 simply return an error from ra8_touch_open; the UI still renders, just without touch input, so this is non-fatal (no panic).

Precondition
app_bringup_clocks has run (IIC_B clock + MSTP up).
None.
Postcondition
On success the GT911 is configured for polled reads.
On failure touch input is simply unavailable.
Note
Not thread-safe; single-shot helper.
Since
0.1.0

Definition at line 430 of file main.c.

References k_er_touch_max_points, k_ra8_touch_irq_pin_unset, and ra8_board_touch_open().

◆ app_panic_halt()

void app_panic_halt ( void )
static

Halt forever with the red board LED on.

Stuck red LED is the visual sign of a fatal init error.

Precondition
None.
None.
Postcondition
Function never returns; CPU parked in a WFI loop.
Red LED is on.
Note
IRQ-safe.
Since
0.1.0

Definition at line 316 of file main.c.

References k_ra8_board_led_red, and ra8_board_led_on().

◆ er_app_render()

void er_app_render ( const ra8_app_t * a)
static

App render trampoline: dispatch to the screen render by app id.

Definition at line 535 of file main.c.

References er_render_keyboard(), er_render_library(), er_render_reading(), k_er_screen_keyboard, k_er_screen_reading, and k_er_screen_settings.

◆ er_apps_init()

void er_apps_init ( void )
static

◆ er_flush_event()

void er_flush_event ( display_turn_event_t event)

Flush the panel for a refresh event through the cadence policy (#78).

Parameters
[in]eventThe page-transition that occurred (open / turn / chapter).
Precondition
s_policy was initialised and s_display is valid.
s_fb describes the bound framebuffer.
Postcondition
One panel flush is issued; g_er_last_hint / g_er_cur_page are current.
Note
Not thread-safe; the reader UI is single-threaded.
Since
0.1.0

Definition at line 623 of file main.c.

References display_flush(), display_full_rect(), display_policy_decide(), display_policy_full_rect(), g_er_cur_page, g_er_last_hint, display_policy_decision_t::hint, k_display_refresh_quality, k_ra8_ok, s_display, s_fb, s_policy, and s_reading_page.

Referenced by er_poll_battery(), er_poll_buttons(), er_poll_touch(), and main().

◆ er_render_current()

void er_render_current ( void )

Render whichever screen is on top of the navigation stack.

Precondition
ra8_gfx is bound; s_nav initialised.
None.
Postcondition
The framebuffer holds the current screen.
No navigation state mutated beyond focusing the active app.
Note
Not thread-safe.
Since
0.1.0

Definition at line 585 of file main.c.

References k_er_nag_vt, k_er_screen_library, k_ra8_batt_nag_none, ra8_app_launch(), ra8_app_render(), ra8_ui_nav_top(), ra8_widget_render_dirty(), s_app_reg, s_batt_nag, and s_nav.

Referenced by er_poll_buttons(), er_poll_touch(), er_render_nag_region(), and main().

◆ er_render_nag_region()

void er_render_nag_region ( void )

Repaint only the low-battery banner rect (dirty-region update).

Precondition
ra8_gfx is bound; s_nav initialised.
None.
Postcondition
Only the banner rect is repainted (full repaint if clip unavailable).
No navigation state mutated.
Note
Not thread-safe.
Since
0.1.0

Definition at line 602 of file main.c.

References er_render_current(), k_er_nag_h, k_er_nag_margin, k_er_nag_top, k_er_nag_vt, k_er_screen_library, k_ra8_batt_nag_none, k_ra8_ok, ra8_app_launch(), ra8_app_render(), ra8_gfx_reset_clip(), ra8_gfx_set_clip(), ra8_ui_nav_top(), ra8_widget_render_dirty(), s_app_reg, s_batt_nag, s_fb, and s_nav.

Referenced by er_poll_battery(), and er_poll_touch().

◆ er_try_load_font()

void er_try_load_font ( void )
static

Best-effort: load FONT.OTF off the Pmod2 SD card into s_font_buf.

Delegates the Pmod2 SPI bring-up, FAT mount, and font read to ra8_sdfont_load. Entirely non-fatal: any failure (no Pmod, no card, no FONT.OTF) leaves s_have_font false and the Reading view falls back to the baked Latin-1 font (or the bundled bitmap), so the chrome is never broken by the absence of an SD card. Provisioning is left disabled (NULL blob): the e-reader reads whatever the user's card already holds and never writes to it – unlike sd_font_render, which self-provisions a blank card.

Precondition
app_bringup_clocks has run.
s_font_buf is reachable (SDRAM).
Postcondition
On success s_have_font is true and s_font_len > 0.
On any failure s_have_font stays false (no panic, no card write).
Note
Not thread-safe; single-shot helper.
Since
0.1.0

Definition at line 462 of file main.c.

References k_er_font_cap, k_er_pin_cipo, k_er_pin_copi, k_er_pin_cs, k_er_pin_sck, k_er_spi_chan, k_ra8_clock_id_pclka, k_ra8_ok, ra8_cgc_get_clock_hz(), ra8_sdfont_load(), s_font_buf, s_font_len, s_have_font, and s_pclka_hz.

Referenced by main().

◆ 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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has configured the clock tree and VTOR.
Postcondition
Control does not return; the image runs until reset or halt.
Any value the application wanted to report has been logged, not returned.
Note
Not thread-safe; single-threaded startup context only.
Warning
Only valid while the translation unit is compiled -ffreestanding. A hosted build rejects this signature.
See also
SystemInit()
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up CGC + BSP audio then plays blocks.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the playback loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up CGC + GPT triple, runs sweep.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the sweep loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up clocks + UART + RMII pins, then ThreadX.

Precondition
Reset_Handler has copied .data and zeroed .bss.
Postcondition
On clean entry the kernel runs the worker thread once.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up clocks + UART, then enters ThreadX.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the kernel runs the worker thread forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up LED, console, SDHI pins, then ThreadX.

Precondition
Reset_Handler has copied .data + zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
CPUCLK0 is raised to the PLL1 target before the kernel starts.
On clean entry the SD card thread runs forever.
On any HAL init failure the function halts in __WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the iso-IN feed loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
SystemInit set VTOR / FPU / priority grouping.

The application entry point Reset_Handler hands control to.

See file header.

Precondition
Boot init has completed.
The secure-boot library's BLXNS into NS image either failed or was skipped (the call site in ra8_trustzone_init is a no-op on host builds).
Postcondition
Diagnostic counter latched, CPU parked in a halt loop.
Function never returns.
Note
Single-threaded entry.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success g_eoh_chapters / g_eoh_crc hold the parsed results, the banner is emitted, and g_eoh_heartbeat advances once per frame.
On any failure g_eoh_err is non-zero and the CPU parks (no heartbeat).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The chapters/ch0-CRC banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the g_etoc_* result globals hold the parsed TOC values, the banner is emitted, and g_etoc_heartbeat advances once per frame.
On any failure g_etoc_err is non-zero and the CPU parks (no heartbeat).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss; SystemInit set VTOR/FPU.
Postcondition
The shelf scans on the panel; taps open books, browse, and read.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The slab/arena/tile/vmem banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the cache globals are latched and g_pc_heartbeat advances.
On any failure g_pc_err is non-zero and the CPU parks (no heartbeat).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Profiles power modes once a second.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the profile + blink loop.
On any HAL hard error LED2 latches ON.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
The shared board boot files installed the vector table.
Postcondition
The demo has run once and its verdict banner is streaming steadily.
The CPU idles re-emitting the banner (or halts after a fatal init error).
Since
0.1.0

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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the CPU loops forever after the PASS banner.
On any failure the function prints FAIL and halts in WFI.
Note
Not thread-safe; this is the single-threaded app entry.
Since
0.1.0

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.

Precondition
SystemInit configured VTOR / FPU / priority grouping.
The OSPI NOR array is present (modelled in ra8_emulator, real on silicon).
Postcondition
Exactly one PASS or FAIL verdict line has been queued on SCI8.
Control parks in an infinite loop; the function never returns.
Note
Single-threaded; runs to the park loop on the main stack.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The page-count + render-hash banner is emitted; the CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The cal=OK / cal=SKIP result and the finger-free touchcal: ready sentinel are emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The open=OK touch banner is emitted; the CPU then loops in WFI.
Since
0.1.0

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.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU, priority grouping.
Postcondition
On clean entry the CPU stays in tx_kernel_enter forever.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held in reset by hardware until released here.
Postcondition
The M33 has been released and is blinking LED1.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this template.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
The application links ra8_c6link and ESP-hosted generated codecs.
No hardware validation is inferred from this function.
Postcondition
No c6link operation is attempted.
No network or storage state is modified.
Note
Single-threaded compile fixture.
Since
0.1.0

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).

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit enabled the MPU + I-cache + D-cache via the ra8_cache HAL.
Postcondition
Exactly one banner (PASS or FAIL) has been emitted.
The core is parked in WFI.
Note
Single-threaded; no RTOS and no IRQ sources in this template.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held inactive by hardware until released here.
Postcondition
The M33 has built a RABOOK1 blob and the M85 has validated it.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the CPU heartbeats after epaper: PASS.
On any HAL error the console prints epaper: FAIL and the red LED latches on.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The chapters/toc/cover banner is emitted; CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The reader loop runs forever, redrawing on each tap.
A page-1 banner is emitted once after the first render.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The cover-size / framebuffer-CRC banner is emitted; CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The panel shows the reader screen and the input loop runs forever.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held inactive by hardware until released here.
Postcondition
The M33 has rendered + re-rendered the held page and the M85 is parked.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The boot banner is emitted; the reader loop services taps forever.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up the timebase then measures forever.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the measure + blink loop forever.
On any HAL init failure the function halts in WFI.
Note
Never returns.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Arms the RIIC1 target and polls the dispatcher.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
The CPU stays in the dispatch poll loop forever.
On any fatal init error the CPU parks in riic_target_panic_halt.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the PASS banner is printed and the CPU loops in WFI.
On any failure the function prints a FAIL line and halts.
Note
Not thread-safe; single-threaded app entry.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the read + print loop forever.
On any HAL hard error LED2 latches ON and the loop exits.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up the LIN commander then drives frames.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the LIN-frame + blink loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held inactive by hardware until released here.
Postcondition
The M33 owns the held page and the M85 is parked.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

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.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU, priority grouping.
Postcondition
On clean entry the CPU stays in tx_kernel_enter forever.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit configured VTOR / FPU.
Postcondition
On clean bring-up the CPU stays in the poll loop.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler initialized static storage.
SystemInit configured VTOR, FPU, and priority grouping.
Postcondition
The startup banner is printed once.
Control enters ThreadX and never returns normally.
Note
The #707 freestanding contract is declared by ra8_boot_entry.h.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the PASS banner is printed and the CPU heartbeats forever.
On any failure LED2 latches ON and the CPU parks.
Since
0.1.0

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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit installed the boot map via ra8_mpu_apply_boot_map().
Postcondition
Exactly one banner (PASS or a step-specific FAIL) has been emitted.
The core is parked in WFI.
Note
Single-threaded; no RTOS and no IRQ sources in this template.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler initialised the C runtime; SystemInit ran.
The EK-RA8D2 J-Link OB VCOM console is attached for the banner.
Postcondition
The commit + rollback attempts have executed against extra-MRAM.
The verdict banner is emitted once per report cycle.
Note
Single entry point; not re-entrant.
Since
0.1.0

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.

Precondition
SystemInit configured VTOR / FPU / priority grouping.
The extra-MRAM region is present (modelled in ra8_emulator, real on silicon).
Postcondition
Exactly one PASS or FAIL verdict line has been queued on SCI8.
Control parks in an infinite loop; the function never returns.
Note
Single-threaded; runs to the park loop on the main stack.
Since
0.1.0

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.

Precondition
SystemInit configured VTOR / FPU / priority grouping.
The extra-MRAM region is present (modelled in ra8_emulator, real on silicon).
Postcondition
Exactly one PASS or FAIL verdict line has been queued on SCI8.
Control parks in an infinite loop; the function never returns.
Note
Single-threaded; runs to the park loop on the main stack.
Since
0.1.0

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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the CPU loops forever after the PASS banner.
On any failure the function prints FAIL and halts in WFI.
Note
Not thread-safe; this is the single-threaded app entry.
Since
0.1.0

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.

Precondition
SystemInit configured VTOR / FPU / priority grouping.
The OSPI NOR array is present (modelled in ra8_emulator, real on silicon).
Postcondition
A PASS or FAIL verdict line has been queued on SCI8 for each abstraction.
Control parks in an infinite loop; the function never returns.
Note
Single-threaded; runs to the park loop on the main stack.
Since
0.1.0

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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the CPU loops forever after the PASS banner.
On any failure the function prints FAIL and halts in WFI.
Note
Not thread-safe; this is the single-threaded app entry.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The whoami PASS banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up clocks + UART + RMII + RSIP, then ThreadX.

Precondition
Reset_Handler has copied .data and zeroed .bss.
Postcondition
On clean entry the kernel runs the worker thread once.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, the FPU and the priority grouping.
Postcondition
The banner was printed exactly once.
Control passed to ThreadX and never came back.
Note
Everything after tx_kernel_enter happens on ThreadX; the panic-halt below is reached only if the kernel refuses to start.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, the FPU and the priority grouping.
Postcondition
The banner and the resolved pin map were printed exactly once.
Control passed to ThreadX and never came back.
Note
Everything after tx_kernel_enter happens on ThreadX; the panic-halt below is reached only if the kernel refuses to start.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, the FPU and priority grouping.
Postcondition
The probe ran exactly once and printed its verdict.
The CPU stays in a slow heartbeat loop afterwards.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, the FPU and the priority grouping.
Postcondition
The banner was printed exactly once.
Control passed to ThreadX and never came back.
Note
Everything after tx_kernel_enter runs on ThreadX; the panic-halt below is reached only if the kernel refuses to start.
Since
0.1.0

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.

Precondition
Reset startup and SystemInit completed successfully.
The selected ADC channel matches the board analog connection.
Postcondition
Every PASS verdict follows a successful channel read.
Any read or LED failure leads to the terminal panic helper.
Note
Does not return during normal operation.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the PASS banner is emitted; otherwise a FAIL line is.
The CPU parks in WFI (observable on ra8_emulator until its budget).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up logging, releases the Cortex-M33 (which then blinks LED1), and idles. See the file header for the teaching narrative.

Precondition
SystemInit has completed core bring-up.
The M33 is held in reset by hardware until released here.
Postcondition
The M33 has been released and is blinking LED1.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this template.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The IDCODE/checks PASS banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

See the file header for the full behaviour summary.

Precondition
SystemInit has enabled the caches + MPU (this build defines RA8_BOOT_ENABLE_CACHE_MPU).
The M33 is held in reset by hardware until released here.
Postcondition
The M33 has been released and the round-trip loop is running.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this template.
Since
0.1.0

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 (cacheable SRAM, RO MRAM const, Device MMIO), 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 and MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU).

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit enabled the MPU + I-cache + D-cache (cache+MPU build).
Postcondition
Exactly one banner (PASS or a step-specific FAIL) has been emitted.
The core is parked in WFI.
Note
Single-threaded; no RTOS and no IRQ sources in this template.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU and priority grouping.
Postcondition
The verdict banner is on SCI8 and the CPU parks.
The result globals hold the outcome for SWD probing.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Lights HOCO + PLL, then runs a 1 Hz blink.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the toggle loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

See file header for behaviour summary.

Precondition
Boot init has completed.
CPU1 is held in reset.
Postcondition
CPU1 released and the ping-pong loop running.
Function never returns.
Note
Single-threaded entry.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU, priority grouping.
Postcondition
Control passes to the active app, or to the ThreadX-hosted DFU device.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss; SystemInit ran.
The embedded image's first two words are a valid MSP + Thumb reset vector.
Postcondition
On success, control is at the image's reset vector in the SRAM run window.
On a failed run-target check, control parks in internal_dcr_panic_halt.
Note
Single entry point; not re-entrant.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU, priority grouping.
Postcondition
On clean entry the CPU stays in tx_kernel_enter forever.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit enabled the MPU + caches via RA8_BOOT_ENABLE_CACHE_MPU.
Postcondition
Exactly one PASS/FAIL banner is emitted, then the core parks.
The core ends in WFI so ra8_emulator's idle-stop terminates the run.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Initializes the demo, executes one comparison per period, increments the exported match or mismatch counter, and toggles the matching LED.

Precondition
Reset startup and SystemInit completed successfully.
DOC and the status LEDs are not owned by another context.
Postcondition
Every iteration increments exactly one HIL result counter.
LED1 represents matches and LED2 represents failures or mismatches.
Note
Does not return during normal operation.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up the clock tree, MSTP, ISR/ELC, and the VCOM console, programs a software-triggered DTC block copy, runs it with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit enabled the MPU + caches via RA8_BOOT_ENABLE_CACHE_MPU.
Postcondition
Exactly one PASS/FAIL banner is emitted, then the core parks.
The core ends in WFI so ra8_emulator's idle-stop terminates the run.
Note
Single-threaded; the completion IRQ is left masked and the result polled.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up logging, zeros the shared control block, releases the Cortex-M33, waits for its boot signature, then yields while the M33 counts autonomously to k_bg_target_count. After the M33 sets done, the M85 reads the counter and logs the PASS/FAIL verdict.

Precondition
SystemInit has completed core bring-up.
The M33 is held in reset by hardware until released here.
Postcondition
The M33 has autonomously incremented the counter and set done.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up logging, releases the Cortex-M33, confirms it booted, runs k_m85_demo_rounds narrated mailbox rounds, then drops into the idle heartbeat. See the file header for the teaching narrative.

Precondition
SystemInit has completed core bring-up.
The M33 is held in reset by hardware until released here.
Postcondition
The M33 has been released and the mailbox exchange is running.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Fires ELC software events once a second.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the trigger + blink loop.
On any HAL hard error LED2 latches ON.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The geometry-hash banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The framebuffer hash banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The bmp/gif framebuffer-CRC banner is emitted; CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The hit-test / nav result banner is emitted; the CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The nav-result banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The per-chapter page-count + render-hash banner is emitted; loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The svg-size / framebuffer-CRC banner is emitted; CPU loops in WFI.
Since
0.1.0

Definition at line 638 of file main.c.

References app_bringup_clocks(), app_bringup_gfx(), app_bringup_panel(), app_bringup_touch(), display_policy_init(), er_apps_init(), er_flush_event(), er_poll_battery(), er_poll_buttons(), er_poll_touch(), er_render_current(), er_try_load_font(), g_er_loop_ticks, k_display_event_open, k_display_policy_fast_clean, k_er_clean_every, k_er_frame_ms, k_er_led_every, k_er_screen_library, k_ra8_board_led_blue, k_ra8_board_sw1, k_ra8_board_sw2, ra8_batt_monitor_init(), ra8_board_led_toggle(), ra8_board_sw_init(), ra8_delay_ms(), ra8_ui_nav_init(), s_batt_mon, s_nav, and s_policy.

◆ RA8_BOARD_PANEL_FRAMEBUFFER()

RA8_BOARD_PANEL_FRAMEBUFFER ( s_framebuffer )

References s_framebuffer.

Variable Documentation

◆ g_er_cur_page

volatile uint32_t g_er_cur_page

SWD / --dump-sym telemetry for the headless page-turn HIL (#78).

Current reading page after the last turn.

Definition at line 254 of file main.c.

Referenced by er_flush_event().

◆ g_er_last_hint

volatile uint32_t g_er_last_hint

Last display_refresh_hint_t flushed.

Definition at line 256 of file main.c.

Referenced by er_flush_event().

◆ g_er_loop_ticks

volatile uint32_t g_er_loop_ticks

Free-running main-loop counter – HIL liveness.

Definition at line 257 of file main.c.

Referenced by main().

◆ g_er_turns

volatile uint32_t g_er_turns

Count of page turns applied since boot.

Definition at line 255 of file main.c.

Referenced by er_apply_pageturn().

◆ k_er_app_vt

const ra8_app_vtable_t k_er_app_vt
static
Initial value:
= {
.render = er_app_render,
}
static void er_app_render(const ra8_app_t *a)
App render trampoline: dispatch to the screen render by app id.
Definition main.c:535

Vtable shared by every screen-app (render-only; nav owns transitions).

Definition at line 551 of file main.c.

Referenced by er_apps_init().

◆ k_er_body_lines

const char* const k_er_body_lines[]
Initial value:
= {
"The Time Traveller (for so it will be convenient to speak of him)",
"was expounding a recondite matter to us. His pale grey eyes shone",
"and twinkled, and his usually pale face was flushed and animated.",
"",
"The fire burnt brightly, and the soft radiance of the incandescent",
"lights in the lilies of silver caught the bubbles that flashed and",
"passed in our glasses. Our chairs, being his patents, embraced and",
"caressed us rather than submitted to be sat upon -- there was that",
"luxurious after-dinner atmosphere when thought roams gracefully free",
"of the trammels of precision.",
}

Reading-view body paragraph lines (pre-wrapped for the font).

Definition at line 110 of file main.c.

Referenced by er_draw_reading_body().

◆ k_er_book_title

const char k_er_book_title[] = "The Time Machine"

Reading title text.

Definition at line 86 of file main.c.

Referenced by er_read_footer_render(), and er_read_sb_render().

◆ k_er_books

const er_book_t k_er_books[]
Initial value:
= {
{"The Time Machine", "H. G. Wells", 5U},
{"Frankenstein", "Mary Shelley", 100U},
{"Pride and Prejudice", "Jane Austen", 42U},
{"Moby-Dick", "Herman Melville", 12U},
{"The Republic", "Plato", 68U},
{"Meditations", "M. Aurelius", 30U},
}

Demo shelf (public-domain works).

Definition at line 96 of file main.c.

Referenced by er_build_library().

◆ k_er_chapter

const char k_er_chapter[] = "I"

Bitmap-fallback heading.

Definition at line 88 of file main.c.

Referenced by er_draw_reading_body().

◆ k_er_chapter2_xhtml

const char k_er_chapter2_xhtml[]
static
Initial value:
=
"<html><body><h1>Chapter II</h1>"
"<p>The Machine, said the Time Traveller, holding the lamp aloft, is the thing "
"I have been at work upon these many years; and now at last it is built.</p>"
"<p>He took one of the small octahedral things from the table and handed it to "
"us. <a href=\"ch1.xhtml\">Back to Chapter I</a>.</p></body></html>"

Reading-view chapter two (cross-chapter <a href> link target).

Definition at line 156 of file main.c.

◆ k_er_chapter_xhtml

const char k_er_chapter_xhtml[]
static
Initial value:
=
"<html><head><style>h1 { text-align: center; color: maroon; }"
".byline { text-align: right; text-decoration: underline; color: #808080; font-size: 14px; }"
".lead { font-size: 130%; } .draft { display: none; }"
" p.lead { color: navy; }</style></head>"
"<body><h1>The Time Machine</h1>"
"<p class=\"draft\">INTERNAL DRAFT -- NOT FOR DISTRIBUTION</p>"
"<p class=\"byline\">by H. G. Wells</p>"
"<img src=\"logo.svg\"/>"
"<p class=\"lead\">The Time Traveller (for so it will be convenient to speak of him) was "
"expounding a recondite matter to us. See the "
"<a href=\"#note\">editor's note</a> for context. His pale grey eyes shone "
"and twinkled, and his usually pale face was flushed and animated.</p>"
"<p>The fire burnt brightly, and the soft radiance of the incandescent lights "
"in the lilies of silver caught the bubbles that flashed and passed in our "
"glasses. Our chairs, being his patents, embraced and caressed us rather than "
"submitted to be sat upon, and thought roamed gracefully free of the trammels "
"of precision.</p>"
"<p id=\"note\">Editor's note: this passage introduces the frame narrator "
"before the Traveller's account begins. <a href=\"ch2.xhtml\">Continue to "
"Chapter II</a>.</p></body></html>"

Reading-view chapter as XHTML, reflowed by reflow when an SD font is present (the same prose as k_er_body_lines, but laid out live at the proportional type scale instead of pre-wrapped bitmap lines).

Kept short so the software glyph rasteriser stays quick under the ra8_emulator CPU emulator.

Definition at line 133 of file main.c.

◆ k_er_count_text

const char k_er_count_text[] = "6 books"

Book-count chip text.

Definition at line 85 of file main.c.

Referenced by er_build_toolbar().

◆ k_er_display_cfg

const display_cfg_t k_er_display_cfg
static
Initial value:
= {
.framebuffer = s_framebuffer,
.framebuffer_bytes = sizeof(s_framebuffer),
.width_px = (uint16_t)k_er_fb_w,
.height_px = (uint16_t)k_er_fb_h,
.panel_timing = &s_ra8_panel_ek_ra8d2_timing,
}
@ k_er_fb_w
Framebuffer width (pixels).
@ k_er_fb_h
Framebuffer height (pixels).
static uint16_t s_framebuffer[(size_t) k_panel_height_px *(size_t) k_panel_width_px]
1024x600 RGB565 framebuffer in external SDRAM (GLCDC scans this).
Definition main.c:67
@ k_display_pixfmt_rgb565
16 bpp, 5/6/5 packed.
const display_backend_iface_t k_display_backend_lcd_ra8_glcdc
LCD backend vtable – pass its address through display_cfg_t.iface to drive the EK-RA8D2 panel.
static const ra8_glcdc_timing_t s_ra8_panel_ek_ra8d2_timing
EK-RA8D2 ER-TFT070-6 RGB timing for ra8_glcdc_init / the LCD backend.

Display PAL config – LCD/GLCDC backend over the SDRAM buffer.

Definition at line 197 of file main.c.

Referenced by app_bringup_panel().

◆ k_er_lib_heading

const char k_er_lib_heading[] = "PAPYR Library"

Library heading text.

Definition at line 82 of file main.c.

Referenced by er_build_library().

◆ k_er_nag_vt

const ra8_widget_vtable_t k_er_nag_vt = {.render = er_nag_render}
static

Nag banner overlay widget vtable (renderer lives in the input TU).

Definition at line 297 of file main.c.

Referenced by er_render_current(), and er_render_nag_region().

◆ k_er_nav_items

const char* const k_er_nav_items[] = {"Library", "Store", "Notes", "Settings"}

Bottom-nav destinations.

Bottom-nav destinations (Library / Store / Notes / Settings).

Definition at line 91 of file main.c.

Referenced by er_build_nav().

◆ k_er_page_label

const char k_er_page_label[] = "Page 12 of 248"

Reading page label.

Definition at line 87 of file main.c.

Referenced by er_read_footer_render().

◆ k_er_pin_cipo

Definition at line 182 of file main.c.

Referenced by er_try_load_font().

◆ k_er_pin_copi

Definition at line 183 of file main.c.

Referenced by er_try_load_font().

◆ k_er_pin_cs

Definition at line 184 of file main.c.

Referenced by er_try_load_font().

◆ k_er_pin_sck

Pmod2 SPI pins (J25) – SCI0 Simple-SPI, per sd_font_render.

Definition at line 181 of file main.c.

Referenced by er_try_load_font().

◆ k_er_search_hint

const char k_er_search_hint[] = "Search"

Search placeholder.

Definition at line 84 of file main.c.

Referenced by er_build_toolbar(), and er_kbd_search_render().

◆ k_er_spine

const er_chapter_t k_er_spine[]
Initial value:
= {
(uint32_t)(sizeof(k_er_chapter_xhtml) - 1U),
"ch1.xhtml",
(uint32_t)(sizeof("ch1.xhtml") - 1U)},
(uint32_t)(sizeof(k_er_chapter2_xhtml) - 1U),
"ch2.xhtml",
(uint32_t)(sizeof("ch2.xhtml") - 1U)},
}
static const char k_er_chapter2_xhtml[]
Reading-view chapter two (cross-chapter <a href> link target).
Definition main.c:156
static const char k_er_chapter_xhtml[]
Reading-view chapter as XHTML, reflowed by reflow when an SD font is present (the same prose as k_er_...
Definition main.c:133

Two-chapter mock spine for in-content cross-chapter navigation (#110).

Definition at line 164 of file main.c.

Referenced by er_nav_chapter(), and er_reflow_relayout().

◆ k_er_status_right

const char k_er_status_right[] = "10:24 98%"

Status-bar right text.

Definition at line 83 of file main.c.

Referenced by er_lib_sb_render(), and er_read_sb_render().

◆ k_er_wordmark

const char k_er_wordmark[6] = "PAPYR"

Wordmark / status text.

Complete bound so er_read_sb_render can take sizeof to advance past it (a static_assert in main.c pins the size).

Definition at line 80 of file main.c.

Referenced by er_read_sb_render().

◆ s_app_keyboard

ra8_app_t s_app_keyboard
static

Definition at line 525 of file main.c.

Referenced by er_apps_init().

◆ s_app_library

ra8_app_t s_app_library
static

Library / Reading / Keyboard (+ optional Settings) app instances.

Definition at line 523 of file main.c.

Referenced by er_apps_init().

◆ s_app_reader

ra8_app_t s_app_reader
static

Definition at line 524 of file main.c.

Referenced by er_apps_init().

◆ s_app_reg

ra8_app_registry_t s_app_reg
static

Definition at line 532 of file main.c.

Referenced by er_apps_init(), er_render_current(), and er_render_nag_region().

◆ s_app_slots

ra8_app_t* s_app_slots[4]
static

App registry storage (4 slots: 3 core + an optional Settings).

Definition at line 531 of file main.c.

Referenced by er_apps_init().

◆ s_batt_mon

ra8_batt_monitor_t s_batt_mon

Low-battery nag policy state (edge-triggered, see ra8_batt).

Low-battery nag policy state.

Definition at line 235 of file main.c.

Referenced by er_poll_battery(), and main().

◆ s_batt_nag

Nag currently shown over the chrome (none = no banner).

Nag currently shown over the chrome.

Definition at line 237 of file main.c.

Referenced by er_handle_tap(), er_nag_render(), er_poll_battery(), er_render_current(), and er_render_nag_region().

◆ s_batt_soc

uint8_t s_batt_soc = 0U

Last fuel-gauge SOC percent (for the banner text).

Last fuel-gauge SOC percent.

Definition at line 239 of file main.c.

Referenced by er_nag_render(), and er_poll_battery().

◆ s_chapter_idx

uint32_t s_chapter_idx

Index of the chapter currently shown in the Reading view.

Reading chapter index.

Definition at line 178 of file main.c.

Referenced by er_apply_pageturn(), er_draw_reading_body_reflow(), er_handle_reading_tap(), er_handle_tap(), er_nav_chapter(), er_push_loc(), and er_reflow_relayout().

◆ s_display

display_handle_t* s_display = nullptr
static

PAL handle returned by display_init.

Definition at line 208 of file main.c.

◆ s_fb

Mutable copy of the FB descriptor; populated at boot.

Mutable copy of the FB descriptor.

Definition at line 211 of file main.c.

◆ s_font_buf

uint8_t s_font_buf[k_er_font_cap]

Font blob read off the SD card – lives in SDRAM (hundreds of KiB).

Font blob read off the SD card.

Definition at line 271 of file main.c.

◆ s_font_len

uint32_t s_font_len

Bytes of font read off the card (0 if none).

Bytes of font read off the card.

Definition at line 288 of file main.c.

Referenced by er_draw_reading_body_reflow(), and er_try_load_font().

◆ s_have_font

bool s_have_font

True once an SD font is loaded; gates the reflow body render.

True once an SD font is loaded.

Definition at line 291 of file main.c.

Referenced by er_draw_reading_body_reflow(), and er_try_load_font().

◆ s_img_arena_buf

uint8_t s_img_arena_buf[k_er_img_arena]

Image-decode bump arena in SDRAM (covers / figures are megabytes).

Image-decode bump arena in SDRAM.

Definition at line 274 of file main.c.

Referenced by er_reflow_relayout().

◆ s_kb

On-screen keyboard grid (built by er_render_keyboard, read on tap).

On-screen keyboard grid.

Definition at line 223 of file main.c.

Referenced by er_draw_key(), er_handle_keyboard_tap(), er_kbd_keys_render(), er_kbd_label(), kb_key_of(), kb_key_of_kind(), kb_tap(), and main().

◆ s_loc_back

Reading back-stack for link round-trips (footnote + chapter) (#110).

Reading back-stack for link jumps.

Definition at line 265 of file main.c.

Referenced by er_handle_reading_tap(), and er_push_loc().

◆ s_loc_back_count

uint32_t s_loc_back_count

Entries used in s_loc_back.

Entries used in s_loc_back.

Definition at line 268 of file main.c.

Referenced by er_handle_reading_tap(), er_handle_tap(), and er_push_loc().

◆ s_nag_region_only

bool s_nag_region_only = false

Set by er_handle_tap when a tap only toggled the nag (incremental repaint).

True when a tap only toggled the nag.

Definition at line 241 of file main.c.

Referenced by er_handle_tap(), and er_poll_touch().

◆ s_nav

ra8_ui_nav_t s_nav

Navigation stack (which screen is shown).

Navigation stack (active screen).

Definition at line 214 of file main.c.

◆ s_pclka_hz

uint32_t s_pclka_hz
static

Cached PCLKA rate (Hz) for the SD SPI clock shim.

Definition at line 294 of file main.c.

◆ s_pending_event

Pending refresh event for the next flush (set by a tap/button handler).

Pending refresh event for next flush.

Defaults to a clean chapter-boundary refresh for any screen change; a same-chapter page turn lowers it to k_display_event_turn.

Definition at line 251 of file main.c.

Referenced by er_apply_pageturn(), er_handle_tap(), er_poll_buttons(), and er_poll_touch().

◆ s_policy

display_policy_t s_policy
static

Refresh-cadence policy driving e-ink page-turn waveforms (#78).

Definition at line 244 of file main.c.

Referenced by er_flush_event(), and main().

◆ s_query

ra8_kbd_text_t s_query

Live search query typed on the keyboard; filters the Library shelf.

Live search query.

Definition at line 226 of file main.c.

Referenced by er_book_matches(), er_handle_keyboard_tap(), er_handle_tap(), and er_kbd_search_render().

◆ s_reading_page

uint32_t s_reading_page

Reading view: current reflow page index (0-based).

Reading current reflow page.

Definition at line 229 of file main.c.

Referenced by er_apply_pageturn(), er_draw_reading_body_reflow(), er_flush_event(), er_handle_reading_tap(), er_handle_tap(), er_nav_chapter(), er_nav_fragment(), er_push_loc(), er_read_footer_render(), and er_reading_link_tap().

◆ s_reading_pages

uint32_t s_reading_pages = 1U

Reading view: total reflow pages from the last layout (>= 1).

Reading total reflow pages (>= 1).

Definition at line 232 of file main.c.

Referenced by er_apply_pageturn(), er_draw_reading_body_reflow(), er_read_footer_render(), and er_reflow_relayout().

◆ s_reflow_chapter

uint32_t s_reflow_chapter = (uint32_t)k_er_chapter_none

Chapter index currently laid out in s_reflow_engine (cache key).

Chapter laid out (cache key).

Definition at line 282 of file main.c.

Referenced by er_draw_reading_body_reflow(), and er_reflow_relayout().

◆ s_reflow_engine

reflow_t s_reflow_engine

reflow engine for the Reading body (page / glyph / token pools).

reflow engine for the body.

Definition at line 277 of file main.c.

Referenced by er_bind_glyph_atlas(), er_draw_reading_body_reflow(), er_nav_chapter(), er_nav_fragment(), er_reading_link_tap(), and er_reflow_relayout().

◆ s_reflow_h

int32_t s_reflow_h = 0

Body height the layout used.

See also
s_reflow_w

Definition at line 285 of file main.c.

Referenced by er_draw_reading_body_reflow(), and er_reflow_relayout().

◆ s_reflow_open

bool s_reflow_open = false

True while s_reflow_engine holds a laid-out chapter (cache valid).

True while the engine holds a layout.

Definition at line 280 of file main.c.

Referenced by er_draw_reading_body_reflow(), and er_reflow_relayout().

◆ s_reflow_w

int32_t s_reflow_w = 0

Body geometry the cached layout was paginated for (cache key).

Body width the layout used.

Definition at line 284 of file main.c.

Referenced by er_draw_reading_body_reflow(), and er_reflow_relayout().

◆ s_target_count

uint16_t s_target_count

Number of tap targets currently populated.

Tap targets currently populated.

Definition at line 220 of file main.c.

Referenced by er_collect_targets(), er_handle_keyboard_tap(), er_handle_tap(), and er_kbd_keys_render().

◆ s_targets

Tap targets for the current screen (rect + action id).

Tap targets for the current screen.

Definition at line 217 of file main.c.

Referenced by er_collect_targets(), er_handle_keyboard_tap(), er_handle_tap(), and er_kbd_keys_render().