42typedef enum : uint32_t {
63 const uint32_t pclka_hz = *(
const uint32_t*)ctx;
126 if (((attr & skip) != 0U) || (size > (uint64_t)UINT32_MAX) || !
sh_book_classify(name, &fmt) ||
156 if ((name ==
nullptr) || (out_len ==
nullptr)) {
168 if ((size == 0U) || (size > (uint64_t)UINT32_MAX)) {
172 *out_len = (uint32_t)size;
183 if (offset > (uint64_t)UINT32_MAX) {
206 if ((buf ==
nullptr) || (
s_book ==
nullptr)) {
209 if (offset > (uint64_t)UINT32_MAX) {
212 const uint32_t want = (len > (size_t)UINT32_MAX) ? UINT32_MAX : (uint32_t)len;
238 if (name ==
nullptr) {
246 if (book ==
nullptr) {
static uint32_t s_pclka_hz
EPUB (.epub) reader and chapter iterator for ra8-firmware.
ra8_fs -> epub bridge: open a .epub straight off a filesystem.
ra8_err_t epub_open_streamed_fs(ra8_fs_mount_t *mount, const char *path, epub_stream_fs_ctx_t *io, epub_book_t *out_book)
Stream-open an EPUB directly off a mounted ra8_fs volume, no residency (#151).
ra8_err_t epub_close_streamed_fs(epub_stream_fs_ctx_t *io, epub_book_t *book)
Close a book opened by epub_open_streamed_fs() and its source file.
static epub_book_t s_book
Opened book (large – file-scope, not on the stack).
static ra8_fs_backend_t s_backend
SD backend; file-scope so the mount handle may reference it.
static epub_stream_fs_ctx_t s_epub_io
Streamed-open source-file context; must outlive s_book (#230).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_pmod2_spi_cipo
Pmod2.3 CIPO (CIPO0_B), P602.
@ k_ra8_board_pmod2_spi_cs
Pmod2.1 CS (SS0_B), P604.
@ k_ra8_board_pmod2_spi_copi
Pmod2.2 COPI (COPI0_B), P603.
@ k_ra8_board_pmod2_spi_sck
Pmod2.4 SCK (SCK0_B), P601.
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_pclka
PCLKA.
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.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ 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.
char * strncpy(char *dst, const char *src, size_t n)
Copy bounded string to destination buffer.
size_t strlen(const char *s)
Calculate string length.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
ra8_err_t ra8_fs_listdir(const ra8_fs_mount_t *handle, const char *path, ra8_fs_listdir_cb_t cb, void *ctx)
Enumerate directory entries; invoke cb once per visible entry.
ra8_err_t ra8_fs_mount(const ra8_fs_backend_t *backend, ra8_fs_mount_t **out_handle)
Mount a FAT volume from a block-device backend, auto-selecting the first partition.
ra8_err_t ra8_fs_size(const ra8_fs_file_t *file, uint64_t *out_bytes)
Report the file's size in bytes (64-bit on exFAT, #676).
ra8_err_t ra8_fs_read(ra8_fs_file_t *file, uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Read up to max_len bytes; advance the cluster chain on cluster crossings.
ra8_err_t ra8_fs_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open or create a file by path, 8.3 or long.
ra8_err_t ra8_fs_close(ra8_fs_file_t *file)
Close an open file, stamping its final modification time.
ra8_err_t ra8_fs_seek(ra8_fs_file_t *file, uint64_t offset_bytes)
Move the file offset to offset_bytes (clamped to size).
@ k_ra8_fs_attr_volume_id
MS FAT spec sec 6 "ATTR_VOLUME_ID".
@ k_ra8_fs_attr_directory
MS FAT spec sec 6 "ATTR_DIRECTORY".
@ k_ra8_fs_mode_read
Read-only, must exist.
@ k_ra8_psel_sci_async
00100b: SCI async serial (UART).
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_output_init(ra8_port_pin_t pin, ra8_level_t init_level)
Configure a pin as a digital output and drive it to an initial level.
ra8_err_t ra8_gpio_write(ra8_port_pin_t pin, ra8_level_t level)
Drive a previously-configured output to the given level.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
SCI Simple-SPI controller-mode driver (polling, full-duplex).
ra8_err_t ra8_sci_spi_set_clock(uint8_t channel, uint32_t baud_hz, uint32_t pclk_hz)
Re-program the bit-rate without otherwise reconfiguring.
ra8_err_t ra8_sci_spi_xfer(uint8_t channel, const uint8_t *tx, uint8_t *rx, uint32_t len)
Full-duplex multi-byte transfer.
ra8_err_t ra8_sci_spi_init(uint8_t channel, const ra8_sci_spi_cfg_t *cfg)
Bring an SCI channel up as a Simple-SPI controller.
SD card driver in SPI-mode (PMOD-attached cards).
@ k_ra8_sdmmc_spi_clock_init_hz
Mandatory init clock floor.
ra8_err_t ra8_sdmmc_spi_init(const ra8_sdmmc_spi_transport_t *transport)
Run the SD SPI-mode identification sequence on a card.
ra8_err_t ra8_sdmmc_spi_bind_fs_backend(ra8_fs_backend_t *out_backend)
Populate an ra8_fs_backend_t that mounts onto this SD driver.
SPI_B controller driver (RA8D2 Type-B SPI peripheral).
@ k_ra8_spi_mode_0
CPOL=0, CPHA=0.
Shared contract for the ereader_shelf multi-screen e-reader.
@ k_sh_name_cap
SD file-name buffer bytes (VFAT long).
@ k_sh_max_books
Shelf / thumbnail-cache capacity.
sh_state_t g_sh
The single whole-app state instance (defined in main.c).
sh_book_fmt_t
Book container format behind a shelf entry / the open book.
@ k_sh_fmt_rabook
book RBKC container (demand-paged chunks).
static bool sh_book_classify(const char *name, sh_book_fmt_t *out_fmt)
Classify a root file name into a book format; true if it is a book.
static const ra8_port_pin_t k_sd_pin_copi
static ra8_err_t sh_sd_xfer(void *ctx, const uint8_t *tx, uint8_t *rx, uint32_t len)
ra8_sdmmc_spi_transport_t::xfer over ra8_sci_spi_xfer.
static const ra8_port_pin_t k_sd_pin_cs
bool sh_sd_open_epub(const char *name, void *out_book)
Stream-open SD file name as an EPUB via epub_open_streamed_fs.
static ra8_err_t sh_sd_cs(void *ctx, bool asserted)
ra8_sdmmc_spi_transport_t::cs over ra8_gpio (CS active-low).
static const char * s_sd_tag
Log tag for SD-read diagnostics.
static ra8_err_t sh_sd_set_clock(void *ctx, uint32_t hz)
void sh_sd_scan(void)
Append every root *.RBK file on the card as an SD shelf entry.
bool sh_sd_book_open(const char *name, uint32_t *out_len)
Open SD file name and hold it as the paged book backing.
size_t sh_sd_comic_read(void *ctx, uint64_t offset, void *buf, size_t len)
comic_read_fn over the held-open SD book file (seek + clamped read).
void sh_sd_close_epub(void *book)
Close a streamed EPUB opened by sh_sd_open_epub and its source file.
static ra8_err_t sh_sd_bus_init(void)
Route Pmod2 SPI pins + CS GPIO and init SCI0 SPI at the 400 kHz floor.
static void sh_sd_listdir_cb(const char *name, uint8_t attr, uint64_t size, void *ctx)
ra8_fs_listdir callback: append each root book file as an SD entry.
static const ra8_port_pin_t k_sd_pin_cipo
bool sh_sd_mount(void)
Bring up the Pmod2 microSD over ra8_sdmmc_spi and mount its FAT volume.
static const ra8_port_pin_t k_sd_pin_sck
void sh_sd_book_close(void)
Close the held SD book file (idempotent).
sh_sd_const_t
SD bus constants.
@ k_sd_spi_chan
Pmod2 / J25 SCI0 Simple-SPI channel.
ra8_err_t sh_sd_book_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
ra8_vsource_read_fn over the held-open SD book file (seek + read).
static ra8_fs_mount_t * s_mount
Mounted FAT volume, or NULL.
Backing state for a streamed ra8_fs EPUB open (#151).
Block-device interface that ra8_fs runs on top of.
Cached parse of one mounted FAT volume.
Configuration descriptor for ra8_sci_spi_init.
Driver-to-bus binding (Dependency Inversion seam).
One shelf book, sourced from MRAM (baked) or the SD card, in either the .rabook or ....
bool from_sd
true: read sd_name from SD; false: use blob.
uint32_t blob_len
Baked length, or SD file size in bytes.
char sd_name[k_sh_name_cap]
SD file name, e.g.
sh_book_fmt_t fmt
Container format (rabook / epub).
char title[k_sh_title_cap]
Display title.
char author[k_sh_author_cap]
Display author.