38#include "ux_device_class_hid.h"
39#include "ux_device_stack.h"
49typedef enum : uint32_t {
58typedef enum : uint8_t {
310 for (uint32_t i = 0U; i < (uint32_t)
k_hid_nkeys; i++) {
343 if (_ux_system_slave != UX_NULL) {
344 _ux_system_slave->ux_system_slave_device.ux_slave_device_state =
345 (
unsigned long)UX_DEVICE_CONFIGURED;
394 return _ux_device_stack_initialize((UCHAR*)UX_NULL,
430 hid_event->ux_device_class_hid_event_report_id = 0UL;
431 hid_event->ux_device_class_hid_event_report_type = (
ULONG)UX_DEVICE_CLASS_HID_REPORT_TYPE_INPUT;
433 hid_event->ux_device_class_hid_event_buffer[
k_hid_seq_idx] = 0U;
457 UX_SLAVE_CLASS_HID_PARAMETER hid_params = {
461 .ux_device_class_hid_parameter_report_id = 0UL,
463 .ux_device_class_hid_parameter_callback = UX_NULL,
466 static UCHAR s_class_name[] =
"ux_slave_class_hid";
468 return _ux_device_stack_class_register(s_class_name,
469 _ux_device_class_hid_entry,
496 if (_ux_system_slave != UX_NULL) {
497 _ux_system_slave->ux_system_slave_device.ux_slave_device_state =
498 (
unsigned long)UX_DEVICE_CONFIGURED;
500 UX_SLAVE_CLASS_HID_EVENT ev;
501 (void)
memset(&ev, 0,
sizeof(ev));
503 ev.ux_device_class_hid_event_report_id = 0UL;
504 ev.ux_device_class_hid_event_report_type = (
ULONG)UX_DEVICE_CLASS_HID_REPORT_TYPE_INPUT;
507 if (_ux_device_class_hid_event_set(
s_hid_class, &ev) == UX_SUCCESS) {
520 if (ux != UX_SUCCESS) {
526 if (ux != UX_SUCCESS) {
static TX_THREAD s_device_thread
ThreadX TCB for the USBX device-side worker thread.
static UCHAR s_string_framework[]
USBX string descriptor table (vendor / product / serial).
static UCHAR s_usbx_pool[k_wlun_usbx_pool_bytes]
USBX memory pool (USBX uses tx_byte_pool internally).
@ k_usb_langid_en_us_lo
LANGID 0x0409 low byte.
@ k_usb_langid_en_us_hi
LANGID 0x0409 high byte.
static UCHAR s_device_framework_fs[]
static UCHAR s_language_id_framework[]
USBX language-id table – US English.
static UCHAR s_device_stack[k_wlun_thread_stack]
Stack backing storage for s_device_thread.
static volatile uint32_t s_dbg_dev_step
Device worker progress: 1 stack, 2 class, 3 dcd, 4 attach, 5 parked.
static volatile uint32_t s_dbg_dev_err
Device worker first failing return code (0 = none).
static CHAR s_device_thread_name[]
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
Native USB controller driver public API (device + host modes).
ra8_err_t ra8_usb_device_attach(ra8_usb_speed_t speed, bool attached)
Raise / drop the D+ pull-up to advertise the device to the host.
@ k_ra8_usb_speed_fs
Full-Speed controller (USBFS @ 0x40250000).
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
char CHAR
ThreadX-compatible CHAR (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.
void usb_host_keyboard_device_thread_create(void)
Create + auto-start the USBX HID device worker thread.
static const uint8_t s_kbd_keys[k_hid_nkeys]
Keycodes the fake keyboard "types": R, A, 8, D, 2.
VOID hid_device_worker(ULONG arg)
Device-side worker: bring the HID device up, then send reports.
hid_dev_step_t
J-Link probe values marking device-worker bring-up progress.
@ k_hid_dev_step_stack
USBX system + device stack up.
@ k_hid_dev_step_dcd
DCD bridge initialized.
@ k_hid_dev_step_send
Report-send loop running.
@ k_hid_dev_step_attach
Device attached (DPRPU).
@ k_hid_dev_step_class
HID class registered.
static VOID hid_activate(VOID *hid_instance)
HID activate callback.
void hid_fill_report_body(uint8_t *out, uint32_t len)
Fill the fixed body of a HID report (bytes 1..len-1).
static UINT hid_class_register(void)
Register the HID class against configuration 1, interface 0.
static VOID hid_deactivate(VOID *hid_instance)
HID deactivate callback.
static UINT hid_usbx_stack_up(void)
Bring USBX system + device stack up with the HID framework.
static UCHAR s_report_descriptor[]
static void hid_send_iter(uint32_t *seq)
One device send iteration: queue a fresh input report.
static volatile uint32_t s_dbg_dev_sent
Device-side report-queue successes (one hid_event_set each).
static UINT hid_get_callback(UX_SLAVE_CLASS_HID *hid, UX_SLAVE_CLASS_HID_EVENT *hid_event)
HID GET_REPORT control-pipe callback: hand back a neutral report.
static UX_SLAVE_CLASS_HID * s_hid_class
Active HID class instance, captured by the activate callback.
Shared seam between usb_host_keyboard main.c and its sibling TUs.
VOID hid_device_worker(ULONG arg)
Device-side worker: bring the HID device up, then send reports.
@ k_hid_report_len
Vendor input report width (bytes).
@ k_hid_nkeys
Keycodes typed ("RA8D2").
@ 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.
@ 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_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.
@ k_hid_thread_stack
Device worker stack (bytes).
@ k_hid_usbx_pool_bytes
USBX memory pool (bytes).
@ k_hid_dev_priority
Device bring-up worker priority.
USBX device-controller-driver (DCD) bridge to ra8_usb.
ra8_err_t ux_dcd_ra8_usb_initialize(ra8_usb_speed_t speed)
Register the ra8_usb bridge as the active USBX DCD.