105typedef enum : uint16_t {
119typedef enum : uint32_t {
161 for (uint32_t i = 0U; i < len; i++) {
226 for (uint8_t attempt = 0U; attempt < (uint8_t)
k_ns_enum_tries; attempt++) {
static ra8_err_t ns_host_enum_hunt(uint8_t *desc)
Wait for attach, then bus-reset + read the device descriptor.
volatile uint32_t g_tz_usb_host_pid
idProduct the HS host read from the looped FS device (expect 0x000A).
volatile uint32_t g_tz_usb_host_err
First non-OK ra8_err_t from the host ladder (0 = none yet).
volatile uint32_t g_tz_usb_host_phase
HS-host ladder phase: 0 boot, 1 host-init, 2 enumerating, 3 echoing, 4 first full pass done.
static ra8_err_t ns_host_open_pipes(void)
Open the host bulk pipes for the device's CDC data endpoints.
static ra8_err_t ns_host_set_address(void)
SET_ADDRESS to k_ns_dev_addr, then retarget the DCP.
VOID ns_host_worker(ULONG arg)
HS host worker – enumerate the looped FS device, then echo forever.
static void ns_host_pattern_fill(uint32_t round, uint8_t *out, uint32_t len)
Fill an echo payload with this round's deterministic bytes.
static ra8_err_t ns_host_echo_round(uint32_t round)
One echo round: bulk-OUT a pattern, bulk-IN the echo, compare.
static ra8_err_t ns_host_enumerate(uint32_t *out_pid)
Full enumeration ladder: hunt, SET_ADDRESS, SET_CONFIG, open pipes.
ns_host_tune_t
Host enumeration timing / retry / geometry tunables.
@ k_ns_ep_in_num
Device bulk-IN endpoint number.
@ k_ns_pat_round_mul
Per-round pattern multiplier.
@ k_ns_attach_spin
Attach spin cap (frozen-tick guard).
@ k_ns_boot_wait_tk
Host start delay (ticks).
@ k_ns_addr_settle_ms
Post-SET_ADDRESS recovery.
@ k_ns_payload
Bytes per echo round (sub-MPS).
@ k_ns_host_pipe_out
Host pipe for the device bulk-OUT.
@ k_ns_mps
Bulk endpoint wMaxPacketSize (FS).
@ k_ns_attach_to_ms
Wait for the D+ pull-up.
@ k_ns_byte_mask
Byte mask.
@ k_ns_reset_hold_ms
USB bus-reset hold (>=10 ms).
@ k_ns_pat_idx_mul
Per-index pattern multiplier.
@ k_ns_vbus_settle_ms
VBUS settle before probing.
@ k_ns_enum_tries
Reset+probe attempts.
@ k_ns_host_pipe_in
Host pipe for the device bulk-IN.
@ k_ns_retry_tk
Pause between failed enum passes.
@ k_ns_debounce_ms
Post-attach debounce (>=100 ms).
@ k_ns_ep_out_num
Device bulk-OUT endpoint number.
@ k_ns_pat_bias
Pattern constant bias.
@ k_ns_dev_addr
Address the host assigns.
@ k_ns_echo_buf
One-MPS host scratch buffer.
@ k_ns_recovery_ms
Post-reset recovery (TRSTRCY).
ns_host_req_t
Chapter-9 standard request / descriptor constants for the host.
@ k_ns_dev_desc_len
DEVICE descriptor length.
@ k_ns_breq_set_config
SET_CONFIGURATION.
@ k_ns_breq_get_desc
GET_DESCRIPTOR.
@ k_ns_bm_std_dev_out
bmRequestType: Std | Device | Out.
@ k_ns_breq_set_addr
SET_ADDRESS.
@ k_ns_desc_device
DEVICE descriptor type.
@ k_ns_bm_std_dev_in
bmRequestType: Std | Device | In.
@ k_ns_off_dev_pid
idProduct LSB byte offset.
@ k_ns_config_value
bConfigurationValue to select.
@ k_ns_byte_bits
Bits per byte.
static ra8_err_t ns_host_set_config(void)
SET_CONFIGURATION(::k_ns_config_value) on the addressed device.
volatile uint32_t g_tz_usb_host_rounds_ok
Bulk echo rounds the HS host has verified byte-equal (advances forever once the loop is healthy – the...
static ra8_err_t ns_host_get_dev_desc(uint8_t *desc)
GET_DESCRIPTOR(DEVICE) over the polled host control engine.
Private split-seam shared between ns_usb.c and ns_usb_host.c (#96).
TX_THREAD s_ns_host_thread
ThreadX TCB for the HS host worker (defined in ns_usb_host.c).
CHAR s_ns_host_thread_name[]
HS host worker thread name (defined in ns_usb_host.c; ThreadX CHAR*).
@ k_ns_host_stack_bytes
HS host worker stack (bytes).
UCHAR s_ns_host_stack[k_ns_host_stack_bytes]
Stack backing storage for s_ns_host_thread (defined in ns_usb_host.c).
@ 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.
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_bulk_out(ra8_usb_speed_t speed, uint8_t pipe_num, const uint8_t *data, uint16_t len)
Transmit one bulk packet to the device and wait for the ACK.
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.
char CHAR
ThreadX-compatible CHAR (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.
Decoded 8-byte USB SETUP packet.