|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Viewable tap-to-zoom image viewer: full-screen zoom + panel loupe (#478). More...
#include <stddef.h>#include <stdint.h>#include "ez_scene.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_board_ek_ra8d2_touch.h"#include "ra8_boot_entry.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_isr.h"#include "ra8_mstp.h"#include "ra8_panel.h"#include "ra8_panel_timing.h"#include "ra8_sdramc.h"#include "ra8_time.h"#include "ra8_touch.h"Go to the source code of this file.
Enumerations | |
| enum | ez_boot_t : uint32_t { k_ez_uart_baud = 115200U , k_ez_settle_ms = 500U , k_ez_frame_ms = 25U , k_ez_led_every = 16U , k_ez_touch_max_points = 1U } |
| Boot, console and touch knobs. More... | |
| enum | ez_fb_t : uint16_t { k_ez_fb_w = k_panel_width_px , k_ez_fb_h = k_panel_height_px } |
| Framebuffer geometry (mirrors the EK-RA8D2 panel). More... | |
| enum | ez_print_t : uint8_t { k_ez_hex_nibbles = 8U , k_ez_nibble_bits = 4U , k_ez_nibble_mask = 0x0FU , k_ez_dec_ten = 10U } |
| Decimal / hexadecimal formatting constants for the banner. More... | |
Functions | |
| RA8_BOARD_PANEL_FRAMEBUFFER (s_framebuffer) | |
| static void | ez_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the console. | |
| static void | ez_panic_halt (const uint8_t *msg, uint32_t len) |
| Print a fail banner, then trap (ra8_emulator halts on the BKPT). | |
| static void | ez_print_hex (uint32_t value) |
| Print a 32-bit value as 8 upper-case hex digits. | |
| static void | ez_print_uint (uint32_t value) |
| Print a small unsigned integer in decimal. | |
| static void | ez_bringup_clocks (void) |
| Bring up clocks, MSTP, system tick, LEDs and the SCI console. | |
| static void | ez_bringup_panel (void) |
| Bring up SDRAM + the GLCDC panel, then bind ra8_gfx to the FB. | |
| static void | ez_bringup_touch (void) |
| Open the GT911 touch controller (best-effort, polled). | |
| static void | ez_flush (const ez_present_t *plan) |
| Flush a scene plan through the PAL with the waveform it asked for. | |
| static bool | ez_redraw (void) |
| Render, then flush whatever the scene says changed. | |
| static void | ez_print_banner (const ez_selftest_t *st) |
| Print the deterministic boot banner (geometry + the four hashes). | |
| static void | ez_poll_touch (bool *was_touching) |
| Poll the GT911 once; on a fresh tap, mutate + redraw the viewport. | |
| static bool | ez_setup_scene (void) |
| Wire the scene over the SDRAM cache storage and the SRAM scratch. | |
| void | main (void) |
| App entry: panel bring-up -> tiled page -> self-check -> zoom loop. | |
Variables | |
| static uint8_t | s_cell_mem [(size_t) k_ez_cells *(size_t) k_ez_cell_bytes] |
| Tile-cache cell storage: k_ez_cells gray8 256x256 tiles, in SDRAM. | |
| static ra8_keycache_cell_t | s_meta [k_ez_cells] |
| Tile-cache link metadata, one entry per cell. | |
| static ra8_tile_key_t | s_keys [k_ez_cells] |
| Tile-cache key storage, one entry per cell. | |
| static ra8_tile_dims_t | s_dims [k_ez_cells] |
| Tile-cache decoded-extent descriptors, one entry per cell. | |
| static int32_t | s_buckets [k_ez_buckets] |
| Tile-cache hash-bucket heads. | |
| static uint8_t | s_row [k_ez_row_bytes] |
| Composite scratch: one source row at the widest viewport (SRAM). | |
| static uint8_t | s_strip [k_ez_strip_bytes] |
| Composite scratch: the gray8 destination strip (SRAM). | |
| static uint8_t | s_packed [k_ez_packed_bytes] |
| Composite scratch: the dithered strip packed to 4 bpp (SRAM). | |
| static const display_cfg_t | k_ez_display_cfg |
| Display PAL configuration: LCD/GLCDC backend over the SDRAM framebuffer. | |
| static display_handle_t * | s_display = nullptr |
| Display PAL handle returned by display_init. | |
| static display_fb_t | s_fb |
| Mutable copy of the framebuffer descriptor, populated at boot. | |
| static ez_scene_t | s_scene |
| The demo scene: tiled page, zoom viewport and loupe. | |
| static const uint8_t | k_msg_boot [] = "ereader-zoom: boot\r\n" |
| Console banner fragment: boot line. | |
| static const uint8_t | k_msg_fail [] = "ereader-zoom: FAIL init\r\n" |
| Console banner fragment: bring-up failure. | |
| static const uint8_t | k_msg_scene [] = "ereader-zoom: FAIL scene\r\n" |
| Console banner fragment: scene wiring failure. | |
| static const uint8_t | k_msg_rend [] = "ereader-zoom: FAIL render\r\n" |
| Console banner fragment: render / self-check failure. | |
| static const uint8_t | k_msg_pre [] = "ereader-zoom: page " |
| Console banner fragment: geometry prefix. | |
| static const uint8_t | k_msg_x [] = "x" |
| Console banner fragment: dimension separator. | |
| static const uint8_t | k_msg_tile [] = " tile " |
| Console banner fragment: tile edge label. | |
| static const uint8_t | k_msg_cells [] = " cells " |
| Console banner fragment: cache cell-count label. | |
| static const uint8_t | k_msg_z1 [] = " z1=" |
| Console banner fragment: 1:1 render hash label. | |
| static const uint8_t | k_msg_pan [] = " pan=" |
| Console banner fragment: panned render hash label. | |
| static const uint8_t | k_msg_z2 [] = " z2=" |
| Console banner fragment: 2x render hash label. | |
| static const uint8_t | k_msg_lens [] = " lens=" |
| Console banner fragment: loupe render hash label. | |
| static const uint8_t | k_msg_hit [] = " hit=" |
| Console banner fragment: cache hit counter label. | |
| static const uint8_t | k_msg_miss [] = " miss=" |
| Console banner fragment: cache miss counter label. | |
| static const uint8_t | k_msg_evict [] = " evict=" |
| Console banner fragment: cache eviction counter label. | |
| static const uint8_t | k_msg_warm [] = " warm=" |
| Console banner fragment: prefetch counter label. | |
| static const uint8_t | k_msg_ok [] = " ok\r\n" |
| Console banner fragment: success suffix. | |
Viewable tap-to-zoom image viewer: full-screen zoom + panel loupe (#478).
The other half of the decision not to downscale .rabook images: keep every pixel at import, and let the reader magnify into them. This app makes that viewable. It brings up the 1024x600 GLCDC panel, binds a 4096x3072 gray8 page – 12 MiB, an order of magnitude past what the part can hold – through an ::ra8_tile_cache, and drives it with the zoom viewport engine:
The banner is deterministic because every stage is integer arithmetic (the sampler is shifts and masks, the composite is nearest-neighbour plus a const blue-noise mask, and the chrome is filled rectangles rather than antialiased glyphs), so it is identical on host, ra8_emulator and silicon:
ereader-zoom: page 4096x3072 tile 256 cells 35 z1=<8hex> pan=<8hex> z2=<8hex> lens=<8hex> hit=<n> miss=<n> evict=<n> warm=<n> ok
Definition in file main.c.
| enum ez_boot_t : uint32_t |
Boot, console and touch knobs.
Copied from the sibling reader demos so every viewable app on this board brings the console and the GT911 up the same way.
| enum ez_fb_t : uint16_t |
Framebuffer geometry (mirrors the EK-RA8D2 panel).
Held separately from the panel constants so the scene's layout asserts have compile-time numbers to check against.
| Enumerator | |
|---|---|
| k_ez_fb_w | Framebuffer width, pixels. |
| k_ez_fb_h | Framebuffer height, pixels. |
| enum ez_print_t : uint8_t |
Decimal / hexadecimal formatting constants for the banner.
The banner is emitted without printf (no float, no heap), so the radix and nibble geometry are named here rather than inlined.
| Enumerator | |
|---|---|
| k_ez_hex_nibbles | Hex digits in a 32-bit value. |
| k_ez_nibble_bits | Bits per hex nibble. |
| k_ez_nibble_mask | Low-nibble mask. |
| k_ez_dec_ten | Decimal radix. |
|
static |
Bring up clocks, MSTP, system tick, LEDs and the SCI console.
Definition at line 345 of file main.c.
References ez_panic_halt(), k_ez_uart_baud, k_msg_fail, k_ra8_board_led_blue, k_ra8_board_led_red, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_isr_globals_enable(), ra8_mstp_init(), and ra8_time_init().
Referenced by main().
|
static |
Bring up SDRAM + the GLCDC panel, then bind ra8_gfx to the FB.
Definition at line 368 of file main.c.
References display_get_framebuffer(), display_init(), ez_panic_halt(), k_ez_display_cfg, k_ez_settle_ms, k_msg_fail, k_ra8_gfx_format_rgb565, k_ra8_ok, ra8_delay_ms(), ra8_gfx_init(), ra8_sdramc_init(), s_display, and s_fb.
Referenced by main().
|
static |
Open the GT911 touch controller (best-effort, polled).
Definition at line 387 of file main.c.
References k_ez_touch_max_points, k_ra8_touch_irq_pin_unset, and ra8_board_touch_open().
Referenced by main().
|
static |
Flush a scene plan through the PAL with the waveform it asked for.
Definition at line 395 of file main.c.
References display_flush(), ra8_ui_rect_t::h, k_display_refresh_fast, k_display_refresh_quality, ez_present_t::quality, ez_present_t::rect, s_display, ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by ez_redraw(), and main().
|
static |
Print a fail banner, then trap (ra8_emulator halts on the BKPT).
Definition at line 303 of file main.c.
References ez_print(), k_ra8_board_led_red, and ra8_board_led_on().
Referenced by ez_bringup_clocks(), ez_bringup_panel(), and main().
|
static |
Poll the GT911 once; on a fresh tap, mutate + redraw the viewport.
Definition at line 459 of file main.c.
References ez_redraw(), ez_scene_tap(), k_ra8_ok, ra8_time_ms(), ra8_touch_read(), s_scene, ra8_touch_point_t::x, and ra8_touch_point_t::y.
Referenced by main().
|
static |
Emit a byte run on the console.
Definition at line 297 of file main.c.
References ra8_board_uart_console_write().
Referenced by ez_panic_halt(), ez_print_banner(), ez_print_hex(), ez_print_uint(), and main().
|
static |
Print the deterministic boot banner (geometry + the four hashes).
Definition at line 429 of file main.c.
References ez_selftest_t::crc_1x, ez_selftest_t::crc_2x, ez_selftest_t::crc_lens, ez_selftest_t::crc_pan, ez_selftest_t::evictions, ez_print(), ez_print_hex(), ez_print_uint(), ez_selftest_t::hits, k_ez_cells, k_ez_page_h, k_ez_page_w, k_ez_tile_edge, k_msg_cells, k_msg_evict, k_msg_hit, k_msg_lens, k_msg_miss, k_msg_ok, k_msg_pan, k_msg_pre, k_msg_tile, k_msg_warm, k_msg_x, k_msg_z1, k_msg_z2, ez_selftest_t::misses, and ez_selftest_t::warmed.
Referenced by main().
|
static |
Print a 32-bit value as 8 upper-case hex digits.
Definition at line 314 of file main.c.
References ez_print(), k_ez_dec_ten, k_ez_hex_nibbles, k_ez_nibble_bits, and k_ez_nibble_mask.
Referenced by ez_print_banner().
|
static |
Print a small unsigned integer in decimal.
Definition at line 326 of file main.c.
References ez_print(), and k_ez_dec_ten.
Referenced by ez_print_banner().
|
static |
Render, then flush whatever the scene says changed.
Definition at line 413 of file main.c.
References ez_flush(), ez_scene_present(), ez_scene_render(), k_ra8_ok, ez_present_t::present, and s_scene.
Referenced by ez_poll_touch(), and main().
|
static |
| void main | ( | void | ) |
App entry: panel bring-up -> tiled page -> self-check -> zoom loop.
The application entry point Reset_Handler hands control to.
Definition at line 502 of file main.c.
References ez_bringup_clocks(), ez_bringup_panel(), ez_bringup_touch(), ez_content_rect(), ez_flush(), ez_panic_halt(), ez_poll_touch(), ez_print(), ez_print_banner(), ez_redraw(), ez_scene_selftest(), ez_scene_tick(), ez_setup_scene(), k_ez_fb_h, k_ez_fb_w, k_ez_frame_ms, k_ez_led_every, k_msg_boot, k_msg_rend, k_msg_scene, k_ra8_board_led_blue, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), ra8_time_ms(), and s_scene.
| RA8_BOARD_PANEL_FRAMEBUFFER | ( | s_framebuffer | ) |
References s_framebuffer.
|
static |
Display PAL configuration: LCD/GLCDC backend over the SDRAM framebuffer.
Immutable; the PAL copies what it needs at display_init.
Definition at line 221 of file main.c.
Referenced by ez_bringup_panel().
|
static |
|
static |
Console banner fragment: cache cell-count label.
Definition at line 276 of file main.c.
Referenced by ez_print_banner().
|
static |
Console banner fragment: cache eviction counter label.
Definition at line 290 of file main.c.
Referenced by ez_print_banner().
|
static |
|
static |
Console banner fragment: cache hit counter label.
Definition at line 286 of file main.c.
Referenced by ez_print_banner(), and imp_run().
|
static |
Console banner fragment: loupe render hash label.
Definition at line 284 of file main.c.
Referenced by ez_print_banner().
|
static |
Console banner fragment: cache miss counter label.
Definition at line 288 of file main.c.
Referenced by ez_print_banner(), imp_run(), and main().
|
static |
|
static |
Console banner fragment: panned render hash label.
Definition at line 280 of file main.c.
Referenced by ez_print_banner().
|
static |
|
static |
|
static |
|
static |
|
static |
Console banner fragment: prefetch counter label.
Definition at line 292 of file main.c.
Referenced by ez_print_banner().
|
static |
|
static |
Console banner fragment: 1:1 render hash label.
Definition at line 278 of file main.c.
Referenced by ez_print_banner().
|
static |
Console banner fragment: 2x render hash label.
Definition at line 282 of file main.c.
Referenced by ez_print_banner().
|
static |
|
static |
Tile-cache cell storage: k_ez_cells gray8 256x256 tiles, in SDRAM.
The viewer's large working set. It lives here, not in the zoom engine, which is the whole point of the strip composite: the magnifier's own scratch is 25 KiB of SRAM.
|
static |
|
static |
Display PAL handle returned by display_init.
NULL until the panel is up.
|
static |
Mutable copy of the framebuffer descriptor, populated at boot.
Used to bind ra8_gfx to whatever the PAL actually handed back.
|
static |
|
static |
|
static |
Composite scratch: the dithered strip packed to 4 bpp (SRAM).
Handed straight to ra8_gfx_blit_gray4_zoom.
Definition at line 211 of file main.c.
Referenced by ez_setup_scene(), internal_publish(), internal_publish_fragment(), and internal_workspace().
|
static |
Composite scratch: one source row at the widest viewport (SRAM).
Part of the viewer's whole 25 KiB footprint; see ez_scene.h.
Definition at line 190 of file main.c.
Referenced by ez_setup_scene().
|
static |
The demo scene: tiled page, zoom viewport and loupe.
All of the app's presentation state; see ez_scene.h.
Definition at line 259 of file main.c.
Referenced by ez_poll_touch(), ez_redraw(), ez_setup_scene(), and main().
|
static |
Composite scratch: the gray8 destination strip (SRAM).
16 destination rows at 1024 px; the strip height is derived from this capacity by zoom_view_open().