ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
39
40#include <stddef.h>
41#include <stdint.h>
42#include <string.h>
43
44#include "cm_tiled_check.h"
45#include "comic.h"
46#include "comic_pages_fixture.h"
47#include "ra8_board_ek_ra8d2.h"
49#include "ra8_boot_entry.h"
50#include "ra8_cgc.h"
51#include "ra8_display_pal.h"
52#include "ra8_display_pal_lcd.h"
53#include "ra8_err.h"
54#include "ra8_gfx.h"
55#include "ra8_gfx_font.h"
56#include "ra8_isr.h"
57#include "ra8_mstp.h"
58#include "ra8_panel.h"
59#include "ra8_panel_timing.h"
60#include "ra8_sdramc.h"
61#include "ra8_time.h"
62#include "ra8_touch.h"
63#include "reflow_image.h"
64
73
90
95typedef enum : uint32_t {
96 k_cm_col_letterbox = 0x0C0C10U,
97 k_cm_col_bar_bg = 0x1C1C24U,
98 k_cm_col_bar_fg = 0xF0F0F0U,
99 k_cm_col_bar_muted = 0x9098A8U,
100 k_cm_col_track = 0x39414FU,
101 k_cm_col_fill = 0x4C8BF5U,
102} cm_color_t;
103
108typedef enum : uint32_t {
109 k_cm_uart_baud = 115200U,
110 k_cm_arena_bytes = 2U * 1024U * 1024U,
113 k_cm_pagebuf = 64U * 1024U,
115 k_cm_fnv_offset = 2166136261U,
116 k_cm_fnv_prime = 16777619U,
124
129typedef enum : uint8_t {
134} cm_zone_t;
135
140typedef enum : uint8_t {
144
149typedef enum : uint8_t {
152
157typedef enum : uint32_t {
161
171
180[[gnu::section(".sdram_data")]] static uint8_t s_img_arena[k_cm_arena_bytes];
181
190[[gnu::section(".sdram_data")]] static uint8_t s_pagebuf[k_cm_pagebuf];
191
201
211
221
230static display_handle_t* s_display = nullptr;
231
241
250static uint32_t s_page = 0U;
251
260static uint32_t s_page_count = 1U;
261
270static bool s_chrome_on = true;
271
280static bool s_was_touching = false;
281
290static uint32_t s_loop_ticks = 0U;
291
293static const char k_cm_title[] = "COMIC READER";
295static const char k_cm_pos_prefix[] = "Page ";
297static const char k_cm_pos_infix[] = " of ";
298
300static const uint8_t k_cm_msg_boot[] = "ereader-comic: boot\r\n";
302static const uint8_t k_cm_msg_cerr[] = "ereader-comic: FAIL comic\r\n";
304static const uint8_t k_cm_msg_pre[] = "ereader-comic: pages=";
306static const uint8_t k_cm_msg_dim[] = " ";
308static const uint8_t k_cm_msg_x[] = "x";
310static const uint8_t k_cm_msg_page[] = " page=1 crc=";
312static const uint8_t k_cm_msg_tiled[] = " tiled=";
314static const uint8_t k_cm_msg_colon[] = ":";
316static const uint8_t k_cm_msg_ok[] = " ok\r\n";
317
322typedef struct {
323 const uint8_t* d;
324 size_t n;
325} cm_src_t;
326
336
347
348/* ===========================================================================
349 * Console helpers
350 * =========================================================================== */
351
353static void cm_print(const uint8_t* msg, uint32_t len)
354{
355 (void)ra8_board_uart_console_write(msg, (size_t)len);
356}
357
359static void cm_print_hex(uint32_t value)
360{
361 uint8_t buf[k_cm_hex_nibbles];
362 for (uint32_t i = 0U; i < (uint32_t)k_cm_hex_nibbles; i++) {
363 const uint32_t shift = ((uint32_t)k_cm_hex_nibbles - 1U - i) * (uint32_t)k_cm_nibble_bits;
364 const uint32_t nib = (value >> shift) & (uint32_t)k_cm_nibble_mask;
365 buf[i] = (uint8_t)((nib < (uint32_t)k_cm_dec_ten) ? ('0' + nib) : ('A' + (nib - k_cm_dec_ten)));
366 }
367 cm_print(buf, (uint32_t)k_cm_hex_nibbles);
368}
369
371static void cm_print_uint(uint32_t value)
372{
373 uint8_t buf[k_cm_dec_ten];
374 uint32_t n = 0U;
375 if (value == 0U) {
376 buf[n] = '0';
377 n++;
378 }
379 while ((value > 0U) && (n < (uint32_t)k_cm_dec_ten)) {
380 buf[n] = (uint8_t)('0' + (value % (uint32_t)k_cm_dec_ten));
381 n++;
382 value /= (uint32_t)k_cm_dec_ten;
383 }
384 for (uint32_t i = 0U; i < n; i++) {
385 cm_print(&buf[n - 1U - i], 1U);
386 }
387}
388
403static uint32_t cm_utoa(uint32_t value, char* buf, uint32_t cap)
404{
405 char tmp[k_cm_dec_ten];
406 uint32_t n = 0U;
407 if (value == 0U) {
408 tmp[n] = '0';
409 n++;
410 }
411 while ((value > 0U) && (n < (uint32_t)k_cm_dec_ten)) {
412 tmp[n] = (char)('0' + (value % (uint32_t)k_cm_dec_ten));
413 n++;
414 value /= (uint32_t)k_cm_dec_ten;
415 }
416 uint32_t o = 0U;
417 while ((n > 0U) && (o < (cap - 1U))) {
418 n--;
419 buf[o] = tmp[n];
420 o++;
421 }
422 buf[o] = '\0';
423 return o;
424}
425
439static void cm_append(char* dst, uint32_t cap, uint32_t* cursor, const char* src)
440{
441 uint32_t o = *cursor;
442 for (uint32_t j = 0U; (src[j] != '\0') && (o < (cap - 1U)); j++) {
443 dst[o] = src[j];
444 o++;
445 }
446 dst[o] = '\0';
447 *cursor = o;
448}
449
451static uint32_t cm_framebuffer_hash(void)
452{
453 const uint8_t* p = (const uint8_t*)s_framebuffer;
454 const size_t nby = sizeof(s_framebuffer);
455 uint32_t hsh = (uint32_t)k_cm_fnv_offset;
456 for (size_t i = 0U; i < nby; i++) {
457 hsh = (hsh ^ (uint32_t)p[i]) * (uint32_t)k_cm_fnv_prime;
458 }
459 return hsh;
460}
461
462/* ===========================================================================
463 * Boot
464 * =========================================================================== */
465
476[[noreturn]] static void cm_panic_halt(void)
477{
479 while (1) {
480 __asm__ volatile("wfi");
481 }
482}
483
493static void cm_bringup_clocks(void)
494{
495 uint32_t cpuclk0_hz = 0U;
496 if ((ra8_cgc_init() != k_ra8_ok) || (ra8_mstp_init() != k_ra8_ok)) {
498 }
501 }
502 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
504 }
507 }
511 }
513}
514
525 .framebuffer = s_framebuffer,
526 .framebuffer_bytes = sizeof(s_framebuffer),
527 .width_px = (uint16_t)k_cm_fb_w,
528 .height_px = (uint16_t)k_cm_fb_h,
529 .pixfmt = k_display_pixfmt_rgb565,
530 .panel_timing = &s_ra8_panel_ek_ra8d2_timing,
531};
532
542static void cm_bringup_panel(void)
543{
544 ra8_delay_ms((uint32_t)k_cm_settle_ms);
545 if (ra8_sdramc_init() != k_ra8_ok) {
547 }
550 }
553 }
554 if (ra8_gfx_init(s_fb.pixels, s_fb.width_px, s_fb.height_px, k_ra8_gfx_format_rgb565) !=
555 k_ra8_ok) {
557 }
558}
559
572static void cm_bringup_touch(void)
573{
574 const ra8_board_touch_cfg_t cfg = {
575 .max_points = (uint8_t)k_cm_touch_max_points,
576 .irq_pin = (uint8_t)k_ra8_touch_irq_pin_unset,
577 };
578 (void)ra8_board_touch_open(&cfg);
579}
580
581/* ===========================================================================
582 * Comic reader
583 * =========================================================================== */
584
586static size_t cm_read(void* ctx, uint64_t off, void* buf, size_t len)
587{
588 const cm_src_t* s = (const cm_src_t*)ctx;
589 if (off >= (uint64_t)s->n) {
590 return 0U;
591 }
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);
595 return k;
596}
597
610static bool cm_open_comic(void)
611{
612 s_src.d = k_comic_cbz;
613 s_src.n = (size_t)k_comic_cbz_len;
614 if (comic_open(&s_comic,
615 cm_read,
616 &s_src,
617 (uint64_t)k_comic_cbz_len,
618 s_pages,
619 (uint32_t)k_cm_page_cap,
620 s_names,
621 (uint32_t)sizeof(s_names)) != k_ra8_ok) {
622 return false;
623 }
625 return (s_page_count >= 1U);
626}
627
628/* ===========================================================================
629 * Rendering
630 * =========================================================================== */
631
644static bool cm_draw_page(void)
645{
646 size_t got = 0U;
647 if (comic_page_read(&s_comic, s_page, s_pagebuf, sizeof(s_pagebuf), &got) != k_ra8_ok) {
648 return false;
649 }
650 ra8_img_arena_t arena = {.base = s_img_arena, .cap = (size_t)k_cm_arena_bytes};
651 const int32_t box_y = (int32_t)k_cm_statusbar_h;
652 const int32_t box_h = (int32_t)k_cm_fb_h - (int32_t)k_cm_statusbar_h - (int32_t)k_cm_progress_h;
653 return (ra8_img_decode_blit(&arena,
654 s_pagebuf,
655 got,
656 0,
657 box_y,
658 (int32_t)k_cm_fb_w,
659 box_h,
660 nullptr,
661 nullptr) == k_ra8_ok);
662}
663
673static void cm_draw_status_bar(void)
674{
675 (void)ra8_gfx_rect(0,
676 0,
677 (int32_t)k_cm_fb_w,
678 (int32_t)k_cm_statusbar_h,
679 (uint32_t)k_cm_col_bar_bg,
680 true);
681 const int32_t ty = ((int32_t)k_cm_statusbar_h - (int32_t)k_cm_glyph_h) / 2;
682 (void)ra8_gfx_text_out((int32_t)k_cm_text_pad,
683 ty,
686 (uint32_t)k_cm_col_bar_fg,
687 (uint32_t)k_cm_col_bar_bg);
688
689 char pos[k_cm_pos_cap];
690 char num[k_cm_dec_ten];
691 uint32_t cur = 0U;
692 (void)cm_utoa(s_page + 1U, num, (uint32_t)sizeof(num));
693 cm_append(pos, (uint32_t)sizeof(pos), &cur, k_cm_pos_prefix);
694 cm_append(pos, (uint32_t)sizeof(pos), &cur, num);
695 cm_append(pos, (uint32_t)sizeof(pos), &cur, k_cm_pos_infix);
696 (void)cm_utoa(s_page_count, num, (uint32_t)sizeof(num));
697 cm_append(pos, (uint32_t)sizeof(pos), &cur, num);
698 const int32_t pos_x = ((int32_t)k_cm_fb_w / 2) - (((int32_t)cur * (int32_t)k_cm_glyph_w) / 2);
699 (void)ra8_gfx_text_out(pos_x,
700 ty,
701 pos,
703 (uint32_t)k_cm_col_bar_fg,
704 (uint32_t)k_cm_col_bar_bg);
705
706 char batt[k_cm_batt_cap];
707 uint32_t bl = cm_utoa((uint32_t)k_cm_batt_pct, batt, (uint32_t)sizeof(batt));
708 batt[bl] = '%';
709 batt[bl + 1U] = '\0';
710 bl++;
711 const int32_t bx =
712 (int32_t)k_cm_fb_w - (int32_t)k_cm_text_pad - ((int32_t)bl * (int32_t)k_cm_glyph_w);
713 (void)ra8_gfx_text_out(bx,
714 ty,
715 batt,
717 (uint32_t)k_cm_col_bar_muted,
718 (uint32_t)k_cm_col_bar_bg);
719}
720
730static void cm_draw_progress_bar(void)
731{
732 const int32_t band_y = (int32_t)k_cm_fb_h - (int32_t)k_cm_progress_h;
733 (void)ra8_gfx_rect(0,
734 band_y,
735 (int32_t)k_cm_fb_w,
736 (int32_t)k_cm_progress_h,
737 (uint32_t)k_cm_col_bar_bg,
738 true);
739 const int32_t tx = (int32_t)k_cm_track_inset;
740 const int32_t tw = (int32_t)k_cm_fb_w - (2 * (int32_t)k_cm_track_inset);
741 const int32_t th = (int32_t)k_cm_track_h;
742 const int32_t ty = band_y + (((int32_t)k_cm_progress_h - th) / 2);
743 (void)ra8_gfx_rect(tx, ty, tw, th, (uint32_t)k_cm_col_track, true);
744 const int32_t fw = (int32_t)(((int64_t)tw * (int64_t)(s_page + 1U)) / (int64_t)s_page_count);
745 (void)ra8_gfx_rect(tx, ty, fw, th, (uint32_t)k_cm_col_fill, true);
746}
747
757static void cm_render(void)
758{
759 (void)ra8_gfx_clear((uint32_t)k_cm_col_letterbox);
760 (void)cm_draw_page();
761 if (s_chrome_on) {
764 }
765}
766
772
773/* ===========================================================================
774 * Tap-zone navigation
775 * =========================================================================== */
776
793static cm_zone_t cm_zone_at(int32_t x, int32_t y)
794{
795 const int32_t third = (int32_t)k_cm_fb_w / (int32_t)k_cm_thirds;
796 if (x < third) {
797 return k_cm_zone_prev;
798 }
799 if (x >= (2 * third)) {
800 return k_cm_zone_next;
801 }
802 if (y < ((int32_t)k_cm_fb_h / (int32_t)k_cm_halves)) {
803 return k_cm_zone_chrome;
804 }
805 return k_cm_zone_none;
806}
807
822static bool cm_handle_tap(int32_t x, int32_t y)
823{
824 switch (cm_zone_at(x, y)) {
825 case k_cm_zone_next:
826 if ((s_page + 1U) < s_page_count) {
827 s_page++;
828 return true;
829 }
830 return false;
831 case k_cm_zone_prev:
832 if (s_page > 0U) {
833 s_page--;
834 return true;
835 }
836 return false;
837 case k_cm_zone_chrome:
839 return true;
840 case k_cm_zone_none:
841 default:
842 return false;
843 }
844}
845
855static void cm_poll_touch(void)
856{
857 ra8_touch_point_t pt = {};
858 uint8_t got = 0U;
859 if (ra8_touch_read(&pt, (uint8_t)k_cm_touch_max_points, &got) != k_ra8_ok) {
860 return;
861 }
862 const bool touching = (got > 0U);
863 if (touching && !s_was_touching) {
864 if (cm_handle_tap((int32_t)pt.x, (int32_t)pt.y)) {
865 cm_render();
866 cm_present();
867 }
868 }
869 s_was_touching = touching;
870}
871
881static void cm_print_banner(void)
882{
883 cm_print(k_cm_msg_pre, (uint32_t)sizeof(k_cm_msg_pre) - 1U);
885 cm_print(k_cm_msg_dim, (uint32_t)sizeof(k_cm_msg_dim) - 1U);
886 cm_print_uint((uint32_t)k_cm_fb_w);
887 cm_print(k_cm_msg_x, (uint32_t)sizeof(k_cm_msg_x) - 1U);
888 cm_print_uint((uint32_t)k_cm_fb_h);
889 cm_print(k_cm_msg_page, (uint32_t)sizeof(k_cm_msg_page) - 1U);
891 cm_print(k_cm_msg_tiled, (uint32_t)sizeof(k_cm_msg_tiled) - 1U);
893 cm_print(k_cm_msg_x, (uint32_t)sizeof(k_cm_msg_x) - 1U);
895 cm_print(k_cm_msg_colon, (uint32_t)sizeof(k_cm_msg_colon) - 1U);
896 cm_print_uint(s_tiled.tiles);
897 cm_print(k_cm_msg_colon, (uint32_t)sizeof(k_cm_msg_colon) - 1U);
899 cm_print(k_cm_msg_ok, (uint32_t)sizeof(k_cm_msg_ok) - 1U);
900}
901
910void main(void)
911{
913 cm_print(k_cm_msg_boot, (uint32_t)sizeof(k_cm_msg_boot) - 1U);
916
917 if (!cm_open_comic()) {
918 cm_print(k_cm_msg_cerr, (uint32_t)sizeof(k_cm_msg_cerr) - 1U);
920 }
921
922 cm_render();
923 cm_present();
926
927 while (1) {
929 if ((s_loop_ticks % (uint32_t)k_cm_led_every) == 0U) {
931 }
932 s_loop_ticks++;
933 ra8_delay_ms((uint32_t)k_cm_frame_ms);
934 }
935}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static const char s_page[]
Definition c6_cam_net.c:42
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.
Definition comic.c:472
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.
Definition comic.c:390
static uint32_t comic_page_count(const comic_t *c)
Number of pages in an open comic.
Definition comic.h:263
Baked multi-page CBZ fixture for the viewable ereader_comic demo (generated by scripts/gen/gen_comic_...
static display_handle_t * s_display
Definition main.c:78
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).
Definition main.c:67
static uint32_t s_src[k_dtc_arm_buf_words]
Source / destination buffers (32-bit aligned by element type).
Definition main.c:181
static display_fb_t s_fb
Definition main.c:203
static const uint8_t k_cm_msg_boot[]
Console boot banner literal (SCI8).
Definition main.c:300
static uint8_t s_img_arena[k_cm_arena_bytes]
Zero-heap bump arena in SDRAM backing the PNG page decode.
Definition main.c:180
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.
Definition main.c:439
static void cm_panic_halt(void)
Halt forever with the red board LED on (fatal init error).
Definition main.c:476
static const uint8_t k_cm_msg_tiled[]
Banner oversized-page tile self-check field prefix (SCI8, #344).
Definition main.c:312
static void cm_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
Definition main.c:371
static bool cm_open_comic(void)
Open the baked CBZ once and cache its page count.
Definition main.c:610
static bool cm_draw_page(void)
Decode the current page and aspect-fit it into the content region.
Definition main.c:644
static void cm_poll_touch(void)
Poll the GT911 once and dispatch a tap on a fresh press.
Definition main.c:855
cm_touch_bus_cfg_t
Clocking for the app-owned GT911 I2C bus.
Definition main.c:157
@ k_cm_touch_pclka_hz
IIC_B clock-source rate.
Definition main.c:159
@ k_cm_touch_bus_hz
Fast-mode I2C clock.
Definition main.c:158
cm_layout_t
Chrome-band and pacing metrics (pixels / milliseconds).
Definition main.c:78
@ k_cm_track_h
Progress-track thickness.
Definition main.c:88
@ k_cm_progress_h
Bottom progress band height.
Definition main.c:83
@ k_cm_frame_ms
Input-poll period (ms).
Definition main.c:80
@ k_cm_statusbar_h
Top status-bar band height.
Definition main.c:82
@ k_cm_settle_ms
PLL / SDRAM / panel power-on settle.
Definition main.c:79
@ k_cm_glyph_h
Bundled 8x16 font cell height.
Definition main.c:85
@ k_cm_led_every
Heartbeat-LED toggle sub-cadence.
Definition main.c:81
@ k_cm_track_inset
Progress-track inset from the band edge.
Definition main.c:87
@ k_cm_glyph_w
Bundled 8x16 font cell width.
Definition main.c:86
@ k_cm_text_pad
Text inset inside a band.
Definition main.c:84
cm_fb_dim_t
Panel framebuffer dimensions, sourced from the BSP panel descriptor.
Definition main.c:69
@ k_cm_fb_h
Framebuffer height (pixels).
Definition main.c:71
@ k_cm_fb_w
Framebuffer width (pixels).
Definition main.c:70
static bool s_was_touching
Debounce: true while a contact is held (fire once per press).
Definition main.c:280
cm_touch_cfg_t
GT911 touch-controller wiring on the EK-RA8D2 carrier.
Definition main.c:149
@ k_cm_touch_max_points
One contact = one tap.
Definition main.c:150
static const char k_cm_title[]
Reader title shown in the status bar.
Definition main.c:293
static const uint8_t k_cm_msg_dim[]
Banner dimension separator (SCI8).
Definition main.c:306
static uint32_t cm_framebuffer_hash(void)
FNV-1a-32 over the whole panel framebuffer (deterministic banner).
Definition main.c:451
static cm_zone_t cm_zone_at(int32_t x, int32_t y)
Classify a panel touch into a navigation zone.
Definition main.c:793
static bool s_chrome_on
Whether the status / progress chrome bands are drawn.
Definition main.c:270
cm_zone_div_t
Tap-zone divisors (thirds / halves of the panel).
Definition main.c:140
@ k_cm_thirds
Left / center / right column split.
Definition main.c:141
@ k_cm_halves
Top / bottom split for the center.
Definition main.c:142
static const char k_cm_pos_infix[]
" of " status-bar infix.
Definition main.c:297
static void cm_bringup_clocks(void)
Bring up clocks, MSTP, SysTick, the console, and both board LEDs.
Definition main.c:493
cm_color_t
Reader palette (0x00RRGGBB, packed to RGB565 by ra8_gfx).
Definition main.c:95
@ k_cm_col_bar_fg
Primary band text.
Definition main.c:98
@ k_cm_col_track
Progress-track (unfilled).
Definition main.c:100
@ k_cm_col_bar_bg
Status / progress band fill.
Definition main.c:97
@ k_cm_col_bar_muted
Secondary band text.
Definition main.c:99
@ k_cm_col_fill
Progress-fill (accent).
Definition main.c:101
@ k_cm_col_letterbox
Dark fill behind an aspect-fit page.
Definition main.c:96
static const uint8_t k_cm_msg_page[]
Banner page + crc separator (SCI8).
Definition main.c:310
static uint32_t s_loop_ticks
Free-running main-loop counter (HIL liveness / LED sub-cadence).
Definition main.c:290
static const char k_cm_pos_prefix[]
"Page " status-bar prefix.
Definition main.c:295
static bool cm_handle_tap(int32_t x, int32_t y)
Apply a tap: turn a page or toggle the chrome.
Definition main.c:822
static void cm_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
Definition main.c:359
static void cm_bringup_panel(void)
Bring up SDRAM + the GLCDC panel and bind ra8_gfx to the framebuffer.
Definition main.c:542
static void cm_print_banner(void)
Print the deterministic boot banner (page-1 framebuffer hash).
Definition main.c:881
static void cm_render(void)
Render the whole reader screen: letterbox, page, and optional chrome.
Definition main.c:757
static void cm_draw_status_bar(void)
Draw the top status bar: title, Page N of M, battery percent.
Definition main.c:673
static void cm_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
Definition main.c:353
static void cm_present(void)
Flush the whole panel so the GLCDC scans out the new frame.
Definition main.c:768
static size_t cm_read(void *ctx, uint64_t off, void *buf, size_t len)
Read callback over the resident archive buffer.
Definition main.c:586
static void cm_draw_progress_bar(void)
Draw the bottom progress bar (filled fraction = read position).
Definition main.c:730
static uint32_t s_page_count
Total page count parsed from the archive (>= 1).
Definition main.c:260
cm_zone_t
Tap-zone classification of a panel touch.
Definition main.c:129
@ k_cm_zone_chrome
Center-top -> toggle chrome.
Definition main.c:133
@ k_cm_zone_none
No actionable zone.
Definition main.c:130
@ k_cm_zone_next
Right third -> next page.
Definition main.c:132
@ k_cm_zone_prev
Left third -> previous page.
Definition main.c:131
static const uint8_t k_cm_msg_ok[]
Banner trailer (SCI8).
Definition main.c:316
static const uint8_t k_cm_msg_x[]
Banner width-height separator (SCI8).
Definition main.c:308
static const uint8_t k_cm_msg_colon[]
Banner numeric-field separator (SCI8).
Definition main.c:314
static const display_cfg_t k_cm_display_cfg
Display PAL config – LCD/GLCDC backend over the SDRAM buffer.
Definition main.c:523
static void cm_bringup_touch(void)
Open the GT911 touch controller (best-effort, polled).
Definition main.c:572
static const uint8_t k_cm_msg_pre[]
Deterministic banner prefix (SCI8).
Definition main.c:304
static uint32_t cm_utoa(uint32_t value, char *buf, uint32_t cap)
Format a small unsigned into a caller ASCII buffer, NUL-terminated.
Definition main.c:403
static cm_tiled_result_t s_tiled
Result of the #344 oversized-page tile self-check.
Definition main.c:346
cm_reader_cfg_t
Reader capacities, demo battery level, and hash constants.
Definition main.c:108
@ k_cm_hex_nibbles
Hex digits in a 32-bit value.
Definition main.c:117
@ k_cm_fnv_offset
FNV-1a-32 offset basis.
Definition main.c:115
@ k_cm_nibble_mask
Low-nibble mask.
Definition main.c:119
@ k_cm_page_cap
Comic page-index capacity.
Definition main.c:111
@ k_cm_uart_baud
SCI8 console baud.
Definition main.c:109
@ k_cm_batt_cap
"NN%" scratch size.
Definition main.c:122
@ k_cm_pos_cap
"Page N of M" scratch size.
Definition main.c:121
@ k_cm_nibble_bits
Bits per hex nibble.
Definition main.c:118
@ k_cm_name_cap
Comic name-arena bytes.
Definition main.c:112
@ k_cm_batt_pct
Demo battery percent.
Definition main.c:114
@ k_cm_pagebuf
Encoded page-image scratch.
Definition main.c:113
@ k_cm_dec_ten
Decimal base / digit split.
Definition main.c:120
@ k_cm_arena_bytes
SDRAM PNG-decode scratch.
Definition main.c:110
@ k_cm_fnv_prime
FNV-1a-32 prime.
Definition main.c:116
static const uint8_t k_cm_msg_cerr[]
Console comic-open failure literal (SCI8).
Definition main.c:302
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.
Definition ra8_cgc.c:132
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
Definition ra8_cgc.h:70
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
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.
Definition ra8_err.h:119
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.
Definition ra8_gfx.h:40
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).
Definition ra8_isr.c:439
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.
Definition ra8_mstp.c:291
Active display-panel descriptor for the EK-RA8D2 (ER-TFT070-6).
@ k_panel_height_px
Native height (pixels).
Definition ra8_panel.h:52
@ k_panel_width_px
Native width (pixels).
Definition ra8_panel.h:51
#define RA8_BOARD_PANEL_FRAMEBUFFER(name)
Declare a correctly aligned, sized and placed RGB565 framebuffer for the on-board panel.
Definition ra8_panel.h:165
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.
Definition ra8_sdramc.c:257
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.
Definition ra8_time.c:59
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Definition ra8_time.c:129
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.
Definition ra8_touch.c:551
@ k_ra8_touch_irq_pin_unset
Sentinel for "no IRQ pin attached".
Definition ra8_touch.h:72
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).
Definition sh_comic.c:82
static char s_names[k_shc_names_cap]
Caller-owned page-name arena.
Definition sh_comic.c:86
static comic_page_t s_pages[k_shc_page_cap]
Caller-owned sorted page index.
Definition sh_comic.c:84
static uint8_t s_pagebuf[k_shc_pagebuf_cap]
One page's extracted encoded image (the decoder input).
Definition sh_comic.c:88
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.
Definition main.c:322
const uint8_t * d
Archive bytes.
Definition main.c:323
size_t n
Archive length.
Definition main.c:324
Outcome of the oversized-page tile self-check.
One entry in the resident, sorted page index.
Definition comic.h:140
One open comic archive: backing, kind, page index, and backend state.
Definition comic.h:179
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.
Definition ra8_touch.h:93
uint16_t x
Panel X coordinate.
Definition ra8_touch.h:94
uint16_t y
Panel Y coordinate.
Definition ra8_touch.h:95