ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
40
41#include <stddef.h>
42#include <stdint.h>
43#include <string.h>
44
45#include "er_pageturn.h"
46#include "ereader_ui_steps.h"
47#include "literata_latin1.h"
48#include "ra8_app.h"
49#include "ra8_batt.h"
50#include "ra8_board_ek_ra8d2.h"
52#include "ra8_boot_entry.h"
53#include "ra8_box.h"
54#include "ra8_cgc.h"
55#include "ra8_display_pal.h"
56#include "ra8_display_pal_lcd.h"
58#include "ra8_err.h"
59#include "ra8_gfx.h"
60#include "ra8_isr.h"
61#include "ra8_mstp.h"
62#include "ra8_panel_timing.h"
63#include "ra8_port_constants.h"
64#include "ra8_port_utils.h"
65#include "ra8_sdfont.h"
66#include "ra8_sdramc.h"
67#include "ra8_time.h"
68#include "ra8_touch.h"
69#include "ra8_ui.h"
70#include "reflow.h"
71
72/* ===========================================================================
73 * Static content (ASCII; public-domain titles)
74 *
75 * Defined here (single definition site) and shared with the helper translation
76 * units through the ``extern`` declarations in ereader_ui_steps.h.
77 * =========================================================================== */
78
80const char k_er_wordmark[6] = "PAPYR";
81static_assert(sizeof(k_er_wordmark) == 6U, "k_er_wordmark size pins the er_read_sb_render advance");
82const char k_er_lib_heading[] = "PAPYR Library";
83const char k_er_status_right[] = "10:24 98%";
84const char k_er_search_hint[] = "Search";
85const char k_er_count_text[] = "6 books";
86const char k_er_book_title[] = "The Time Machine";
87const char k_er_page_label[] = "Page 12 of 248";
88const char k_er_chapter[] = "I";
89
91const char* const k_er_nav_items[] = {"Library", "Store", "Notes", "Settings"};
92static_assert((sizeof(k_er_nav_items) / sizeof(k_er_nav_items[0])) == (size_t)k_er_nav_count,
93 "k_er_nav_count must match k_er_nav_items");
94
97 {"The Time Machine", "H. G. Wells", 5U},
98 {"Frankenstein", "Mary Shelley", 100U},
99 {"Pride and Prejudice", "Jane Austen", 42U},
100 {"Moby-Dick", "Herman Melville", 12U},
101 {"The Republic", "Plato", 68U},
102 {"Meditations", "M. Aurelius", 30U},
103};
104static_assert((sizeof(k_er_books) / sizeof(k_er_books[0])) == (size_t)k_er_book_count,
105 "k_er_book_count must match k_er_books");
106
110const char* const k_er_body_lines[] = {
111 "The Time Traveller (for so it will be convenient to speak of him)",
112 "was expounding a recondite matter to us. His pale grey eyes shone",
113 "and twinkled, and his usually pale face was flushed and animated.",
114 "",
115 "The fire burnt brightly, and the soft radiance of the incandescent",
116 "lights in the lilies of silver caught the bubbles that flashed and",
117 "passed in our glasses. Our chairs, being his patents, embraced and",
118 "caressed us rather than submitted to be sat upon -- there was that",
119 "luxurious after-dinner atmosphere when thought roams gracefully free",
120 "of the trammels of precision.",
121};
122static_assert((sizeof(k_er_body_lines) / sizeof(k_er_body_lines[0])) ==
123 (size_t)k_er_body_line_count,
124 "k_er_body_line_count must match k_er_body_lines");
125
133static const char k_er_chapter_xhtml[] =
134 "<html><head><style>h1 { text-align: center; color: maroon; }"
135 ".byline { text-align: right; text-decoration: underline; color: #808080; font-size: 14px; }"
136 ".lead { font-size: 130%; } .draft { display: none; }"
137 " p.lead { color: navy; }</style></head>"
138 "<body><h1>The Time Machine</h1>"
139 "<p class=\"draft\">INTERNAL DRAFT -- NOT FOR DISTRIBUTION</p>"
140 "<p class=\"byline\">by H. G. Wells</p>"
141 "<img src=\"logo.svg\"/>"
142 "<p class=\"lead\">The Time Traveller (for so it will be convenient to speak of him) was "
143 "expounding a recondite matter to us. See the "
144 "<a href=\"#note\">editor's note</a> for context. His pale grey eyes shone "
145 "and twinkled, and his usually pale face was flushed and animated.</p>"
146 "<p>The fire burnt brightly, and the soft radiance of the incandescent lights "
147 "in the lilies of silver caught the bubbles that flashed and passed in our "
148 "glasses. Our chairs, being his patents, embraced and caressed us rather than "
149 "submitted to be sat upon, and thought roamed gracefully free of the trammels "
150 "of precision.</p>"
151 "<p id=\"note\">Editor's note: this passage introduces the frame narrator "
152 "before the Traveller's account begins. <a href=\"ch2.xhtml\">Continue to "
153 "Chapter II</a>.</p></body></html>";
154
156static const char k_er_chapter2_xhtml[] =
157 "<html><body><h1>Chapter II</h1>"
158 "<p>The Machine, said the Time Traveller, holding the lamp aloft, is the thing "
159 "I have been at work upon these many years; and now at last it is built.</p>"
160 "<p>He took one of the small octahedral things from the table and handed it to "
161 "us. <a href=\"ch1.xhtml\">Back to Chapter I</a>.</p></body></html>";
162
166 (uint32_t)(sizeof(k_er_chapter_xhtml) - 1U),
167 "ch1.xhtml",
168 (uint32_t)(sizeof("ch1.xhtml") - 1U)},
170 (uint32_t)(sizeof(k_er_chapter2_xhtml) - 1U),
171 "ch2.xhtml",
172 (uint32_t)(sizeof("ch2.xhtml") - 1U)},
173};
174static_assert((sizeof(k_er_spine) / sizeof(k_er_spine[0])) == (size_t)k_er_spine_count,
175 "k_er_spine_count must match k_er_spine");
176
179
185
186/* ===========================================================================
187 * Static storage
188 * =========================================================================== */
189
195
199 .framebuffer = s_framebuffer,
200 .framebuffer_bytes = sizeof(s_framebuffer),
201 .width_px = (uint16_t)k_er_fb_w,
202 .height_px = (uint16_t)k_er_fb_h,
203 .pixfmt = k_display_pixfmt_rgb565,
204 .panel_timing = &s_ra8_panel_ek_ra8d2_timing,
205};
206
208static display_handle_t* s_display = nullptr;
209
212
215
218
221
224
227
230
232uint32_t s_reading_pages = 1U;
233
239uint8_t s_batt_soc = 0U;
241bool s_nag_region_only = false;
242
245
252
254volatile uint32_t g_er_cur_page;
255volatile uint32_t g_er_turns;
256volatile uint32_t g_er_last_hint;
257volatile uint32_t g_er_loop_ticks;
258
260enum : uint16_t {
262};
263
266
269
271[[gnu::section(".sdram_data")]] uint8_t s_font_buf[k_er_font_cap];
272
274[[gnu::section(".sdram_data")]] uint8_t s_img_arena_buf[k_er_img_arena];
275
278
280bool s_reflow_open = false;
284int32_t s_reflow_w = 0;
285int32_t s_reflow_h = 0;
286
288uint32_t s_font_len;
289
292
294static uint32_t s_pclka_hz;
295
298
299/* ===========================================================================
300 * Boot helpers
301 * =========================================================================== */
302
316static void app_panic_halt(void)
317{
319 while (1) {
320 __asm__ volatile("wfi");
321 }
322}
323
337static void app_bringup_clocks(void)
338{
339 uint32_t cpuclk0_hz = 0U;
340 if (ra8_cgc_init() != k_ra8_ok) {
342 }
345 }
346 if (ra8_mstp_init() != k_ra8_ok) {
348 }
349 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
351 }
354 }
357 }
359}
360
376static void app_bringup_panel(void)
377{
378 ra8_delay_ms((uint32_t)k_er_settle_ms);
379 if (ra8_sdramc_init() != k_ra8_ok) {
381 }
384 }
387 }
388}
389
403static void app_bringup_gfx(void)
404{
405 if (ra8_gfx_init(s_fb.pixels, s_fb.width_px, s_fb.height_px, k_ra8_gfx_format_rgb565) !=
406 k_ra8_ok) {
408 }
409}
410
430static void app_bringup_touch(void)
431{
432 const ra8_board_touch_cfg_t cfg = {
433 .max_points = (uint8_t)k_er_touch_max_points,
434 .irq_pin = (uint8_t)k_ra8_touch_irq_pin_unset,
435 };
436 (void)ra8_board_touch_open(&cfg);
437}
438
439/* ===========================================================================
440 * Optional SD-loaded font for the reflow Reading body
441 * =========================================================================== */
442
462static void er_try_load_font(void)
463{
465 return;
466 }
467 const ra8_sdfont_cfg_t cfg = {
468 .spi_channel = (uint8_t)k_er_spi_chan,
469 .sck = k_er_pin_sck,
470 .cipo = k_er_pin_cipo,
471 .copi = k_er_pin_copi,
472 .cs = k_er_pin_cs,
473 .pclka_hz = s_pclka_hz,
474 .filename = "FONT.OTF",
475 .provision_blob = nullptr, /* read-only: never write to the user's card */
476 .provision_len = 0U,
477 };
478 uint32_t got = 0U;
479 if (ra8_sdfont_load(&cfg, s_font_buf, (uint32_t)k_er_font_cap, &got, nullptr) != k_ra8_ok) {
480 return;
481 }
482 s_font_len = got;
483 s_have_font = true;
484}
485
486#ifdef RA8_APP_SETTINGS
500static void er_render_settings(void)
501{
502 (void)ra8_gfx_clear((uint32_t)k_er_paper);
503 (void)ra8_gfx_rect(0, 0, (int32_t)k_er_fb_w, (int32_t)k_er_statusbar_h, (uint32_t)k_er_ink, true);
504 s_target_count = 0U;
505}
506#endif
507
508/* ===========================================================================
509 * App framework integration (#146)
510 *
511 * Each screen is re-expressed as an ``ra8_app``: the screen-id stack (``s_nav``)
512 * remains the source of truth for *which* screen is active, and that id is the
513 * active app's id, so ::er_render_current focuses the matching app and renders
514 * its tree. The render callbacks are the existing ``er_render_*`` functions, so
515 * the composited chrome is byte-identical (``just apps::emulator::golden`` stays green)
516 * while the control flow is now an app composition rather than a hardcoded
517 * if/else. ``RA8_APP_SETTINGS`` shows the build-time "uninstallable core" knob: a
518 * Settings app is only registered when the macro is defined.
519 * ===========================================================================
520 */
521
526#ifdef RA8_APP_SETTINGS
527static ra8_app_t s_app_settings;
528#endif
529
533
535static void er_app_render(const ra8_app_t* a)
536{
537 if (a->id == (uint16_t)k_er_screen_reading) {
539 } else if (a->id == (uint16_t)k_er_screen_keyboard) {
541#ifdef RA8_APP_SETTINGS
542 } else if (a->id == (uint16_t)k_er_screen_settings) {
543 er_render_settings();
544#endif
545 } else {
547 }
548}
549
552 .render = er_app_render,
553};
554
556static void er_apps_init(void)
557{
559 .id = (uint16_t)k_er_screen_library,
560 .name = "Library",
561 .removable = false};
563 .id = (uint16_t)k_er_screen_reading,
564 .name = "Reader",
565 .removable = false};
567 .id = (uint16_t)k_er_screen_keyboard,
568 .name = "Search",
569 .removable = false};
572 (uint16_t)(sizeof(s_app_slots) / sizeof(s_app_slots[0])));
576#ifdef RA8_APP_SETTINGS
577 s_app_settings = (ra8_app_t){.vt = &k_er_app_vt,
578 .id = (uint16_t)k_er_screen_settings,
579 .name = "Settings",
580 .removable = true};
581 (void)ra8_app_register(&s_app_reg, &s_app_settings);
582#endif
583}
584
586{
587 uint16_t top = (uint16_t)k_er_screen_library;
588 (void)ra8_ui_nav_top(&s_nav, &top);
589 /* The nav top is the active screen-app's id: focus it (idempotent if already
590 * focused, so no flicker) and render its widget tree. */
591 (void)ra8_app_launch(&s_app_reg, top);
593 /* Low-battery nag (#145/#146): an app-framework-level overlay widget drawn
594 * over whichever screen-app is active. A no-op at a healthy SOC, so the chrome
595 * golden (rendered at the default battery) stays byte-identical. */
597 ra8_widget_t nag = {.vt = &k_er_nag_vt, .visible = true, .dirty = true};
598 (void)ra8_widget_render_dirty(&nag, 1U);
599 }
600}
601
603{
604 const int32_t nx = (int32_t)k_er_nag_margin;
605 const int32_t ny = (int32_t)k_er_nag_top;
606 const int32_t nw = (int32_t)s_fb.width_px - (2 * (int32_t)k_er_nag_margin);
607 const int32_t nh = (int32_t)k_er_nag_h;
608 if (ra8_gfx_set_clip(nx, ny, nw, nh) != k_ra8_ok) {
609 er_render_current(); /* clip unavailable -> safe full repaint. */
610 return;
611 }
612 uint16_t top = (uint16_t)k_er_screen_library;
613 (void)ra8_ui_nav_top(&s_nav, &top);
614 (void)ra8_app_launch(&s_app_reg, top);
617 ra8_widget_t nag = {.vt = &k_er_nag_vt, .visible = true, .dirty = true};
618 (void)ra8_widget_render_dirty(&nag, 1U);
619 }
620 (void)ra8_gfx_reset_clip();
621}
622
624{
626 if (display_policy_decide(&s_policy, event, &dec) != k_ra8_ok) {
627 dec.hint = k_display_refresh_quality; /* safe fallback: a clean full update */
628 }
629 display_rect_t rect = {};
630 if (display_policy_full_rect(s_fb.width_px, s_fb.height_px, &rect) != k_ra8_ok) {
632 }
633 (void)display_flush(s_display, rect, dec.hint);
634 g_er_last_hint = (uint32_t)dec.hint;
636}
637
638void main(void)
639{
644 (void)ra8_batt_monitor_init(&s_batt_mon); /* low-battery nag policy (#145/#146) */
645 /* User switches SW1/SW2 as inputs with internal pull-ups (active-low). Best-
646 * effort: a config failure just leaves page-turn on the touch path. */
649 er_try_load_font(); /* Best-effort SD font for the reflow Reading body. */
650
651 /* Default refresh cadence: fast A2 turns with a periodic GC16 clean (#78). */
653 (void)ra8_ui_nav_init(&s_nav, (uint16_t)k_er_screen_library);
654 er_apps_init(); /* re-express the screens as ra8_app instances (#146) */
656 er_flush_event(k_display_event_open); /* boot -> a clean INIT panel update */
657
658 while (1) {
659 er_poll_touch(); /* fast cadence so taps feel responsive */
660 er_poll_buttons(); /* page-turn switches */
661 er_poll_battery(); /* self-throttled (~1 Hz) low-battery nag */
662 /* Heartbeat LED toggles on a slow sub-cadence so it blinks (~1 Hz) instead
663 * of strobing at the input-poll rate. */
664 if ((g_er_loop_ticks % (uint32_t)k_er_led_every) == 0U) {
666 }
667 /* Free-running liveness counter: the jlink_memprobe HIL reads it twice across
668 * a window and asserts the render/poll loop advanced (it never WFIs). */
670 ra8_delay_ms((uint32_t)k_er_frame_ms);
671 }
672}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static uint32_t s_pclka_hz
Definition c6_cam_app.c:38
Pure page-turn + input-region decisions for the e-reader (#78).
E-reader UI chrome – shared contract between main.c and the per-aspect helper translation units (scre...
@ k_er_spine_count
Number of chapters in k_er_spine.
bool s_have_font
True once an SD font is loaded.
Definition main.c:291
const char k_er_count_text[]
Book-count chip text.
Definition main.c:85
@ k_er_paper
Page background (g15).
@ k_er_ink
Primary text / glyphs (g0).
@ k_er_fb_w
Framebuffer width (pixels).
@ k_er_fb_h
Framebuffer height (pixels).
void er_poll_buttons(void)
Poll SW1/SW2 and turn a page on a fresh press (#78).
bool s_reflow_open
True while the engine holds a layout.
Definition main.c:280
const char k_er_search_hint[]
Search placeholder.
Definition main.c:84
ra8_ui_target_t s_targets[]
Tap targets for the current screen.
Definition main.c:217
reflow_t s_reflow_engine
reflow engine for the body.
Definition main.c:277
ra8_kbd_layout_t s_kb
On-screen keyboard grid.
Definition main.c:223
ra8_kbd_text_t s_query
Live search query.
Definition main.c:226
@ k_er_img_arena
SDRAM image-decode scratch.
@ k_er_font_cap
Max font read off the card (bytes).
@ k_er_spi_chan
Pmod2 / J25 = SCI0 Simple-SPI.
const char *const k_er_body_lines[]
Reading-view body paragraph lines (pre-wrapped for the font).
Definition main.c:110
uint32_t s_chapter_idx
Reading chapter index.
Definition main.c:178
uint16_t s_target_count
Tap targets currently populated.
Definition main.c:220
uint32_t s_reflow_chapter
Chapter laid out (cache key).
Definition main.c:282
bool s_nag_region_only
True when a tap only toggled the nag.
Definition main.c:241
volatile uint32_t g_er_turns
Count of page turns applied since boot.
Definition main.c:255
const char *const k_er_nav_items[]
Bottom-nav destinations (Library / Store / Notes / Settings).
Definition main.c:91
@ k_er_page_back_cap
Footnote-jump back-stack depth.
@ k_er_max_targets
Max collected tap targets.
const char k_er_page_label[]
Reading page label.
Definition main.c:87
@ k_er_statusbar_h
Top status-bar band height.
@ k_er_touch_max_points
One contact = one tap.
display_turn_event_t s_pending_event
Pending refresh event for next flush.
Definition main.c:251
void er_render_reading(void)
Render the full Reading screen (status bar, body, footer).
int32_t s_reflow_w
Body width the layout used.
Definition main.c:284
const char k_er_book_title[]
Reading title text.
Definition main.c:86
uint8_t s_img_arena_buf[]
Image-decode bump arena in SDRAM.
Definition main.c:274
@ k_er_nav_count
Number of bottom-nav destinations.
void er_nag_render(ra8_widget_t *w)
Nag banner overlay widget: a centered low-battery toast over the screen.
ra8_batt_monitor_t s_batt_mon
Low-battery nag policy state.
Definition main.c:235
volatile uint32_t g_er_last_hint
Last display_refresh_hint_t flushed.
Definition main.c:256
@ k_er_nag_margin
Banner inset from the screen sides.
@ k_er_nag_h
Banner height (px).
@ k_er_nag_top
Banner top y (clear of the status bar).
const char k_er_status_right[]
Status-bar right text.
Definition main.c:83
int32_t s_reflow_h
Body height the layout used.
Definition main.c:285
uint32_t s_loc_back_count
Entries used in s_loc_back.
Definition main.c:268
er_loc_t s_loc_back[]
Reading back-stack for link jumps.
Definition main.c:265
uint32_t s_reading_pages
Reading total reflow pages (>= 1).
Definition main.c:232
const char k_er_chapter[]
Bitmap-fallback heading.
Definition main.c:88
ra8_batt_nag_t s_batt_nag
Nag currently shown over the chrome.
Definition main.c:237
const char k_er_wordmark[6]
Wordmark / status text.
Definition main.c:80
uint32_t s_reading_page
Reading current reflow page.
Definition main.c:229
const er_chapter_t k_er_spine[]
Two-chapter mock spine for in-content cross-chapter navigation (#110).
Definition main.c:164
const er_book_t k_er_books[]
Demo shelf (public-domain works).
Definition main.c:96
void er_poll_battery(void)
Poll the fuel gauge, fold it into the nag policy, and toggle the banner.
const char k_er_lib_heading[]
Library heading text.
Definition main.c:82
@ k_er_book_count
Number of demo books.
@ k_er_chapter_none
s_reflow_chapter when nothing is laid out.
@ k_er_body_line_count
Number of pre-wrapped body lines.
void er_render_keyboard(void)
Render the on-screen keyboard screen + collect its key targets.
@ k_er_screen_reading
Reading view.
@ k_er_screen_keyboard
On-screen keyboard (search entry).
@ k_er_screen_library
Library / home grid.
@ k_er_screen_settings
Settings (optional app, if RA8_APP_SETTINGS).
uint8_t s_batt_soc
Last fuel-gauge SOC percent.
Definition main.c:239
uint32_t s_font_len
Bytes of font read off the card.
Definition main.c:288
void er_poll_touch(void)
Poll the touch controller and dispatch a tap on a fresh press.
@ k_er_settle_ms
PLL / SDRAM / panel-POR settle.
@ k_er_frame_ms
Input poll period (ms): touch / button cadence.
@ k_er_led_every
Toggle the heartbeat LED every Nth frame.
volatile uint32_t g_er_cur_page
SWD / --dump-sym telemetry for the headless page-turn HIL (#78).
Definition main.c:254
void er_render_library(void)
Render the full Library screen.
static display_handle_t * s_display
Definition main.c:78
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
static uint8_t s_font_buf[k_pc_font_cap]
Font blob read off the card.
Definition main.c:197
static display_fb_t s_fb
Definition main.c:203
static void app_bringup_touch(void)
Open the GT911 touch controller (best-effort, polled; non-fatal).
Definition main.c:461
static void app_bringup_clocks(void)
Bring up clocks, MSTP, SysTick, the SCI8 console and both LEDs.
Definition main.c:414
static void app_bringup_panel(void)
Bring up external SDRAM + the GLCDC panel, then cache the FB.
Definition main.c:437
static void app_panic_halt(void)
Halt forever with the red board LED on (visual sign of fatal init).
Definition main.c:405
static void app_bringup_gfx(void)
Bind ra8_gfx to the panel framebuffer.
Definition main.c:452
static ra8_app_nav_t s_nav
Navigation back-stack layered over s_reg.
Definition main.c:236
static display_policy_t s_policy
Refresh-cadence policy driving e-ink page-turn waveforms (#78).
Definition main.c:244
static ra8_app_t s_app_library
Library / Reading / Keyboard (+ optional Settings) app instances.
Definition main.c:523
static void er_try_load_font(void)
Best-effort: load FONT.OTF off the Pmod2 SD card into s_font_buf.
Definition main.c:462
volatile uint32_t g_er_loop_ticks
Free-running main-loop counter – HIL liveness.
Definition main.c:257
static const ra8_app_vtable_t k_er_app_vt
Vtable shared by every screen-app (render-only; nav owns transitions).
Definition main.c:551
static const ra8_widget_vtable_t k_er_nag_vt
Nag banner overlay widget vtable (renderer lives in the input TU).
Definition main.c:297
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
static void er_apps_init(void)
Register the e-reader screen-apps into s_app_reg.
Definition main.c:556
static ra8_app_t s_app_reader
Definition main.c:524
static const ra8_port_pin_t k_er_pin_sck
Pmod2 SPI pins (J25) – SCI0 Simple-SPI, per sd_font_render.
Definition main.c:181
static ra8_app_t * s_app_slots[4]
App registry storage (4 slots: 3 core + an optional Settings).
Definition main.c:531
void er_flush_event(display_turn_event_t event)
Flush the panel for a refresh event through the cadence policy (#78).
Definition main.c:623
static const ra8_port_pin_t k_er_pin_copi
Definition main.c:183
@ k_er_clean_every
Er clean every.
Definition main.c:261
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
static const ra8_port_pin_t k_er_pin_cs
Definition main.c:184
void er_render_current(void)
Render whichever screen is on top of the navigation stack.
Definition main.c:585
static const ra8_port_pin_t k_er_pin_cipo
Definition main.c:182
static ra8_app_t s_app_keyboard
Definition main.c:525
void er_render_nag_region(void)
Repaint only the low-battery banner rect (dirty-region update).
Definition main.c:602
static const display_cfg_t k_er_display_cfg
Display PAL config – LCD/GLCDC backend over the SDRAM buffer.
Definition main.c:197
static ra8_app_registry_t s_app_reg
Definition main.c:532
Declaration of the Latin-1 Literata font baked into internal flash.
Zero-heap app framework: lifecycle + static registry + launcher (#146).
ra8_err_t ra8_app_launch(ra8_app_registry_t *reg, uint16_t id)
Launch (focus) the app with id, running the focus lifecycle.
Definition ra8_app.c:78
ra8_err_t ra8_app_register(ra8_app_registry_t *reg, ra8_app_t *app)
Register an app (calls its init once) and add it to the registry.
Definition ra8_app.c:48
ra8_err_t ra8_app_render(ra8_app_registry_t *reg)
Run the focused app's render (on-target; no-op if none / NULL).
Definition ra8_app.c:153
ra8_err_t ra8_app_registry_init(ra8_app_registry_t *reg, ra8_app_t **storage, uint16_t cap)
Bind a registry to caller-owned pointer storage (empty, no focus).
Definition ra8_app.c:20
Bounded, allocation-free low-battery nag policy.
ra8_batt_nag_t
The low-battery warning a single ra8_batt_update step raises.
Definition ra8_batt.h:54
@ k_ra8_batt_nag_none
No new warning this step.
Definition ra8_batt.h:55
ra8_err_t ra8_batt_monitor_init(ra8_batt_monitor_t *mon)
Reset a nag monitor to the un-nagged, fully-armed state.
Definition ra8_batt.c:27
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_sw_init(ra8_board_sw_id_t sw)
Configure a switch pin as an input with internal pull-up.
@ k_ra8_board_pmod2_spi_cipo
Pmod2.3 CIPO (CIPO0_B), P602.
@ k_ra8_board_pmod2_spi_cs
Pmod2.1 CS (SS0_B), P604.
@ k_ra8_board_pmod2_spi_copi
Pmod2.2 COPI (COPI0_B), P603.
@ k_ra8_board_pmod2_spi_sck
Pmod2.4 SCK (SCK0_B), P601.
@ k_ra8_board_sw1
SW1, P009, IRQ13-DS (jumper E31).
@ k_ra8_board_sw2
SW2, P008, IRQ12-DS (jumper E32).
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ k_ra8_board_led_blue
Convenience aliases by colour.
@ k_ra8_board_led_red
RA8 board led red.
One-call bring-up of the EK-RA8D2 panel's GoodIX GT911 touch controller.
ra8_err_t ra8_board_touch_open(const ra8_board_touch_cfg_t *cfg)
Bring the on-board GT911 up and open the touch driver against it.
Boot entry points shared between a vector table and its startup code.
Bounded, allocation-free box-model layout for e-reader chrome.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
Definition ra8_cgc.c:132
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
Definition ra8_cgc.h:70
@ k_ra8_clock_id_pclka
PCLKA.
Definition ra8_cgc.h:73
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
Display Platform Abstraction Layer for the RA8D2.
@ k_display_pixfmt_rgb565
16 bpp, 5/6/5 packed.
display_rect_t display_full_rect(const display_handle_t *d)
Convenience helper returning the rect covering the whole framebuffer.
ra8_err_t display_get_framebuffer(const display_handle_t *d, display_fb_t *out)
Return the framebuffer descriptor the backend is targeting.
ra8_err_t display_flush(const display_handle_t *d, display_rect_t rect, display_refresh_hint_t hint)
Commit pending framebuffer changes to the panel.
struct display_handle display_handle_t
ra8_err_t display_init(const display_cfg_t *cfg, display_handle_t **out_handle)
Initialise the display PAL and bring the selected backend up to a state where display_flush succeeds.
@ k_display_refresh_quality
Prioritise final quality.
LCD backend (ra8_glcdc) for the display PAL.
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.
Pluggable page-turn refresh-cadence policy for bistable (e-ink) panels.
ra8_err_t display_policy_init(display_policy_t *p, display_policy_kind_t kind, uint16_t clean_every)
Initialise a refresh-cadence policy.
@ k_display_policy_fast_clean
A2 partial, periodic GC16 clean (default).
display_turn_event_t
The page-transition event the policy reacts to.
@ k_display_event_chapter
Chapter-boundary turn – wants a clean refresh.
@ k_display_event_open
Book/first page opened – wants a clean INIT.
ra8_err_t display_policy_full_rect(uint16_t w, uint16_t h, display_rect_t *out)
Build the full-page damage rectangle for a page turn.
ra8_err_t display_policy_decide(display_policy_t *p, display_turn_event_t event, display_policy_decision_t *out)
Decide the flush parameters for one page-transition event.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
Software 2D graphics primitives layered on top of a caller-ownedframebuffer (DRW / D/AVE 2D / GLCDC r...
@ k_ra8_gfx_format_rgb565
16-bit RGB565, little-endian in memory.
Definition ra8_gfx.h:40
ra8_err_t ra8_gfx_reset_clip(void)
Reset the clip rectangle to the whole framebuffer.
ra8_err_t ra8_gfx_set_clip(int32_t x, int32_t y, int32_t w, int32_t h)
Restrict all subsequent drawing to a rectangle (dirty-region updates).
ra8_err_t ra8_gfx_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
ra8_err_t ra8_gfx_init(void *fb, uint16_t width, uint16_t height, ra8_gfx_format_t format)
Bind ra8_gfx to a caller-owned framebuffer.
ra8_err_t ra8_gfx_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color, bool filled)
Draw an axis-aligned rectangle.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Definition ra8_isr.c:439
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
Definition ra8_mstp.c:291
#define RA8_BOARD_PANEL_FRAMEBUFFER(name)
Declare a correctly aligned, sized and placed RGB565 framebuffer for the on-board panel.
Definition ra8_panel.h:165
EK-RA8D2 panel timing as the HAL's ra8_glcdc_timing_t (ER-TFT070-6).
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.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
High-level GPIO helpers on top of the PORT + PFS register layer.
Load a TTF/OTF font off a Pmod SD card, self-provisioning if absent.
ra8_err_t ra8_sdfont_load(const ra8_sdfont_cfg_t *cfg, uint8_t *buf, uint32_t cap, uint32_t *out_len, ra8_sdfont_source_t *out_source)
Mount the Pmod SD card and load a font, provisioning it if absent.
Definition ra8_sdfont.c:392
External SDRAM controller driver (framework).
ra8_err_t ra8_sdramc_init(void)
Initialise the external SDRAM at k_ra8_sdram_base_addr.
Definition ra8_sdramc.c:257
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
Definition ra8_time.c:59
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Definition ra8_time.c:129
Multi-touch input driver – GoodIX GT911 backend.
@ k_ra8_touch_irq_pin_unset
Sentinel for "no IRQ pin attached".
Definition ra8_touch.h:72
Bounded UI interaction core: hit-testing, screen stack, paging.
ra8_err_t ra8_ui_nav_init(ra8_ui_nav_t *nav, uint16_t root_screen)
Initialise a navigation stack with a root screen.
Definition ra8_ui.c:71
ra8_err_t ra8_ui_nav_top(const ra8_ui_nav_t *nav, uint16_t *out_screen)
Read the current (top) screen id.
Definition ra8_ui.c:115
ra8_err_t ra8_widget_render_dirty(ra8_widget_t *widgets, uint16_t count)
Render every visible + dirty widget, clearing its damage.
Definition ra8_widget.c:331
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
Configuration descriptor passed into display_init.
Framebuffer descriptor returned by display_get_framebuffer.
What the app should pass to display_flush for this event.
display_refresh_hint_t hint
Waveform intent (fast/quality/init).
Caller-owned policy state (zero heap; init once, decide per turn).
Rectangle in framebuffer coordinates passed into display_flush.
One library entry: title, author, reading progress percent.
One mock-spine chapter: its XHTML, length, and resolving href.
A reading location (chapter + page) for the navigation back-stack.
Fixed table of registered apps + the focused index.
Definition ra8_app.h:161
One app instance + its metadata (caller-owned, static).
App lifecycle callbacks (shared by all instances of one app).
Definition ra8_app.h:133
Caller-owned nag state carried across ra8_batt_update calls.
Definition ra8_batt.h:85
The two touch settings that are an APPLICATION choice, not a board fact.
The key grid for the active layer, plus SHIFT / layer / frame state.
The typed query buffer + commit state.
SD-card font-store bus description + provisioning policy.
Definition ra8_sdfont.h:92
Fixed-depth screen-id stack (caller-owned).
Definition ra8_ui.h:163
One tap target: a rectangle bound to an opaque action id.
Definition ra8_ui.h:83
One widget instance (caller-owned, no allocation).
Behaviour table shared by all widgets of one kind.
Definition ra8_widget.h:121
Reflow / pagination engine state.