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
41
42#include <stddef.h>
43#include <stdint.h>
44
45#include "epub.h"
46#include "epub_fs.h"
47#include "epub_toc_fixture.h"
48#include "ra8_board_ek_ra8d2.h"
49#include "ra8_boot_entry.h"
50#include "ra8_cgc.h"
51#include "ra8_err.h"
52#include "ra8_isr.h"
53#include "ra8_log.h"
54#include "ra8_port_constants.h"
55#include "ra8_port_utils.h"
56#include "ra8_sci_spi.h"
57#include "ra8_sdmmc_spi.h"
58#include "ra8_spi.h"
59#include "ra8_time.h"
60
62typedef enum : uint32_t {
63 k_etoc_uart_baud = 115200U,
65 k_etoc_crc_init = 0xFFFFFFFFU,
66 k_etoc_crc_poly = 0xEDB88320U,
69 k_etoc_no_chap = 0xFFFFU,
72
85
91
93static const char k_etoc_path_ncx[] = "TOCNCX.EPB";
94static const char k_etoc_path_nav[] = "TOCNAV.EPB";
95static const char k_etoc_path_bad[] = "TOCBAD.EPB";
96
111
113typedef enum : uint32_t {
116
122volatile uint32_t g_etoc_err = (uint32_t)k_etoc_err_none;
123volatile uint32_t g_etoc_ncx_kind = 0U;
124volatile uint32_t g_etoc_ncx_n = 0U;
125volatile uint32_t g_etoc_ncx_e0crc = 0U;
126volatile uint32_t g_etoc_ncx_ch0 = 0U;
127volatile uint32_t g_etoc_nav_kind = 0U;
128volatile uint32_t g_etoc_nav_n = 0U;
129volatile uint32_t g_etoc_nav_e0crc = 0U;
130volatile uint32_t g_etoc_nav_ch0 = 0U;
131volatile uint32_t g_etoc_bad_kind = 0U;
132volatile uint32_t g_etoc_bad_chap = 0U;
134volatile uint32_t g_etoc_heartbeat = 0U;
135
142
143static const uint8_t k_msg_boot[] = "epub-toc-hil: boot\r\n";
144static const uint8_t k_msg_cardok[] = "epub-toc-hil: card ready\r\n";
145static const uint8_t k_msg_finit[] = "toc-hil: FAIL init\r\n";
146static const uint8_t k_msg_fcard[] = "toc-hil: FAIL card\r\n";
147static const uint8_t k_msg_fmount[] = "toc-hil: FAIL mount\r\n";
148static const uint8_t k_msg_fprov[] = "toc-hil: FAIL provision\r\n";
149static const uint8_t k_msg_fncx[] = "toc-hil: FAIL ncx\r\n";
150static const uint8_t k_msg_fnav[] = "toc-hil: FAIL nav\r\n";
151static const uint8_t k_msg_fbad[] = "toc-hil: FAIL bad\r\n";
152static const uint8_t k_msg_ok[] = "toc-hil: ncx+nav+fallback PASS\r\n";
153
155static void etoc_print(const uint8_t* msg, uint32_t len)
156{
157 (void)ra8_board_uart_console_write(msg, (size_t)len);
158}
159
167static void etoc_fail(uint32_t err, const uint8_t* msg, uint32_t len)
168{
169 g_etoc_err = err;
170 etoc_print(msg, len);
171 while (1) {
172 __asm__ volatile("wfi");
173 }
174}
175
177static uint32_t etoc_crc32(const uint8_t* data, size_t len)
178{
179 uint32_t crc = (uint32_t)k_etoc_crc_init;
180 for (size_t i = 0U; i < len; i++) {
181 crc ^= (uint32_t)data[i];
182 for (uint32_t bit = 0U; bit < (uint32_t)k_etoc_crc_bits; bit++) {
183 const uint32_t mask = (uint32_t)(-(int32_t)(crc & 1U));
184 crc = (crc >> 1U) ^ ((uint32_t)k_etoc_crc_poly & mask);
185 }
186 }
187 return ~crc;
188}
189
191static uint32_t etoc_title_crc(const char* title)
192{
193 size_t len = 0U;
194 while ((len < (size_t)k_etoc_title_max) && (title[len] != '\0')) {
195 len++;
196 }
197 return etoc_crc32((const uint8_t*)title, len);
198}
199
200/* ---- SPI -> ra8_sdmmc_spi transport adapter (mirror of epub_open) ---- */
201
202/* cppcheck-suppress constParameterCallback -- bound to ra8_sdmmc_spi_transport_t::set_clock, `ra8_err_t (*)(void*, uint32_t)`; constifying ctx would break the binding. */
203static ra8_err_t etoc_spi_set_clock(void* ctx, uint32_t hz)
204{
205 const uint32_t pclka_hz = *(const uint32_t*)ctx;
206 return ra8_sci_spi_set_clock((uint8_t)k_etoc_spi_chan, hz, pclka_hz);
207}
208
210static ra8_err_t etoc_spi_cs(void* ctx, bool asserted)
211{
212 (void)ctx;
214}
215
217static ra8_err_t etoc_spi_xfer(void* ctx, const uint8_t* tx, uint8_t* rx, uint32_t len)
218{
219 (void)ctx;
220 return ra8_sci_spi_xfer((uint8_t)k_etoc_spi_chan, tx, rx, len);
221}
222
224[[nodiscard]] static ra8_err_t etoc_spi_pins_init(void)
225{
227 if (err != k_ra8_ok) {
228 return err;
229 }
231 if (err != k_ra8_ok) {
232 return err;
233 }
235 if (err != k_ra8_ok) {
236 return err;
237 }
239}
240
242static void etoc_setup_or_halt(uint32_t* out_pclka_hz)
243{
244 uint32_t cpuclk0_hz = 0U;
245 uint32_t pclka_hz = 0U;
246 if ((ra8_cgc_init() != k_ra8_ok) ||
249 (ra8_time_init(cpuclk0_hz) != k_ra8_ok)) {
250 etoc_fail((uint32_t)k_etoc_err_init, k_msg_finit, (uint32_t)sizeof(k_msg_finit) - 1U);
251 }
253 etoc_fail((uint32_t)k_etoc_err_init, k_msg_finit, (uint32_t)sizeof(k_msg_finit) - 1U);
254 }
255 if (etoc_spi_pins_init() != k_ra8_ok) {
256 etoc_fail((uint32_t)k_etoc_err_init, k_msg_finit, (uint32_t)sizeof(k_msg_finit) - 1U);
257 }
258 const ra8_sci_spi_cfg_t spi_cfg = {.baud_hz = (uint32_t)k_ra8_sdmmc_spi_clock_init_hz,
259 .pclk_hz = pclka_hz,
260 .mode = k_ra8_spi_mode_0,
261 .lsb_first = false};
262 if (ra8_sci_spi_init((uint8_t)k_etoc_spi_chan, &spi_cfg) != k_ra8_ok) {
263 etoc_fail((uint32_t)k_etoc_err_init, k_msg_finit, (uint32_t)sizeof(k_msg_finit) - 1U);
264 }
265 *out_pclka_hz = pclka_hz;
266}
267
269static void etoc_init_card_or_halt(uint32_t* pclka_hz)
270{
271 const ra8_sdmmc_spi_transport_t transport = {.set_clock = etoc_spi_set_clock,
272 .cs = etoc_spi_cs,
273 .xfer = etoc_spi_xfer,
274 .ctx = pclka_hz};
275 if (ra8_sdmmc_spi_init(&transport) != k_ra8_ok) {
276 etoc_fail((uint32_t)k_etoc_err_card, k_msg_fcard, (uint32_t)sizeof(k_msg_fcard) - 1U);
277 }
278 etoc_print(k_msg_cardok, (uint32_t)sizeof(k_msg_cardok) - 1U);
279}
280
283{
285 etoc_fail((uint32_t)k_etoc_err_mount, k_msg_fmount, (uint32_t)sizeof(k_msg_fmount) - 1U);
286 }
287 ra8_fs_mount_t* mount = nullptr;
288 if (ra8_fs_mount(&s_backend, &mount) != k_ra8_ok) {
289 ra8_fs_format_opts_t opts = {};
291 opts.label = "RAEPUB";
292 if ((ra8_fs_format(&s_backend, &opts) != k_ra8_ok) ||
293 (ra8_fs_mount(&s_backend, &mount) != k_ra8_ok)) {
294 etoc_fail((uint32_t)k_etoc_err_mount, k_msg_fmount, (uint32_t)sizeof(k_msg_fmount) - 1U);
295 }
296 }
297 return mount;
298}
299
301static void
302etoc_provision_one(ra8_fs_mount_t* mount, const char* path, const uint8_t* data, uint32_t len)
303{
304 ra8_fs_file_t* file = nullptr;
305 if (ra8_fs_open(mount, path, k_ra8_fs_mode_read, &file) == k_ra8_ok) {
306 (void)ra8_fs_close(file); /* already present -- nothing to provision. */
307 return;
308 }
309 if (ra8_fs_write_file(mount, path, data, len) != k_ra8_ok) {
310 etoc_fail((uint32_t)k_etoc_err_prov, k_msg_fprov, (uint32_t)sizeof(k_msg_fprov) - 1U);
311 }
312}
313
321
335static void etoc_read_toc(ra8_fs_mount_t* mount,
336 const char* path,
337 uint32_t stage,
338 const uint8_t* fmsg,
339 uint32_t fmsglen,
340 volatile uint32_t* kind,
341 volatile uint32_t* count,
342 volatile uint32_t* e0crc,
343 volatile uint32_t* ch0)
344{
345 if (epub_open_streamed_fs(mount, path, &s_epub_io, &s_book) != k_ra8_ok) {
346 etoc_fail(stage, fmsg, fmsglen);
347 }
348 uint8_t k = 0U;
349 uint16_t n = 0U;
350 if ((epub_get_toc_kind(&s_book, &k) != k_ra8_ok) ||
352 etoc_fail(stage, fmsg, fmsglen);
353 }
354 *kind = (uint32_t)k;
355 *count = (uint32_t)n;
356 *e0crc = 0U;
357 *ch0 = (uint32_t)k_etoc_no_chap;
358 if (n > 0U) {
359 epub_toc_entry_t entry = {};
360 uint16_t chap = (uint16_t)k_etoc_no_chap;
361 if ((epub_get_toc_entry(&s_book, 0U, &entry) != k_ra8_ok) ||
362 (epub_toc_entry_to_chapter(&s_book, 0U, &chap) != k_ra8_ok)) {
363 etoc_fail(stage, fmsg, fmsglen);
364 }
365 *e0crc = etoc_title_crc(entry.title);
366 *ch0 = (uint32_t)chap;
367 }
369}
370
373{
374 etoc_read_toc(mount,
376 (uint32_t)k_etoc_err_ncx,
378 (uint32_t)sizeof(k_msg_fncx) - 1U,
383 if ((g_etoc_ncx_kind != (uint32_t)k_etoc_ncx_kind) ||
384 (g_etoc_ncx_n != (uint32_t)k_etoc_ncx_count) ||
385 (g_etoc_ncx_e0crc != (uint32_t)k_etoc_ncx_crc) ||
386 (g_etoc_ncx_ch0 != (uint32_t)k_etoc_entry0)) {
387 etoc_fail((uint32_t)k_etoc_err_ncx, k_msg_fncx, (uint32_t)sizeof(k_msg_fncx) - 1U);
388 }
389}
390
393{
394 etoc_read_toc(mount,
396 (uint32_t)k_etoc_err_nav,
398 (uint32_t)sizeof(k_msg_fnav) - 1U,
403 if ((g_etoc_nav_kind != (uint32_t)k_etoc_nav_kind) ||
404 (g_etoc_nav_n != (uint32_t)k_etoc_nav_count) ||
405 (g_etoc_nav_e0crc != (uint32_t)k_etoc_nav_crc) ||
406 (g_etoc_nav_ch0 != (uint32_t)k_etoc_entry0)) {
407 etoc_fail((uint32_t)k_etoc_err_nav, k_msg_fnav, (uint32_t)sizeof(k_msg_fnav) - 1U);
408 }
409}
410
419{
421 etoc_fail((uint32_t)k_etoc_err_bad, k_msg_fbad, (uint32_t)sizeof(k_msg_fbad) - 1U);
422 }
423 uint8_t kind = (uint8_t)k_etoc_kind_unset;
424 uint16_t chap = 0U;
425 if ((epub_get_toc_kind(&s_book, &kind) != k_ra8_ok) ||
426 (epub_get_chapter_count(&s_book, &chap) != k_ra8_ok)) {
427 etoc_fail((uint32_t)k_etoc_err_bad, k_msg_fbad, (uint32_t)sizeof(k_msg_fbad) - 1U);
428 }
429 g_etoc_bad_kind = (uint32_t)kind;
430 g_etoc_bad_chap = (uint32_t)chap;
431 if ((kind != (uint8_t)k_etoc_bad_kind) || (chap != (uint16_t)k_etoc_exp_chap)) {
432 etoc_fail((uint32_t)k_etoc_err_bad, k_msg_fbad, (uint32_t)sizeof(k_msg_fbad) - 1U);
433 }
435}
436
447void main(void)
448{
449 uint32_t pclka_hz = 0U;
450 etoc_setup_or_halt(&pclka_hz);
452 ra8_log_init();
453 etoc_print(k_msg_boot, (uint32_t)sizeof(k_msg_boot) - 1U);
454
455 etoc_init_card_or_halt(&pclka_hz);
456 ra8_fs_mount_t* const mount = etoc_mount_or_halt();
458
459 etoc_check_ncx(mount);
460 etoc_check_nav(mount);
461 etoc_check_bad(mount);
462
463 etoc_print(k_msg_ok, (uint32_t)sizeof(k_msg_ok) - 1U);
464
465 /* Idle with a heartbeat that advances ONLY here -- every failure path parks in
466 * WFI without bumping it -- so a memprobe gate proves both TOC code paths plus
467 * the malformed-TOC fallback ran on real SD bytes. */
468 while (1) {
471 }
472}
void main(void)
Secure fallback main entry point.
Definition main.c:37
EPUB (.epub) reader and chapter iterator for ra8-firmware.
ra8_err_t epub_toc_entry_to_chapter(const epub_book_t *book, uint16_t toc_idx, uint16_t *out_chapter_idx)
Resolve a TOC entry to the spine chapter index it points into.
ra8_err_t epub_get_toc_kind(const epub_book_t *book, uint8_t *out_kind)
Report which navigation document the TOC was parsed from.
ra8_err_t epub_get_toc_entry(const epub_book_t *book, uint16_t idx, epub_toc_entry_t *out_entry)
Copy one table-of-contents entry into the caller's struct.
ra8_err_t epub_get_chapter_count(const epub_book_t *book, uint16_t *out_count)
Report how many chapters the spine contains.
ra8_err_t epub_get_toc_count(const epub_book_t *book, uint16_t *out_count)
Report how many table-of-contents entries the book exposes.
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.
Baked EPUB TOC fixtures for epub_toc (#116).
@ k_etoc_bad_len
Etoc bad length.
@ k_etoc_nav_len
Etoc nav length.
@ k_etoc_ncx_len
Etoc ncx length.
static const uint8_t k_etoc_bad[k_etoc_bad_len]
static const uint8_t k_etoc_nav[k_etoc_nav_len]
static const uint8_t k_etoc_ncx[k_etoc_ncx_len]
static const uint8_t k_msg_fcard[]
Definition main.c:143
static epub_book_t s_book
Opened book (large – file-scope, not on the stack).
Definition main.c:132
static const uint8_t k_msg_cardok[]
Definition main.c:141
static const uint8_t k_msg_ok[]
Definition main.c:153
static ra8_fs_backend_t s_backend
SD backend; file-scope so the mount handle may reference it.
Definition main.c:138
static const uint8_t k_msg_fprov[]
Definition main.c:145
static epub_stream_fs_ctx_t s_epub_io
Streamed-open source-file context; must outlive s_book (#230).
Definition main.c:134
static const uint8_t k_msg_boot[]
Definition main.c:140
static const uint8_t k_msg_finit[]
Definition main.c:142
static const uint8_t k_msg_fmount[]
Definition main.c:144
static const char k_etoc_path_ncx[]
SD paths for the three baked books (8.3 short names; ra8_fs root-only).
Definition main.c:93
static const ra8_port_pin_t k_etoc_pin_cipo
Definition main.c:88
volatile uint32_t g_etoc_bad_chap
malformed-TOC spine fallback.
Definition main.c:132
static const ra8_port_pin_t k_etoc_pin_copi
Definition main.c:89
static const char k_etoc_path_nav[]
Definition main.c:94
etoc_expect_t
Byte-exact expected TOC results (host-verified).
Definition main.c:74
@ k_etoc_entry0
Entry-0 -> spine index 0.
Definition main.c:83
@ k_etoc_ncx_crc
crc32("Intro").
Definition main.c:77
@ k_etoc_exp_chap
Spine length in every fixture.
Definition main.c:82
@ k_etoc_ncx_kind
k_epub_toc_ncx.
Definition main.c:75
@ k_etoc_bad_kind
k_epub_toc_none (no TOC doc).
Definition main.c:81
@ k_etoc_nav_count
nav <ol> entries.
Definition main.c:79
@ k_etoc_nav_crc
crc32("Cover").
Definition main.c:80
@ k_etoc_nav_kind
k_epub_toc_nav.
Definition main.c:78
@ k_etoc_ncx_count
navMap navPoints.
Definition main.c:76
volatile uint32_t g_etoc_ncx_n
NCX toc_count on success.
Definition main.c:124
static const ra8_port_pin_t k_etoc_pin_sck
Pmod2 SPI pins (J25) – SCI0 Simple-SPI; CS held by GPIO.
Definition main.c:87
static void etoc_fail(uint32_t err, const uint8_t *msg, uint32_t len)
Stamp the failure stage, print the FAIL banner, and park the CPU.
Definition main.c:167
volatile uint32_t g_etoc_bad_kind
malformed-TOC kind (expect 0).
Definition main.c:131
volatile uint32_t g_etoc_nav_ch0
nav entry-0 -> spine index.
Definition main.c:130
volatile uint32_t g_etoc_ncx_e0crc
NCX entry-0 label CRC.
Definition main.c:125
static const ra8_port_pin_t k_etoc_pin_cs
Definition main.c:90
etoc_pace_t
Idle-loop pacing for the success heartbeat.
Definition main.c:113
@ k_etoc_frame_ms
Heartbeat period in milliseconds.
Definition main.c:114
static const uint8_t k_msg_fnav[]
Definition main.c:150
static void etoc_check_ncx(ra8_fs_mount_t *mount)
Parse + assert the NCX (EPUB2) TOC; latch the result globals.
Definition main.c:372
static void etoc_read_toc(ra8_fs_mount_t *mount, const char *path, uint32_t stage, const uint8_t *fmsg, uint32_t fmsglen, volatile uint32_t *kind, volatile uint32_t *count, volatile uint32_t *e0crc, volatile uint32_t *ch0)
Open one book off SD and read its TOC kind/count + entry-0 label CRC.
Definition main.c:335
volatile uint32_t g_etoc_err
First failing stage (etoc_err_t), 0 on success.
Definition main.c:122
static ra8_err_t etoc_spi_cs(void *ctx, bool asserted)
ra8_sdmmc_spi_transport_t::cs over ra8_gpio (CS active-low).
Definition main.c:210
static const uint8_t k_msg_fbad[]
Definition main.c:151
static const uint8_t k_msg_fncx[]
Definition main.c:149
static void etoc_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
Definition main.c:155
static void etoc_check_bad(ra8_fs_mount_t *mount)
Assert the malformed-TOC fallback: no TOC, spine still readable.
Definition main.c:418
volatile uint32_t g_etoc_ncx_kind
NCX toc_kind on success.
Definition main.c:123
volatile uint32_t g_etoc_nav_e0crc
nav entry-0 label CRC.
Definition main.c:129
static ra8_err_t etoc_spi_set_clock(void *ctx, uint32_t hz)
Definition main.c:203
static ra8_err_t etoc_spi_pins_init(void)
Route Pmod2 SPI pins and claim CS as a GPIO output (idle high).
Definition main.c:224
volatile uint32_t g_etoc_nav_kind
nav toc_kind on success.
Definition main.c:127
etoc_consts_t
Console / SPI / parse knobs (no magic numbers).
Definition main.c:62
@ k_etoc_spi_chan
Pmod2 / J25 SCI0 Simple-SPI.
Definition main.c:64
@ k_etoc_crc_poly
CRC-32 reflected polynomial.
Definition main.c:66
@ k_etoc_uart_baud
Console baud.
Definition main.c:63
@ k_etoc_kind_unset
Sentinel: toc_kind not yet read.
Definition main.c:70
@ k_etoc_crc_init
CRC-32 initial value.
Definition main.c:65
@ k_etoc_no_chap
Sentinel: entry has no spine target.
Definition main.c:69
@ k_etoc_crc_bits
Bits folded per byte.
Definition main.c:67
@ k_etoc_title_max
Bounded title scan (NASA Rule 2).
Definition main.c:68
static ra8_fs_mount_t * etoc_mount_or_halt(void)
Mount the card, formatting FAT32 first if it is blank/unmountable.
Definition main.c:282
static void etoc_init_card_or_halt(uint32_t *pclka_hz)
Init the SD card over SPI; halt with a diagnostic on failure.
Definition main.c:269
static ra8_err_t etoc_spi_xfer(void *ctx, const uint8_t *tx, uint8_t *rx, uint32_t len)
ra8_sdmmc_spi_transport_t::xfer over ra8_sci_spi_xfer.
Definition main.c:217
static void etoc_check_nav(ra8_fs_mount_t *mount)
Parse + assert the nav (EPUB3) TOC; latch the result globals.
Definition main.c:392
volatile uint32_t g_etoc_heartbeat
Idle heartbeat; advances ONLY after all asserts pass (the HIL gate).
Definition main.c:134
static void etoc_provision_one(ra8_fs_mount_t *mount, const char *path, const uint8_t *data, uint32_t len)
Write one baked book onto the volume if path is absent.
Definition main.c:302
static void etoc_provision_or_halt(ra8_fs_mount_t *mount)
Provision all three baked TOC fixtures onto the card.
Definition main.c:315
static uint32_t etoc_title_crc(const char *title)
CRC-32 over a null-terminated title (bounded by k_etoc_title_max).
Definition main.c:191
etoc_err_t
Failure-stage codes stamped to g_etoc_err for SWD / --dump-sym.
Definition main.c:101
@ k_etoc_err_mount
Mount (and format-if-blank).
Definition main.c:105
@ k_etoc_err_nav
nav (EPUB3) TOC assertion.
Definition main.c:108
@ k_etoc_err_ncx
NCX (EPUB2) TOC assertion.
Definition main.c:107
@ k_etoc_err_bad
Malformed-TOC fallback assertion.
Definition main.c:109
@ k_etoc_err_none
No failure (success path).
Definition main.c:102
@ k_etoc_err_init
CGC / time / console / SPI bring-up.
Definition main.c:103
@ k_etoc_err_prov
Provision a .epub onto the card.
Definition main.c:106
@ k_etoc_err_card
SD card SPI init.
Definition main.c:104
static const char k_etoc_path_bad[]
Definition main.c:95
static uint32_t etoc_crc32(const uint8_t *data, size_t len)
CRC-32 (reflected, poly 0xEDB88320) over data.
Definition main.c:177
static void etoc_setup_or_halt(uint32_t *out_pclka_hz)
Bring up CGC + SysTick + console SCI + SPI + CS GPIO; halt on fail.
Definition main.c:242
volatile uint32_t g_etoc_ncx_ch0
NCX entry-0 -> spine index.
Definition main.c:126
volatile uint32_t g_etoc_nav_n
nav toc_count on success.
Definition main.c:128
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.
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.
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
@ k_ra8_clock_id_pclka
PCLKA.
Definition ra8_cgc.h:73
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_err_t ra8_fs_format(const ra8_fs_backend_t *backend, const ra8_fs_format_opts_t *opts)
Format a block device as a fresh, empty FAT12/FAT16/FAT32/exFAT volume.
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_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_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_type_fat32
count_of_clusters >= 65525.
@ k_ra8_fs_mode_read
Read-only, must exist.
@ k_ra8_psel_sci_async
00100b: SCI async serial (UART).
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Definition ra8_isr.c:439
Lightweight Logging Interface for ra8-firmware.
void ra8_log_init(void)
Initialise the logging backend.
Definition ra8_log.c:379
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.
Definition gpio.c:88
ra8_err_t ra8_gpio_write(ra8_port_pin_t pin, ra8_level_t level)
Drive a previously-configured output to the given level.
Definition gpio.c:154
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.
Definition gpio.c:238
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.
Definition ra8_spi.h:62
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
Opened EPUB book.
Definition epub.h:286
Backing state for a streamed ra8_fs EPUB open (#151).
Definition epub_fs.h:55
One titled entry in the table of contents.
Definition epub.h:142
char title[k_epub_meta_len]
Navigation label text ("" if none).
Definition epub.h:143
Block-device interface that ra8_fs runs on top of.
Open-file state.
Tunables for ra8_fs_format() (the on-disk geometry of a fresh volume).
ra8_fs_type_t type
FAT variant to lay down (12/16/32).
const char * label
0..11 char volume label, or NULL.
Cached parse of one mounted FAT volume.
Configuration descriptor for ra8_sci_spi_init.
Definition ra8_sci_spi.h:49
Driver-to-bus binding (Dependency Inversion seam).