84typedef enum : uint16_t {
104typedef enum : uint32_t {
128typedef enum : uint32_t {
146typedef enum : uint32_t {
160typedef enum : uint16_t {
170typedef enum : uint32_t {
184typedef enum : int32_t {
193typedef enum : uint32_t {
212typedef enum : uint8_t {
222static const char*
const s_tag =
"ereader_longstrip";
322static const uint8_t
k_msg_boot[] =
"ereader-longstrip: boot\r\n";
323static const uint8_t
k_msg_pre[] =
"ereader-longstrip: bands=";
336static void ls_print(
const uint8_t* msg, uint32_t len)
363 buf[n] = (uint8_t)(
'0' + (value % (uint32_t)
k_ls_dec_ten));
367 for (uint32_t i = 0U; i < n; i++) {
379static const char*
ls_utoa(
char* buf, uint32_t value)
388 tmp[n] = (char)(
'0' + (value % (uint32_t)
k_ls_dec_ten));
392 for (uint32_t i = 0U; i < n; i++) {
393 buf[i] = tmp[n - 1U - i];
409 __asm__
volatile(
"wfi");
416 uint32_t cpuclk0_hz = 0U;
525 for (uint32_t n = 0U; n < bands; n++) {
526 const uint32_t y0 = n * band_h;
527 const uint32_t th = ((height - y0) < band_h) ? (height - y0) : band_h;
532 const uint32_t ftr = index_off + (bands * (uint32_t)
k_ls_idx_entry);
552 return (uint8_t)(((uint32_t)v * pct) / (uint32_t)
k_ls_pct_full);
569static void ls_row_color(uint32_t base, uint32_t r, uint32_t th, uint8_t* rgb)
577 const uint32_t span = (th > 1U) ? (th - 1U) : 1U;
615 const uint32_t y0 = (uint32_t)key->
tile_y * (uint32_t)pc->
band_h;
616 uint32_t th = (uint32_t)pc->
band_h;
620 if ((pc->
width * th * (uint32_t)pc->
bpp) > cell_bytes) {
625 for (uint32_t r = 0U; r < th; r++) {
628 for (uint32_t x = 0U; x < pc->
width; x++) {
630 cell[off + 1U] = rgb[1];
631 cell[off + 2U] = rgb[2];
632 off += (uint32_t)pc->
bpp;
635 *out_w = (uint16_t)pc->
width;
636 *out_h = (uint16_t)th;
646 const uint8_t* pixels,
682 .blit_ctx =
nullptr};
702 const uint8_t* pixels,
716static int32_t
ls_text(int32_t x, int32_t y,
const char* str, uint32_t color)
724 return x + (int32_t)w;
737 const uint32_t band =
772 if ((
s_strip.max_scroll > 0) && (range > 0)) {
773 ty = (int32_t)(((uint32_t)
s_strip.scroll_y * (uint32_t)range) / (uint32_t)
s_strip.max_scroll);
806 for (
size_t i = 0U; i < n; i++) {
846 const int32_t before =
s_strip.scroll_y;
848 if ((
s_strip.scroll_y == before) && (delta != 0)) {
void main(void)
Secure fallback main entry point.
static const uint8_t k_msg_pre[]
static const uint8_t k_msg_crc[]
static const uint8_t k_msg_boot[]
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 void ls_poll_buttons(void)
Poll SW1/SW2 and page up/down on a fresh press (button fallback).
static void app_bringup_touch(void)
Open the GT911 touch controller (best-effort, polled; non-fatal).
volatile uint32_t g_ls_scroll_y
Current scroll position (px) mirrored for --dump-sym telemetry.
static const uint8_t k_msg_scroll[]
static int32_t ls_text(int32_t x, int32_t y, const char *str, uint32_t color)
Draw a text run in the bundled font; return the next x column.
static uint8_t s_cells[(size_t) k_ls_cells *(size_t) k_ls_band_bytes]
Tile-cache cell storage in SDRAM (one decoded band per cell).
static void app_bringup_clocks(void)
Bring up clocks, MSTP, SysTick, the SCI8 console and both LEDs.
static ls_paint_ctx_t s_paint
Painter context bound as the tile cache's decode ctx.
static ra8_err_t ls_blit(void *ctx, const uint8_t *pixels, uint16_t src_w, uint16_t src_h, uint8_t bpp, int32_t dst_x, int32_t dst_y)
Longstrip blit sink -> ra8_gfx software blit (RGB888 -> RGB565).
static void app_bringup_panel(void)
Bring up external SDRAM + the GLCDC panel, then cache the FB.
static void ls_draw_status(void)
Draw the status bar overlay: wordmark + band + scroll-position text.
static void app_panic_halt(void)
Halt forever with the red board LED on (visual sign of fatal init).
static void ls_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
static const uint8_t k_msg_eol[]
static uint32_t ls_hash_fb(void)
Fold an FNV-1a-32 over the whole panel framebuffer.
ls_rail_t
Scroll-rail thumb geometry, pixels.
@ k_ls_rail_min_thumb
Minimum thumb height so it stays grabbable.
static void ls_apply_nav(int32_t delta, bool toggle)
Apply one navigation action, redrawing + presenting if state changed.
ls_touch_cfg_t
GT911 touch-controller wiring (IIC_B channel 0, polled).
@ k_ls_touch_max_points
One contact = one tap.
static bool s_chrome
True while the status bar + scroll rail chrome is shown.
ls_zone_t
Vertical tap-zone thresholds (thirds of the panel), pixels.
@ k_ls_zone_top
y < this: up.
@ k_ls_zone_mid
< this: chrome.
static const char * ls_utoa(char *buf, uint32_t value)
Format an unsigned integer as a NUL-terminated ASCII decimal string.
ls_color_t
Chrome palette, 0x00RRGGBB.
@ k_ls_col_status_bg
Status-bar fill.
@ k_ls_col_text
Status-bar primary text.
@ k_ls_col_rail_thumb
Scroll-rail thumb (amber).
@ k_ls_col_rail_bg
Scroll-rail track.
@ k_ls_col_bg
Content backdrop (behind bands).
@ k_ls_col_text_dim
Status-bar secondary text.
static void ls_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
static const uint8_t k_msg_view[]
ls_paint_t
Procedural band-painter constants.
@ k_ls_seam_level
Seam-stripe grey level (near white).
@ k_ls_grad_span
Top->bottom brightness gain (percent).
@ k_ls_seam_h
White seam-stripe rows at each band top.
@ k_ls_grad_lo
Band-top brightness (percent of the hue).
@ k_ls_pct_full
Percentage denominator.
@ k_ls_palette_size
Entries in the vivid band palette.
static void ls_print_uint(uint32_t value)
Print a small unsigned integer in decimal on the console.
static void ls_put_u16(uint8_t *p, uint16_t v)
Write a little-endian u16 at p.
static void ls_redraw(void)
Repaint the whole panel: strip bands, then the chrome overlays.
static bool s_was_sw1
Edge-detect: was SW1 held on the previous button poll.
static const uint32_t k_ls_palette[k_ls_palette_size]
Vivid 16-hue band palette (0x00RRGGBB) – distinct so scroll is obvious.
static uint16_t s_last_skipped
Skipped-band count from the last render (must stay 0: #289 contract).
volatile uint32_t g_ls_frame_crc
FNV-1a-32 over the panel FB at the boot banner (render fingerprint).
static ra8_tile_key_t s_keys[(size_t) k_ls_cells]
Cache key storage.
static longstrip_t s_strip
Opened longstrip scroll state.
static uint8_t ls_scale_u8(uint8_t v, uint32_t pct)
Scale an 8-bit channel by a 0..100 percentage (saturating at 255).
static const display_cfg_t k_ls_display_cfg
Display-PAL config: LCD/GLCDC backend over the SDRAM framebuffer.
static void ls_draw_rail(void)
Draw the right-edge scroll rail overlay (track + proportional thumb).
static bool s_was_sw2
Edge-detect: was SW2 held on the previous button poll.
volatile uint32_t g_ls_loop_ticks
Free-running main-loop counter – HIL/liveness probe symbol.
static ra8_err_t ls_band_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: paint band key->tile_y procedurally.
static void ls_row_color(uint32_t base, uint32_t r, uint32_t th, uint8_t *rgb)
Compute the RGB888 colour of one strip row inside a band.
static uint8_t s_atlas[k_ls_atlas_total]
Metadata-only JOF atlas backing (header + index + footer).
static void app_bringup_gfx(void)
Bind ra8_gfx to the panel framebuffer.
static void ls_present(void)
Present the framebuffer to the panel (clean full refresh).
static void ls_put_u32(uint8_t *p, uint32_t v)
Write a little-endian u32 at p.
static uint32_t ls_build_atlas(void)
Build the metadata-only JOF band-tile atlas; return its byte length.
static void ls_poll_touch(void)
Poll the touch controller; dispatch one tap per delivered GT911 frame.
static int32_t s_buckets[(size_t) k_ls_buckets]
Cache hash buckets.
ls_size_t
32-bit strip + cache + scroll magnitudes.
@ k_ls_buckets
Tile-cache hash buckets.
@ k_ls_band_bytes
One band payload, bytes.
@ k_ls_bpp
RGB888 strip pixels.
@ k_ls_scroll_page
Page-scroll step (~90% of a viewport), pixels.
@ k_ls_cells
Tile-cache cells (< 16 bands -> LRU eviction).
@ k_ls_canvas_w
Strip width, pixels.
@ k_ls_image_id
Tile-cache key namespace for this strip.
static jof_memstore_t s_store
Atlas backing-read seam.
static ra8_tile_cache_t s_cache
Band cache (procedural decode).
ls_atlas_t
JOF metadata-only atlas layout (procedural bands -> no pixel region).
@ k_ls_shift_24
Three-byte shift.
@ k_ls_ftr_magic_off
Footer "JOFE" magic offset.
@ k_ls_hdr_bytes
JOF header length.
@ k_ls_shift_16
Two-byte shift.
@ k_ls_idx_entry
Index-entry length (offset + len).
@ k_ls_shift_8
One-byte shift.
@ k_ls_ftr_bytes
JOF footer length.
@ k_ls_atlas_total
176-byte atlas length.
@ k_ls_byte_mask
Low-byte mask.
static ra8_keycache_cell_t s_meta[(size_t) k_ls_cells]
Cache link metadata.
volatile uint32_t g_ls_redraws
Count of full redraws since boot – render-progress telemetry.
static void ls_open_strip(uint32_t total)
Wire the memstore/painter/cache and open the strip; halt on failure.
static void ls_emit_banner(void)
Emit the deterministic boot banner (bands, viewport, scroll, FB CRC).
static ra8_tile_dims_t s_dims[(size_t) k_ls_cells]
Cache dim storage.
ls_geom_t
Panel, chrome and strip geometry in pixels.
@ k_ls_glyph_h
Bundled font cell height.
@ k_ls_status_h
Status-bar overlay band height.
@ k_ls_settle_ms
PLL / SDRAM / panel-POR settle.
@ k_ls_view_w
Viewport / strip width (== panel).
@ k_ls_view_h
Viewport / strip-window height.
@ k_ls_led_every
Toggle heartbeat LED every Nth frame.
@ k_ls_bands
Bands in the strip (16 palette hues).
@ k_ls_band_h
One band (JOF tile) height, pixels.
@ k_ls_text_pad
Status-bar left text inset.
@ k_ls_glyph_w
Bundled font cell width.
@ k_ls_rail_w
Scroll-rail overlay width, pixels.
@ k_ls_frame_ms
Input-poll period (ms).
static void ls_handle_tap(int32_t y)
Map a tap Y coordinate to a navigation action (tap-zone hit-test).
ls_console_t
Console baud + FNV-1a-32 + decimal/hex print knobs.
@ k_ls_nibble_mask
Low-nibble mask.
@ k_ls_dec_digits
Max decimal digits (u32).
@ k_ls_hex_nibbles
Hex digits in a 32-bit value.
@ k_ls_nibble_bits
Bits per hex nibble.
@ k_ls_fnv_prime
FNV-1a-32 prime.
@ k_ls_fnv_offset
FNV-1a-32 offset basis.
@ k_ls_uart_baud
SCI8 console baud.
@ k_ls_dec_ten
Decimal base / hex split.
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_codec_raw
Tile stream is the packed pixels.
Continuous vertical-scroll (longstrip / manhwa) reading mode over an JOF band-tile atlas (#289).
ra8_err_t longstrip_scroll_by(longstrip_t *wt, int32_t delta)
Scroll by a signed pixel delta (a finger drag), clamping at the ends.
ra8_err_t longstrip_render(longstrip_t *wt, longstrip_render_stats_t *stats)
Composite every visible band at the current scroll position.
ra8_err_t longstrip_open(longstrip_t *wt, const longstrip_cfg_t *cfg)
Open a longstrip strip over a parsed + validated JOF atlas.
static const char * s_tag
Logging / check tag.
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_sw_read(ra8_board_sw_id_t sw, ra8_board_sw_state_t *out_pressed)
Sample the current state of sw.
ra8_err_t ra8_board_sw_init(ra8_board_sw_id_t sw)
Configure a switch pin as an input with internal pull-up.
@ k_ra8_board_sw1
SW1, P009, IRQ13-DS (jumper E31).
@ k_ra8_board_sw2
SW2, P008, IRQ12-DS (jumper E32).
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).
ra8_board_sw_state_t
Logical "pressed" / "released" state.
@ k_ra8_board_sw_pressed
RA8 board sw pressed.
@ 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.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
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_err_out_of_range
Sensor or peripheral output out of valid range.
@ 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.
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.
@ k_ra8_gfx_format_rgb888
24-bit packed R,G,B bytes.
ra8_err_t ra8_gfx_reset_clip(void)
Reset the clip rectangle to the whole framebuffer.
ra8_err_t ra8_gfx_blit(const void *src_buf, uint16_t src_w, uint16_t src_h, ra8_gfx_format_t src_format, int32_t dst_x, int32_t dst_y)
Copy a sub-image from src_buf into the framebuffer at (dst_x,dst_y).
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.
ra8_io I2C-bus facade – one controller-transfer vtable over thechip's two I2C implementations.
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_ra8_board_fb_align_bytes
GLCDC AXI burst alignment, in bytes.
@ k_panel_height_px
Native height (pixels).
@ k_panel_width_px
Native width (pixels).
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.
Append-only memory store: the simplest atlas backing (RAM/SDRAM).
One-shot configuration handed to longstrip_open.
Per-frame render accounting returned by longstrip_render.
uint16_t skipped
Visible bands that failed to composite.
Opened longstrip-strip scroll state (caller-owned; treat as private).
Geometry the procedural band painter needs (tile-cache decode ctx).
uint8_t bpp
Bytes per pixel (3 = RGB888).
uint32_t canvas_h
Total strip height, pixels.
uint32_t width
Strip / band width, pixels.
uint16_t band_h
Nominal band height, pixels.
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.
uint16_t tile_y
Tile row index (in tile units).
One decoded touch contact.
uint16_t y
Panel Y coordinate.