|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Nested ra8_widget tree composited on the live GLCDC panel (#145). More...
#include <stddef.h>#include <stdint.h>#include "ra8_board_ek_ra8d2.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_err.h"#include "ra8_gfx.h"#include "ra8_gfx_font.h"#include "ra8_glcdc.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_panel.h"#include "ra8_panel_timing.h"#include "ra8_time.h"#include "ra8_ui.h"#include "ra8_widget.h"Go to the source code of this file.
Data Structures | |
| struct | wc_status_ctx_t |
| Status-bar state: the live frame counter it renders. More... | |
| struct | wc_tile_ctx_t |
| One body tile: a label over a coloured fill + a render counter. More... | |
Enumerations | |
| enum | wc_geom_t : uint16_t { k_wc_fb_w = 512U , k_wc_fb_h = 512U , k_wc_status_h = 44U , k_wc_footer_h = 28U , k_wc_pad = 8U , k_wc_line_h = 18U , k_wc_tile_gap = 6U } |
| Framebuffer + band geometry (no magic numbers). More... | |
| enum | wc_color_t : uint32_t { k_wc_col_clear = 0x000008U , k_wc_col_status_bg = 0x1E2A40U , k_wc_col_footer_bg = 0x14141AU , k_wc_col_left_bg = 0x102038U , k_wc_col_right_bg = 0x382414U , k_wc_col_text = 0xFFFFFFU , k_wc_col_dim = 0xA0A0B0U } |
| 0xRRGGBB palette (ra8_gfx packs to RGB565). More... | |
| enum | wc_widget_idx_t : uint16_t { k_wc_w_status = 0U , k_wc_w_body = 1U , k_wc_w_footer = 2U , k_wc_root_n = 3U , k_wc_root_cap = 4U , k_wc_w_left = 0U , k_wc_w_right = 1U , k_wc_body_n = 2U , k_wc_body_cap = 3U } |
| Index of each widget within its parent array. More... | |
| enum | wc_console_t : uint32_t { k_wc_uart_baud = 115200U , k_wc_frame_ms = 500U , k_wc_fnv_offset = 2166136261U , k_wc_fnv_prime = 16777619U , k_wc_hex_nibbles = 8U , k_wc_nibble_bits = 4U , k_wc_nibble_mask = 0x0FU , k_wc_dec_ten = 10U , k_wc_frame_buf = 24U } |
| Console baud + text-format constants. More... | |
Functions | |
| static void | wc_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the board console. | |
| static void | wc_fail_halt (const uint8_t *msg, uint32_t len) |
| Print a fail banner and park forever in WFI. | |
| static void | wc_print_hex (uint32_t value) |
Print value as 8 uppercase hex digits. | |
| static void | wc_print_uint (uint32_t value) |
| Print a small unsigned integer in decimal. | |
| static uint32_t | wc_framebuffer_hash (void) |
| FNV-1a-32 over the composited framebuffer bytes. | |
| static void | wc_fmt_frame (char *buf, uint32_t frame) |
Format "frame=<n>" into buf (>= k_wc_frame_buf bytes, NUL-term). | |
| static void | wc_status_render (ra8_widget_t *w) |
| Status-bar render: fill + title over the live frame counter. | |
| static void | wc_tile_render (ra8_widget_t *w) |
| Body-tile render: fill + label + a per-tile render counter. | |
| static void | wc_footer_render (ra8_widget_t *w) |
| Footer render: fill + a one-line hint. | |
| static void | wc_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. | |
| static bool | wc_build_tree (void) |
| Assemble the nested widget tree; return false on a bind error. | |
| static void | wc_invalidate_all (ra8_widget_refresh_t refresh) |
| Mark every root child dirty so the next compose repaints the tree. | |
| static ra8_err_t | wc_compose (ra8_ui_rect_t *dmg, ra8_widget_refresh_t *hint, uint16_t *dirty) |
| Compose the tree into the framebuffer; report the flush rect. | |
| static bool | wc_panel_up (void) |
| Bring up the GLCDC panel and bind ra8_gfx to its framebuffer. | |
| static display_refresh_hint_t | wc_map_hint (ra8_widget_refresh_t hint) |
| Map a widget refresh hint to the display PAL refresh hint. | |
| static void | wc_flush_rect (const ra8_ui_rect_t *dmg, ra8_widget_refresh_t hint) |
Flush only dmg to the panel with the mapped refresh hint. | |
| static bool | wc_check_full (uint32_t *out_crc, uint16_t *out_dirty) |
| Assert the full compose: 3 dirty, full-frame quality, tiles drawn. | |
| static bool | wc_check_partial (uint32_t *out_crc, uint16_t *out_dirty) |
| Assert the partial compose: status-only damage, tiles untouched. | |
| static bool | wc_selfcheck (uint32_t *crc0, uint16_t *d0, uint32_t *crc1, uint16_t *d1) |
| Run the whole deterministic surface; return both composites' CRCs. | |
| static void | wc_setup_or_halt (void) |
| Bring up clocks/MSTP/time and the console. | |
| static void | wc_print_banner (uint16_t d0, uint32_t crc0, uint16_t d1, uint32_t crc1) |
| Emit the PASS banner once every self-check assertion holds. | |
| static void | wc_tick_live (void) |
| Advance the frame counter and partial-flush only the status band. | |
| void | main (void) |
| App entry: bring the panel up, self-check, then run the live loop. | |
Variables | |
| static uint16_t | s_framebuffer [(uint32_t) k_wc_fb_w *(uint32_t) k_wc_fb_h] |
| GLCDC-scanned render target in SRAM, AXI-burst aligned. | |
| static wc_status_ctx_t | s_status = {.frame = 0U, .renders = 0U} |
| static wc_tile_ctx_t | s_left = {.label = "Left widget", .bg = (uint32_t)k_wc_col_left_bg} |
| static wc_tile_ctx_t | s_right = {.label = "Right widget", .bg = (uint32_t)k_wc_col_right_bg} |
| static ra8_widget_t | s_root_kids [k_wc_root_n] |
| [status, body, footer]. | |
| static ra8_widget_t | s_body_kids [k_wc_body_n] |
| [left tile, right tile]. | |
| static ra8_box_t | s_body_scratch [k_wc_body_cap] |
| Body layout scratch. | |
| static ra8_box_t | s_root_scratch [k_wc_root_cap] |
| Root layout scratch. | |
| static ra8_widget_panel_t | s_body_panel |
| Body row-panel descriptor (the nested panel). | |
| static ra8_widget_panel_t | s_root_panel |
| Root column-panel descriptor. | |
| static ra8_widget_t | s_root |
| The root panel widget (composed each frame). | |
| static display_handle_t * | s_display = nullptr |
| Live display handle once the GLCDC panel is up. | |
| static const uint8_t | k_wc_msg_boot [] = "widget-compose-demo: boot\r\n" |
| static const uint8_t | k_wc_msg_finit [] = "widget-compose-demo: FAIL init\r\n" |
| static const uint8_t | k_wc_msg_fpanl [] = "widget-compose-demo: FAIL panel\r\n" |
| static const uint8_t | k_wc_msg_ftree [] = "widget-compose-demo: FAIL tree\r\n" |
| static const uint8_t | k_wc_msg_fchk [] = "widget-compose-demo: FAIL selfcheck\r\n" |
| static const uint8_t | k_wc_msg_pre [] = "widget-compose-demo: dirty0=" |
| static const uint8_t | k_wc_msg_crc0 [] = " crc0=" |
| static const uint8_t | k_wc_msg_d1 [] = " dirty1=" |
| static const uint8_t | k_wc_msg_crc1 [] = " crc1=" |
| static const uint8_t | k_wc_msg_tail [] = " flush=512x44 hint=fast" |
| static const uint8_t | k_wc_msg_pass [] = " PASS\r\n" |
| static const ra8_widget_vtable_t | k_wc_status_vt |
| Status / footer / tiles are display-only (NULL on_input). | |
| static const ra8_widget_vtable_t | k_wc_tile_vt |
| static const ra8_widget_vtable_t | k_wc_footer_vt |
| static const display_cfg_t | k_wc_display_cfg |
| Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer. | |
Nested ra8_widget tree composited on the live GLCDC panel (#145).
The sibling widget_app_demo proves the ra8_widget + ra8_app stack as an interactive launcher. This app is the focused demonstration of the new compositor primitive issue #145 adds: ra8_widget_panel – a container that is itself a ra8_widget_t, which is what turns the flat widget array into a tree. It composes a small tree and shows the damage-tracked partial flush on ra8_emulator's panel window.
The tree (dwm-style, each piece opt-in):
root (column panel) |- status (leaf, fixed) – title + a live frame counter |- body (ROW PANEL) – a nested panel ... | |- left tile (leaf, flex) | |- right tile (leaf, flex) |- footer (leaf, fixed) – a hint line
body is the new primitive in action: a panel nested inside the root panel. The whole tree is composed by one ra8_widget_panel_compose call, which lays the children out, computes the minimal damage rect + refresh hint, and renders only the dirty children – a dirty nested panel repaints its whole subtree.
A deterministic self-check runs before the live loop:
It then emits one banner so the app doubles as a ra8_emulator gate:
widget-compose-demo: dirty0=3 crc0=<8hex> dirty1=1 crc1=<8hex> flush=512x44 hint=fast PASS
Any failed assertion prints FAIL ... and parks. After the banner the loop advances the frame counter and partial-composes the status bar live, so the panel visibly updates only its top band (the damage-tracked A2 path).
[Ring 6 / APP] {World: S}
Definition in file main.c.
| enum wc_color_t : uint32_t |
0xRRGGBB palette (ra8_gfx packs to RGB565).
| enum wc_console_t : uint32_t |
Console baud + text-format constants.
| enum wc_geom_t : uint16_t |
Framebuffer + band geometry (no magic numbers).
| enum wc_widget_idx_t : uint16_t |
Index of each widget within its parent array.
| void main | ( | void | ) |
App entry: bring the panel up, self-check, then run the live loop.
The application entry point Reset_Handler hands control to.
Definition at line 633 of file main.c.
References k_ra8_ok, k_ra8_widget_refresh_none, k_ra8_widget_refresh_quality, k_wc_col_clear, k_wc_frame_ms, k_wc_msg_boot, k_wc_msg_fchk, k_wc_msg_fpanl, k_wc_msg_ftree, ra8_delay_ms(), ra8_gfx_clear(), ra8_isr_globals_enable(), wc_build_tree(), wc_compose(), wc_fail_halt(), wc_flush_rect(), wc_invalidate_all(), wc_panel_up(), wc_print(), wc_print_banner(), wc_selfcheck(), wc_setup_or_halt(), and wc_tick_live().
|
static |
Assemble the nested widget tree; return false on a bind error.
Definition at line 400 of file main.c.
References k_ra8_ok, k_wc_footer_h, k_wc_footer_vt, k_wc_status_h, k_wc_status_vt, k_wc_tile_vt, k_wc_w_body, k_wc_w_footer, k_wc_w_left, k_wc_w_right, k_wc_w_status, ra8_widget_panel_init(), s_body_kids, s_body_panel, s_left, s_right, s_root, s_root_kids, s_root_panel, s_status, and wc_leaf_init().
Referenced by main().
|
static |
Assert the full compose: 3 dirty, full-frame quality, tiles drawn.
Definition at line 499 of file main.c.
References ra8_ui_rect_t::h, k_ra8_ok, k_ra8_widget_refresh_none, k_ra8_widget_refresh_quality, k_wc_fb_h, k_wc_fb_w, k_wc_root_n, s_left, s_right, ra8_ui_rect_t::w, wc_compose(), wc_framebuffer_hash(), and wc_invalidate_all().
Referenced by wc_selfcheck().
|
static |
Assert the partial compose: status-only damage, tiles untouched.
Definition at line 528 of file main.c.
References ra8_ui_rect_t::h, k_ra8_ok, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wc_fb_w, k_wc_status_h, k_wc_w_status, ra8_widget_invalidate(), s_left, s_right, s_root_kids, s_status, ra8_ui_rect_t::w, wc_compose(), wc_framebuffer_hash(), ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by wc_selfcheck().
|
static |
Compose the tree into the framebuffer; report the flush rect.
Definition at line 424 of file main.c.
References k_wc_fb_h, k_wc_fb_w, ra8_widget_panel_compose(), and s_root.
Referenced by main(), wc_check_full(), wc_check_partial(), and wc_tick_live().
|
static |
Print a fail banner and park forever in WFI.
Definition at line 225 of file main.c.
References wc_print().
Referenced by main(), and wc_setup_or_halt().
|
static |
Flush only dmg to the panel with the mapped refresh hint.
Definition at line 478 of file main.c.
References display_flush(), ra8_ui_rect_t::h, s_display, ra8_ui_rect_t::w, wc_map_hint(), ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by main(), and wc_tick_live().
|
static |
Format "frame=<n>" into buf (>= k_wc_frame_buf bytes, NUL-term).
Definition at line 282 of file main.c.
References k_wc_dec_ten.
Referenced by wc_status_render().
|
static |
Footer render: fill + a one-line hint.
Definition at line 355 of file main.c.
References k_wc_col_dim, k_wc_col_footer_bg, k_wc_footer_h, k_wc_pad, ra8_gfx_font_8x16, ra8_gfx_rect(), and ra8_gfx_text_out().
|
static |
FNV-1a-32 over the composited framebuffer bytes.
Definition at line 265 of file main.c.
References k_wc_fnv_offset, k_wc_fnv_prime, and s_framebuffer.
Referenced by wc_check_full(), and wc_check_partial().
|
static |
Mark every root child dirty so the next compose repaints the tree.
Definition at line 416 of file main.c.
References k_wc_root_n, ra8_widget_invalidate(), and s_root_kids.
Referenced by main(), and wc_check_full().
|
static |
Build a leaf widget bound to a vtable + context.
Definition at line 385 of file main.c.
Referenced by wc_build_tree().
|
static |
Map a widget refresh hint to the display PAL refresh hint.
Definition at line 469 of file main.c.
References k_display_refresh_fast, k_display_refresh_quality, and k_ra8_widget_refresh_fast.
Referenced by wc_flush_rect().
|
static |
Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
Definition at line 447 of file main.c.
References display_get_framebuffer(), display_init(), k_ra8_gfx_format_rgb565, k_ra8_ok, k_wc_display_cfg, k_wc_fb_h, k_wc_fb_w, display_fb_t::pixels, ra8_gfx_init(), s_display, and s_framebuffer.
Referenced by main().
|
static |
Emit a byte run on the board console.
Definition at line 219 of file main.c.
References ra8_board_uart_console_write().
Referenced by main(), wc_fail_halt(), wc_print_banner(), wc_print_hex(), and wc_print_uint().
|
static |
Emit the PASS banner once every self-check assertion holds.
Definition at line 596 of file main.c.
References k_wc_msg_crc0, k_wc_msg_crc1, k_wc_msg_d1, k_wc_msg_pass, k_wc_msg_pre, k_wc_msg_tail, wc_print(), wc_print_hex(), and wc_print_uint().
Referenced by main().
|
static |
Print value as 8 uppercase hex digits.
Definition at line 234 of file main.c.
References k_wc_dec_ten, k_wc_hex_nibbles, k_wc_nibble_bits, k_wc_nibble_mask, and wc_print().
Referenced by wc_print_banner().
|
static |
Print a small unsigned integer in decimal.
Definition at line 246 of file main.c.
References k_wc_dec_ten, and wc_print().
Referenced by wc_print_banner().
|
static |
Run the whole deterministic surface; return both composites' CRCs.
Definition at line 561 of file main.c.
References wc_check_full(), and wc_check_partial().
Referenced by main().
|
static |
Bring up clocks/MSTP/time and the console.
Definition at line 578 of file main.c.
References k_ra8_clock_id_cpuclk0, k_ra8_ok, k_wc_msg_finit, k_wc_uart_baud, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), and wc_fail_halt().
Referenced by main().
|
static |
Status-bar render: fill + title over the live frame counter.
Definition at line 309 of file main.c.
References wc_status_ctx_t::frame, k_wc_col_dim, k_wc_col_status_bg, k_wc_col_text, k_wc_frame_buf, k_wc_line_h, k_wc_pad, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), wc_status_ctx_t::renders, and wc_fmt_frame().
|
static |
Advance the frame counter and partial-flush only the status band.
Definition at line 611 of file main.c.
References k_ra8_ok, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wc_w_status, ra8_widget_invalidate(), s_root_kids, s_status, wc_compose(), and wc_flush_rect().
Referenced by main().
|
static |
Body-tile render: fill + label + a per-tile render counter.
Definition at line 333 of file main.c.
References wc_tile_ctx_t::bg, k_wc_col_dim, k_wc_col_text, k_wc_line_h, k_wc_pad, wc_tile_ctx_t::label, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), and wc_tile_ctx_t::renders.
|
static |
Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.
Definition at line 436 of file main.c.
Referenced by wc_panel_up().
|
static |
Definition at line 375 of file main.c.
Referenced by wc_build_tree().
|
static |
|
static |
Definition at line 207 of file main.c.
Referenced by wc_print_banner().
|
static |
Definition at line 209 of file main.c.
Referenced by wc_print_banner().
|
static |
Definition at line 208 of file main.c.
Referenced by wc_print_banner().
|
static |
|
static |
Definition at line 202 of file main.c.
Referenced by wc_setup_or_halt().
|
static |
|
static |
|
static |
Definition at line 211 of file main.c.
Referenced by wc_print_banner().
|
static |
Definition at line 206 of file main.c.
Referenced by wc_print_banner().
|
static |
Definition at line 210 of file main.c.
Referenced by wc_print_banner().
|
static |
Status / footer / tiles are display-only (NULL on_input).
Definition at line 369 of file main.c.
Referenced by wc_build_tree().
|
static |
Definition at line 372 of file main.c.
Referenced by wc_build_tree().
|
static |
[left tile, right tile].
Definition at line 172 of file main.c.
Referenced by wc_build_tree(), and wk_build_tree().
|
static |
Body row-panel descriptor (the nested panel).
Definition at line 177 of file main.c.
Referenced by wc_build_tree(), and wk_build_tree().
|
static |
|
static |
|
static |
Definition at line 168 of file main.c.
Referenced by wc_build_tree(), wc_check_full(), and wc_check_partial().
|
static |
Definition at line 169 of file main.c.
Referenced by wc_build_tree(), wc_check_full(), and wc_check_partial().
|
static |
|
static |
|
static |
Root column-panel descriptor.
|
static |
|
static |