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 for the on-screen keyboard widget ra8_keyboard (#105). 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_keyboard.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  kb_consts_t : int32_t {
  k_kb_uart_baud = 115200 ,
  k_kb_frame_x = 0 ,
  k_kb_frame_y = 600 ,
  k_kb_frame_w = 1024 ,
  k_kb_frame_h = 360 ,
  k_kb_half = 2 ,
  k_kb_dec_ten = 10
}
 Console / frame knobs (no magic numbers). More...

Functions

static void kb_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void kb_panic_halt (const uint8_t *msg, uint32_t len)
 Print the fail banner and trap (ra8_emulator halts on the BKPT).
static void kb_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static uint8_t kb_key_of (char ch)
 Find the key index of printable ch, or k_ra8_kbd_no_hit.
static uint8_t kb_key_of_kind (ra8_kbd_key_kind_t kind)
 Find the first key of a non-char kind, or k_ra8_kbd_no_hit.
static void kb_tap (ra8_kbd_text_t *t, uint8_t idx, uint32_t *taps)
 Tap key idx's centre through hit-test + apply; count the tap.
static void kb_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
static bool kb_streq (const char *a, const char *b)
 Compare two NUL-terminated strings for equality.
void main (void)
 App entry: type a phrase via synthetic taps, verify, print the banner.

Variables

static ra8_kbd_layout_t s_kb
 The laid-out keyboard (large – file-scope, not on the stack).
static const char k_kb_word [] = "hi"
 Lowercase letters typed (with SHIFT before the first) -> "Hi".
static const char k_kb_expected [] = "Hi 9"
 Expected query after the SHIFT / SPACE / 123-layer / digit sequence.
static const uint8_t k_msg_boot [] = "keyboard-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "keyboard-hil: FAIL init\r\n"
static const uint8_t k_msg_lay [] = "kbd: FAIL layout\r\n"
static const uint8_t k_msg_miss [] = "kbd: FAIL mismatch\r\n"
static const uint8_t k_msg_pre [] = "kbd: q="
static const uint8_t k_msg_mid [] = " commit="
static const uint8_t k_msg_taps [] = " taps="
static const uint8_t k_msg_ok [] = " PASS\r\n"

Detailed Description

On-silicon HIL for the on-screen keyboard widget ra8_keyboard (#105).

Drives the real ra8_keyboard model with synthetic taps – the same input-injection pattern as ereader_input (#118), but for text entry. It lays the iOS-style key grid into a frame, then "taps" key centres to type the string Hi 9 – exercising one-shot SHIFT (the capital H), SPACE, and the 123 layer toggle to reach a digit (9) – routing every tap through ra8_kbd_hit -> ra8_kbd_apply exactly as a finger on the panel would, then commits with ENTER and asserts the query before printing a banner on the SCI8 J-Link OB console:

kbd: q=Hi 9 commit=1 taps=7 PASS

No panel / SD / touch hardware is needed – the widget is pure layout + hit-test + text-buffer logic, so the banner is identical on host, ra8_emulator, and silicon. A mismatch halts on a BKPT before the PASS line.

[Ring 7 / App] {World: NS}

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ kb_consts_t

enum kb_consts_t : int32_t

Console / frame knobs (no magic numbers).

Enumerator
k_kb_uart_baud 

Console baud.

k_kb_frame_x 

Keyboard frame: left.

k_kb_frame_y 

Keyboard frame: top (lower panel).

k_kb_frame_w 

Keyboard frame: width.

k_kb_frame_h 

Keyboard frame: height.

k_kb_half 

Centre divisor.

k_kb_dec_ten 

Decimal radix / small-buf cap.

Definition at line 43 of file main.c.

Function Documentation

◆ kb_key_of()

uint8_t kb_key_of ( char ch)
static

Find the key index of printable ch, or k_ra8_kbd_no_hit.

Definition at line 106 of file main.c.

References k_ra8_kbd_key_char, k_ra8_kbd_no_hit, and s_kb.

Referenced by main().

◆ kb_key_of_kind()

uint8_t kb_key_of_kind ( ra8_kbd_key_kind_t kind)
static

Find the first key of a non-char kind, or k_ra8_kbd_no_hit.

Definition at line 117 of file main.c.

References k_ra8_kbd_no_hit, and s_kb.

Referenced by main().

◆ kb_panic_halt()

void kb_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 77 of file main.c.

References kb_print().

Referenced by kb_setup_or_halt(), and main().

◆ kb_print()

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

Emit a byte run on the SCI8 console.

Definition at line 71 of file main.c.

References ra8_board_uart_console_write().

Referenced by kb_panic_halt(), kb_print_uint(), and main().

◆ kb_print_uint()

void kb_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 87 of file main.c.

References k_kb_dec_ten, and kb_print().

Referenced by main().

◆ kb_setup_or_halt()

void kb_setup_or_halt ( void )
static

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

Definition at line 139 of file main.c.

References k_kb_uart_baud, k_msg_fail, k_ra8_clock_id_cpuclk0, k_ra8_ok, kb_panic_halt(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().

Referenced by main().

◆ kb_streq()

bool kb_streq ( const char * a,
const char * b )
static

Compare two NUL-terminated strings for equality.

Definition at line 157 of file main.c.

References k_ra8_kbd_text_max.

Referenced by main().

◆ kb_tap()

void kb_tap ( ra8_kbd_text_t * t,
uint8_t idx,
uint32_t * taps )
static

Tap key idx's centre through hit-test + apply; count the tap.

Definition at line 128 of file main.c.

References ra8_ui_rect_t::h, k_kb_half, ra8_kbd_apply(), ra8_kbd_hit(), s_kb, ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Referenced by main().

◆ main()

void main ( void )

App entry: type a phrase via synthetic taps, verify, 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 query/commit banner is emitted; the CPU then loops in WFI.
Since
0.1.0

Definition at line 178 of file main.c.

References ra8_kbd_text_t::buf, ra8_kbd_text_t::committed, k_kb_expected, k_kb_frame_h, k_kb_frame_w, k_kb_frame_x, k_kb_frame_y, k_kb_word, k_msg_boot, k_msg_lay, k_msg_mid, k_msg_miss, k_msg_ok, k_msg_pre, k_msg_taps, k_ra8_kbd_key_enter, k_ra8_kbd_key_layer, k_ra8_kbd_key_shift, k_ra8_kbd_key_space, k_ra8_ok, kb_key_of(), kb_key_of_kind(), kb_panic_halt(), kb_print(), kb_print_uint(), kb_setup_or_halt(), kb_streq(), kb_tap(), ra8_kbd_text_t::len, ra8_isr_globals_enable(), ra8_kbd_layout_init(), ra8_kbd_text_init(), and s_kb.

Variable Documentation

◆ k_kb_expected

const char k_kb_expected[] = "Hi 9"
static

Expected query after the SHIFT / SPACE / 123-layer / digit sequence.

Definition at line 59 of file main.c.

Referenced by main().

◆ k_kb_word

const char k_kb_word[] = "hi"
static

Lowercase letters typed (with SHIFT before the first) -> "Hi".

Definition at line 57 of file main.c.

Referenced by main().

◆ k_msg_boot

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

Definition at line 61 of file main.c.

◆ k_msg_fail

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

Definition at line 62 of file main.c.

◆ k_msg_lay

const uint8_t k_msg_lay[] = "kbd: FAIL layout\r\n"
static

Definition at line 63 of file main.c.

Referenced by main().

◆ k_msg_mid

const uint8_t k_msg_mid[] = " commit="
static

Definition at line 66 of file main.c.

◆ k_msg_miss

const uint8_t k_msg_miss[] = "kbd: FAIL mismatch\r\n"
static

Definition at line 64 of file main.c.

◆ k_msg_ok

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

Definition at line 68 of file main.c.

◆ k_msg_pre

const uint8_t k_msg_pre[] = "kbd: q="
static

Definition at line 65 of file main.c.

◆ k_msg_taps

const uint8_t k_msg_taps[] = " taps="
static

Definition at line 67 of file main.c.

Referenced by main().

◆ s_kb

ra8_kbd_layout_t s_kb
static

The laid-out keyboard (large – file-scope, not on the stack).

Definition at line 54 of file main.c.