51static const char*
s_tag =
"SDFONT";
66typedef enum : uint32_t {
380 const uint32_t* out_len,
425 if (out_source !=
nullptr) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
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.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_data
No application data available (e.g.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
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_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_unmount(ra8_fs_mount_t *handle)
Unmount a previously mounted volume and release its slot.
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_write_file(ra8_fs_mount_t *handle, const char *path, const uint8_t *data, uint32_t len)
Create a whole file in one call (provisioning helper).
@ k_ra8_fs_mode_read
Read-only, must exist.
PSEL codes for peripheral pin routing on the RA8D2.
@ k_ra8_psel_sci_async
00100b: SCI async serial (UART).
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.
static ra8_err_t internal_validate(const ra8_sdfont_cfg_t *cfg, const uint8_t *buf, const uint32_t *out_len, uint32_t cap)
Validate the public load arguments (precondition gate).
static sdfont_ctx_t s_ctx
Single-shot transport context for the SD bus shim.
static ra8_err_t internal_mount(ra8_fs_mount_t **out_mount)
Run SD identification and mount the FAT volume.
static ra8_err_t internal_read_font(ra8_fs_file_t *file, uint8_t *buf, uint32_t cap, uint32_t *out_len)
Read an open font into the caller buffer and validate its length.
static ra8_err_t internal_cs(void *ctx, bool asserted)
Transport chip-select callback: drive CS low (asserted) or high.
static ra8_err_t internal_bringup_spi(const ra8_sdfont_cfg_t *cfg)
Route the Pmod SPI pins to SCI Simple-SPI and init the channel.
ra8_err_t ra8_sdfont_load(const ra8_sdfont_cfg_t *cfg, uint8_t *buf, uint32_t cap, uint32_t *out_len, ra8_sdfont_source_t *out_source)
Mount the Pmod SD card and load a font, provisioning it if absent.
static const char * s_default_name
Default 8.3 font filename used when the caller passes NULL.
static ra8_err_t internal_open_or_provision(const ra8_sdfont_cfg_t *cfg, ra8_fs_mount_t *mount, const char *name, ra8_fs_file_t **out_file, ra8_sdfont_source_t *out_source)
Open the font for reading, provisioning from the blob if absent.
static ra8_err_t internal_xfer(void *ctx, const uint8_t *tx, uint8_t *rx, uint32_t len)
Transport transfer callback: full-duplex byte exchange.
static ra8_err_t internal_set_clock(void *ctx, uint32_t hz)
Transport set-clock callback: retune the SCI baud divider.
sdfont_limits_t
Sanity floors for a loaded font.
@ k_sdfont_min_bytes
Smallest plausible TTF/OTF header – guards a truncated read.
Load a TTF/OTF font off a Pmod SD card, self-provisioning if absent.
ra8_sdfont_source_t
Provenance of the font bytes returned by ra8_sdfont_load.
@ k_ra8_sdfont_source_card
File already on the card; read as-is.
@ k_ra8_sdfont_source_provisioned
File was absent; written from the blob, then read back from the card.
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.
Block-device interface that ra8_fs runs on top of.
Cached parse of one mounted FAT volume.
Configuration descriptor for ra8_sci_spi_init.
SD-card font-store bus description + provisioning policy.
ra8_port_pin_t copi
Controller-Out / Peripheral-In pin.
uint32_t provision_len
Length of provision_blob in bytes.
ra8_port_pin_t sck
SPI clock pin.
ra8_port_pin_t cipo
Controller-In / Peripheral-Out pin.
uint8_t spi_channel
SCI channel in Simple-SPI mode (Pmod2 = SCI0 = 0).
ra8_port_pin_t cs
Chip-select pin, driven as a GPIO output.
const char * filename
8.3 file to load; NULL selects "FONT.OTF".
const uint8_t * provision_blob
Fallback font written if the file is absent; NULL disables provisioning (read-only load).
uint32_t pclka_hz
PCLKA rate (Hz) feeding the SCI baud divider.
Driver-to-bus binding (Dependency Inversion seam).
Bus context handed to the ra8_sdmmc_spi transport callbacks.
ra8_port_pin_t cs
Chip-select GPIO pin.
uint32_t pclka_hz
PCLKA rate for the baud shim.
uint8_t channel
SCI Simple-SPI channel.