69typedef enum : uint16_t {
78typedef enum : uint16_t {
95typedef enum : uint32_t {
108typedef enum : uint32_t {
129typedef enum : uint8_t {
140typedef enum : uint8_t {
149typedef enum : uint8_t {
157typedef enum : uint32_t {
353static void cm_print(
const uint8_t* msg, uint32_t len)
380 buf[n] = (uint8_t)(
'0' + (value % (uint32_t)
k_cm_dec_ten));
384 for (uint32_t i = 0U; i < n; i++) {
403static uint32_t
cm_utoa(uint32_t value,
char* buf, uint32_t cap)
412 tmp[n] = (char)(
'0' + (value % (uint32_t)
k_cm_dec_ten));
417 while ((n > 0U) && (o < (cap - 1U))) {
439static void cm_append(
char* dst, uint32_t cap, uint32_t* cursor,
const char* src)
441 uint32_t o = *cursor;
442 for (uint32_t j = 0U; (src[j] !=
'\0') && (o < (cap - 1U)); j++) {
456 for (
size_t i = 0U; i < nby; i++) {
480 __asm__
volatile(
"wfi");
495 uint32_t cpuclk0_hz = 0U;
586static size_t cm_read(
void* ctx, uint64_t off,
void* buf,
size_t len)
589 if (off >= (uint64_t)s->
n) {
592 const uint64_t avail = (uint64_t)s->
n - off;
593 const size_t k = (len > (size_t)avail) ? (
size_t)avail : len;
594 (void)
memcpy(buf, &s->
d[off], k);
694 cm_append(pos, (uint32_t)
sizeof(pos), &cur, num);
697 cm_append(pos, (uint32_t)
sizeof(pos), &cur, num);
709 batt[bl + 1U] =
'\0';
744 const int32_t fw = (int32_t)(((int64_t)tw * (int64_t)(
s_page + 1U)) / (int64_t)
s_page_count);
799 if (x >= (2 * third)) {
862 const bool touching = (got > 0U);
void main(void)
Secure fallback main entry point.
static const char s_page[]
Boot-time self-check that opens an oversized comic page via the JOF tile path and reports a determini...
cm_tiled_result_t cm_comic_tiled_selfcheck(void)
Open the baked oversized page through the tile path and digest it.
Unified demand-paged reader for comic-book archives – CBZ (ZIP) and CBR (RAR).
ra8_err_t comic_page_read(comic_t *c, uint32_t page, uint8_t *buf, size_t cap, size_t *got)
Extract one page's encoded image bytes for the decoder.
ra8_err_t comic_open(comic_t *c, comic_read_fn read, void *ctx, uint64_t size, comic_page_t *pages, uint32_t page_cap, char *names, uint32_t names_cap)
Open a comic archive (CBZ or CBR) and build its sorted page index.
static uint32_t comic_page_count(const comic_t *c)
Number of pages in an open comic.
Baked multi-page CBZ fixture for the viewable ereader_comic demo (generated by scripts/gen/gen_comic_...
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 uint32_t s_src[k_dtc_arm_buf_words]
Source / destination buffers (32-bit aligned by element type).
static const uint8_t k_cm_msg_boot[]
Console boot banner literal (SCI8).
static uint8_t s_img_arena[k_cm_arena_bytes]
Zero-heap bump arena in SDRAM backing the PNG page decode.
static void cm_append(char *dst, uint32_t cap, uint32_t *cursor, const char *src)
Append a NUL-terminated string into a bounded buffer at *cursor.
static void cm_panic_halt(void)
Halt forever with the red board LED on (fatal init error).
static const uint8_t k_cm_msg_tiled[]
Banner oversized-page tile self-check field prefix (SCI8, #344).
static void cm_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
static bool cm_open_comic(void)
Open the baked CBZ once and cache its page count.
static bool cm_draw_page(void)
Decode the current page and aspect-fit it into the content region.
static void cm_poll_touch(void)
Poll the GT911 once and dispatch a tap on a fresh press.
cm_touch_bus_cfg_t
Clocking for the app-owned GT911 I2C bus.
@ k_cm_touch_pclka_hz
IIC_B clock-source rate.
@ k_cm_touch_bus_hz
Fast-mode I2C clock.
cm_layout_t
Chrome-band and pacing metrics (pixels / milliseconds).
@ k_cm_track_h
Progress-track thickness.
@ k_cm_progress_h
Bottom progress band height.
@ k_cm_frame_ms
Input-poll period (ms).
@ k_cm_statusbar_h
Top status-bar band height.
@ k_cm_settle_ms
PLL / SDRAM / panel power-on settle.
@ k_cm_glyph_h
Bundled 8x16 font cell height.
@ k_cm_led_every
Heartbeat-LED toggle sub-cadence.
@ k_cm_track_inset
Progress-track inset from the band edge.
@ k_cm_glyph_w
Bundled 8x16 font cell width.
@ k_cm_text_pad
Text inset inside a band.
cm_fb_dim_t
Panel framebuffer dimensions, sourced from the BSP panel descriptor.
@ k_cm_fb_h
Framebuffer height (pixels).
@ k_cm_fb_w
Framebuffer width (pixels).
static bool s_was_touching
Debounce: true while a contact is held (fire once per press).
cm_touch_cfg_t
GT911 touch-controller wiring on the EK-RA8D2 carrier.
@ k_cm_touch_max_points
One contact = one tap.
static const char k_cm_title[]
Reader title shown in the status bar.
static const uint8_t k_cm_msg_dim[]
Banner dimension separator (SCI8).
static uint32_t cm_framebuffer_hash(void)
FNV-1a-32 over the whole panel framebuffer (deterministic banner).
static cm_zone_t cm_zone_at(int32_t x, int32_t y)
Classify a panel touch into a navigation zone.
static bool s_chrome_on
Whether the status / progress chrome bands are drawn.
cm_zone_div_t
Tap-zone divisors (thirds / halves of the panel).
@ k_cm_thirds
Left / center / right column split.
@ k_cm_halves
Top / bottom split for the center.
static const char k_cm_pos_infix[]
" of " status-bar infix.
static void cm_bringup_clocks(void)
Bring up clocks, MSTP, SysTick, the console, and both board LEDs.
cm_color_t
Reader palette (0x00RRGGBB, packed to RGB565 by ra8_gfx).
@ k_cm_col_bar_fg
Primary band text.
@ k_cm_col_track
Progress-track (unfilled).
@ k_cm_col_bar_bg
Status / progress band fill.
@ k_cm_col_bar_muted
Secondary band text.
@ k_cm_col_fill
Progress-fill (accent).
@ k_cm_col_letterbox
Dark fill behind an aspect-fit page.
static const uint8_t k_cm_msg_page[]
Banner page + crc separator (SCI8).
static uint32_t s_loop_ticks
Free-running main-loop counter (HIL liveness / LED sub-cadence).
static const char k_cm_pos_prefix[]
"Page " status-bar prefix.
static bool cm_handle_tap(int32_t x, int32_t y)
Apply a tap: turn a page or toggle the chrome.
static void cm_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
static void cm_bringup_panel(void)
Bring up SDRAM + the GLCDC panel and bind ra8_gfx to the framebuffer.
static void cm_print_banner(void)
Print the deterministic boot banner (page-1 framebuffer hash).
static void cm_render(void)
Render the whole reader screen: letterbox, page, and optional chrome.
static void cm_draw_status_bar(void)
Draw the top status bar: title, Page N of M, battery percent.
static void cm_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
static void cm_present(void)
Flush the whole panel so the GLCDC scans out the new frame.
static size_t cm_read(void *ctx, uint64_t off, void *buf, size_t len)
Read callback over the resident archive buffer.
static void cm_draw_progress_bar(void)
Draw the bottom progress bar (filled fraction = read position).
static uint32_t s_page_count
Total page count parsed from the archive (>= 1).
cm_zone_t
Tap-zone classification of a panel touch.
@ k_cm_zone_chrome
Center-top -> toggle chrome.
@ k_cm_zone_none
No actionable zone.
@ k_cm_zone_next
Right third -> next page.
@ k_cm_zone_prev
Left third -> previous page.
static const uint8_t k_cm_msg_ok[]
Banner trailer (SCI8).
static const uint8_t k_cm_msg_x[]
Banner width-height separator (SCI8).
static const uint8_t k_cm_msg_colon[]
Banner numeric-field separator (SCI8).
static const display_cfg_t k_cm_display_cfg
Display PAL config – LCD/GLCDC backend over the SDRAM buffer.
static void cm_bringup_touch(void)
Open the GT911 touch controller (best-effort, polled).
static const uint8_t k_cm_msg_pre[]
Deterministic banner prefix (SCI8).
static uint32_t cm_utoa(uint32_t value, char *buf, uint32_t cap)
Format a small unsigned into a caller ASCII buffer, NUL-terminated.
static cm_tiled_result_t s_tiled
Result of the #344 oversized-page tile self-check.
cm_reader_cfg_t
Reader capacities, demo battery level, and hash constants.
@ k_cm_hex_nibbles
Hex digits in a 32-bit value.
@ k_cm_fnv_offset
FNV-1a-32 offset basis.
@ k_cm_nibble_mask
Low-nibble mask.
@ k_cm_page_cap
Comic page-index capacity.
@ k_cm_uart_baud
SCI8 console baud.
@ k_cm_batt_cap
"NN%" scratch size.
@ k_cm_pos_cap
"Page N of M" scratch size.
@ k_cm_nibble_bits
Bits per hex nibble.
@ k_cm_name_cap
Comic name-arena bytes.
@ k_cm_batt_pct
Demo battery percent.
@ k_cm_pagebuf
Encoded page-image scratch.
@ k_cm_dec_ten
Decimal base / digit split.
@ k_cm_arena_bytes
SDRAM PNG-decode scratch.
@ k_cm_fnv_prime
FNV-1a-32 prime.
static const uint8_t k_cm_msg_cerr[]
Console comic-open failure literal (SCI8).
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.
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_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
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.
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.
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".
Zero-heap raster image decode + scale + blit for reflow (#106).
ra8_err_t ra8_img_decode_blit(ra8_img_arena_t *arena, const uint8_t *bytes, size_t len, int32_t dst_x, int32_t dst_y, int32_t box_w, int32_t box_h, int32_t *out_w, int32_t *out_h)
Decode bytes and blit it, scaled to fit, into the bound framebuffer.
static comic_t s_comic
The open comic (large: page-index storage + backend scratch).
static char s_names[k_shc_names_cap]
Caller-owned page-name arena.
static comic_page_t s_pages[k_shc_page_cap]
Caller-owned sorted page index.
static uint8_t s_pagebuf[k_shc_pagebuf_cap]
One page's extracted encoded image (the decoder input).
static const uint32_t k_comic_cbz_len
static const uint8_t k_comic_cbz[]
Baked 576-byte comic fixture.
Resident-buffer backing for the reader's seek+read callback.
const uint8_t * d
Archive bytes.
Outcome of the oversized-page tile self-check.
One entry in the resident, sorted page index.
One open comic archive: backing, kind, page index, and backend state.
Configuration descriptor passed into display_init.
Framebuffer descriptor returned by display_get_framebuffer.
The two touch settings that are an APPLICATION choice, not a board fact.
Caller-owned bump arena backing a single image decode.
One decoded touch contact.
uint16_t x
Panel X coordinate.
uint16_t y
Panel Y coordinate.