ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

Headless on-silicon HIL gate for <table> grid layout (#107). More...

#include <stddef.h>
#include <stdint.h>
#include "font_fixture.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_time.h"
#include "reflow.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  tb_consts_t : uint32_t {
  k_tb_view_w = 280U ,
  k_tb_view_h = 360U ,
  k_tb_font_px = 16U ,
  k_tb_ink = 0xFF101010U ,
  k_tb_link_col = 0xFF2A52BEU ,
  k_tb_uart_baud = 115200U ,
  k_tb_fnv_offset = 2166136261U ,
  k_tb_fnv_prime = 16777619U ,
  k_tb_hex_nibbles = 8U ,
  k_tb_nibble_bits = 4U ,
  k_tb_nibble_mask = 0x0FU ,
  k_tb_dec_ten = 10U
}
 Viewport / console / hash knobs (no magic numbers). More...

Functions

static void tb_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void tb_panic_halt (const uint8_t *msg, uint32_t len)
 Print the fail banner and trap (ra8_emulator halts on the BKPT).
static void tb_print_hex (uint32_t value)
 Print a 32-bit value as 8 upper-case hex digits.
static void tb_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static uint32_t tb_geom_hash (void)
 FNV-1a-32 over every laid-out glyph's (x, y) position.
static void tb_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
void main (void)
 App entry: lay out the table chapter, hash the geometry, print.

Variables

static reflow_t s_engine
 Reflow engine (large – file-scope, not on the stack).
static const char k_tb_chapter []
 Baked chapter: a heading, a 2-column table, and a trailing paragraph.
static const uint8_t k_msg_boot [] = "ereader-table-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "ereader-table-hil: FAIL init\r\n"
static const uint8_t k_msg_lerr [] = "ereader-table-hil: FAIL layout\r\n"
static const uint8_t k_msg_pre [] = "ereader-table-hil: glyphs="
static const uint8_t k_msg_geom [] = " geom="
static const uint8_t k_msg_eol [] = "\r\n"

Detailed Description

Headless on-silicon HIL gate for <table> grid layout (#107).

Closes the real-hardware gap for the table layout: tokenize table/tr/td/th, size equal columns, flow each cell, stack rows (with row-level page breaks) – no panel / SD / touch needed. The app lays out a baked chapter with a 2-column table (plus a heading and trailing paragraph) through reflow with the fixed-metric Ahem face, folds an FNV-1a-32 hash over the laid-out glyph geometry (every glyph's x + y), and prints a banner on the SCI8 J-Link OB console:

ereader-table-hil: glyphs=<N> geom=<8 hex>

Ahem's fixed metrics make the grid deterministic; the banner is identical every boot and matches the host / ra8_emulator run, so any drift in the column sizing, cell flow, or row stacking changes the hash.

[Ring 7 / App] {World: NS}

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ tb_consts_t

enum tb_consts_t : uint32_t

Viewport / console / hash knobs (no magic numbers).

Enumerator
k_tb_view_w 

Layout viewport width, pixels.

k_tb_view_h 

Layout viewport height, pixels.

k_tb_font_px 

Body font size, pixels.

k_tb_ink 

Body ink colour (ARGB).

k_tb_link_col 

Anchor colour (ARGB).

k_tb_uart_baud 

Console baud.

k_tb_fnv_offset 

FNV-1a-32 offset basis.

k_tb_fnv_prime 

FNV-1a-32 prime.

k_tb_hex_nibbles 

Hex digits in a 32-bit value.

k_tb_nibble_bits 

Bits per hex nibble.

k_tb_nibble_mask 

Low-nibble mask.

k_tb_dec_ten 

Hex digit / decimal split.

Definition at line 42 of file main.c.

Function Documentation

◆ main()

void main ( void )

App entry: lay out the table chapter, hash the geometry, print.

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The geometry-hash banner is emitted; the CPU then loops in WFI.
Since
0.1.0

Definition at line 166 of file main.c.

References k_ahem_ttf, k_ahem_ttf_len, k_msg_boot, k_msg_eol, k_msg_fail, k_msg_geom, k_msg_lerr, k_msg_pre, k_ra8_ok, k_tb_chapter, k_tb_font_px, k_tb_ink, k_tb_link_col, k_tb_view_h, k_tb_view_w, ra8_isr_globals_enable(), reflow_init(), reflow_layout_chapter(), s_engine, tb_geom_hash(), tb_panic_halt(), tb_print(), tb_print_hex(), tb_print_uint(), and tb_setup_or_halt().

◆ tb_geom_hash()

uint32_t tb_geom_hash ( void )
static

FNV-1a-32 over every laid-out glyph's (x, y) position.

Definition at line 126 of file main.c.

References k_tb_fnv_offset, k_tb_fnv_prime, and s_engine.

Referenced by main().

◆ tb_panic_halt()

void tb_panic_halt ( const uint8_t * msg,
uint32_t len )
static

Print the fail banner and trap (ra8_emulator halts on the BKPT).

Definition at line 85 of file main.c.

References tb_print().

Referenced by main(), and tb_setup_or_halt().

◆ tb_print()

void tb_print ( const uint8_t * msg,
uint32_t len )
static

Emit a byte run on the SCI8 console.

Definition at line 79 of file main.c.

References ra8_board_uart_console_write().

Referenced by main(), tb_panic_halt(), tb_print_hex(), and tb_print_uint().

◆ tb_print_hex()

void tb_print_hex ( uint32_t value)
static

Print a 32-bit value as 8 upper-case hex digits.

Definition at line 95 of file main.c.

References k_tb_dec_ten, k_tb_hex_nibbles, k_tb_nibble_bits, k_tb_nibble_mask, and tb_print().

Referenced by main().

◆ tb_print_uint()

void tb_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 107 of file main.c.

References k_tb_dec_ten, and tb_print().

Referenced by main().

◆ tb_setup_or_halt()

void tb_setup_or_halt ( void )
static

Bring up clocks/MSTP/time + the SCI8 console; halt on failure.

Definition at line 141 of file main.c.

References k_msg_fail, k_ra8_clock_id_cpuclk0, k_ra8_ok, k_tb_uart_baud, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), and tb_panic_halt().

Referenced by main().

Variable Documentation

◆ k_msg_boot

const uint8_t k_msg_boot[] = "ereader-table-hil: boot\r\n"
static

Definition at line 71 of file main.c.

◆ k_msg_eol

const uint8_t k_msg_eol[] = "\r\n"
static

Definition at line 76 of file main.c.

◆ k_msg_fail

const uint8_t k_msg_fail[] = "ereader-table-hil: FAIL init\r\n"
static

Definition at line 72 of file main.c.

◆ k_msg_geom

const uint8_t k_msg_geom[] = " geom="
static

Definition at line 75 of file main.c.

◆ k_msg_lerr

const uint8_t k_msg_lerr[] = "ereader-table-hil: FAIL layout\r\n"
static

Definition at line 73 of file main.c.

◆ k_msg_pre

const uint8_t k_msg_pre[] = "ereader-table-hil: glyphs="
static

Definition at line 74 of file main.c.

◆ k_tb_chapter

const char k_tb_chapter[]
static
Initial value:
=
"<html><body><h1>Schedule</h1>"
"<table>"
"<tr><th>Day</th><th>Activity for the morning</th></tr>"
"<tr><td>Monday</td><td>Read the first three chapters</td></tr>"
"<tr><td>Tuesday</td><td>Notes and a short summary</td></tr>"
"<tr><td>Wednesday</td><td>Review and discuss</td></tr>"
"</table>"
"<p>Text after the table resumes the normal flow.</p></body></html>"

Baked chapter: a heading, a 2-column table, and a trailing paragraph.

Definition at line 61 of file main.c.

Referenced by main().

◆ s_engine

reflow_t s_engine
static

Reflow engine (large – file-scope, not on the stack).

Definition at line 58 of file main.c.