45typedef enum : uint32_t {
78typedef enum : uint16_t {
95typedef enum : uint32_t {
180 for (uint8_t attempt = 0U; attempt < (uint8_t)
k_hid_enum_tries; attempt++) {
381 return hid_print(
" reports verified -- USB SELFTEST HID PASS\r\n");
483 for (uint32_t r = 0U; r < (uint32_t)
k_hid_rounds; r++) {
static volatile uint32_t s_dbg_pid
Device-reported product id captured at enumeration.
hid_phase_t
J-Link probe values marking host-ladder progress.
@ k_hid_phase_enum
Enumerating.
@ k_hid_phase_boot
Host thread not started.
@ k_hid_phase_pass
All reports verified.
@ k_hid_phase_verify
Reading + checking reports.
@ k_hid_phase_init
Host controller init.
static volatile uint32_t s_dbg_last_seq
Seq byte of the most recent report the host read back.
hid_usb_req_t
Standard chapter-9 request / descriptor constants for the host.
@ k_hid_desc_device
DEVICE descriptor type.
@ k_hid_dev_desc_len
DEVICE descriptor length.
@ k_hid_bm_std_dev_out
bmRequestType: Std | Device | Out.
@ k_hid_config_value
bConfigurationValue to select.
@ k_hid_byte_bits
Bits per byte.
@ k_hid_off_dev_pid
idProduct LSB byte offset.
@ k_hid_breq_set_config
SET_CONFIGURATION.
@ k_hid_bm_std_dev_in
bmRequestType: Std | Device | In.
@ k_hid_breq_set_addr
SET_ADDRESS.
@ k_hid_breq_get_desc
GET_DESCRIPTOR.
hid_enum_tune_t
Timing / retry tunables for the polled enumeration ladder.
@ k_hid_enum_tries
Reset+probe attempts.
@ k_hid_vbus_settle_ms
VBUS settle before probing.
@ k_hid_recovery_ms
Post-reset recovery (TRSTRCY).
@ k_hid_addr_settle_ms
Post-SET_ADDRESS recovery.
@ k_hid_reset_hold_ms
USB bus-reset hold (>=10 ms).
@ k_hid_attach_spin
Attach spin cap (frozen-tick guard).
@ k_hid_attach_to_ms
Wait for the D+ pull-up.
@ k_hid_debounce_ms
Post-attach debounce (>=100 ms).
static volatile uint32_t s_dbg_rounds_ok
Reports the host confirmed pattern-equal (expect k_hid_rounds).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
SysTick-based tick counter, delay and timestamp helpers.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
uint32_t ra8_time_ms(void)
Get the current 1 kHz tick count.
Native USB controller driver public API (device + host modes).
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
ra8_err_t ra8_usb_host_bus_reset(ra8_usb_speed_t speed, bool assert_reset)
Drive (or release) the bus reset line.
uint16_t ra8_usb_host_line_state(ra8_usb_speed_t speed)
Read the host port's D+/D- line state (SYSSTS0.LNST).
ra8_err_t ra8_usb_host_pipe_setup(ra8_usb_speed_t speed, uint8_t pipe_num, uint8_t dev_addr, uint8_t ep_num, bool device_to_host, uint16_t max_packet)
Configure a controller pipe against an attached device's bulk endpoint.
ra8_err_t ra8_usb_host_bulk_in(ra8_usb_speed_t speed, uint8_t pipe_num, uint8_t *buf, uint16_t max_len, uint16_t *out_received)
Receive a bulk transfer from the device into buf.
ra8_err_t ra8_usb_host_init(ra8_usb_speed_t speed)
Bring up a USB controller in HOST mode.
ra8_err_t ra8_usb_host_deinit(ra8_usb_speed_t speed)
Tear down a host-mode controller and drop its MSTP reference.
ra8_err_t ra8_usb_host_control_xfer(ra8_usb_speed_t speed, const ra8_usb_setup_t *setup, uint8_t *data, uint16_t data_len, uint16_t *out_received)
Run a complete host control transfer (SETUP, optional DATA, STATUS).
ra8_err_t ra8_usb_host_set_uact(ra8_usb_speed_t speed, bool enable)
Enable / disable SOF (Start-of-Frame) generation on the bus.
ra8_err_t ra8_usb_host_set_target(ra8_usb_speed_t speed, uint8_t dev_addr)
Retarget the host's default control pipe at a device address.
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Decoded 8-byte USB SETUP packet.
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.
@ k_hid_hex_chars_u16
16-bit value -> "ABCD".
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.
@ 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_pipe_in
Host pipe for the device IN.
@ 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_body_idx
Report body starts at byte 1.
@ k_hid_seq_idx
Report byte 0: modifier / rolling seq.
@ k_hid_idle_ticks
Parked-loop back-off (ticks).
@ k_hid_retry_ticks
Pause between ladder retries.
@ k_hid_boot_wait_ticks
Host start delay (1 ms ticks).
static ra8_err_t hid_read_round(uint32_t round)
One report round: read an interrupt-IN report, check its body.
VOID hid_host_worker(ULONG arg)
Host-side worker: retry the full pass until it succeeds.
static ra8_err_t hid_print_enum(uint32_t pid)
Print "enumerated pid=0xNNNN" for the looped device.
static ra8_err_t hid_enum_hunt(uint8_t *desc)
Wait for the device to attach, then bus-reset + read its descriptor.
static ra8_err_t hid_enumerate(uint32_t *out_pid)
Run the full enumeration ladder and open the bulk pipes.
static ra8_err_t hid_print_pass(void)
Print "N reports verified -- USB SELFTEST HID PASS".
static ra8_err_t hid_open_pipes(void)
Open the host receive pipe for the device's HID interrupt-IN endpoint.
static ra8_err_t hid_enum_set_address(void)
SET_ADDRESS to k_hid_dev_addr, then retarget the DCP.
static ra8_err_t hid_enum_set_config(void)
SET_CONFIGURATION(::k_hid_config_value) on the addressed device.
static ra8_err_t hid_host_pass(void)
One full host-side pass: enumerate, then read + check reports.
static ra8_err_t hid_ctrl_get_dev_desc(uint8_t *desc)
GET_DESCRIPTOR(DEVICE) over the polled control engine.
Shared contract for the USB HID self-loop console + host clusters.
static volatile uint32_t s_dbg_phase
Host-ladder phase marker (wlun_phase_t).
static volatile uint32_t s_dbg_pass_count
Completed full passes (sticky success counter).
static volatile uint32_t s_dbg_mismatch
First mismatching sector, or k_wlun_no_mismatch.