69typedef enum : uint32_t {
82typedef enum : uint32_t {
138 "tile cache is smaller than the 1:1 viewport tile demand: re-derive k_mg_cells from "
139 "the panel + tile geometry so a single-step pan cannot thrash (#338)");
141 "resident tile arena exceeds its SDRAM budget: the tile-cache derivation grew past "
142 "k_mg_cell_budget_bytes");
170 "work arena is below the producer band term for the advertised cap: re-derive "
171 "k_mg_work_bytes from jof_work_bytes() for k_mg_cap_edge");
178typedef enum : uint16_t {
254static const uint8_t
k_msg_boot[] =
"ereader-manga: boot\r\n";
255static const uint8_t
k_msg_fail[] =
"ereader-manga: FAIL init\r\n";
256static const uint8_t
k_msg_atl[] =
"ereader-manga: FAIL atlas\r\n";
257static const uint8_t
k_msg_rend[] =
"ereader-manga: FAIL render\r\n";
258static const uint8_t
k_msg_pre[] =
"ereader-manga: page ";
262static const uint8_t
k_msg_view[] =
" view=0,0 zoom=1:1 crc=";
266static void mg_print(
const uint8_t* msg, uint32_t len)
276 __asm__
volatile(
"bkpt #0");
278 __asm__
volatile(
"wfi");
304 buf[n] = (uint8_t)(
'0' + (value % (uint32_t)
k_mg_dec_ten));
308 for (uint32_t i = 0U; i < n; ++i) {
320 uint32_t cpuclk0_hz = 0U;
375 const uint32_t avail = c->
len - c->
pos;
376 size_t take = ((uint32_t)cap < avail) ? cap : (size_t)avail;
378 c->
pos += (uint32_t)take;
395 if ((need == 0U) || (need > (uint32_t)
sizeof(
s_work))) {
417 .work_cap =
sizeof(
s_work),
418 .webp_work =
nullptr,
433 .scratch_cap = (uint32_t)
sizeof(
s_scratch)};
477 const bool touching = (got > 0U);
478 if (touching && !(*was_touching)) {
488 *was_touching = touching;
526 bool was_touching =
false;
void main(void)
Secure fallback main entry point.
static uint8_t s_scratch[(size_t) k_ra8_compress_scratch_bytes]
Compressor scratch (one miniz tdefl_compressor) in SRAM.
static const uint8_t k_msg_pre[]
static const uint8_t k_msg_ok[]
static const uint8_t k_msg_boot[]
static const uint8_t k_msg_fail[]
static display_handle_t * s_display
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).
static const uint8_t k_msg_x[]
static const uint8_t k_msg_view[]
static ra8_tile_key_t s_keys[(size_t) k_ls_cells]
Cache key storage.
static int32_t s_buckets[(size_t) k_ls_buckets]
Cache hash buckets.
static jof_memstore_t s_store
Atlas backing-read seam.
static ra8_tile_cache_t s_cache
Band cache (procedural decode).
static ra8_keycache_cell_t s_meta[(size_t) k_ls_cells]
Cache link metadata.
static ra8_tile_dims_t s_dims[(size_t) k_ls_cells]
Cache dim storage.
static const uint8_t k_msg_tiles[]
static const display_cfg_t k_mg_display_cfg
Display PAL config – LCD/GLCDC backend over the SDRAM framebuffer.
static mg_reader_t s_reader
The pan/zoom viewer over the tiled page.
static ra8_err_t mg_png_pull(void *ctx, uint8_t *buf, size_t cap, size_t *got)
produce pull seam: stream the baked PNG bytes to the transcoder.
static uint8_t s_work[k_mg_work_bytes]
Producer work arena (SDRAM: the transcode working set).
static const uint8_t k_msg_atl[]
static void mg_bringup_panel(void)
Bring up SDRAM + the GLCDC panel, then bind ra8_gfx to the FB.
static mg_png_cursor_t s_png_cursor
PNG pull cursor for the produce source.
static const uint8_t k_msg_atlas[]
static jof_info_t s_info
Parsed atlas geometry after produce.
static void mg_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
static const uint8_t k_msg_rend[]
static bool mg_setup_cache(void)
Wire the tile cache (decode-on-miss = read_tile) over the atlas.
static void mg_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
mg_boot_t
Boot / console / touch knobs.
@ k_mg_led_every
Heartbeat LED toggle sub-cadence.
@ k_mg_settle_ms
PLL / SDRAM / panel-POR settle.
@ k_mg_uart_baud
Console baud.
@ k_mg_touch_max_points
One contact = one tap.
@ k_mg_frame_ms
Input poll period, ms.
static void mg_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the console.
static void mg_print_banner(void)
Print the deterministic boot banner (geometry + render hash).
mg_fb_t
Framebuffer geometry (mirrors the EK-RA8D2 panel).
@ k_mg_fb_w
Framebuffer width, pixels.
@ k_mg_fb_h
Framebuffer height, pixels.
static void mg_present(void)
Present the framebuffer (clean full update).
static mg_tile_src_t s_tile_src
Decode-on-miss context bound into the cache.
static bool mg_build_atlas(void)
Transcode the baked page into a JOF atlas + parse its geometry.
static uint8_t s_store_buf[k_mg_store_bytes]
Atlas memstore backing (SDRAM: the produced JOF atlas).
static void mg_bringup_touch(void)
Open the GT911 touch controller (best-effort, polled).
static uint8_t s_cell_mem[(size_t) k_mg_cells *(size_t) k_mg_cell_bytes]
Tile-cache cell storage (k_mg_cells gray8 256x256 tiles, SDRAM).
mg_atlas_t
JOF produce + cache budget (page geometry rides in the fixture).
@ k_mg_store_bytes
SDRAM atlas memstore.
@ k_mg_view_cols
1:1 cols.
@ k_mg_cells
Frame + 1-tile pan margin.
@ k_mg_image_id
Tile-cache key image id.
@ k_mg_cell_bytes
One gray8 256x256 tile.
@ k_mg_tile_edge
Import + cache tile edge, pixels.
@ k_mg_cell_budget_bytes
SDRAM tile cache may claim.
@ k_mg_nibble_mask
Low-nibble mask.
@ k_mg_scratch
read_tile deflate staging.
@ k_mg_hex_nibbles
Hex digits per 32-bit value.
@ k_mg_buckets
Hash buckets (>= cells).
@ k_mg_nibble_bits
Bits per hex nibble.
@ k_mg_dec_ten
Decimal radix / hex split.
@ k_mg_work_bytes
SDRAM producer work arena.
@ k_mg_cap_edge
Produce budget cap, pixels.
@ k_mg_view_rows
1:1 content rows.
static void mg_panic_halt(const uint8_t *msg, uint32_t len)
Print a fail banner, then trap (ra8_emulator halts on the BKPT).
static void mg_poll_touch(bool *was_touching)
Poll the GT911 once; on a fresh tap, mutate + redraw the viewport.
static void mg_bringup_clocks(void)
Bring up clocks, MSTP, system tick, LEDs and the SCI console.
JOF band-tile atlas: the display-native normalized image format (#231, shared with the longstrip scro...
ra8_err_t jof_memstore_pread(void *ctx, uint64_t offset, uint8_t *buf, size_t len, size_t *got)
Positioned read from a jof_memstore_t (reader seam).
@ k_jof_bpp_max
Max bytes per pixel.
ra8_err_t jof_parse(jof_pread_fn pread, void *pread_ctx, uint64_t total_size, jof_info_t *out_info)
Parse + validate a JOF atlas's header, footer and index bounds.
@ k_jof_codec_deflate
Tile stream is one raw-DEFLATE run.
ra8_err_t jof_memstore_sink(void *ctx, const uint8_t *buf, size_t len)
Append len bytes to a jof_memstore_t (producer sink).
Import-time transcode producer: JPEG/PNG/WebP -> JOF band-tile atlas in bounded RAM (#231,...
uint32_t jof_work_bytes(uint16_t max_width, uint16_t max_height, uint16_t tile_w, uint16_t tile_h)
Compute the work-arena size the producer needs for given caps.
ra8_err_t jof_produce(const jof_produce_cfg_t *cfg, jof_info_t *out_info)
Transcode one encoded JPEG/PNG/WebP source into a JOF atlas (#231, #290).
Baked demo manga page for the ereader_manga viewer.
static const uint32_t k_mg_png_len
Length of k_mg_png in bytes.
static const uint8_t k_mg_png[]
Baked 19680-byte 1536x2048 grayscale PNG page.
Tap-driven pan/zoom viewer over a tiled manga page (ereader_manga).
bool mg_reader_tap(mg_reader_t *r, int32_t x, int32_t y)
Apply a tap: pan or toggle zoom, and report whether state changed.
ra8_err_t mg_tile_decode(void *ctx, const ra8_tile_key_t *key, uint8_t *cell, uint32_t cell_bytes, uint16_t *out_w, uint16_t *out_h)
Tile-cache decode-on-miss callback: page one atlas tile into a cell.
uint32_t mg_fnv1a(const void *buf, uint32_t len)
FNV-1a-32 over a byte buffer (framebuffer render hash for the banner).
ra8_err_t mg_reader_prefetch(mg_reader_t *r)
Warm the tiles one step ahead of the last pan (predictive prefetch).
ra8_err_t mg_reader_render(mg_reader_t *r)
Render the current viewport + chrome into the framebuffer.
@ k_mg_statusbar_h
Top status-bar band height, panel px.
ra8_err_t mg_reader_init(mg_reader_t *r, const mg_reader_cfg_t *cfg)
Bind a viewer to a produced atlas and reset it to 1:1 top-left.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ k_ra8_board_led_blue
Convenience aliases by colour.
@ k_ra8_board_led_red
RA8 board led red.
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.
One-call bring-up of the EK-RA8D2 panel's GoodIX GT911 touch controller.
ra8_err_t ra8_board_touch_open(const ra8_board_touch_cfg_t *cfg)
Bring the on-board GT911 up and open the touch driver against it.
Boot entry points shared between a vector table and its startup code.
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.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Display Platform Abstraction Layer for the RA8D2.
@ k_display_pixfmt_rgb565
16 bpp, 5/6/5 packed.
display_rect_t display_full_rect(const display_handle_t *d)
Convenience helper returning the rect covering the whole framebuffer.
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.
@ 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.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
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.
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.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
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.
Active display-panel descriptor for the EK-RA8D2 (ER-TFT070-6).
@ k_panel_height_px
Native height (pixels).
@ k_panel_width_px
Native width (pixels).
#define RA8_BOARD_PANEL_FRAMEBUFFER(name)
Declare a correctly aligned, sized and placed RGB565 framebuffer for the on-board panel.
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.
External SDRAM controller driver (framework).
ra8_err_t ra8_sdramc_init(void)
Initialise the external SDRAM at k_ra8_sdram_base_addr.
Fixed-RAM-budget image-tile cache with LRU eviction (Layer 3b, #147).
ra8_err_t ra8_tile_cache_init(ra8_tile_cache_t *tc, const ra8_tile_cache_cfg_t *cfg)
Initialise a tile cache over caller-supplied storage.
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.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Multi-touch input driver – GoodIX GT911 backend.
ra8_err_t ra8_touch_read(ra8_touch_point_t *out_points, uint8_t max_count, uint8_t *got_count)
Drain the current touch frame.
@ k_ra8_touch_irq_pin_unset
Sentinel for "no IRQ pin attached".
Configuration descriptor passed into display_init.
Framebuffer descriptor returned by display_get_framebuffer.
Parsed + validated geometry of one JOF atlas.
Append-only memory store: the simplest atlas backing (RAM/SDRAM).
Producer configuration: source, sink, tile geometry and work arena.
Forward cursor over the baked PNG for the produce pull seam.
const uint8_t * data
Baked PNG bytes.
uint32_t len
Total length.
uint32_t pos
Bytes delivered so far.
Everything mg_reader_init needs to bind a viewer to a page.
Viewer state: the page geometry plus the current viewport + zoom.
Decode-on-miss context bound into the tile cache (DIP seam).
The two touch settings that are an APPLICATION choice, not a board fact.
Per-cell link metadata (one caller-owned array entry per cell).
Caller-supplied storage + decoder for ra8_tile_cache_init.
Tile-cache state (caller-owned; treat as private).
Per-cell user descriptor: the decoded tile dimensions.
Identifies one decoded image tile.
One decoded touch contact.
uint16_t x
Panel X coordinate.
uint16_t y
Panel Y coordinate.