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

On-silicon HIL: SVG vector-art render-at-size + CRC gate (#143). More...

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

Go to the source code of this file.

Enumerations

enum  es_consts_t : uint32_t {
  k_es_uart_baud = 115200U ,
  k_es_fb_w = 160U ,
  k_es_fb_h = 120U ,
  k_es_col_bg = 0x202028U ,
  k_es_fnv_offset = 0x811C9DC5U ,
  k_es_fnv_prime = 0x01000193U ,
  k_es_hex_nibbles = 8U ,
  k_es_nibble_bits = 4U ,
  k_es_nibble_mask = 0x0FU ,
  k_es_dec_ten = 10U
}
 Console / render knobs (no magic numbers). More...

Functions

static void es_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void es_panic_halt (const uint8_t *msg, uint32_t len)
 Print the fail banner and trap (ra8_emulator halts on the BKPT).
static uint32_t es_framebuffer_hash (void)
 FNV-1a hash over the rendered framebuffer.
static void es_print_hex (uint32_t value)
 Print a 32-bit value as 8 upper-case hex digits.
static void es_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static void es_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
static void es_render_svg_or_halt (int32_t *out_w, int32_t *out_h)
 Read the SVG intrinsic size and render it into the framebuffer.
void main (void)
 App entry: render the baked SVG on silicon, print the banner.

Variables

static uint16_t s_framebuffer [(size_t) k_es_fb_h *(size_t) k_es_fb_w]
 RGB565 framebuffer the SVG is rendered into.
static const uint8_t k_msg_boot [] = "ereader-svg-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "ereader-svg-hil: FAIL init\r\n"
static const uint8_t k_msg_size [] = "ereader-svg-hil: FAIL size\r\n"
static const uint8_t k_msg_rerr [] = "ereader-svg-hil: FAIL render\r\n"
static const uint8_t k_msg_pre [] = "ereader-svg-hil: svg "
static const uint8_t k_msg_x [] = "x"
static const uint8_t k_msg_crc [] = " crc="
static const uint8_t k_msg_ok [] = " PASS\r\n"

Detailed Description

On-silicon HIL: SVG vector-art render-at-size + CRC gate (#143).

The vector half of the cover-art family: render an SVG document to a fixed-size framebuffer through the reflow SVG rasterizer (#112/#141) and CRC-gate the result – the SVG counterpart to ereader_image (PNG) and ereader_jpeg (JPEG), which cover the raster stb_image path.

  1. ra8_gfx_init – bind a 160x120 RGB565 framebuffer in internal SRAM.
  2. ra8_svg_size – read the SVG's intrinsic size from its viewBox.
  3. ra8_svg_render – map the viewBox onto the framebuffer box and draw the supported shapes (<rect> / <circle> / <polygon> filled) through ra8_gfx. No allocation (NASA Rule 3) – the rasterizer's only side effect is drawing.
  4. FNV-1a-32 hash the rendered framebuffer.

The console banner on success is:

ereader-svg-hil: svg 100x100 crc=<8hex> PASS

where 100x100 is the SVG's intrinsic viewBox size and <8hex> the framebuffer hash. The whole chain is deterministic (a fixed document through a deterministic rasterizer), so the banner is identical on host, ra8_emulator, and silicon. Any failure prints a FAIL banner and halts on a BKPT before the PASS line, so the gate is exact.

[Ring 7 / App] {World: NS}

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ es_consts_t

enum es_consts_t : uint32_t

Console / render knobs (no magic numbers).

Enumerator
k_es_uart_baud 

Console baud.

k_es_fb_w 

Framebuffer width, pixels.

k_es_fb_h 

Framebuffer height, pixels.

k_es_col_bg 

Framebuffer clear colour.

k_es_fnv_offset 

FNV-1a 32-bit offset basis.

k_es_fnv_prime 

FNV-1a 32-bit prime.

k_es_hex_nibbles 

Hex digits in a 32-bit value.

k_es_nibble_bits 

Bits per hex nibble.

k_es_nibble_mask 

Low-nibble mask.

k_es_dec_ten 

Hex digit / decimal split.

Definition at line 52 of file main.c.

Function Documentation

◆ es_framebuffer_hash()

uint32_t es_framebuffer_hash ( void )
static

FNV-1a hash over the rendered framebuffer.

Definition at line 94 of file main.c.

References k_es_fnv_offset, k_es_fnv_prime, and s_framebuffer.

Referenced by main().

◆ es_panic_halt()

void es_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 84 of file main.c.

References es_print().

Referenced by es_render_svg_or_halt(), es_setup_or_halt(), and main().

◆ es_print()

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

Emit a byte run on the SCI8 console.

Definition at line 78 of file main.c.

References ra8_board_uart_console_write().

Referenced by es_panic_halt(), es_print_hex(), es_print_uint(), and main().

◆ es_print_hex()

void es_print_hex ( uint32_t value)
static

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

Definition at line 106 of file main.c.

References es_print(), k_es_dec_ten, k_es_hex_nibbles, k_es_nibble_bits, and k_es_nibble_mask.

Referenced by main().

◆ es_print_uint()

void es_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 118 of file main.c.

References es_print(), and k_es_dec_ten.

Referenced by main().

◆ es_render_svg_or_halt()

void es_render_svg_or_halt ( int32_t * out_w,
int32_t * out_h )
static

Read the SVG intrinsic size and render it into the framebuffer.

Halts on any failure before returning. On success the SVG has been rasterized into s_framebuffer and its intrinsic dimensions returned.

Parameters
[out]out_wReceives the SVG viewBox width.
[out]out_hReceives the SVG viewBox height.
Precondition
es_setup_or_halt ran and ra8_gfx_init bound s_framebuffer.
Postcondition
On return s_framebuffer holds the rendered SVG; out_w/out_h set.
Since
0.1.0

Definition at line 167 of file main.c.

References es_panic_halt(), k_es_fb_h, k_es_fb_w, k_msg_rerr, k_msg_size, k_ra8_ok, k_svg_fixture, ra8_svg_render(), and ra8_svg_size().

Referenced by main().

◆ es_setup_or_halt()

void es_setup_or_halt ( void )
static

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

Definition at line 137 of file main.c.

References es_panic_halt(), k_es_uart_baud, k_msg_fail, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().

Referenced by main().

◆ main()

void main ( void )

App entry: render the baked SVG on silicon, print the banner.

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 svg-size / framebuffer-CRC banner is emitted; CPU loops in WFI.
Since
0.1.0

Definition at line 191 of file main.c.

References es_framebuffer_hash(), es_panic_halt(), es_print(), es_print_hex(), es_print_uint(), es_render_svg_or_halt(), es_setup_or_halt(), k_es_col_bg, k_es_fb_h, k_es_fb_w, k_msg_boot, k_msg_crc, k_msg_fail, k_msg_ok, k_msg_pre, k_msg_x, k_ra8_gfx_format_rgb565, k_ra8_ok, ra8_gfx_clear(), ra8_gfx_init(), ra8_isr_globals_enable(), and s_framebuffer.

Variable Documentation

◆ k_msg_boot

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

Definition at line 68 of file main.c.

◆ k_msg_crc

const uint8_t k_msg_crc[] = " crc="
static

Definition at line 74 of file main.c.

◆ k_msg_fail

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

Definition at line 69 of file main.c.

◆ k_msg_ok

const uint8_t k_msg_ok[] = " PASS\r\n"
static

Definition at line 75 of file main.c.

◆ k_msg_pre

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

Definition at line 72 of file main.c.

◆ k_msg_rerr

const uint8_t k_msg_rerr[] = "ereader-svg-hil: FAIL render\r\n"
static

Definition at line 71 of file main.c.

Referenced by es_render_svg_or_halt().

◆ k_msg_size

const uint8_t k_msg_size[] = "ereader-svg-hil: FAIL size\r\n"
static

Definition at line 70 of file main.c.

Referenced by es_render_svg_or_halt().

◆ k_msg_x

const uint8_t k_msg_x[] = "x"
static

Definition at line 73 of file main.c.

◆ s_framebuffer

uint16_t s_framebuffer[(size_t) k_es_fb_h *(size_t) k_es_fb_w]
static

RGB565 framebuffer the SVG is rendered into.

Definition at line 66 of file main.c.