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
54
55#include <stddef.h>
56#include <stdint.h>
57
58#include "ra8_board_ek_ra8d2.h"
59#include "ra8_boot_entry.h"
60#include "ra8_box.h"
61#include "ra8_cgc.h"
62#include "ra8_display_pal.h"
63#include "ra8_display_pal_lcd.h"
64#include "ra8_err.h"
65#include "ra8_gfx.h"
66#include "ra8_gfx_font.h"
67#include "ra8_glcdc.h"
68#include "ra8_isr.h"
69#include "ra8_mstp.h"
70#include "ra8_panel.h"
71#include "ra8_panel_timing.h"
72#include "ra8_time.h"
73#include "ra8_ui.h"
74#include "ra8_widget.h"
75
81typedef enum : uint16_t {
82 k_wk_fb_w = 512U,
83 k_wk_fb_h = 512U,
86 k_wk_body_h = 440U,
87 k_wk_pad = 6U,
90} wk_geom_t;
91
97typedef enum : uint32_t {
98 k_wk_col_clear = 0x000010U,
99 k_wk_col_title_bg = 0x182438U,
100 k_wk_col_footer_bg = 0x101018U,
101 k_wk_col_text = 0xFFFFFFU,
102 k_wk_col_dim = 0xA8A8B8U,
103 k_wk_col_btn_a = 0x204060U,
104 k_wk_col_btn_a_hi = 0x3A6CB0U,
105 k_wk_col_btn_b = 0x603020U,
106 k_wk_col_btn_b_hi = 0xB06030U,
107 k_wk_col_btn_brd = 0x05080CU,
108} wk_color_t;
109
128
134typedef enum : int32_t {
138} wk_touch_t;
139
145typedef enum : uint32_t {
146 k_wk_uart_baud = 115200U,
148 k_wk_fnv_offset = 2166136261U,
149 k_wk_fnv_prime = 16777619U,
155
160[[gnu::aligned(k_ra8_board_fb_align_bytes)]] static uint16_t
161 s_framebuffer[(uint32_t)k_wk_fb_w * (uint32_t)k_wk_fb_h];
162
163/* ===========================================================================
164 * Paint backend: ra8_widget_paint_t -> ra8_gfx (the only ra8_gfx call sites)
165 * ===========================================================================
166 */
167
169static void wk_paint_fill(void* user, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
170{
171 (void)user;
172 (void)ra8_gfx_rect(x, y, w, h, color, true);
173}
174
176static void
177wk_paint_text(void* user, int32_t x, int32_t y, const char* str, uint32_t fg, uint32_t bg)
178{
179 (void)user;
180 (void)ra8_gfx_text_out(x, y, str, &ra8_gfx_font_8x16, fg, bg);
181}
182
184static void wk_paint_size(void* user, const char* str, int32_t* out_w, int32_t* out_h)
185{
186 (void)user;
187 uint32_t pw = 0U;
188 uint32_t ph = 0U;
189 (void)ra8_gfx_text_size(str, &ra8_gfx_font_8x16, &pw, &ph);
190 *out_w = (int32_t)pw;
191 *out_h = (int32_t)ph;
192}
193
196 .user = nullptr,
197 .fill_rect = wk_paint_fill,
198 .draw_text = wk_paint_text,
199 .text_size = wk_paint_size,
200};
201
202/* ===========================================================================
203 * Widget instances (caller-owned, no allocation)
204 * ===========================================================================
205 */
206
207static void wk_on_button_press(ra8_widget_t* w);
208
211 .text = "widget_kit_demo",
212 .fg = (uint32_t)k_wk_col_text,
213 .bg = (uint32_t)k_wk_col_title_bg,
214 .pad = (int16_t)k_wk_pad,
216 .reserved = 0U};
217
220 .text = "label + button leaves on ra8_widget_panel",
221 .fg = (uint32_t)k_wk_col_dim,
222 .bg = (uint32_t)k_wk_col_footer_bg,
223 .pad = (int16_t)k_wk_pad,
225 .reserved = 0U};
226
229 .text = "Prev",
230 .on_press = wk_on_button_press,
231 .fg = (uint32_t)k_wk_col_text,
232 .face = (uint32_t)k_wk_col_btn_a,
233 .face_pressed = (uint32_t)k_wk_col_btn_a_hi,
234 .border = (uint32_t)k_wk_col_btn_brd,
235 .presses = 0U,
236 .pad = (int16_t)k_wk_pad,
237 .border_w = (int16_t)k_wk_btn_border,
239 .pressed = false,
240 .reserved = 0U};
241
244 .text = "Next",
245 .on_press = wk_on_button_press,
246 .fg = (uint32_t)k_wk_col_text,
247 .face = (uint32_t)k_wk_col_btn_b,
248 .face_pressed = (uint32_t)k_wk_col_btn_b_hi,
249 .border = (uint32_t)k_wk_col_btn_brd,
250 .presses = 0U,
251 .pad = (int16_t)k_wk_pad,
252 .border_w = (int16_t)k_wk_btn_border,
254 .pressed = false,
255 .reserved = 0U};
256
261
264 .box_scratch = s_body_scratch,
265 .count = (uint16_t)k_wk_body_n,
266 .box_cap = (uint16_t)k_wk_body_cap,
267 .gap = (int16_t)k_wk_btn_gap,
268 .pad = 0,
269 .axis = k_ra8_widget_axis_row,
270 .reserved = 0U};
271
274 .box_scratch = s_root_scratch,
275 .count = (uint16_t)k_wk_root_n,
276 .box_cap = (uint16_t)k_wk_root_cap,
277 .gap = 0,
278 .pad = 0,
279 .axis = k_ra8_widget_axis_col,
280 .reserved = 0U};
281
285static display_handle_t* s_display = nullptr;
287static uint32_t s_tick = 0U;
288
289static const uint8_t k_wk_msg_boot[] = "widget-kit-demo: boot\r\n";
290static const uint8_t k_wk_msg_finit[] = "widget-kit-demo: FAIL init\r\n";
291static const uint8_t k_wk_msg_fpanl[] = "widget-kit-demo: FAIL panel\r\n";
292static const uint8_t k_wk_msg_ftree[] = "widget-kit-demo: FAIL tree\r\n";
293static const uint8_t k_wk_msg_fchk[] = "widget-kit-demo: FAIL selfcheck\r\n";
294static const uint8_t k_wk_msg_pre[] = "widget-kit-demo: dirty0=3 crc0=";
295static const uint8_t k_wk_msg_mid[] = " press=1 dirty1=1 crc1=";
296static const uint8_t k_wk_msg_tail[] = " flush=512x440 hint=fast PASS\r\n";
297
298/* ===========================================================================
299 * Console
300 * ===========================================================================
301 */
302
304static void wk_print(const uint8_t* msg, uint32_t len)
305{
306 (void)ra8_board_uart_console_write(msg, (size_t)len);
307}
308
310static void wk_fail_halt(const uint8_t* msg, uint32_t len)
311{
312 wk_print(msg, len);
313 while (1) {
314 __asm__ volatile("wfi");
315 }
316}
317
319static void wk_print_hex(uint32_t value)
320{
321 uint8_t buf[k_wk_hex_nibbles];
322 for (uint32_t i = 0U; i < (uint32_t)k_wk_hex_nibbles; i++) {
323 const uint32_t shift = ((uint32_t)k_wk_hex_nibbles - 1U - i) * (uint32_t)k_wk_nibble_bits;
324 const uint32_t nib = (value >> shift) & (uint32_t)k_wk_nibble_mask;
325 buf[i] = (uint8_t)((nib < (uint32_t)k_wk_dec_ten) ? ('0' + nib) : ('A' + (nib - k_wk_dec_ten)));
326 }
327 wk_print(buf, (uint32_t)k_wk_hex_nibbles);
328}
329
331static uint32_t wk_framebuffer_hash(void)
332{
333 const uint8_t* p = (const uint8_t*)s_framebuffer;
334 const size_t n = sizeof(s_framebuffer);
335 uint32_t hsh = (uint32_t)k_wk_fnv_offset;
336 for (size_t i = 0U; i < n; i++) {
337 hsh = (hsh ^ (uint32_t)p[i]) * (uint32_t)k_wk_fnv_prime;
338 }
339 return hsh;
340}
341
342/* ===========================================================================
343 * Tree assembly + compose
344 * ===========================================================================
345 */
346
353
355static bool wk_build_tree(void)
356{
358 return false;
359 }
360 s_root_kids[k_wk_w_title].fixed = (int16_t)k_wk_title_h;
362 return false;
363 }
364 s_root_kids[k_wk_w_footer].fixed = (int16_t)k_wk_footer_h;
366 return false;
367 }
368 s_body_kids[k_wk_w_btn_a].flex = 1U;
369 s_body_kids[k_wk_w_btn_a].action_id = (uint16_t)k_wk_act_a;
371 return false;
372 }
373 s_body_kids[k_wk_w_btn_b].flex = 1U;
374 s_body_kids[k_wk_w_btn_b].action_id = (uint16_t)k_wk_act_b;
376 return false;
377 }
378 s_root_kids[k_wk_w_body].flex = 1U;
380}
381
384{
385 for (uint16_t i = 0U; i < (uint16_t)k_wk_root_n; i++) {
386 (void)ra8_widget_invalidate(&s_root_kids[i], refresh);
387 }
388}
389
391static ra8_err_t wk_compose(ra8_ui_rect_t* dmg, ra8_widget_refresh_t* hint, uint16_t* dirty)
392{
393 const ra8_ui_rect_t frame = {.x = 0, .y = 0, .w = (int32_t)k_wk_fb_w, .h = (int32_t)k_wk_fb_h};
394 return ra8_widget_panel_compose(&s_root, &frame, dmg, hint, dirty);
395}
396
398static bool wk_route_touch(int32_t x, int32_t y)
399{
400 const ra8_widget_event_t ev = {.kind = k_ra8_widget_ev_touch, .x = x, .y = y};
401 if (s_root.vt == nullptr) {
402 return false;
403 }
404 if (s_root.vt->on_input == nullptr) {
405 return false;
406 }
407 return s_root.vt->on_input(&s_root, &ev);
408}
409
410/* ===========================================================================
411 * GLCDC panel bring-up + flush
412 * ===========================================================================
413 */
414
418 .framebuffer = s_framebuffer,
419 .framebuffer_bytes = sizeof(s_framebuffer),
420 .width_px = (uint16_t)k_wk_fb_w,
421 .height_px = (uint16_t)k_wk_fb_h,
422 .pixfmt = k_display_pixfmt_rgb565,
423 .panel_timing = &s_ra8_panel_ek_ra8d2_timing,
424};
425
427static bool wk_panel_up(void)
428{
430 return false;
431 }
432 if (s_display == nullptr) {
433 return false;
434 }
435 display_fb_t fb = {};
437 return false;
438 }
439 if (fb.pixels != (void*)s_framebuffer) {
440 return false;
441 }
443 (uint16_t)k_wk_fb_w,
444 (uint16_t)k_wk_fb_h,
446}
447
456
459{
460 if (s_display == nullptr) {
461 return;
462 }
463 if (dmg->w <= 0) {
464 return;
465 }
466 if (dmg->h <= 0) {
467 return;
468 }
469 const display_rect_t r = {.x = (uint16_t)dmg->x,
470 .y = (uint16_t)dmg->y,
471 .w = (uint16_t)dmg->w,
472 .h = (uint16_t)dmg->h};
473 (void)display_flush(s_display, r, wk_map_hint(hint));
474}
475
476/* ===========================================================================
477 * Deterministic self-check
478 * ===========================================================================
479 */
480
482static bool wk_check_full(uint32_t* out_crc)
483{
484 (void)ra8_gfx_clear((uint32_t)k_wk_col_clear);
486 ra8_ui_rect_t dmg = {};
488 uint16_t nd = 0U;
489 if (wk_compose(&dmg, &hint, &nd) != k_ra8_ok) {
490 return false;
491 }
492 if (nd != (uint16_t)k_wk_root_n) {
493 return false;
494 }
495 if (dmg.w != (int32_t)k_wk_fb_w) {
496 return false;
497 }
498 if (dmg.h != (int32_t)k_wk_fb_h) {
499 return false;
500 }
501 if (hint != k_ra8_widget_refresh_quality) {
502 return false;
503 }
504 *out_crc = wk_framebuffer_hash();
505 return true;
506}
507
509static bool wk_check_press(void)
510{
511 if (!wk_route_touch((int32_t)k_wk_touch_ax, (int32_t)k_wk_touch_y)) {
512 return false;
513 }
514 if (s_btn_a.presses != 1U) {
515 return false;
516 }
517 return s_btn_a.pressed;
518}
519
521static bool wk_check_partial(uint32_t* out_crc)
522{
523 ra8_ui_rect_t dmg = {};
525 uint16_t nd = 0U;
526 if (wk_compose(&dmg, &hint, &nd) != k_ra8_ok) {
527 return false;
528 }
529 if (nd != 1U) {
530 return false;
531 }
532 if (dmg.y != (int32_t)k_wk_title_h) {
533 return false;
534 }
535 if (dmg.h != (int32_t)k_wk_body_h) {
536 return false;
537 }
538 if (hint != k_ra8_widget_refresh_fast) {
539 return false;
540 }
541 *out_crc = wk_framebuffer_hash();
542 return true;
543}
544
546static bool wk_selfcheck(uint32_t* crc0, uint32_t* crc1)
547{
548 if (!wk_check_full(crc0)) {
549 return false;
550 }
551 if (!wk_check_press()) {
552 return false;
553 }
554 if (!wk_check_partial(crc1)) {
555 return false;
556 }
557 return (*crc0 != *crc1); /* button A's pressed face changes the composite */
558}
559
560/* ===========================================================================
561 * Boot
562 * ===========================================================================
563 */
564
566static void wk_setup_or_halt(void)
567{
568 uint32_t cpuclk0_hz = 0U;
569 if ((ra8_cgc_init() != k_ra8_ok) || (ra8_mstp_init() != k_ra8_ok)) {
570 wk_fail_halt(k_wk_msg_finit, (uint32_t)sizeof(k_wk_msg_finit) - 1U);
571 }
573 wk_fail_halt(k_wk_msg_finit, (uint32_t)sizeof(k_wk_msg_finit) - 1U);
574 }
575 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
576 wk_fail_halt(k_wk_msg_finit, (uint32_t)sizeof(k_wk_msg_finit) - 1U);
577 }
579 wk_fail_halt(k_wk_msg_finit, (uint32_t)sizeof(k_wk_msg_finit) - 1U);
580 }
581}
582
584static void wk_print_banner(uint32_t crc0, uint32_t crc1)
585{
586 wk_print(k_wk_msg_pre, (uint32_t)sizeof(k_wk_msg_pre) - 1U);
587 wk_print_hex(crc0);
588 wk_print(k_wk_msg_mid, (uint32_t)sizeof(k_wk_msg_mid) - 1U);
589 wk_print_hex(crc1);
590 wk_print(k_wk_msg_tail, (uint32_t)sizeof(k_wk_msg_tail) - 1U);
591}
592
594static void wk_tick_live(void)
595{
596 const int32_t tx = ((s_tick & 1U) == 0U) ? (int32_t)k_wk_touch_ax : (int32_t)k_wk_touch_bx;
597 s_tick++;
598 (void)wk_route_touch(tx, (int32_t)k_wk_touch_y);
599 ra8_ui_rect_t dmg = {};
601 uint16_t nd = 0U;
602 if (wk_compose(&dmg, &hint, &nd) == k_ra8_ok) {
603 wk_flush_rect(&dmg, hint);
604 }
605}
606
617void main(void)
618{
621 wk_print(k_wk_msg_boot, (uint32_t)sizeof(k_wk_msg_boot) - 1U);
622
623 if (!wk_panel_up()) {
624 wk_fail_halt(k_wk_msg_fpanl, (uint32_t)sizeof(k_wk_msg_fpanl) - 1U);
625 }
626 if (!wk_build_tree()) {
627 wk_fail_halt(k_wk_msg_ftree, (uint32_t)sizeof(k_wk_msg_ftree) - 1U);
628 }
629
630 uint32_t crc0 = 0U;
631 uint32_t crc1 = 0U;
632 if (!wk_selfcheck(&crc0, &crc1)) {
633 wk_fail_halt(k_wk_msg_fchk, (uint32_t)sizeof(k_wk_msg_fchk) - 1U);
634 }
635 wk_print_banner(crc0, crc1);
636
637 /* Land on a clean full composite and show it live on the panel. */
638 (void)ra8_gfx_clear((uint32_t)k_wk_col_clear);
640 ra8_ui_rect_t dmg = {};
642 uint16_t nd = 0U;
643 if (wk_compose(&dmg, &hint, &nd) == k_ra8_ok) {
644 wk_flush_rect(&dmg, hint);
645 }
646
647 while (1) {
648 wk_tick_live();
649 ra8_delay_ms((uint32_t)k_wk_frame_ms);
650 }
651}
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_widget_panel_t s_root_panel
Root column-panel descriptor tiling the five chrome bands.
Definition main.c:349
static ra8_widget_t s_root_kids[k_wd_root_n]
The five chrome bands.
Definition main.c:345
static ra8_box_t s_root_scratch[k_wd_root_cap]
Root layout scratch.
Definition main.c:346
static ra8_widget_t s_root
The root panel widget (composed each frame).
Definition main.c:359
static ra8_box_t s_body_scratch[k_wc_body_cap]
Body layout scratch.
Definition main.c:173
static ra8_widget_panel_t s_body_panel
Body row-panel descriptor (the nested panel).
Definition main.c:177
static ra8_widget_t s_body_kids[k_wc_body_n]
[left tile, right tile].
Definition main.c:172
static ra8_widget_label_t s_title
Title label: a centred heading over the slate band.
Definition main.c:210
static bool wk_route_touch(int32_t x, int32_t y)
Route a synthetic touch through the root panel to a leaf widget.
Definition main.c:398
static ra8_widget_button_t s_btn_b
Button B ("Next"): brown face, latches + flushes the body on tap.
Definition main.c:243
wk_touch_t
Synthetic touch points used by the self-check + live loop.
Definition main.c:134
@ k_wk_touch_y
Y at the body vertical centre.
Definition main.c:137
@ k_wk_touch_bx
X inside button B (right half of body).
Definition main.c:136
@ k_wk_touch_ax
X inside button A (left half of body).
Definition main.c:135
static void wk_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:458
static const ra8_widget_paint_t k_wk_paint
The shared paint backend every leaf widget draws through.
Definition main.c:195
static ra8_err_t wk_compose(ra8_ui_rect_t *dmg, ra8_widget_refresh_t *hint, uint16_t *dirty)
Compose the tree into the framebuffer; report the flush rect.
Definition main.c:391
static ra8_widget_label_t s_footer
Footer label: a left-aligned hint line.
Definition main.c:219
static bool wk_build_tree(void)
Assemble the nested widget tree; return false on a bind error.
Definition main.c:355
static void wk_paint_fill(void *user, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
Paint backend fill: a solid ra8_gfx rectangle.
Definition main.c:169
static bool wk_selfcheck(uint32_t *crc0, uint32_t *crc1)
Run the whole deterministic surface; return both composites' CRCs.
Definition main.c:546
static const display_cfg_t k_wk_display_cfg
Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.
Definition main.c:416
static display_refresh_hint_t wk_map_hint(ra8_widget_refresh_t hint)
Map a widget refresh hint to the display PAL refresh hint.
Definition main.c:449
static bool wk_check_press(void)
Assert button A latches a routed touch + invalidates the body.
Definition main.c:509
static const uint8_t k_wk_msg_pre[]
Definition main.c:294
static void wk_invalidate_all(ra8_widget_refresh_t refresh)
Mark every root child dirty so the next compose repaints the tree.
Definition main.c:383
static void wk_paint_text(void *user, int32_t x, int32_t y, const char *str, uint32_t fg, uint32_t bg)
Paint backend text: an 8x16 ra8_gfx string.
Definition main.c:177
static uint32_t wk_framebuffer_hash(void)
FNV-1a-32 over the composited framebuffer bytes.
Definition main.c:331
static void wk_print_hex(uint32_t value)
Print value as 8 uppercase hex digits.
Definition main.c:319
static ra8_widget_button_t s_btn_a
Button A ("Prev"): blue face, latches + flushes the body on tap.
Definition main.c:228
static uint32_t s_tick
Live-loop tick used to alternate which button is tapped.
Definition main.c:287
wk_widget_idx_t
Index + action id of each widget within its parent array.
Definition main.c:115
@ k_wk_w_title
Root child 0: title label (fixed).
Definition main.c:116
@ k_wk_root_n
Root child count.
Definition main.c:119
@ k_wk_body_n
Body child count.
Definition main.c:123
@ k_wk_body_cap
Body ra8_box scratch (count + 1).
Definition main.c:124
@ k_wk_root_cap
Root ra8_box scratch (count + 1).
Definition main.c:120
@ k_wk_w_footer
Root child 2: footer label (fixed).
Definition main.c:118
@ k_wk_w_btn_b
Body child 1: button B (flex).
Definition main.c:122
@ k_wk_act_a
Button A hit-routing action id.
Definition main.c:125
@ k_wk_w_body
Root child 1: nested body panel.
Definition main.c:117
@ k_wk_w_btn_a
Body child 0: button A (flex).
Definition main.c:121
@ k_wk_act_b
Button B hit-routing action id.
Definition main.c:126
wk_color_t
0xRRGGBB palette (ra8_gfx packs to RGB565).
Definition main.c:97
@ k_wk_col_text
Primary text (white).
Definition main.c:101
@ k_wk_col_btn_b
Button B face, released (brown).
Definition main.c:105
@ k_wk_col_btn_a_hi
Button A face, pressed (bright).
Definition main.c:104
@ k_wk_col_btn_a
Button A face, released (blue).
Definition main.c:103
@ k_wk_col_footer_bg
Footer-label fill (dark).
Definition main.c:100
@ k_wk_col_title_bg
Title-label fill (slate).
Definition main.c:99
@ k_wk_col_btn_b_hi
Button B face, pressed (warm).
Definition main.c:106
@ k_wk_col_clear
Whole-frame clear (near black).
Definition main.c:98
@ k_wk_col_dim
Secondary text (gray).
Definition main.c:102
@ k_wk_col_btn_brd
Button outline (near black).
Definition main.c:107
static bool wk_check_full(uint32_t *out_crc)
Assert the full compose: clear, 3 dirty, full-frame quality.
Definition main.c:482
wk_console_t
Console baud + text-format constants.
Definition main.c:145
@ k_wk_nibble_mask
Low-nibble mask.
Definition main.c:152
@ k_wk_dec_ten
Decimal radix.
Definition main.c:153
@ k_wk_frame_ms
Live repaint cadence (ms).
Definition main.c:147
@ k_wk_hex_nibbles
Hex digits per 32-bit.
Definition main.c:150
@ k_wk_uart_baud
Console baud.
Definition main.c:146
@ k_wk_nibble_bits
Bits per hex nibble.
Definition main.c:151
@ k_wk_fnv_offset
FNV-1a-32 offset basis.
Definition main.c:148
@ k_wk_fnv_prime
FNV-1a-32 prime.
Definition main.c:149
static const uint8_t k_wk_msg_fchk[]
Definition main.c:293
static void wk_tick_live(void)
Alternate-tap a button and partial-flush only the body band.
Definition main.c:594
static const uint8_t k_wk_msg_finit[]
Definition main.c:290
static void wk_paint_size(void *user, const char *str, int32_t *out_w, int32_t *out_h)
Paint backend measure: 8x16 ra8_gfx string size (for centring).
Definition main.c:184
static const uint8_t k_wk_msg_mid[]
Definition main.c:295
static const uint8_t k_wk_msg_fpanl[]
Definition main.c:291
static void wk_print_banner(uint32_t crc0, uint32_t crc1)
Emit the PASS banner once every self-check assertion holds.
Definition main.c:584
static const uint8_t k_wk_msg_ftree[]
Definition main.c:292
wk_geom_t
Framebuffer + band geometry (no magic numbers).
Definition main.c:81
@ k_wk_title_h
Title-label band height, pixels.
Definition main.c:84
@ k_wk_pad
Inner text padding, pixels.
Definition main.c:87
@ k_wk_fb_w
Framebuffer width, pixels.
Definition main.c:82
@ k_wk_fb_h
Framebuffer height, pixels.
Definition main.c:83
@ k_wk_btn_gap
Gap between the two body buttons.
Definition main.c:88
@ k_wk_footer_h
Footer-label band height, pixels.
Definition main.c:85
@ k_wk_body_h
Body band height (fb_h - title - footer).
Definition main.c:86
@ k_wk_btn_border
Button outline thickness, pixels.
Definition main.c:89
static void wk_fail_halt(const uint8_t *msg, uint32_t len)
Print a fail banner and park forever in WFI.
Definition main.c:310
static const uint8_t k_wk_msg_boot[]
Definition main.c:289
static void wk_on_button_press(ra8_widget_t *w)
Mark the body band dirty so a button press flushes only that rect.
Definition main.c:348
static void wk_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the board console.
Definition main.c:304
static const uint8_t k_wk_msg_tail[]
Definition main.c:296
static void wk_setup_or_halt(void)
Bring up clocks/MSTP/time and the console.
Definition main.c:566
static bool wk_check_partial(uint32_t *out_crc)
Assert the partial compose: body-only damage, fast hint.
Definition main.c:521
static bool wk_panel_up(void)
Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
Definition main.c:427
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
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_row
Horizontal stack (left -> right).
Definition ra8_widget.h:177
@ 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_label_init(ra8_widget_t *w, ra8_widget_label_t *label)
Bind a widget instance to a text label.
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
@ k_ra8_widget_ev_touch
A touch / tap at (x, y).
Definition ra8_widget.h:69
@ k_ra8_widget_align_left
Hug the left inner inset.
Definition ra8_widget.h:541
@ k_ra8_widget_align_center
Centre horizontally in the rect.
Definition ra8_widget.h:542
ra8_err_t ra8_widget_button_init(ra8_widget_t *w, ra8_widget_button_t *button)
Bind a widget instance to a push button.
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 push-button leaf widget: a bordered face + label that latches on tap.
One input event delivered to ra8_widget_dispatch.
Definition ra8_widget.h:77
A text-label leaf widget: a background fill plus an aligned string.
Drawing backend the concrete leaf widgets paint through (a DI seam).
A container widget's child array + stack-layout parameters (#145).
One widget instance (caller-owned, no allocation).