|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Shared contract for the USB HID self-loop console + host clusters. More...
Go to the source code of this file.
Enumerations | |
| enum | hid_config_t : uint32_t { k_hid_thread_stack = 4096U , k_hid_host_stack = 8192U , k_hid_usbx_pool_bytes = 32768U , k_hid_idle_ticks = 50U , k_hid_boot_wait_ticks = 500U , k_hid_retry_ticks = 3000U , k_hid_baud = 115200U , k_hid_print_cap = 160U , k_hid_dev_priority = 8U , k_hid_host_priority = 24U } |
| Compile-time settings: threads, pool, console, cadence. More... | |
| enum | hid_hex_t : uint8_t { k_hid_hex_chars_u16 = 4U , k_hid_hex_chars_u32 = 8U , k_hid_dec_chars_u32 = 10U , k_hid_nibble_bits = 4U , k_hid_hex_digit_split = 10U } |
| Hex/decimal text-formatter sizing constants. More... | |
| enum | hid_geom_t : uint32_t { k_hid_mps = 64U , k_hid_report_len = 8U , k_hid_rounds = 8U , k_hid_read_buf = 64U , k_hid_dev_addr = 1U , k_hid_ep_in_num = 1U , k_hid_pipe_in = 1U , k_hid_seq_idx = 0U , k_hid_body_idx = 1U , k_hid_no_mismatch = 0xFFFFFFFFU , k_hid_pat_idx_mul = 7U , k_hid_pat_bias = 0x5AU , k_hid_byte_mask = 0xFFU } |
| HID report + interrupt-pipe + pattern constants. More... | |
Functions | |
| 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 (const char *text) |
| Print a NUL-terminated ASCII string over the console. | |
| ra8_err_t | hid_print_dec (uint32_t value) |
| Print a uint32_t as ASCII decimal. | |
| ra8_err_t | hid_print_hex (uint32_t value, uint8_t digits) |
| Print a value as fixed-width uppercase hex. | |
| ra8_err_t | hid_print_fail (const char *what, ra8_err_t err) |
| Print "FAIL <what> err=0xNNNNNNNN" on its own line. | |
| VOID | hid_host_worker (ULONG arg) |
| Host-side worker: retry the full pass until it succeeds. | |
Shared contract for the USB HID self-loop console + host clusters.
The usb_selftest_hid application is split across three translation units to keep every file under the source-size cap:
This header is the seam between those units. It carries the compile-time constant enums shared across the three TUs, the console-formatter prototypes, the shared report-pattern helper, and the host worker entry.
Definition in file usb_selftest_hid_steps.h.
| enum hid_config_t : uint32_t |
Compile-time settings: threads, pool, console, cadence.
Definition at line 44 of file usb_selftest_hid_steps.h.
| enum hid_geom_t : uint32_t |
HID report + interrupt-pipe + pattern constants.
Definition at line 73 of file usb_selftest_hid_steps.h.
| enum hid_hex_t : uint8_t |
Hex/decimal text-formatter sizing constants.
Definition at line 61 of file usb_selftest_hid_steps.h.
| void hid_fill_report_body | ( | uint8_t * | out, |
| uint32_t | len ) |
Fill the fixed body of a HID report (bytes 1..len-1).
Body byte i = (i*7 + 0x5A) & 0xFF, independent of the report sequence. Byte 0 (the seq) is left untouched – the device stamps it with a rolling counter and the host ignores it for the pattern check. Both the device (to build) and the host (to verify) compute the same body.
| [out] | out | Report buffer. |
| [in] | len | Report width in bytes (>= 1). |
out has len writable bytes. len is at most k_hid_read_buf. out[1..len-1] hold the fixed pattern bytes. out[0] is unchanged.Boot-keyboard report: byte 1 = reserved, bytes 2.. = the typed "RA8D2" keycodes, the remainder 0. Byte 0 (the seq) is left untouched. Both the device (to build) and the host (to verify) compute the same body.
| [out] | out | Report buffer. |
| [in] | len | Report width in bytes (>= 1). |
out has len writable bytes. len is at most k_hid_read_buf. out[1..len-1] hold the fixed pattern bytes. out[0] is unchanged.Fill the fixed body of a HID report (bytes 1..len-1).
Definition at line 302 of file usb_host_keyboard_device.c.
References k_hid_body_idx, k_hid_byte_mask, k_hid_pat_bias, and k_hid_pat_idx_mul.
Referenced by hid_get_callback(), and hid_send_iter().
| VOID hid_host_worker | ( | ULONG | arg | ) |
Host-side worker: retry the full pass until it succeeds.
Waits for the device side to attach, then loops the full host pass with a retry pause until every report round verifies; afterwards parks so the verdict stays on the wire.
| [in] | arg | ThreadX entry argument (unused). |
Definition at line 502 of file usb_selftest_hid_host.c.
References hid_host_pass(), k_hid_boot_wait_ticks, k_hid_idle_ticks, k_hid_retry_ticks, k_ra8_ok, and tx_thread_sleep.
|
nodiscard |
Print a NUL-terminated ASCII string over the console.
Length-bounded by the console-string cap.
| [in] | text | String to print (CR/LF included by the caller). |
| k_ra8_ok | All bytes queued. |
text is non-NULL. text is NUL-terminated within k_hid_print_cap bytes. | [in] | text | String to print (CR/LF included by the caller). |
| k_ra8_ok | All bytes queued. |
text is non-NULL. text is NUL-terminated within k_hid_print_cap bytes. Definition at line 56 of file usb_host_keyboard_console.c.
References hid_sci_write(), and hid_str_len().
Referenced by hid_print_fail().
|
nodiscard |
Print a uint32_t as ASCII decimal.
Digit-reversal into a bounded scratch buffer.
| [in] | value | Value to print. |
| k_ra8_ok | All bytes queued. |
| [in] | value | Value to print. |
| k_ra8_ok | All bytes queued. |
Definition at line 61 of file usb_host_keyboard_console.c.
References hid_sci_write(), k_hid_dec_chars_u32, and k_hid_dec_radix.
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
One-line diagnostic; first failing chunk's code returned.
| [in] | what | Short description of the failed step. |
| [in] | err | Error code returned by the step. |
| k_ra8_ok | The diagnostic line is queued. |
what is NUL-terminated within the print cap. | [in] | what | Short description of the failed step. |
| [in] | err | Error code returned by the step. |
| k_ra8_ok | The diagnostic line is queued. |
what is NUL-terminated within the print cap. Definition at line 99 of file usb_host_keyboard_console.c.
References hid_print(), hid_print_hex(), k_hid_hex_chars_u32, and k_ra8_ok.
|
nodiscard |
Print a value as fixed-width uppercase hex.
Width is clamped to 8 hex digits.
| [in] | value | Value to print. |
| [in] | digits | Hex digit count (4 for u16, 8 for u32). |
| k_ra8_ok | All bytes queued. |
digits is at most k_hid_hex_chars_u32. | [in] | value | Value to print. |
| [in] | digits | Hex digit count (4 for u16, 8 for u32). |
| k_ra8_ok | All bytes queued. |
digits is at most k_hid_hex_chars_u32. Definition at line 85 of file usb_host_keyboard_console.c.
References hid_nibble_to_hex(), hid_sci_write(), k_hid_hex_chars_u32, k_hid_nibble_bits, and k_hid_nibble_mask.
Referenced by hid_print_fail().