ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_hhub.h
Go to the documentation of this file.
1
40
41#pragma once
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#include <stdint.h>
48
49#include "ra8_err.h"
50#include "ra8_usb.h"
51
52/* =============================================================================
53 * Constants
54 * =============================================================================
55 */
56
61typedef enum : uint8_t {
64
69typedef enum : uint8_t {
72
86
105
122
134
140typedef struct {
142 uint8_t port_count;
143 uint16_t vendor_id;
144 uint16_t product_id;
146
157typedef void (*ra8_usb_hhub_attach_fn_t)(void* ctx, const ra8_usb_hhub_device_t* device);
158
159/* =============================================================================
160 * Lifecycle
161 * =============================================================================
162 */
163
191[[nodiscard]] ra8_err_t ra8_usb_hhub_init(ra8_usb_speed_t speed);
192
209[[nodiscard]] ra8_err_t ra8_usb_hhub_close(void);
210
211/* =============================================================================
212 * Attach callback
213 * =============================================================================
214 */
215
232[[nodiscard]] ra8_err_t ra8_usb_hhub_attach_callback(ra8_usb_hhub_attach_fn_t on_attach, void* ctx);
233
234/* =============================================================================
235 * HUB class control transfers
236 * =============================================================================
237 */
238
264[[nodiscard]] ra8_err_t ra8_usb_hhub_get_port_count(uint8_t* count);
265
299[[nodiscard]] ra8_err_t ra8_usb_hhub_get_port_status(uint8_t port, uint32_t* status);
300
329[[nodiscard]] ra8_err_t ra8_usb_hhub_set_port_feature(uint8_t port, ra8_usb_hhub_feature_t feature);
330
359[[nodiscard]] ra8_err_t ra8_usb_hhub_clear_port_feature(uint8_t port,
360 ra8_usb_hhub_feature_t feature);
361
362/* =============================================================================
363 * Test / introspection helpers
364 * =============================================================================
365 */
366
388[[nodiscard]] ra8_err_t ra8_usb_hhub_step(void);
389
390#ifdef __cplusplus
391}
392#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
void(* ra8_usb_hhub_attach_fn_t)(void *ctx, const ra8_usb_hhub_device_t *device)
Attach-callback signature.
ra8_usb_hhub_port_status_bits_t
Bit positions in the 32-bit port status word (USB 2.0 Table 11-21).
@ k_ra8_hhub_status_bit_high_speed
High-speed device.
@ k_ra8_hhub_status_bit_enable
Port enabled.
@ k_ra8_hhub_status_bit_connection
Current connect status.
@ k_ra8_hhub_status_bit_suspend
Suspend state.
@ k_ra8_hhub_status_bit_low_speed
Low-speed device.
@ k_ra8_hhub_status_bit_reset
Reset in progress.
@ k_ra8_hhub_status_bit_power
Port power on.
@ k_ra8_hhub_status_bit_overcurrent
Over-current latch.
ra8_usb_hhub_feature_t
HUB port feature selectors (USB 2.0 Table 11-17).
@ k_ra8_hhub_feature_port_connection
C_PORT_CONNECTION cleared.
@ k_ra8_hhub_feature_port_reset
PORT_RESET.
@ k_ra8_hhub_feature_port_low_speed
PORT_LOW_SPEED.
@ k_ra8_hhub_feature_c_port_reset
C_PORT_RESET (change).
@ k_ra8_hhub_feature_port_enable
PORT_ENABLE.
@ k_ra8_hhub_feature_port_suspend
PORT_SUSPEND.
@ k_ra8_hhub_feature_c_port_overcurr
C_PORT_OVER_CURRENT (change).
@ k_ra8_hhub_feature_port_overcurrent
PORT_OVER_CURRENT.
@ k_ra8_hhub_feature_c_port_enable
C_PORT_ENABLE (change).
@ k_ra8_hhub_feature_c_port_connection
C_PORT_CONNECTION (change).
@ k_ra8_hhub_feature_c_port_suspend
C_PORT_SUSPEND (change).
@ k_ra8_hhub_feature_port_power
PORT_POWER.
ra8_err_t ra8_usb_hhub_set_port_feature(uint8_t port, ra8_usb_hhub_feature_t feature)
Issue SET_PORT_FEATURE (USB 2.0 sec 11.24.2.13) over the DCP.
ra8_err_t ra8_usb_hhub_step(void)
Drive the enumeration step machine forward by one step.
ra8_err_t ra8_usb_hhub_close(void)
Tear down the host-HUB driver and release the controller.
ra8_usb_hhub_request_t
HUB class-specific request codes (USB 2.0 sec 11.24.2).
@ k_ra8_hhub_req_clear_feature
CLEAR_FEATURE.
@ k_ra8_hhub_req_set_feature
SET_FEATURE.
@ k_ra8_hhub_req_get_descriptor
GET_DESCRIPTOR.
@ k_ra8_hhub_req_get_status
GET_STATUS.
@ k_ra8_hhub_req_reset_tt
RESET_TT.
@ k_ra8_hhub_req_set_descriptor
SET_DESCRIPTOR.
@ k_ra8_hhub_req_clear_tt_buffer
CLEAR_TT_BUFFER.
ra8_usb_hhub_class_t
HUB class code per USB 2.0 sec 11.24.1.
@ k_ra8_hhub_class_hub
bDeviceClass / bInterfaceClass = HUB.
ra8_err_t ra8_usb_hhub_attach_callback(ra8_usb_hhub_attach_fn_t on_attach, void *ctx)
Register (or detach) the HUB attach callback.
ra8_err_t ra8_usb_hhub_init(ra8_usb_speed_t speed)
Bring up the host-HUB driver on a chosen USB controller.
ra8_err_t ra8_usb_hhub_clear_port_feature(uint8_t port, ra8_usb_hhub_feature_t feature)
Issue CLEAR_PORT_FEATURE (USB 2.0 sec 11.24.2.2) over the DCP.
ra8_err_t ra8_usb_hhub_get_port_status(uint8_t port, uint32_t *status)
Issue GET_PORT_STATUS (USB 2.0 sec 11.24.2.7) over the DCP.
ra8_err_t ra8_usb_hhub_get_port_count(uint8_t *count)
Read the cached downstream port count from the HUB descriptor.
ra8_usb_hhub_desc_t
HUB descriptor types (USB 2.0 sec 11.23.2).
@ k_ra8_hhub_desc_hub
HUB class descriptor type.
ra8_usb_hhub_limits_t
Hard ceilings on hub topology this driver tracks.
@ k_ra8_hhub_first_port
Port numbering starts at 1.
@ k_ra8_hhub_max_ports
FSP-aligned downstream port ceiling.
Snapshot of the attached HUB device, passed to the attach callback.
uint8_t device_address
Assigned USB address (1..127).
uint16_t product_id
idProduct.
uint16_t vendor_id
idVendor.
uint8_t port_count
bNbrPorts from HUB descriptor.