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 e-reader interaction / hit-test (#118). 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_isr.h"
#include "ra8_mstp.h"
#include "ra8_time.h"
#include "ra8_ui.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  iu_consts_t : uint32_t {
  k_iu_uart_baud = 115200U ,
  k_iu_dec_ten = 10U
}
 Console knobs (no magic numbers). More...
enum  iu_action_t : uint16_t {
  k_iu_act_book0 = 10U ,
  k_iu_act_book1 = 11U ,
  k_iu_act_book2 = 12U ,
  k_iu_act_book3 = 13U ,
  k_iu_act_toolbar = 20U
}
 Chrome tap-target action ids. More...
enum  iu_screen_t : uint16_t {
  k_iu_screen_library = 1U ,
  k_iu_screen_reading = 2U
}
 Screen ids for the nav stack. More...
enum  iu_miss_pt_t : int32_t {
  k_iu_miss_gutter_x = 112 ,
  k_iu_miss_gutter_y = 70 ,
  k_iu_miss_off_x = 300 ,
  k_iu_miss_off_y = 400 ,
  k_iu_tap_half = 2 ,
  k_iu_miss_count = 2
}
 Off-target tap coordinates that must miss. More...
enum  iu_rect_t : int32_t {
  k_iu_grid_col0_x = 8 ,
  k_iu_grid_col1_x = 116 ,
  k_iu_grid_row0_y = 40 ,
  k_iu_grid_row1_y = 110 ,
  k_iu_cell_w = 100 ,
  k_iu_cell_h = 60 ,
  k_iu_toolbar_y = 4 ,
  k_iu_toolbar_w = 60 ,
  k_iu_toolbar_h = 28
}
 Pixel geometry of the chrome tap-target rects. More...

Functions

static void iu_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void iu_panic_halt (void)
 Print the fail banner and trap (ra8_emulator halts on the BKPT).
static void iu_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static bool iu_tap (int32_t px, int32_t py, bool want_hit, uint16_t want_act, uint32_t *hits)
 Hit-test a synthetic tap; verify hit-ness + the resolved action.
static bool iu_nav_check (void)
 Drive the screen stack: open book -> reading, back -> library.
static void iu_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
void main (void)
 App entry: inject synthetic taps + nav events, assert, print result.

Variables

static const ra8_ui_target_t k_iu_targets []
 Representative chrome targets: a 2x2 book grid + a toolbar button.
static const uint8_t k_msg_boot [] = "ui-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "ui-hil: FAIL init\r\n"
static const uint8_t k_msg_pre [] = "ui-hil: taps="
static const uint8_t k_msg_hits [] = " hits="
static const uint8_t k_msg_nav [] = " nav_ok="
static const uint8_t k_msg_pass [] = " PASS\r\n"
static const uint8_t k_msg_failr [] = " FAIL\r\n"

Detailed Description

Headless on-silicon HIL gate for e-reader interaction / hit-test (#118).

#80 built the e-reader interaction layer – ra8_ui hit-testing + screen-stack navigation – but no HIL routes an input event through it; the chrome HIL only checks the render. This app closes that gap with synthetic input (no GT911 touch needed): it builds a representative chrome target set (book cells

  • a toolbar button), injects a sequence of taps at known coordinates, and asserts each resolves to the expected ra8_ui action id (and that off-target taps miss). It then drives the screen stack (open book -> reading, back -> library) and asserts each transition. The result is printed on the SCI8 J-Link OB console:

    ui-hil: taps=<N> hits=<M> nav_ok=<0|1> PASS

Pure logic (no peripheral state), so the banner is identical every boot and matches the host / ra8_emulator run.

[Ring 7 / App] {World: NS}

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ iu_action_t

enum iu_action_t : uint16_t

Chrome tap-target action ids.

Enumerator
k_iu_act_book0 

Library book cell 0.

k_iu_act_book1 

Library book cell 1.

k_iu_act_book2 

Library book cell 2.

k_iu_act_book3 

Library book cell 3.

k_iu_act_toolbar 

Status-bar toolbar button.

Definition at line 48 of file main.c.

◆ iu_consts_t

enum iu_consts_t : uint32_t

Console knobs (no magic numbers).

Enumerator
k_iu_uart_baud 

Console baud.

k_iu_dec_ten 

Decimal base.

Definition at line 42 of file main.c.

◆ iu_miss_pt_t

enum iu_miss_pt_t : int32_t

Off-target tap coordinates that must miss.

Enumerator
k_iu_miss_gutter_x 

Column gutter (between cells 0 and 1).

k_iu_miss_gutter_y 

Mid-height of the first cell row.

k_iu_miss_off_x 

Far off-screen x.

k_iu_miss_off_y 

Far off-screen y.

k_iu_tap_half 

Divisor for a rect's centre point.

k_iu_miss_count 

Number of off-target (miss) taps.

Definition at line 63 of file main.c.

◆ iu_rect_t

enum iu_rect_t : int32_t

Pixel geometry of the chrome tap-target rects.

Enumerator
k_iu_grid_col0_x 

Left column x of the 2x2 book grid.

k_iu_grid_col1_x 

Right column x of the 2x2 book grid.

k_iu_grid_row0_y 

Top row y of the 2x2 book grid.

k_iu_grid_row1_y 

Bottom row y of the 2x2 book grid.

k_iu_cell_w 

Book-cell width.

k_iu_cell_h 

Book-cell height.

k_iu_toolbar_y 

Toolbar-button y.

k_iu_toolbar_w 

Toolbar-button width.

k_iu_toolbar_h 

Toolbar-button height.

Definition at line 73 of file main.c.

◆ iu_screen_t

enum iu_screen_t : uint16_t

Screen ids for the nav stack.

Enumerator
k_iu_screen_library 

Library / home grid.

k_iu_screen_reading 

Reading view.

Definition at line 57 of file main.c.

Function Documentation

◆ iu_nav_check()

bool iu_nav_check ( void )
static

Drive the screen stack: open book -> reading, back -> library.

Returns
true iff every transition + top-of-stack check matched.

Definition at line 174 of file main.c.

References k_iu_screen_library, k_iu_screen_reading, k_ra8_ok, ra8_ui_nav_init(), ra8_ui_nav_pop(), ra8_ui_nav_push(), and ra8_ui_nav_top().

Referenced by main().

◆ iu_panic_halt()

void iu_panic_halt ( void )
static

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

Definition at line 114 of file main.c.

References iu_print(), and k_msg_fail.

Referenced by iu_setup_or_halt().

◆ iu_print()

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

Emit a byte run on the SCI8 console.

Definition at line 108 of file main.c.

References ra8_board_uart_console_write().

Referenced by iu_panic_halt(), iu_print_uint(), and main().

◆ iu_print_uint()

void iu_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 124 of file main.c.

References iu_print(), and k_iu_dec_ten.

Referenced by main().

◆ iu_setup_or_halt()

void iu_setup_or_halt ( void )
static

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

Definition at line 204 of file main.c.

References iu_panic_halt(), k_iu_uart_baud, 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().

◆ iu_tap()

bool iu_tap ( int32_t px,
int32_t py,
bool want_hit,
uint16_t want_act,
uint32_t * hits )
static

Hit-test a synthetic tap; verify hit-ness + the resolved action.

Parameters
[in]pxTap x.
[in]pyTap y.
[in]want_hitExpected hit-ness.
[in]want_actExpected action id (when want_hit).
[in,out]hitsRunning hit counter (incremented on a real hit).
Returns
true iff the tap resolved exactly as expected.

Definition at line 152 of file main.c.

References k_iu_targets, k_ra8_ok, and ra8_ui_hit_test().

Referenced by main().

◆ main()

void main ( void )

App entry: inject synthetic taps + nav events, assert, print result.

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 hit-test / nav result banner is emitted; the CPU loops in WFI.
Since
0.1.0

Definition at line 229 of file main.c.

References ra8_ui_rect_t::h, iu_nav_check(), iu_print(), iu_print_uint(), iu_setup_or_halt(), iu_tap(), k_iu_miss_count, k_iu_miss_gutter_x, k_iu_miss_gutter_y, k_iu_miss_off_x, k_iu_miss_off_y, k_iu_tap_half, k_iu_targets, k_msg_boot, k_msg_failr, k_msg_hits, k_msg_nav, k_msg_pass, k_msg_pre, ra8_isr_globals_enable(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Variable Documentation

◆ k_iu_targets

const ra8_ui_target_t k_iu_targets[]
static
Initial value:
= {
{.rect = {.x = k_iu_grid_col0_x, .y = k_iu_grid_row0_y, .w = k_iu_cell_w, .h = k_iu_cell_h},
.action_id = (uint16_t)k_iu_act_book0},
{.rect = {.x = k_iu_grid_col1_x, .y = k_iu_grid_row0_y, .w = k_iu_cell_w, .h = k_iu_cell_h},
.action_id = (uint16_t)k_iu_act_book1},
{.rect = {.x = k_iu_grid_col0_x, .y = k_iu_grid_row1_y, .w = k_iu_cell_w, .h = k_iu_cell_h},
.action_id = (uint16_t)k_iu_act_book2},
{.rect = {.x = k_iu_grid_col1_x, .y = k_iu_grid_row1_y, .w = k_iu_cell_w, .h = k_iu_cell_h},
.action_id = (uint16_t)k_iu_act_book3},
{.rect = {.x = k_iu_grid_col0_x, .y = k_iu_toolbar_y, .w = k_iu_toolbar_w, .h = k_iu_toolbar_h},
.action_id = (uint16_t)k_iu_act_toolbar},
}
@ k_iu_act_book3
Library book cell 3.
Definition main.c:52
@ k_iu_act_book2
Library book cell 2.
Definition main.c:51
@ k_iu_act_book0
Library book cell 0.
Definition main.c:49
@ k_iu_act_book1
Library book cell 1.
Definition main.c:50
@ k_iu_act_toolbar
Status-bar toolbar button.
Definition main.c:53
@ k_iu_toolbar_y
Toolbar-button y.
Definition main.c:80
@ k_iu_toolbar_h
Toolbar-button height.
Definition main.c:82
@ k_iu_grid_row0_y
Top row y of the 2x2 book grid.
Definition main.c:76
@ k_iu_toolbar_w
Toolbar-button width.
Definition main.c:81
@ k_iu_cell_w
Book-cell width.
Definition main.c:78
@ k_iu_grid_row1_y
Bottom row y of the 2x2 book grid.
Definition main.c:77
@ k_iu_cell_h
Book-cell height.
Definition main.c:79
@ k_iu_grid_col0_x
Left column x of the 2x2 book grid.
Definition main.c:74
@ k_iu_grid_col1_x
Right column x of the 2x2 book grid.
Definition main.c:75

Representative chrome targets: a 2x2 book grid + a toolbar button.

Definition at line 86 of file main.c.

Referenced by iu_tap(), and main().

◆ k_msg_boot

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

Definition at line 99 of file main.c.

◆ k_msg_fail

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

Definition at line 100 of file main.c.

◆ k_msg_failr

const uint8_t k_msg_failr[] = " FAIL\r\n"
static

Definition at line 105 of file main.c.

Referenced by main().

◆ k_msg_hits

const uint8_t k_msg_hits[] = " hits="
static

Definition at line 102 of file main.c.

Referenced by main().

◆ k_msg_nav

const uint8_t k_msg_nav[] = " nav_ok="
static

Definition at line 103 of file main.c.

Referenced by main().

◆ k_msg_pass

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

Definition at line 104 of file main.c.

◆ k_msg_pre

const uint8_t k_msg_pre[] = "ui-hil: taps="
static

Definition at line 101 of file main.c.