ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
usb_host_keyboard_steps.h
Go to the documentation of this file.
1
34
35#pragma once
36
37#include <stdint.h>
38
39#include "ra8_err.h"
40
41#ifndef RA8_OFF_TARGET
42#include "tx_api.h"
43#endif
44
45/* -------------------------------------------------------------------------- */
46/* Shared compile-time constants */
47/* -------------------------------------------------------------------------- */
48
65
77
82typedef enum : uint32_t {
86
108
113typedef enum : uint8_t {
114 k_hid_kc_a = 0x04U,
115 k_hid_kc_z = 0x1DU,
116 k_hid_kc_1 = 0x1EU,
117 k_hid_kc_0 = 0x27U,
118 k_hid_kc_r = 0x15U,
119 k_hid_kc_8 = 0x25U,
120 k_hid_kc_d = 0x07U,
121 k_hid_kc_2 = 0x1FU,
123
124#ifndef RA8_OFF_TARGET
125
126/* -------------------------------------------------------------------------- */
127/* Shared mutable state (defined once in main.c) */
128/* -------------------------------------------------------------------------- */
129
139extern TX_SEMAPHORE s_usb_host_keyboard_hid_active_sem;
140
141/* -------------------------------------------------------------------------- */
142/* Shared HID report pattern */
143/* -------------------------------------------------------------------------- */
144
163void hid_fill_report_body(uint8_t* out, uint32_t len);
164
165/* -------------------------------------------------------------------------- */
166/* Device side: USBX HID interrupt-IN reports */
167/* -------------------------------------------------------------------------- */
168
187VOID hid_device_worker(ULONG arg);
188
205
206/* -------------------------------------------------------------------------- */
207/* Console helpers (SCI8 -> J-Link OB CDC) */
208/* -------------------------------------------------------------------------- */
209
225uint8_t hid_nibble_to_hex(uint32_t nibble);
226
242uint32_t hid_str_len(const char* text);
243
260[[nodiscard]] ra8_err_t hid_sci_write(const uint8_t* data, uint32_t len);
261
277[[nodiscard]] ra8_err_t hid_print(const char* text);
278
294[[nodiscard]] ra8_err_t hid_print_dec(uint32_t value);
295
312[[nodiscard]] ra8_err_t hid_print_hex(uint32_t value, uint8_t digits);
313
330[[nodiscard]] ra8_err_t hid_print_fail(const char* what, ra8_err_t err);
331
332#endif /* !RA8_OFF_TARGET */
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
void usb_host_keyboard_device_thread_create(void)
Create + auto-start the USBX HID device worker thread.
VOID hid_device_worker(ULONG arg)
Device-side worker: bring the HID device up, then send reports.
ra8_err_t hid_print(const char *text)
Print a NUL-terminated ASCII string over the console.
ra8_err_t hid_print_fail(const char *what, ra8_err_t err)
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
ra8_err_t hid_print_hex(uint32_t value, uint8_t digits)
Print a value as fixed-width uppercase hex.
uint8_t hid_nibble_to_hex(uint32_t nibble)
Format one nibble (0..15) into an uppercase hex character.
hid_hex_t
Hex/decimal text-formatter sizing constants.
@ k_hid_dec_chars_u32
Max digits for a 32-bit count.
@ k_hid_hex_chars_u32
32-bit value -> "ABCDEF01".
@ k_hid_nibble_bits
Bits per hex nibble.
@ k_hid_hex_chars_u16
16-bit value -> "ABCD".
@ k_hid_hex_digit_split
Threshold between '0-9'/'A-F'.
void hid_fill_report_body(uint8_t *out, uint32_t len)
Fill the fixed body of a HID report (bytes 1..len-1).
ra8_err_t hid_print_dec(uint32_t value)
Print a uint32_t as ASCII decimal.
hid_geom_t
HID report + interrupt-pipe + pattern constants.
@ k_hid_report_len
Vendor input report width (bytes).
@ k_hid_ep_in_num
Device interrupt-IN endpoint num.
@ k_hid_rounds
Reports the host reads + checks.
@ k_hid_pat_bias
Pattern constant bias.
@ k_hid_pipe_in
Host pipe for the device IN.
@ k_hid_nkeys
Keycodes typed ("RA8D2").
@ k_hid_pat_idx_mul
Per-index pattern multiplier.
@ k_hid_mps
Interrupt endpoint wMaxPacketSize.
@ k_hid_no_mismatch
Probe: no mismatch.
@ k_hid_read_buf
One-MPS receive buffer (bytes).
@ k_hid_dev_addr
Address the host assigns.
@ k_hid_key0_idx
Boot-keyboard first-keycode byte.
@ k_hid_body_idx
Report body starts at byte 1.
@ k_hid_byte_mask
Byte mask.
@ k_hid_seq_idx
Report byte 0: modifier / rolling seq.
uint32_t hid_str_len(const char *text)
Bounded ASCII string length (cap k_hid_print_cap).
hid_keycode_t
HID Usage-Table keycode ranges for decoding keycodes back to ASCII.
@ k_hid_kc_a
Keycode for 'a' / 'A'.
@ k_hid_kc_d
Keycode for 'd' / 'D'.
@ k_hid_kc_r
Keycode for 'r' / 'R'.
@ k_hid_kc_z
Keycode for 'z' / 'Z'.
@ k_hid_kc_1
Keycode for '1'.
@ k_hid_kc_0
Keycode for '0' (top of digits).
@ k_hid_kc_8
Keycode for '8'.
@ k_hid_kc_2
Keycode for '2'.
TX_SEMAPHORE s_usb_host_keyboard_hid_active_sem
Activation semaphore shared by the device worker and main.c.
Definition main.c:163
ra8_err_t hid_sci_write(const uint8_t *data, uint32_t len)
Push a literal block over SCI8 polled.
hid_mask_t
Bit-mask constants used by the text formatters.
@ k_hid_dec_radix
Base for decimal conversion.
@ k_hid_nibble_mask
4-bit nibble mask.
hid_config_t
Compile-time settings: threads, pool, console, cadence.
@ k_hid_print_cap
Bound for console-string scans.
@ k_hid_thread_stack
Device worker stack (bytes).
@ k_hid_idle_ticks
Parked-loop back-off (ticks).
@ k_hid_usbx_pool_bytes
USBX memory pool (bytes).
@ k_hid_host_stack
Host worker stack (bytes).
@ k_hid_host_priority
Host worker priority (below USBX).
@ k_hid_retry_ticks
Pause between ladder retries.
@ k_hid_baud
J-Link OB CDC log baud.
@ k_hid_boot_wait_ticks
Host start delay (1 ms ticks).
@ k_hid_dev_priority
Device bring-up worker priority.