|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Shared seam between usb_host_keyboard main.c and its sibling TUs. 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_mask_t : uint32_t { k_hid_nibble_mask = 0xFU , k_hid_dec_radix = 10U } |
| Bit-mask constants used by the text formatters. 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 , k_hid_key0_idx = 2U , k_hid_nkeys = 5U } |
| HID report + interrupt-pipe + pattern constants. More... | |
| enum | hid_keycode_t : uint8_t { k_hid_kc_a = 0x04U , k_hid_kc_z = 0x1DU , k_hid_kc_1 = 0x1EU , k_hid_kc_0 = 0x27U , k_hid_kc_r = 0x15U , k_hid_kc_8 = 0x25U , k_hid_kc_d = 0x07U , k_hid_kc_2 = 0x1FU } |
| HID Usage-Table keycode ranges for decoding keycodes back to ASCII. 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). | |
| VOID | hid_device_worker (ULONG arg) |
| Device-side worker: bring the HID device up, then send reports. | |
| void | usb_host_keyboard_device_thread_create (void) |
| Create + auto-start the USBX HID device worker thread. | |
| uint8_t | hid_nibble_to_hex (uint32_t nibble) |
| Format one nibble (0..15) into an uppercase hex character. | |
| uint32_t | hid_str_len (const char *text) |
| Bounded ASCII string length (cap k_hid_print_cap). | |
| ra8_err_t | hid_sci_write (const uint8_t *data, uint32_t len) |
| Push a literal block over SCI8 polled. | |
| 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. | |
Variables | |
| TX_SEMAPHORE | s_usb_host_keyboard_hid_active_sem |
| Activation semaphore shared by the device worker and main.c. | |
Shared seam between usb_host_keyboard main.c and its sibling TUs.
Declares the helper clusters carved out of the oversized usb_host_keyboard/main.c so that every translation unit stays under the 1000-line cap. Two siblings sit behind this header:
Only the symbols that genuinely cross a TU boundary are published here. The shared compile-time enums live in this header so both siblings and main.c agree on one definition. The shared report-pattern builder (hid_fill_report_body) is computed by the device side and re-computed by the host side to verify, so it is published too. The activation semaphore is the single mutable object the device worker and main.c share; it is defined once in main.c as s_usb_host_keyboard_hid_active_sem and externed here.
Definition in file usb_host_keyboard_steps.h.
| enum hid_config_t : uint32_t |
Compile-time settings: threads, pool, console, cadence.
Definition at line 53 of file usb_host_keyboard_steps.h.
| enum hid_geom_t : uint32_t |
HID report + interrupt-pipe + pattern constants.
Definition at line 91 of file usb_host_keyboard_steps.h.
| enum hid_hex_t : uint8_t |
Hex/decimal text-formatter sizing constants.
Definition at line 70 of file usb_host_keyboard_steps.h.
| enum hid_keycode_t : uint8_t |
HID Usage-Table keycode ranges for decoding keycodes back to ASCII.
Definition at line 113 of file usb_host_keyboard_steps.h.
| enum hid_mask_t : uint32_t |
Bit-mask constants used by the text formatters.
| Enumerator | |
|---|---|
| k_hid_nibble_mask | 4-bit nibble mask. |
| k_hid_dec_radix | Base for decimal conversion. |
Definition at line 82 of file usb_host_keyboard_steps.h.
| VOID hid_device_worker | ( | ULONG | arg | ) |
Device-side worker: bring the HID device up, then send reports.
USBX system + device stack + HID class + DCD bridge on the USBFS controller, then DPRPU attach. Blocks on the activation semaphore until the host configures the device, then loops to keep the interrupt-IN report queue fed.
| [in] | arg | ThreadX entry argument (unused). |
Definition at line 515 of file usb_host_keyboard_device.c.
References hid_class_register(), hid_send_iter(), hid_usbx_stack_up(), k_hid_dev_step_attach, k_hid_dev_step_class, k_hid_dev_step_dcd, k_hid_dev_step_send, k_hid_dev_step_stack, k_ra8_ok, k_ra8_usb_speed_fs, ra8_usb_device_attach(), s_dbg_dev_err, s_dbg_dev_step, s_hid_class, s_usb_host_keyboard_hid_active_sem, TX_WAIT_FOREVER, and ux_dcd_ra8_usb_initialize().
Referenced by tx_application_define(), and usb_host_keyboard_device_thread_create().
| void hid_fill_report_body | ( | uint8_t * | out, |
| uint32_t | len ) |
Fill the fixed body of a HID report (bytes 1..len-1).
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_key0_idx, k_hid_nkeys, and s_kbd_keys.
Referenced by hid_get_callback(), hid_read_round(), hid_read_round(), and hid_send_iter().
| uint8_t hid_nibble_to_hex | ( | uint32_t | nibble | ) |
Format one nibble (0..15) into an uppercase hex character.
| [in] | nibble | 4-bit value. |
| '0' | For a zero nibble. |
Definition at line 31 of file usb_host_keyboard_console.c.
References k_hid_hex_digit_split.
Referenced by hid_print_hex().
|
nodiscard |
Print a NUL-terminated ASCII string over the console.
| [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_host_pass(), hid_host_pass(), hid_print_enum(), hid_print_enum(), hid_print_pass(), and hid_print_pass().
|
nodiscard |
Print a uint32_t as ASCII decimal.
| [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.
Referenced by hid_print_pass(), and hid_print_pass().
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
| [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.
Referenced by hid_enumerate(), hid_enumerate(), hid_host_pass(), hid_host_pass(), hid_read_round(), and hid_read_round().
|
nodiscard |
Print a value as fixed-width uppercase hex.
| [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_enum(), and hid_print_enum().
|
nodiscard |
Push a literal block over SCI8 polled.
| [in] | data | Buffer to send. |
| [in] | len | Byte count. |
| k_ra8_ok | All bytes queued. |
data is non-NULL; SCI8 init already ran. len excludes any NUL terminator. Definition at line 51 of file usb_host_keyboard_console.c.
References ra8_board_uart_console_write().
Referenced by hid_print(), hid_print_dec(), and hid_print_hex().
| uint32_t hid_str_len | ( | const char * | text | ) |
Bounded ASCII string length (cap k_hid_print_cap).
| [in] | text | NUL-terminated string. |
| 0 | For an empty string. |
text is non-NULL. text points to readable storage of at least the length. Definition at line 39 of file usb_host_keyboard_console.c.
References k_hid_print_cap.
Referenced by hid_print().
| void usb_host_keyboard_device_thread_create | ( | void | ) |
Create + auto-start the USBX HID device worker thread.
Owns the device thread's TCB + stack storage at file scope in the device sibling and spawns hid_device_worker at k_hid_dev_priority. Called once from tx_application_define in main.c.
Definition at line 555 of file usb_host_keyboard_device.c.
References hid_device_worker(), k_hid_dev_priority, k_hid_thread_stack, s_device_stack, s_device_thread, s_device_thread_name, TX_AUTO_START, TX_NO_TIME_SLICE, and tx_thread_create.
Referenced by tx_application_define().
|
extern |
Activation semaphore shared by the device worker and main.c.
Posted by the activate callback so the send worker blocks on it instead of polling s_hid_class with tx_thread_sleep (which has been observed never returning on this silicon under load).
Posted by the HID activate callback (device sibling) so the send worker blocks on it instead of polling; created by tx_application_define in main.c. Defined once in main.c.
Defined here; the device worker (sibling TU) and this main.c both reference it via the extern in usb_host_keyboard_steps.h.
Definition at line 163 of file main.c.
Referenced by hid_activate(), hid_device_worker(), and tx_application_define().