112 (void)snprintf(line,
sizeof(line),
"%s: %u byte(s)", label, n);
198 if ((data ==
nullptr) || (len == 0U)) {
233 return "CONFIGURED (HID active)";
235 return "CONFIGURED (MSC active)";
237 return "CONFIGURED (CDC-ACM active)";
239 return "CONFIGURED (Printer active)";
241 return "CONFIGURED (Vendor active)";
258 for (uint32_t i = 0U; i <
s_log_n; i++) {
264 (void)
priv_emu_io_errf(
" USB: enumeration INCOMPLETE (device did not reach CONFIGURED)\n");
267 (void)
priv_emu_io_errf(
" USB HID : %u mouse report(s), cursor (%d,%d) buttons 0x%02X\n",
275 " USB MSC : capacity %u blocks x %uB, INQUIRY %s, sector read %u byte(s)\n",
282 (void)
priv_emu_io_errf(
" USB CDC echo : sent %u byte(s) OUT, read %u byte(s) IN\n",
288 " USB self-loop : fw host drove %u SETUP(s), %u bulk-OUT, %u bulk-IN pkt(s)\n",
Multi-channel console log store backing the board view's tabbed console.
void board_console_push(board_console_ch_t ch, const char *line)
Append one completed line to a channel ring and the ALL ring.
@ k_board_console_ch_usb
USBFS transfer / enumeration summaries.
static char s_log[k_usb_log_cap][k_usb_log_width]
void board_usb_feed_bulk_in(const uint8_t *data, uint32_t len)
Queue host->device bulk bytes for the CDC data OUT pipe (echo test).
void board_usb_report(void)
Print the USB section of the end-of-run summary.
uint32_t board_usb_echo_received(void)
Number of bulk bytes the host has read back as the device's echo.
void board_usb_tick(uc_engine *uc)
Advance the virtual USB host one emulation chunk.
void board_usb_init(bool trace)
Reset the USBFS controller model and the virtual host state machine.
const char * board_usb_state_string(void)
One-line, human-readable USB device state for the board view.
static const char * internal_usb_dvsq_name(uint16_t dvsq)
Print the device-state name for the report line.
bool board_usb_configured(void)
Report whether enumeration reached the CONFIGURED state.
void priv_usb_log_line(const char *msg)
Append one already-formatted line to the enumeration-step log.
void board_usb_set_irq_raiser(board_usb_irq_raiser_t raise)
Install the ICU event-raise hook used to pend the USBFS interrupt.
void priv_usb_log_count(const char *label, unsigned n)
Append a "<label>: <n> byte(s)"-style line built from one count.
USBFS controller model + a virtual USB host for the board emulator.
void(* board_usb_irq_raiser_t)(uc_engine *uc, uint16_t event)
Signature of the ICU event-raise hook board_periph installs.
Module-private state + interfaces shared by the board_usb TUs.
uint32_t s_msc_blocks
MSC capacity in blocks (vhost).
uint32_t s_loop_bulk_in_pkts
Bulk-IN packets (loop).
uint32_t s_loop_setups
SETUPs from the fw host (loop).
uint8_t s_dcp_hold[k_usb_in_cap]
Held control-OUT bytes (core).
@ k_sub_deliver
Latch the SETUP + raise CTRT.
bool s_external_host
Bridge host owns the bus (core).
usb_host_phase_t
Host state-machine phases.
@ k_phase_reset
Holding bus reset; device re-arms its DCP.
@ k_phase_done
Terminal idle.
@ k_phase_idle
Waiting for the device pull-up (DPRPU).
@ k_phase_configured
Device configured; optional bulk echo.
@ k_phase_setup
Walking the enumeration script.
usb_state_t s_usb
Controller + FIFO state (core).
uint32_t s_loop_bulk_out_pkts
Bulk-OUT packets (loop).
uint8_t s_host_substate
Per-step sub-state (core).
int32_t s_hid_cy
Accumulated HID mouse Y (vhost).
uint32_t s_echo_in_got
Echoed bytes read back (core).
uint8_t s_host_step
Enumeration-script index (core).
uint32_t s_host_wait
Sub-state wait ticks (core).
uint32_t s_msc_block_len
MSC block size (vhost).
uint8_t s_dev_class
Detected device class (vhost).
uint8_t s_echo_out[k_usb_echo_cap]
Host bulk-OUT payload (core).
uint8_t s_host_phase
Virtual-host phase (core).
void priv_host_run_configured_phase(uc_engine *uc)
Virtual-host phase driver: post-CONFIGURED class traffic (vhost).
void priv_bridge_pump_device(uc_engine *uc)
Pump the device's level-triggered DCP-OUT receive (bridge).
void priv_host_run_setup_phase(uc_engine *uc)
Virtual-host phase driver: walking the enumeration script (vhost).
@ k_usb_echo_cap
Bulk echo staging capacity.
@ k_usb_in_cap
DCP/bulk IN staging cap (multi-MPS).
uint32_t s_msc_read_ok
MSC read data bytes (vhost).
const char * priv_usb_class_active_str(void)
Human label of the detected class + live traffic totals (vhost).
int32_t s_hid_cx
Accumulated HID mouse X (vhost).
usb_dev_class_t
USB device class the host detected from the interface descriptor.
@ k_usb_class_printer
Printer (7/1/x), issue #265.
@ k_usb_class_cdc
CDC-ACM (virtual serial).
@ k_usb_class_hid
HID (boot mouse / keyboard).
@ k_usb_class_msc
Mass storage (BOT/SCSI).
@ k_usb_class_unknown
Not yet detected.
@ k_usb_class_vendor
Vendor specific (0xFF).
void priv_host_echo_read_in(uc_engine *uc)
Drain any device bulk-IN data the virtual host is owed (vhost).
uint32_t s_usb_irqs
USB interrupts raised (core).
bool s_dcp_hold_pending
Held bytes await the arm (core).
bool s_msc_inquiry_ok
MSC INQUIRY completed (vhost).
@ k_usb_log_width
Bytes per enumeration-step log line.
@ k_usb_log_cap
Enumeration-step log capacity.
void priv_host_run_idle_phase(uc_engine *uc)
Virtual-host phase driver: waiting for the device pull-up (vhost).
uint16_t s_dcp_hold_len
Held byte count (core).
uint32_t s_hid_reports
HID reports read (vhost).
uint32_t s_echo_out_len
Bytes queued by –usb-in (core).
bool s_loop_latched
Firmware host owns the bus (loop).
bool s_roles_swapped
Self-loop role polarity (core).
uint16_t g_dev_irq_event
Device ICU event number (core).
uint8_t s_hid_buttons
Last HID button bitmap (vhost).
board_usb_irq_raiser_t s_raise
ICU pend callback (core).
void priv_host_run_reset_phase(uc_engine *uc)
Virtual-host phase driver: holding bus reset (vhost).
uint32_t s_echo_out_sent
Bytes delivered to device (core).
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
static volatile bool s_configured
Latched true once the host drives the device to CONFIGURED.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Event Link Controller (ELC) register layout for the Renesas RA8D2.
@ k_ra8_elc_event_usbfs_int
USBFS controller interrupt.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
@ k_ra8_intsts0_mask_dvsq
Device state.
@ k_ra8_dvsq_address
Address assigned.
@ k_ra8_dvsq_default
Default (post bus reset).
@ k_ra8_dvsq_configured
Configured.
@ k_ra8_dvsq_powered
Powered (no reset yet).
Aggregate USBFS controller + virtual-host model state.
static volatile uint32_t s_trace[k_dcd_trace_entries]
JLink-readable ring of packed transfer/SETUP events.