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
50
51#include <stddef.h>
52#include <stdint.h>
53
54#include "ra8_board_ek_ra8d2.h"
55#include "ra8_boot_entry.h"
56#include "ra8_box.h"
57#include "ra8_cgc.h"
58#include "ra8_display_pal.h"
59#include "ra8_display_pal_lcd.h"
60#include "ra8_err.h"
61#include "ra8_gfx.h"
62#include "ra8_gfx_font.h"
63#include "ra8_glcdc.h"
64#include "ra8_isr.h"
65#include "ra8_mstp.h"
66#include "ra8_panel.h"
67#include "ra8_panel_timing.h"
68#include "ra8_time.h"
69#include "ra8_ui.h"
70#include "ra8_widget.h"
71#include "ra8_widget_book.h"
72#include "ra8_widget_nav_bar.h"
75#include "ra8_widget_toolbar.h"
76
82typedef enum : uint16_t {
83 k_wd_fb_w = 512U,
84 k_wd_fb_h = 512U,
88 k_wd_nav_h = 40U,
89 k_wd_pad = 8U,
90 k_wd_gap = 8U,
94} wd_geom_t;
95
101typedef enum : uint32_t {
102 k_wd_col_clear = 0x000008U,
103 k_wd_col_paper = 0xF4F0E8U,
104 k_wd_col_status = 0x1E2A40U,
105 k_wd_col_toolbar = 0x14141AU,
106 k_wd_col_field = 0x2A2A34U,
107 k_wd_col_rule = 0x50607AU,
108 k_wd_col_ink = 0x101018U,
109 k_wd_col_dim = 0x808494U,
110 k_wd_col_white = 0xFFFFFFU,
111 k_wd_col_cover_a = 0x806040U,
112 k_wd_col_cover_b = 0x404060U,
113 k_wd_col_cover_c = 0x406050U,
114 k_wd_col_cover_d = 0x604048U,
115 k_wd_col_track = 0x303038U,
116 k_wd_col_fill = 0xE0A020U,
117 k_wd_col_nav = 0x14141AU,
118} wd_color_t;
119
134
155
160[[gnu::aligned(k_ra8_board_fb_align_bytes)]] static uint16_t
161 s_framebuffer[(uint32_t)k_wd_fb_w * (uint32_t)k_wd_fb_h];
162
164static display_handle_t* s_display = nullptr;
165
167static char s_clock[k_wd_clock_len] = "0";
168
170static uint32_t s_clock_val = 0U;
171
176typedef enum : uint8_t {
182
185 {.title = "Dune",
186 .author = "Herbert",
187 .cover = (uint32_t)k_wd_col_cover_a,
188 .percent = k_wd_pct_dune},
189 {.title = "1984",
190 .author = "Orwell",
191 .cover = (uint32_t)k_wd_col_cover_b,
192 .percent = k_wd_pct_1984},
193 {.title = "Solaris",
194 .author = "Lem",
195 .cover = (uint32_t)k_wd_col_cover_c,
196 .percent = k_wd_pct_solaris},
197 {.title = "Neuromancer",
198 .author = "Gibson",
199 .cover = (uint32_t)k_wd_col_cover_d,
200 .percent = k_wd_pct_neuromancer},
201};
202
204static const char* const s_nav_items[] = {"Library", "Store", "Settings"};
205
206/* ===========================================================================
207 * ra8_gfx paint backend (the DI seam the widgets paint through)
208 * ===========================================================================
209 */
210
227static void wd_fill(void* user, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
228{
229 (void)user;
230 (void)ra8_gfx_rect(x, y, w, h, color, true);
231}
232
249static void wd_text(void* user, int32_t x, int32_t y, const char* str, uint32_t fg, uint32_t bg)
250{
251 (void)user;
252 (void)ra8_gfx_text_out(x, y, str, &ra8_gfx_font_8x16, fg, bg);
253}
254
269static void wd_size(void* user, const char* str, int32_t* out_w, int32_t* out_h)
270{
271 (void)user;
272 uint32_t w = 0U;
273 uint32_t h = 0U;
274 (void)ra8_gfx_text_size(str, &ra8_gfx_font_8x16, &w, &h);
275 *out_w = (int32_t)w;
276 *out_h = (int32_t)h;
277}
278
281 .user = nullptr,
282 .fill_rect = wd_fill,
283 .draw_text = wd_text,
284 .text_size = wd_size,
285};
286
287/* ===========================================================================
288 * Chrome widget descriptors + the root panel
289 * ===========================================================================
290 */
291
293 .left = "widget-chrome-demo Library",
294 .right = s_clock,
295 .bg = (uint32_t)k_wd_col_status,
296 .fg = (uint32_t)k_wd_col_white,
297 .fg_right = (uint32_t)k_wd_col_dim,
298 .rule = (uint32_t)k_wd_col_rule,
299 .pad = (int16_t)k_wd_pad,
300 .rule_h = 1};
301
303 .hint = "Search",
304 .count = "4 books",
305 .on_search = nullptr,
306 .bg = (uint32_t)k_wd_col_toolbar,
307 .field = (uint32_t)k_wd_col_field,
308 .border = (uint32_t)k_wd_col_rule,
309 .hint_fg = (uint32_t)k_wd_col_dim,
310 .count_fg = (uint32_t)k_wd_col_dim,
311 .pad = (int16_t)k_wd_pad,
312 .border_w = 1,
313 .count_w = (int16_t)k_wd_count_w};
314
316 .books = s_books,
317 .on_open = nullptr,
318 .bg = (uint32_t)k_wd_col_paper,
319 .title_fg = (uint32_t)k_wd_col_ink,
320 .author_fg = (uint32_t)k_wd_col_dim,
321 .bar_track = (uint32_t)k_wd_col_track,
322 .bar_fill = (uint32_t)k_wd_col_fill,
323 .count = (uint16_t)k_wd_book_count,
324 .cols = (uint16_t)k_wd_grid_cols,
325 .pad = (int16_t)k_wd_pad,
326 .gap = (int16_t)k_wd_gap,
327 .label_h = (int16_t)k_wd_label_h,
328 .bar_h = (int16_t)k_wd_bar_h};
329
331 .track = (uint32_t)k_wd_col_track,
332 .fill = (uint32_t)k_wd_col_fill,
333 .value = (uint16_t)k_wd_prog_value,
334 .total = (uint16_t)k_wd_prog_total};
335
337 .items = s_nav_items,
338 .on_select = nullptr,
339 .bg = (uint32_t)k_wd_col_nav,
340 .fg_active = (uint32_t)k_wd_col_white,
341 .fg_muted = (uint32_t)k_wd_col_dim,
342 .count = 3U,
343 .active = 0U};
344
347
350 .box_scratch = s_root_scratch,
351 .count = (uint16_t)k_wd_root_n,
352 .box_cap = (uint16_t)k_wd_root_cap,
353 .gap = 0,
354 .pad = 0,
355 .axis = k_ra8_widget_axis_col,
356 .reserved = 0U};
357
360
361static const uint8_t k_wd_msg_boot[] = "widget-chrome-demo: boot\r\n";
362static const uint8_t k_wd_msg_finit[] = "widget-chrome-demo: FAIL init\r\n";
363static const uint8_t k_wd_msg_fpanl[] = "widget-chrome-demo: FAIL panel\r\n";
364static const uint8_t k_wd_msg_ftree[] = "widget-chrome-demo: FAIL tree\r\n";
365static const uint8_t k_wd_msg_fchk[] = "widget-chrome-demo: FAIL selfcheck\r\n";
366static const uint8_t k_wd_msg_pre[] = "widget-chrome-demo: dirty0=";
367static const uint8_t k_wd_msg_crc0[] = " crc0=";
368static const uint8_t k_wd_msg_d1[] = " dirty1=";
369static const uint8_t k_wd_msg_crc1[] = " crc1=";
370static const uint8_t k_wd_msg_tail[] = " flush=512x44 hint=fast";
371static const uint8_t k_wd_msg_pass[] = " PASS\r\n";
372
373/* ===========================================================================
374 * Console
375 * ===========================================================================
376 */
377
379static void wd_print(const uint8_t* msg, uint32_t len)
380{
381 (void)ra8_board_uart_console_write(msg, (size_t)len);
382}
383
385static void wd_fail_halt(const uint8_t* msg, uint32_t len)
386{
387 wd_print(msg, len);
388 while (1) {
389 __asm__ volatile("wfi");
390 }
391}
392
394static void wd_print_hex(uint32_t value)
395{
396 uint8_t buf[k_wd_hex_nibbles];
397 for (uint32_t i = 0U; i < (uint32_t)k_wd_hex_nibbles; i++) {
398 const uint32_t shift = ((uint32_t)k_wd_hex_nibbles - 1U - i) * (uint32_t)k_wd_nibble_bits;
399 const uint32_t nib = (value >> shift) & (uint32_t)k_wd_nibble_mask;
400 buf[i] = (uint8_t)((nib < (uint32_t)k_wd_dec_ten) ? ('0' + nib) : ('A' + (nib - k_wd_dec_ten)));
401 }
402 wd_print(buf, (uint32_t)k_wd_hex_nibbles);
403}
404
406static void wd_print_uint(uint32_t value)
407{
408 uint8_t buf[k_wd_dec_ten];
409 uint32_t n = 0U;
410 if (value == 0U) {
411 buf[n] = '0';
412 n++;
413 }
414 while ((value > 0U) && (n < (uint32_t)k_wd_dec_ten)) {
415 buf[n] = (uint8_t)('0' + (value % (uint32_t)k_wd_dec_ten));
416 n++;
417 value /= (uint32_t)k_wd_dec_ten;
418 }
419 for (uint32_t i = 0U; i < n; i++) {
420 wd_print(&buf[n - 1U - i], 1U);
421 }
422}
423
425static uint32_t wd_framebuffer_hash(void)
426{
427 const uint8_t* p = (const uint8_t*)s_framebuffer;
428 const size_t n = sizeof(s_framebuffer);
429 uint32_t hsh = (uint32_t)k_wd_fnv_offset;
430 for (size_t i = 0U; i < n; i++) {
431 hsh = (hsh ^ (uint32_t)p[i]) * (uint32_t)k_wd_fnv_prime;
432 }
433 return hsh;
434}
435
436/* ===========================================================================
437 * Clock string + tree assembly + compose
438 * ===========================================================================
439 */
440
442static void wd_clock_fmt(void)
443{
444 uint32_t v = s_clock_val;
445 char tmp[k_wd_clock_len];
446 uint32_t n = 0U;
447 if (v == 0U) {
448 tmp[n] = '0';
449 n++;
450 }
451 while ((v > 0U) && (n < (uint32_t)(k_wd_clock_len - 1U))) {
452 tmp[n] = (char)('0' + (v % (uint32_t)k_wd_dec_ten));
453 n++;
454 v /= (uint32_t)k_wd_dec_ten;
455 }
456 for (uint32_t i = 0U; i < n; i++) {
457 s_clock[i] = tmp[n - 1U - i];
458 }
459 s_clock[n] = '\0';
460}
461
464 const ra8_widget_vtable_t* vt,
465 void* ctx,
466 int16_t fixed,
467 uint16_t flex)
468{
469 *w = (ra8_widget_t){};
470 w->vt = vt;
471 w->ctx = ctx;
472 w->fixed = fixed;
473 w->flex = flex;
474 w->visible = true;
475}
476
503
505static ra8_err_t wd_compose(ra8_ui_rect_t* dmg, ra8_widget_refresh_t* hint, uint16_t* dirty)
506{
507 const ra8_ui_rect_t frame = {.x = 0, .y = 0, .w = (int32_t)k_wd_fb_w, .h = (int32_t)k_wd_fb_h};
508 return ra8_widget_panel_compose(&s_root, &frame, dmg, hint, dirty);
509}
510
513{
514 for (uint16_t i = 0U; i < (uint16_t)k_wd_root_n; i++) {
515 (void)ra8_widget_invalidate(&s_root_kids[i], refresh);
516 }
517}
518
519/* ===========================================================================
520 * GLCDC panel bring-up + flush
521 * ===========================================================================
522 */
523
527 .framebuffer = s_framebuffer,
528 .framebuffer_bytes = sizeof(s_framebuffer),
529 .width_px = (uint16_t)k_wd_fb_w,
530 .height_px = (uint16_t)k_wd_fb_h,
531 .pixfmt = k_display_pixfmt_rgb565,
532 .panel_timing = &s_ra8_panel_ek_ra8d2_timing,
533};
534
536static bool wd_panel_up(void)
537{
539 return false;
540 }
541 if (s_display == nullptr) {
542 return false;
543 }
544 display_fb_t fb = {};
546 return false;
547 }
548 if (fb.pixels != (void*)s_framebuffer) {
549 return false;
550 }
552 (uint16_t)k_wd_fb_w,
553 (uint16_t)k_wd_fb_h,
555}
556
565
568{
569 if (s_display == nullptr) {
570 return;
571 }
572 if ((dmg->w <= 0) || (dmg->h <= 0)) {
573 return;
574 }
575 const display_rect_t r = {.x = (uint16_t)dmg->x,
576 .y = (uint16_t)dmg->y,
577 .w = (uint16_t)dmg->w,
578 .h = (uint16_t)dmg->h};
579 (void)display_flush(s_display, r, wd_map_hint(hint));
580}
581
582/* ===========================================================================
583 * Deterministic self-check
584 * ===========================================================================
585 */
586
588static bool wd_check_full(uint32_t* out_crc, uint16_t* out_dirty)
589{
591 ra8_ui_rect_t dmg = {};
593 uint16_t nd = 0U;
594 if (wd_compose(&dmg, &hint, &nd) != k_ra8_ok) {
595 return false;
596 }
597 if (nd != (uint16_t)k_wd_root_n) {
598 return false;
599 }
600 if ((dmg.w != (int32_t)k_wd_fb_w) || (dmg.h != (int32_t)k_wd_fb_h)) {
601 return false;
602 }
603 if (hint != k_ra8_widget_refresh_quality) {
604 return false;
605 }
606 *out_crc = wd_framebuffer_hash();
607 *out_dirty = nd;
608 return true;
609}
610
612static bool wd_check_partial(uint32_t* out_crc, uint16_t* out_dirty)
613{
614 s_clock_val++;
615 wd_clock_fmt();
617 ra8_ui_rect_t dmg = {};
619 uint16_t nd = 0U;
620 if (wd_compose(&dmg, &hint, &nd) != k_ra8_ok) {
621 return false;
622 }
623 if (nd != 1U) {
624 return false;
625 }
626 if ((dmg.x != 0) || (dmg.y != 0) || (dmg.w != (int32_t)k_wd_fb_w)) {
627 return false;
628 }
629 if (dmg.h != (int32_t)k_wd_status_h) {
630 return false;
631 }
632 if (hint != k_ra8_widget_refresh_fast) {
633 return false;
634 }
635 *out_crc = wd_framebuffer_hash();
636 *out_dirty = nd;
637 return true;
638}
639
641static bool wd_selfcheck(uint32_t* crc0, uint16_t* d0, uint32_t* crc1, uint16_t* d1)
642{
643 if (!wd_check_full(crc0, d0)) {
644 return false;
645 }
646 if (!wd_check_partial(crc1, d1)) {
647 return false;
648 }
649 return (*crc0 != *crc1); /* the advanced clock changes the status band */
650}
651
652/* ===========================================================================
653 * Boot
654 * ===========================================================================
655 */
656
658static void wd_setup_or_halt(void)
659{
660 uint32_t cpuclk0_hz = 0U;
661 if ((ra8_cgc_init() != k_ra8_ok) || (ra8_mstp_init() != k_ra8_ok)) {
662 wd_fail_halt(k_wd_msg_finit, (uint32_t)sizeof(k_wd_msg_finit) - 1U);
663 }
665 wd_fail_halt(k_wd_msg_finit, (uint32_t)sizeof(k_wd_msg_finit) - 1U);
666 }
667 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
668 wd_fail_halt(k_wd_msg_finit, (uint32_t)sizeof(k_wd_msg_finit) - 1U);
669 }
671 wd_fail_halt(k_wd_msg_finit, (uint32_t)sizeof(k_wd_msg_finit) - 1U);
672 }
673}
674
676static void wd_print_banner(uint16_t d0, uint32_t crc0, uint16_t d1, uint32_t crc1)
677{
678 wd_print(k_wd_msg_pre, (uint32_t)sizeof(k_wd_msg_pre) - 1U);
679 wd_print_uint((uint32_t)d0);
680 wd_print(k_wd_msg_crc0, (uint32_t)sizeof(k_wd_msg_crc0) - 1U);
681 wd_print_hex(crc0);
682 wd_print(k_wd_msg_d1, (uint32_t)sizeof(k_wd_msg_d1) - 1U);
683 wd_print_uint((uint32_t)d1);
684 wd_print(k_wd_msg_crc1, (uint32_t)sizeof(k_wd_msg_crc1) - 1U);
685 wd_print_hex(crc1);
686 wd_print(k_wd_msg_tail, (uint32_t)sizeof(k_wd_msg_tail) - 1U);
687 wd_print(k_wd_msg_pass, (uint32_t)sizeof(k_wd_msg_pass) - 1U);
688}
689
691static void wd_tick_live(void)
692{
693 s_clock_val++;
694 wd_clock_fmt();
696 ra8_ui_rect_t dmg = {};
698 uint16_t nd = 0U;
699 if (wd_compose(&dmg, &hint, &nd) == k_ra8_ok) {
700 wd_flush_rect(&dmg, hint);
701 }
702}
703
714void main(void)
715{
718 wd_print(k_wd_msg_boot, (uint32_t)sizeof(k_wd_msg_boot) - 1U);
719
720 if (!wd_panel_up()) {
721 wd_fail_halt(k_wd_msg_fpanl, (uint32_t)sizeof(k_wd_msg_fpanl) - 1U);
722 }
723 if (!wd_build_tree()) {
724 wd_fail_halt(k_wd_msg_ftree, (uint32_t)sizeof(k_wd_msg_ftree) - 1U);
725 }
726
727 uint32_t crc0 = 0U;
728 uint32_t crc1 = 0U;
729 uint16_t d0 = 0U;
730 uint16_t d1 = 0U;
731 if (!wd_selfcheck(&crc0, &d0, &crc1, &d1)) {
732 wd_fail_halt(k_wd_msg_fchk, (uint32_t)sizeof(k_wd_msg_fchk) - 1U);
733 }
734 wd_print_banner(d0, crc0, d1, crc1);
735
736 /* Land on a full composite and show it live on the panel. */
737 (void)ra8_gfx_clear((uint32_t)k_wd_col_clear);
739 ra8_ui_rect_t dmg = {};
741 uint16_t nd = 0U;
742 if (wd_compose(&dmg, &hint, &nd) == k_ra8_ok) {
743 wd_flush_rect(&dmg, hint);
744 }
745
746 while (1) {
747 wd_tick_live();
748 ra8_delay_ms((uint32_t)k_wd_frame_ms);
749 }
750}
void main(void)
Secure fallback main entry point.
Definition main.c:37
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 ra8_app_nav_t s_nav
Navigation back-stack layered over s_reg.
Definition main.c:236
static const uint8_t k_wd_msg_fchk[]
Definition main.c:255
@ k_wd_w_status
Status bar (fixed).
Definition main.c:136
static const display_cfg_t k_wd_display_cfg
Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.
Definition main.c:591
static const uint8_t k_wd_msg_fpanl[]
Definition main.c:253
static const uint8_t k_wd_msg_boot[]
Definition main.c:251
static void wd_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
Definition main.c:295
static void wd_setup_or_halt(void)
Bring up clocks/MSTP/time, the console, and the SW1/SW2 inputs.
Definition main.c:854
static bool wd_selfcheck(uint32_t *out_lib, uint32_t *out_rdr)
Run the whole deterministic surface; return the two composites' hashes.
Definition main.c:813
static void wd_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
Definition main.c:268
static void wd_print_banner(uint32_t lib_crc, uint32_t rdr_crc)
Emit the PASS banner once the self-check holds.
Definition main.c:876
static void wd_print_hex(uint32_t value)
Print value as 8 uppercase hex digits.
Definition main.c:283
wd_geom_t
Framebuffer + band geometry (no magic numbers).
Definition main.c:81
@ k_wd_fb_h
Framebuffer height, pixels.
Definition main.c:83
@ k_wd_status_h
Status-bar band height, pixels.
Definition main.c:84
@ k_wd_pad
Inner text padding, pixels.
Definition main.c:86
@ k_wd_fb_w
Framebuffer width, pixels.
Definition main.c:82
static void wd_fail_halt(const uint8_t *msg, uint32_t len)
Print a fail banner and park forever in WFI.
Definition main.c:274
static uint32_t wd_framebuffer_hash(void)
FNV-1a-32 over the composited framebuffer bytes.
Definition main.c:314
static bool wd_panel_up(void)
Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
Definition main.c:602
wd_color_t
0xRRGGBB palette (ra8_gfx packs to RGB565).
Definition main.c:96
@ k_wd_col_dim
Secondary text (gray).
Definition main.c:103
@ k_wd_col_clear
Whole-frame clear (near black).
Definition main.c:97
static const uint8_t k_wd_msg_pre[]
Definition main.c:256
@ k_wd_frame_ms
Input poll period (ms).
Definition main.c:150
@ k_wd_hex_nibbles
Hex digits per 32-bit.
Definition main.c:153
@ k_wd_dec_ten
Hex/decimal split + buf.
Definition main.c:156
@ k_wd_fnv_prime
FNV-1a-32 prime.
Definition main.c:152
@ k_wd_nibble_bits
Bits per hex nibble.
Definition main.c:154
@ k_wd_nibble_mask
Low-nibble mask.
Definition main.c:155
@ k_wd_fnv_offset
FNV-1a-32 offset basis.
Definition main.c:151
@ k_wd_uart_baud
Console baud.
Definition main.c:149
static const uint8_t k_wd_msg_pass[]
Definition main.c:260
static const uint8_t k_wd_msg_finit[]
Definition main.c:252
static void wd_fill(void *user, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
Paint backend: fill a rectangle through ra8_gfx.
Definition main.c:227
static ra8_widget_status_bar_t s_status
Definition main.c:292
static const ra8_widget_paint_t k_wd_paint
The single paint backend the chrome widgets share.
Definition main.c:280
static const uint8_t k_wd_msg_tail[]
Definition main.c:370
static bool wd_check_partial(uint32_t *out_crc, uint16_t *out_dirty)
Assert the partial compose: status-only damage, fast hint.
Definition main.c:612
static const uint8_t k_wd_msg_d1[]
Definition main.c:368
static bool wd_build_tree(void)
Assemble the chrome panel tree; return false on a bind error.
Definition main.c:478
static void wd_flush_rect(const ra8_ui_rect_t *dmg, ra8_widget_refresh_t hint)
Flush only dmg to the panel with the mapped refresh hint.
Definition main.c:567
static bool wd_check_full(uint32_t *out_crc, uint16_t *out_dirty)
Assert the full compose: all 5 chrome bands dirty, full-frame quality.
Definition main.c:588
@ k_wd_gap
Grid gap, pixels.
Definition main.c:90
@ k_wd_label_h
Card title / author row height.
Definition main.c:91
@ k_wd_nav_h
Nav-strip band height, pixels.
Definition main.c:88
@ k_wd_bar_h
Card progress-bar height.
Definition main.c:92
@ k_wd_count_w
Toolbar count-chip width.
Definition main.c:93
@ k_wd_toolbar_h
Toolbar band height, pixels.
Definition main.c:86
@ k_wd_prog_h
Overall progress band height, pixels.
Definition main.c:87
static ra8_widget_panel_t s_root_panel
Root column-panel descriptor tiling the five chrome bands.
Definition main.c:349
static const uint8_t k_wd_msg_crc0[]
Definition main.c:367
static ra8_widget_book_grid_t s_grid
Definition main.c:315
static display_refresh_hint_t wd_map_hint(ra8_widget_refresh_t hint)
Map a widget refresh hint to the display PAL refresh hint.
Definition main.c:558
static void wd_tick_live(void)
Advance the clock and partial-flush only the status band.
Definition main.c:691
@ k_wd_col_cover_c
Cover swatch C.
Definition main.c:113
@ k_wd_col_track
Progress track.
Definition main.c:115
@ k_wd_col_cover_a
Cover swatch A.
Definition main.c:111
@ k_wd_col_ink
Primary ink.
Definition main.c:108
@ k_wd_col_fill
Progress fill (amber).
Definition main.c:116
@ k_wd_col_status
Status-bar fill (slate).
Definition main.c:104
@ k_wd_col_toolbar
Toolbar fill (dark).
Definition main.c:105
@ k_wd_col_white
White text.
Definition main.c:110
@ k_wd_col_field
Search-field fill.
Definition main.c:106
@ k_wd_col_paper
Grid / page background.
Definition main.c:103
@ k_wd_col_cover_d
Cover swatch D.
Definition main.c:114
@ k_wd_col_nav
Nav-strip fill.
Definition main.c:117
@ k_wd_col_cover_b
Cover swatch B.
Definition main.c:112
@ k_wd_col_rule
Hairline / border.
Definition main.c:107
wd_data_t
Book count + progress + console constants.
Definition main.c:140
@ k_wd_clock_len
"NNNNN" clock buffer + NUL.
Definition main.c:153
@ k_wd_grid_cols
Grid columns.
Definition main.c:142
@ k_wd_prog_total
Overall progress full-scale.
Definition main.c:144
@ k_wd_book_count
Book records in the grid.
Definition main.c:141
@ k_wd_prog_value
Overall progress value.
Definition main.c:143
wd_child_idx_t
Index of each chrome band within the root panel array.
Definition main.c:125
@ k_wd_root_cap
Root ra8_box scratch (count + 1).
Definition main.c:132
@ k_wd_w_nav
Root child 4: nav strip (fixed).
Definition main.c:130
@ k_wd_w_toolbar
Root child 1: toolbar (fixed).
Definition main.c:127
@ k_wd_w_grid
Root child 2: book grid (flex).
Definition main.c:128
@ k_wd_w_prog
Root child 3: progress (fixed).
Definition main.c:129
@ k_wd_root_n
Root child count.
Definition main.c:131
static const uint8_t k_wd_msg_ftree[]
Definition main.c:364
static void wd_invalidate_all(ra8_widget_refresh_t refresh)
Mark every chrome band dirty so the next compose repaints the tree.
Definition main.c:512
static ra8_widget_t s_root_kids[k_wd_root_n]
The five chrome bands.
Definition main.c:345
static void wd_size(void *user, const char *str, int32_t *out_w, int32_t *out_h)
Paint backend: measure a string's pixel size through ra8_gfx.
Definition main.c:269
static void wd_clock_fmt(void)
Reformat s_clock as the decimal s_clock_val (bounded, NUL-term).
Definition main.c:442
static void wd_leaf_init(ra8_widget_t *w, const ra8_widget_vtable_t *vt, void *ctx, int16_t fixed, uint16_t flex)
Build a leaf widget bound to a vtable + context.
Definition main.c:463
static uint32_t s_clock_val
Monotonic clock counter shown in the status bar.
Definition main.c:170
static ra8_box_t s_root_scratch[k_wd_root_cap]
Root layout scratch.
Definition main.c:346
wd_book_pct_t
Sample reading-progress percentages for the four demo books.
Definition main.c:176
@ k_wd_pct_dune
"Dune" read progress, percent.
Definition main.c:177
@ k_wd_pct_solaris
"Solaris" read progress, percent.
Definition main.c:179
@ k_wd_pct_1984
"1984" read progress, percent.
Definition main.c:178
@ k_wd_pct_neuromancer
"Neuromancer" read progress, percent.
Definition main.c:180
static ra8_widget_t s_root
The root panel widget (composed each frame).
Definition main.c:359
static ra8_widget_toolbar_t s_toolbar
Definition main.c:302
static ra8_err_t wd_compose(ra8_ui_rect_t *dmg, ra8_widget_refresh_t *hint, uint16_t *dirty)
Compose the chrome tree into the framebuffer; report the flush rect.
Definition main.c:505
static void wd_text(void *user, int32_t x, int32_t y, const char *str, uint32_t fg, uint32_t bg)
Paint backend: draw ASCII text through ra8_gfx.
Definition main.c:249
static const char *const s_nav_items[]
Nav-strip destinations.
Definition main.c:204
static ra8_widget_progress_bar_t s_prog
Definition main.c:330
static const uint8_t k_wd_msg_crc1[]
Definition main.c:369
static const ra8_widget_book_t s_books[k_wd_book_count]
The four book records shown in the grid.
Definition main.c:184
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
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
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.
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.
display_refresh_hint_t
Intent passed into display_flush; backends map this onto whatever waveform/mode their controller offe...
@ k_display_refresh_fast
Prioritise latency.
@ 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.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
static ra8_fs_clock_t s_clock
The installed calendar binding; meaningful only when s_clock_bound.
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_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
ra8_err_t ra8_gfx_text_size(const char *str, const ra8_gfx_font_t *font, uint32_t *out_w, uint32_t *out_h)
Compute rendered pixel dimensions of a string.
ra8_err_t ra8_gfx_text_out(int32_t x, int32_t y, const char *str, const ra8_gfx_font_t *font, uint32_t fg_color, uint32_t bg_color)
Render a NUL-terminated ASCII string.
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.
Bitmap font descriptor + bundled font handles for ra8_gfx.
const ra8_gfx_font_t ra8_gfx_font_8x16
Bundled 8x16 IBM PC VGA bitmap font, ASCII 0x20..0x7E.
Graphics LCD Controller driver (two-layer with alpha blending).
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
Active display-panel descriptor for the EK-RA8D2 (ER-TFT070-6).
@ k_ra8_board_fb_align_bytes
GLCDC AXI burst alignment, in bytes.
Definition ra8_panel.h:108
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.
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
Bounded UI interaction core: hit-testing, screen stack, paging.
Zero-heap composable widget layer (dwm-style) over ra8_box + ra8_ui.
@ k_ra8_widget_axis_col
Vertical stack (top -> bottom).
Definition ra8_widget.h:176
ra8_err_t ra8_widget_panel_init(ra8_widget_t *w, ra8_widget_panel_t *panel)
Bind a widget instance to a container panel.
ra8_err_t ra8_widget_panel_compose(ra8_widget_t *panel_w, const ra8_ui_rect_t *frame, ra8_ui_rect_t *out_damage, ra8_widget_refresh_t *out_hint, uint16_t *out_dirty)
Run one top-level compose cycle over a panel and report the flush.
ra8_err_t ra8_widget_invalidate(ra8_widget_t *w, ra8_widget_refresh_t refresh)
Mark a widget dirty with a refresh hint (folds upward in strength).
Definition ra8_widget.c:286
ra8_widget_refresh_t
E-ink-style refresh hint carried by a dirty widget.
Definition ra8_widget.h:98
@ k_ra8_widget_refresh_fast
Partial / A2 (text-only change).
Definition ra8_widget.h:100
@ k_ra8_widget_refresh_none
Clean – not dirty.
Definition ra8_widget.h:99
@ k_ra8_widget_refresh_quality
Full / GC16 (whole-area redraw).
Definition ra8_widget.h:101
Book-card + book-grid leaf widget for the ra8_widget tree (#145 Phase 2).
const ra8_widget_vtable_t * ra8_widget_book_grid_vtable(void)
Return the shared vtable backing every book-grid widget.
Navigation-strip leaf widget for the ra8_widget tree model (#145 Phase 2).
const ra8_widget_vtable_t * ra8_widget_nav_bar_vtable(void)
Return the shared vtable backing every navigation-strip widget.
Progress-bar leaf widget for the ra8_widget tree model (#145 Phase 2).
const ra8_widget_vtable_t * ra8_widget_progress_bar_vtable(void)
Return the shared vtable backing every progress-bar widget.
Status-bar leaf widget for the ra8_widget tree model (#145 Phase 2).
const ra8_widget_vtable_t * ra8_widget_status_bar_vtable(void)
Return the shared vtable backing every status-bar widget.
Toolbar leaf widget for the ra8_widget tree model (#145 Phase 2).
const ra8_widget_vtable_t * ra8_widget_toolbar_vtable(void)
Return the shared vtable backing every toolbar widget.
Configuration descriptor passed into display_init.
Framebuffer descriptor returned by display_get_framebuffer.
void * pixels
Base of pixel data (RGB565 unless noted).
Rectangle in framebuffer coordinates passed into display_flush.
One node in a box tree (caller-owned).
Definition ra8_box.h:90
Axis-aligned rectangle in framebuffer pixel coordinates.
Definition ra8_ui.h:72
int32_t w
Width (pixels, >= 0).
Definition ra8_ui.h:75
int32_t h
Height (pixels, >= 0).
Definition ra8_ui.h:76
int32_t x
Left edge (pixels).
Definition ra8_ui.h:73
int32_t y
Top edge (pixels).
Definition ra8_ui.h:74
A tappable N-column grid of book cards.
One book card's data: cover colour, title, author, read progress.
An equal-cell navigation strip: N labels, one active, each tappable.
Drawing backend the concrete leaf widgets paint through (a DI seam).
A container widget's child array + stack-layout parameters (#145).
A proportional progress bar: a track plus a value / total fill.
A status band: a fill, a left + right label, and a bottom hairline.
One widget instance (caller-owned, no allocation).
A search-field + count-chip toolbar band with a tappable field.
Behaviour table shared by all widgets of one kind.
Definition ra8_widget.h:121