ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
board_input.c
Go to the documentation of this file.
1
14
15#include "board_input.h"
16
17#include <stdint.h>
18
20typedef enum : uint32_t {
23
24static char s_ring[k_key_ring_cap];
25static uint32_t s_head;
26static uint32_t s_tail;
27
29{
30 const uint32_t next = (s_tail + 1U) % (uint32_t)k_key_ring_cap;
31 if (next != s_head) {
32 s_ring[s_tail] = ch;
33 s_tail = next;
34 }
35}
36
37bool board_input_pop_key(char* out)
38{
39 if ((out == nullptr) || (s_head == s_tail)) {
40 return false;
41 }
42 *out = s_ring[s_head];
43 s_head = (s_head + 1U) % (uint32_t)k_key_ring_cap;
44 return true;
45}
void board_input_push_key(char ch)
Push one keystroke byte into the input FIFO.
Definition board_input.c:28
board_input_cfg_t
Keystroke ring geometry.
Definition board_input.c:20
@ k_key_ring_cap
Ring capacity (one slot is the full/empty guard).
Definition board_input.c:21
static char s_ring[k_key_ring_cap]
Keystroke ring storage.
Definition board_input.c:24
static uint32_t s_tail
Write cursor (next free).
Definition board_input.c:26
bool board_input_pop_key(char *out)
Pop the oldest buffered keystroke, if any.
Definition board_input.c:37
static uint32_t s_head
Read cursor (oldest byte).
Definition board_input.c:25
Host-side keystroke FIFO: window / CLI key source -> UART RX sink.