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

Host-side keystroke FIFO implementation (see board_input.h). More...

#include "board_input.h"
#include <stdint.h>
Include dependency graph for board_input.c:

Go to the source code of this file.

Enumerations

enum  board_input_cfg_t : uint32_t { k_key_ring_cap = 64U }
 Keystroke ring geometry. More...

Functions

void board_input_push_key (char ch)
 Push one keystroke byte into the input FIFO.
bool board_input_pop_key (char *out)
 Pop the oldest buffered keystroke, if any.

Variables

static char s_ring [k_key_ring_cap]
 Keystroke ring storage.
static uint32_t s_head
 Read cursor (oldest byte).
static uint32_t s_tail
 Write cursor (next free).

Detailed Description

Host-side keystroke FIFO implementation (see board_input.h).

A fixed-size ring buffer. The window's keyDown handler and the --keys flag both push through board_input_push_key; the run loop drains via board_input_pop_key into the console UART RX. Single-threaded harness use.

Since
0.1.0

Definition in file board_input.c.

Enumeration Type Documentation

◆ board_input_cfg_t

enum board_input_cfg_t : uint32_t

Keystroke ring geometry.

Enumerator
k_key_ring_cap 

Ring capacity (one slot is the full/empty guard).

Definition at line 20 of file board_input.c.

Function Documentation

◆ board_input_pop_key()

bool board_input_pop_key ( char * out)

Pop the oldest buffered keystroke, if any.

Parameters
[out]outReceives one keystroke byte when true is returned.
Returns
true if a byte was dequeued (and consumed); false if empty / out is NULL.
Note
Not thread-safe; single-threaded harness use.
Since
0.1.0

Pop the oldest buffered keystroke, if any; this step is contained within the board input model and uses bounded caller or module-owned storage.

Return values
trueThe board input pop key condition holds or completed successfully; false otherwise.
Precondition
Arguments satisfy the ranges documented for board input pop key.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board input model and documented output objects.
Ownership of caller-supplied storage is unchanged.

Definition at line 37 of file board_input.c.

References k_key_ring_cap, s_head, s_ring, and s_tail.

Referenced by internal_run_loop_tick_inputs().

◆ board_input_push_key()

void board_input_push_key ( char ch)

Push one keystroke byte into the input FIFO.

Appends ch to the ring; on overflow the newest key is dropped (the firmware draining the FIFO is the slow consumer). Called by the window keyDown handler and by the --keys injector alike, so both reach the UART through one path.

Parameters
[in]chKeystroke byte to enqueue.
Returns
Nothing.
Note
Not thread-safe; single-threaded harness use.
Since
0.1.0
Precondition
Arguments satisfy the ranges documented for board input push key.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board input model and documented output objects.
Ownership of caller-supplied storage is unchanged.

Definition at line 28 of file board_input.c.

References k_key_ring_cap, s_head, s_ring, and s_tail.

Referenced by internal_main_feed_inputs().

Variable Documentation

◆ s_head

uint32_t s_head
static

Read cursor (oldest byte).

Definition at line 25 of file board_input.c.

Referenced by board_input_pop_key(), and board_input_push_key().

◆ s_ring

char s_ring[k_key_ring_cap]
static

Keystroke ring storage.

Definition at line 24 of file board_input.c.

Referenced by board_input_pop_key(), and board_input_push_key().

◆ s_tail

uint32_t s_tail
static

Write cursor (next free).

Definition at line 26 of file board_input.c.

Referenced by board_input_pop_key(), and board_input_push_key().