|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Interactive ra8_widget + ra8_app launcher on the live GLCDC panel. More...
#include <stddef.h>#include <stdint.h>#include "ra8_app.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_port_constants.h"#include "ra8_port_utils.h"#include "ra8_time.h"#include "ra8_ui.h"#include "ra8_widget.h"Go to the source code of this file.
Data Structures | |
| struct | wa_content_t |
| Per-app content widget state: a title over a list of text lines. More... | |
| struct | wa_chrome_t |
| Shared chrome state: the registry the status bar + tab bar read. More... | |
| struct | wa_app_state_t |
| Per-app state: its widget tree + a focus-lifecycle counter. More... | |
Macros | |
| #define | WA_APP_SETTINGS (1) |
| Build-time guard for the optional Settings app (#146 exclusion). | |
Enumerations | |
| enum | wd_geom_t : uint16_t { k_wd_fb_w = 512U , k_wd_fb_h = 512U , k_wd_status_h = 44U , k_wd_tabbar_h = 56U , k_wd_pad = 8U , k_wd_line_h = 18U , k_wd_tab_inset = 3U } |
| Framebuffer + band geometry (no magic numbers). More... | |
| enum | wd_color_t : uint32_t { k_wd_col_clear = 0x000008U , k_wd_col_status_bg = 0x1E2A40U , k_wd_col_tabbar_bg = 0x14141AU , k_wd_col_tab_on = 0x3060C0U , k_wd_col_tab_off = 0x303038U , k_wd_col_text = 0xFFFFFFU , k_wd_col_dim = 0xA0A0B0U , k_wd_col_lib_bg = 0x102038U , k_wd_col_rdr_bg = 0x382414U , k_wd_col_set_bg = 0x102818U } |
| 0xRRGGBB palette (ra8_gfx packs to RGB565). More... | |
| enum | wd_app_id_t : uint16_t { k_wd_app_library = 1U , k_wd_app_reader = 2U , k_wd_app_settings = 3U } |
| Registered app ids (launch keys). More... | |
| enum | wd_btn_t : uint16_t { k_wd_btn_prev = 1U , k_wd_btn_next = 2U } |
| Navigation button ids carried in a button widget event. More... | |
| enum | wd_widget_idx_t : uint16_t { k_wd_w_status = 0U , k_wd_w_content = 1U , k_wd_w_tabbar = 2U , k_wd_w_count = 3U , k_wd_box_cap = 4U } |
| Index of each widget within an app's tree. More... | |
| enum | wd_console_t : uint32_t { k_wd_uart_baud = 115200U , k_wd_frame_ms = 25U , k_wd_fnv_offset = 2166136261U , k_wd_fnv_prime = 16777619U , k_wd_hex_nibbles = 8U , k_wd_nibble_bits = 4U , k_wd_nibble_mask = 0x0FU , k_wd_dec_ten = 10U } |
| Console baud + text-format constants. More... | |
Functions | |
| static void | wd_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the SCI8 console. | |
| static void | wd_fail_halt (const uint8_t *msg, uint32_t len) |
| Print a fail banner and park forever in WFI. | |
| static void | wd_print_hex (uint32_t value) |
Print value as 8 uppercase hex digits. | |
| static void | wd_print_uint (uint32_t value) |
| Print a small unsigned integer in decimal. | |
| static uint32_t | wd_framebuffer_hash (void) |
| FNV-1a-32 over the composited framebuffer bytes. | |
| static const char * | wd_active_name (const ra8_app_registry_t *reg) |
| Name of the focused app, or a placeholder if none. | |
| static void | wd_status_render (ra8_widget_t *w) |
| Status-bar render: fill + active app name + the button hint. | |
| static void | wd_content_render (ra8_widget_t *w) |
| Content render: fill + title over the app's body lines. | |
| static void | wd_tabbar_render (ra8_widget_t *w) |
| Tab-bar render: one cell per app, the active one highlighted. | |
| static bool | wd_tabbar_on_input (ra8_widget_t *w, const ra8_widget_event_t *ev) |
| Tab-bar input: map a touch column to an app id (request a launch). | |
| static int16_t | wd_neighbor_id (int32_t dir) |
| Resolve the app id at (active + dir), wrapped, or k_ra8_app_none. | |
| static bool | wd_app_on_input (ra8_app_t *a, const ra8_widget_event_t *ev) |
| App input: SW button -> neighbour app; touch -> widget dispatch. | |
| static void | wd_app_render (const ra8_app_t *a) |
| App render: clear, lay out the tree, mark all dirty, composite. | |
| static void | wd_app_enter (ra8_app_t *a) |
| static void | wd_app_leave (ra8_app_t *a) |
| static void | wd_state_init (wa_app_state_t *st, const char *title, const char *const *lines, uint16_t nlines, uint32_t bg) |
| Build one app's widget tree: status (fixed) / content (flex) / tabs (fixed). | |
| static bool | wd_panel_up (void) |
| Bring up the GLCDC panel and bind ra8_gfx to its framebuffer. | |
| static void | wd_flush_full (void) |
| Push the whole composited frame to the panel (GC16-quality). | |
| static void | wd_render_active (void) |
| Render the focused app and flush the whole panel. | |
| static bool | wd_sw_pressed (ra8_port_pin_t pin) |
| Read a user switch (active-low); true == pressed. | |
| static void | wd_route_button (wd_btn_t btn) |
| Route a navigation button through the focused app (#146). | |
| static void | wd_poll_buttons (void) |
| Poll SW1/SW2 (edge-triggered) and route a fresh press as a button. | |
| static void | wd_service_request (void) |
| Apply a pending app-switch request: launch + re-composite if changed. | |
| static bool | wd_register_apps (ra8_app_t *library, ra8_app_t *reader, ra8_app_t *settings) |
| Initialise app state, the registry, and register every app. | |
| static bool | wd_check_touch_dispatch (void) |
| Drive a synthetic touch on the Library tab while Reader is focused. | |
| static bool | wd_check_damage (void) |
| Assert status-bar-only invalidation yields exactly its rect, fast. | |
| static bool | wd_selfcheck (uint32_t *out_lib, uint32_t *out_rdr) |
| Run the whole deterministic surface; return the two composites' hashes. | |
| static void | wd_setup_or_halt (void) |
| Bring up clocks/MSTP/time, the console, and the SW1/SW2 inputs. | |
| static void | wd_print_banner (uint32_t lib_crc, uint32_t rdr_crc) |
| Emit the PASS banner once the self-check holds. | |
| void | main (void) |
| App entry: bring the panel up, self-check, then run the launcher. | |
Variables | |
| static ra8_port_pin_t | s_wd_sw1_pin = k_ra8_pin_none |
| SW1 (previous app) port pin, sourced from the board layer at init. | |
| static ra8_port_pin_t | s_wd_sw2_pin = k_ra8_pin_none |
| SW2 (next app) port pin, sourced from the board layer at init. | |
| static uint16_t | s_framebuffer [(uint32_t) k_wd_fb_w *(uint32_t) k_wd_fb_h] |
| GLCDC-scanned render target in SRAM, AXI-burst aligned. | |
| static ra8_app_registry_t | s_reg |
| The app registry. | |
| static ra8_app_t * | s_slots [k_wd_app_settings] |
| Registry storage (<=3). | |
| static wa_chrome_t | s_chrome = {.reg = &s_reg} |
| Shared chrome state. | |
| static wa_app_state_t | s_library |
| Library app state. | |
| static wa_app_state_t | s_reader |
| Reader app state. | |
| static wa_app_state_t | s_settings |
| Settings app state (optional). | |
| static volatile int16_t | g_wd_request = (int16_t)k_ra8_app_none |
| App id an input handler asked to focus, or k_ra8_app_none. | |
| static display_handle_t * | s_display = nullptr |
| Live display handle once the GLCDC panel is up. | |
| static bool | s_was_sw1 |
| Debounce latch: true while SW1 is held (fire once per press). | |
| static bool | s_was_sw2 |
| Debounce latch: true while SW2 is held. | |
| static const char *const | k_wd_lib_lines [] |
| static const char *const | k_wd_rdr_lines [] |
| static const char *const | k_wd_set_lines [] |
| static const uint8_t | k_wd_msg_boot [] = "widget-app-demo: boot\r\n" |
| static const uint8_t | k_wd_msg_finit [] = "widget-app-demo: FAIL init\r\n" |
| static const uint8_t | k_wd_msg_fpanl [] = "widget-app-demo: FAIL panel\r\n" |
| static const uint8_t | k_wd_msg_freg [] = "widget-app-demo: FAIL register\r\n" |
| static const uint8_t | k_wd_msg_fchk [] = "widget-app-demo: FAIL selfcheck\r\n" |
| static const uint8_t | k_wd_msg_pre [] = "widget-app-demo: apps=" |
| static const uint8_t | k_wd_msg_lib [] = " lib=" |
| static const uint8_t | k_wd_msg_rdr [] = " rdr=" |
| static const uint8_t | k_wd_msg_route [] = " route=ok flush=512x44 hint=fast" |
| static const uint8_t | k_wd_msg_pass [] = " PASS\r\n" |
| static const ra8_widget_vtable_t | k_wd_status_vt |
| Status / content widgets ignore input (NULL handler never consumes). | |
| static const ra8_widget_vtable_t | k_wd_content_vt |
| static const ra8_widget_vtable_t | k_wd_tabbar_vt |
| static const ra8_app_vtable_t | k_wd_app_vt |
| Shared app lifecycle vtable (every app behaves the same way). | |
| static const display_cfg_t | k_wd_display_cfg |
| Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer. | |
Interactive ra8_widget + ra8_app launcher on the live GLCDC panel.
The companion widget_app gate proves the ra8_widget compositor (#145) and ra8_app framework (#146) headlessly (off-screen framebuffer + CRC). This app is the visible, interactive counterpart: it brings the GLCDC panel up so the composition is shown on ra8_emulator's panel window, and drives it with the physical SW1/SW2 push-buttons.
What it shows:
Before the interactive loop a deterministic self-check exercises the whole surface (register, launch + lifecycle, distinct composites, touch dispatch, button routing, status-bar-only damage) and emits one banner:
widget-app-demo: apps=<n> lib=<8hex> rdr=<8hex> route=ok flush=512x44 hint=fast PASS
so the app doubles as a ra8_emulator regression gate; any failure prints a FAIL ... banner and parks. The 512x512 RGB565 framebuffer lives in SRAM (the full 1024x600 panel needs SDRAM, a separate task) and composites top-left over the GLCDC background plane.
[Ring 6 / APP] {World: S}
Definition in file main.c.
| #define WA_APP_SETTINGS (1) |
| enum wd_app_id_t : uint16_t |
| enum wd_btn_t : uint16_t |
| enum wd_color_t : uint32_t |
0xRRGGBB palette (ra8_gfx packs to RGB565).
| enum wd_console_t : uint32_t |
Console baud + text-format constants.
| enum wd_geom_t : uint16_t |
Framebuffer + band geometry (no magic numbers).
| enum wd_widget_idx_t : uint16_t |
| void main | ( | void | ) |
App entry: bring the panel up, self-check, then run the launcher.
The application entry point Reset_Handler hands control to.
Definition at line 899 of file main.c.
References g_wd_request, k_ra8_app_none, k_wd_app_library, k_wd_frame_ms, k_wd_msg_boot, k_wd_msg_fchk, k_wd_msg_fpanl, k_wd_msg_freg, ra8_app_launch(), ra8_delay_ms(), ra8_isr_globals_enable(), s_reg, wd_fail_halt(), wd_panel_up(), wd_poll_buttons(), wd_print(), wd_print_banner(), wd_register_apps(), wd_render_active(), wd_selfcheck(), wd_service_request(), and wd_setup_or_halt().
|
static |
Name of the focused app, or a placeholder if none.
Definition at line 331 of file main.c.
References k_ra8_ok, and ra8_app_active().
Referenced by wd_status_render().
|
static |
App input: SW button -> neighbour app; touch -> widget dispatch.
Definition at line 488 of file main.c.
References ra8_widget_event_t::button_id, g_wd_request, k_ra8_widget_ev_button, k_wd_btn_next, k_wd_btn_prev, k_wd_w_count, ra8_widget_event_t::kind, ra8_widget_dispatch(), wd_neighbor_id(), and wa_app_state_t::widgets.
|
static |
App render: clear, lay out the tree, mark all dirty, composite.
Definition at line 511 of file main.c.
References k_ra8_widget_axis_col, k_ra8_widget_refresh_quality, k_wd_box_cap, k_wd_col_clear, k_wd_fb_h, k_wd_fb_w, k_wd_w_count, ra8_gfx_clear(), ra8_widget_invalidate(), ra8_widget_layout_stack(), ra8_widget_render_dirty(), and wa_app_state_t::widgets.
|
static |
Assert status-bar-only invalidation yields exactly its rect, fast.
Definition at line 796 of file main.c.
References ra8_ui_rect_t::h, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wd_status_h, k_wd_w_count, k_wd_w_status, ra8_widget_damage(), ra8_widget_invalidate(), and s_reader.
Referenced by wd_selfcheck().
|
static |
Drive a synthetic touch on the Library tab while Reader is focused.
Definition at line 770 of file main.c.
References g_wd_request, k_ra8_app_none, k_ra8_ok, k_ra8_widget_ev_touch, k_wd_app_library, k_wd_w_tabbar, ra8_app_count(), ra8_app_route_input(), s_reader, and s_reg.
Referenced by wd_selfcheck().
|
static |
Content render: fill + title over the app's body lines.
Definition at line 365 of file main.c.
References wa_content_t::bg, k_wd_col_dim, k_wd_col_text, k_wd_line_h, k_wd_pad, wa_content_t::lines, wa_content_t::nlines, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), and wa_content_t::title.
|
static |
Print a fail banner and park forever in WFI.
Definition at line 274 of file main.c.
References wd_print().
Referenced by main(), and wd_setup_or_halt().
|
static |
Push the whole composited frame to the panel (GC16-quality).
Definition at line 624 of file main.c.
References display_flush(), display_full_rect(), k_display_refresh_quality, and s_display.
Referenced by wd_render_active().
|
static |
FNV-1a-32 over the composited framebuffer bytes.
Definition at line 314 of file main.c.
References k_wd_fnv_offset, k_wd_fnv_prime, and s_framebuffer.
Referenced by wd_check_full(), wd_check_partial(), and wd_selfcheck().
|
static |
Resolve the app id at (active + dir), wrapped, or k_ra8_app_none.
Definition at line 466 of file main.c.
References k_ra8_app_none, k_ra8_ok, ra8_app_at(), ra8_app_count(), and s_reg.
Referenced by wd_app_on_input().
|
static |
Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
Definition at line 602 of file main.c.
References display_get_framebuffer(), display_init(), k_ra8_gfx_format_rgb565, k_ra8_ok, k_wd_display_cfg, k_wd_fb_h, k_wd_fb_w, display_fb_t::pixels, ra8_gfx_init(), s_display, and s_framebuffer.
Referenced by main().
|
static |
Poll SW1/SW2 (edge-triggered) and route a fresh press as a button.
Definition at line 667 of file main.c.
References k_wd_btn_next, k_wd_btn_prev, s_was_sw1, s_was_sw2, s_wd_sw1_pin, s_wd_sw2_pin, wd_route_button(), and wd_sw_pressed().
Referenced by main().
|
static |
Emit a byte run on the SCI8 console.
Definition at line 268 of file main.c.
References ra8_board_uart_console_write().
Referenced by main(), wd_fail_halt(), wd_print_banner(), wd_print_banner(), wd_print_hex(), and wd_print_uint().
|
static |
Emit the PASS banner once the self-check holds.
Definition at line 876 of file main.c.
References k_wd_msg_lib, k_wd_msg_pass, k_wd_msg_pre, k_wd_msg_rdr, k_wd_msg_route, ra8_app_count(), s_reg, wd_print(), wd_print_hex(), and wd_print_uint().
Referenced by main().
|
static |
Print value as 8 uppercase hex digits.
Definition at line 283 of file main.c.
References k_wd_dec_ten, k_wd_hex_nibbles, k_wd_nibble_bits, k_wd_nibble_mask, and wd_print().
Referenced by wd_print_banner(), and wd_print_banner().
|
static |
Print a small unsigned integer in decimal.
Definition at line 295 of file main.c.
References k_wd_dec_ten, and wd_print().
Referenced by wd_print_banner(), and wd_print_banner().
Initialise app state, the registry, and register every app.
Definition at line 719 of file main.c.
References k_ra8_ok, k_wd_app_library, k_wd_app_reader, k_wd_app_settings, k_wd_app_vt, k_wd_col_lib_bg, k_wd_col_rdr_bg, k_wd_col_set_bg, k_wd_lib_lines, k_wd_rdr_lines, k_wd_set_lines, ra8_app_register(), ra8_app_registry_init(), s_library, s_reader, s_reg, s_settings, s_slots, and wd_state_init().
Referenced by main().
|
static |
Render the focused app and flush the whole panel.
Definition at line 633 of file main.c.
References ra8_app_render(), s_reg, and wd_flush_full().
Referenced by main(), and wd_service_request().
|
static |
Route a navigation button through the focused app (#146).
Definition at line 655 of file main.c.
References k_ra8_widget_ev_button, ra8_app_route_input(), and s_reg.
Referenced by wd_poll_buttons().
|
static |
Run the whole deterministic surface; return the two composites' hashes.
Definition at line 813 of file main.c.
References k_ra8_ok, k_wd_app_library, k_wd_app_reader, ra8_app_launch(), ra8_app_render(), s_library, s_reader, s_reg, wd_check_damage(), wd_check_touch_dispatch(), and wd_framebuffer_hash().
Referenced by main().
|
static |
Apply a pending app-switch request: launch + re-composite if changed.
Definition at line 694 of file main.c.
References g_wd_request, k_ra8_app_none, k_ra8_ok, ra8_app_active(), ra8_app_launch(), s_reg, and wd_render_active().
Referenced by main().
|
static |
Bring up clocks/MSTP/time, the console, and the SW1/SW2 inputs.
Definition at line 854 of file main.c.
References k_ra8_board_sw1, k_ra8_board_sw2, k_ra8_clock_id_cpuclk0, k_ra8_ok, k_wd_msg_finit, k_wd_uart_baud, ra8_board_sw_init(), ra8_board_sw_pin(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), s_wd_sw1_pin, s_wd_sw2_pin, and wd_fail_halt().
Referenced by main().
|
static |
Build one app's widget tree: status (fixed) / content (flex) / tabs (fixed).
Definition at line 553 of file main.c.
References wa_content_t::bg, wa_app_state_t::content, wa_app_state_t::enters, k_wd_content_vt, k_wd_status_h, k_wd_status_vt, k_wd_tabbar_h, k_wd_tabbar_vt, k_wd_w_content, k_wd_w_status, k_wd_w_tabbar, wa_app_state_t::leaves, wa_content_t::lines, wa_content_t::nlines, s_chrome, wa_content_t::title, and wa_app_state_t::widgets.
Referenced by wd_register_apps().
|
static |
Status-bar render: fill + active app name + the button hint.
Definition at line 344 of file main.c.
References k_wd_col_dim, k_wd_col_status_bg, k_wd_col_text, k_wd_line_h, k_wd_pad, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), wa_chrome_t::reg, and wd_active_name().
|
static |
Read a user switch (active-low); true == pressed.
Definition at line 645 of file main.c.
References k_ra8_level_high, k_ra8_level_low, k_ra8_ok, pin, and ra8_gpio_read().
Referenced by wd_poll_buttons().
|
static |
Tab-bar input: map a touch column to an app id (request a launch).
Definition at line 417 of file main.c.
References g_wd_request, k_ra8_ok, k_ra8_widget_ev_touch, ra8_widget_event_t::kind, ra8_app_at(), ra8_app_count(), wa_chrome_t::reg, and ra8_widget_event_t::x.
|
static |
Tab-bar render: one cell per app, the active one highlighted.
Definition at line 380 of file main.c.
References ra8_app_registry_t::active, k_ra8_ok, k_wd_col_tab_off, k_wd_col_tab_on, k_wd_col_tabbar_bg, k_wd_col_text, k_wd_line_h, k_wd_pad, k_wd_tab_inset, ra8_app_at(), ra8_app_count(), ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), and wa_chrome_t::reg.
|
static |
App id an input handler asked to focus, or k_ra8_app_none.
Definition at line 220 of file main.c.
Referenced by main(), wd_app_on_input(), wd_check_touch_dispatch(), wd_service_request(), and wd_tabbar_on_input().
|
static |
Shared app lifecycle vtable (every app behaves the same way).
Definition at line 542 of file main.c.
Referenced by wd_register_apps().
|
static |
Definition at line 453 of file main.c.
Referenced by wd_state_init().
|
static |
Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.
Definition at line 591 of file main.c.
Referenced by wd_panel_up().
|
static |
Definition at line 229 of file main.c.
Referenced by wd_register_apps().
|
static |
|
static |
|
static |
Definition at line 252 of file main.c.
Referenced by wd_setup_or_halt().
|
static |
|
static |
|
static |
Definition at line 257 of file main.c.
Referenced by wd_print_banner().
|
static |
Definition at line 260 of file main.c.
Referenced by wd_print_banner(), and wd_print_banner().
|
static |
Definition at line 256 of file main.c.
Referenced by wd_print_banner(), and wd_print_banner().
|
static |
Definition at line 258 of file main.c.
Referenced by wd_print_banner().
|
static |
Definition at line 259 of file main.c.
Referenced by wd_print_banner().
|
static |
Definition at line 235 of file main.c.
Referenced by wd_register_apps().
|
static |
Definition at line 243 of file main.c.
Referenced by wd_register_apps().
|
static |
Status / content widgets ignore input (NULL handler never consumes).
Definition at line 450 of file main.c.
Referenced by wd_state_init().
|
static |
Definition at line 456 of file main.c.
Referenced by wd_state_init().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Settings app state (optional).
Definition at line 210 of file main.c.
Referenced by wd_register_apps().
|
static |
|
static |
|
static |
|
static |
SW1 (previous app) port pin, sourced from the board layer at init.
Definition at line 160 of file main.c.
Referenced by wd_poll_buttons(), and wd_setup_or_halt().
|
static |
SW2 (next app) port pin, sourced from the board layer at init.
Definition at line 162 of file main.c.
Referenced by wd_poll_buttons(), and wd_setup_or_halt().