File syn_usb_host.h¶
FileList > drivers > syn_usb_host.h
Go to the source code of this file
Zero-Heap USB 2.0 Host Core Protocol Engine. More...
#include "syntropic/common/syn_defs.h"#include "syntropic/drivers/syn_usb.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "syntropic/pt/syn_pt.h"
Classes¶
| Type | Name |
|---|---|
| struct | SYN_USB_Host |
| struct | SYN_USB_HostClassDriver |
| struct | SYN_USB_HostDevInfo |
Public Functions¶
| Type | Name |
|---|---|
| const SYN_USB_HostDevInfo * | syn_usb_host_get_dev_info (const SYN_USB_Host * host) Get cached device information from last enumeration. |
| SYN_Status | syn_usb_host_init (SYN_USB_Host * host) Initialize USB Host Core. |
| bool | syn_usb_host_is_ready (const SYN_USB_Host * host) Check if USB Host has a device enumerated and ready. |
| SYN_Status | syn_usb_host_process (SYN_USB_Host * host) Process USB Host state machine (call each scheduler tick). |
| SYN_Status | syn_usb_host_register_class (SYN_USB_Host * host, const SYN_USB_HostClassDriver * cls) Register a host class driver for interface matching. |
Macros¶
| Type | Name |
|---|---|
| define | PT_USB_HOST_WAIT_READY (pt, host) [**PT\_WAIT\_UNTIL**](syn__pt_8h.md#define-pt_wait_until)(pt, [**syn\_usb\_host\_is\_ready**](syn__usb__host_8c.md#function-syn_usb_host_is_ready)(host))Block a protothread coroutine until a USB device is enumerated and ready. |
| define | SYN_USB_HOST_ENUM_BUF_SIZE 256U |
| define | SYN_USB_HOST_ENUM_CLASS_PROBE 5U |
| define | SYN_USB_HOST_ENUM_DONE 6U |
| define | SYN_USB_HOST_ENUM_GET_CFG 3U |
| define | SYN_USB_HOST_ENUM_GET_DEV8 0U |
| define | SYN_USB_HOST_ENUM_GET_DEV_FULL 2U |
| define | SYN_USB_HOST_ENUM_SET_ADDR 1U |
| define | SYN_USB_HOST_ENUM_SET_CFG 4U |
| define | SYN_USB_HOST_MAX_CLASSES 4U |
| define | SYN_USB_HOST_MAX_PIPES 4U |
| define | SYN_USB_HOST_STATE_ATTACHED 1U |
| define | SYN_USB_HOST_STATE_DISCONNECTED 0U |
| define | SYN_USB_HOST_STATE_ENUMERATING 3U |
| define | SYN_USB_HOST_STATE_ERROR 5U |
| define | SYN_USB_HOST_STATE_READY 4U |
| define | SYN_USB_HOST_STATE_RESET 2U |
Detailed Description¶
Manages device attach/detach detection, bus reset, standard enumeration (GET_DESCRIPTOR, SET_ADDRESS, SET_CONFIGURATION), and dispatches matched interfaces to registered host class drivers.
Public Functions Documentation¶
function syn_usb_host_get_dev_info¶
Get cached device information from last enumeration.
Parameters:
hostPointer to USB Host instance.
Returns:
Pointer to device info struct, or NULL if no device.
function syn_usb_host_init¶
Initialize USB Host Core.
Parameters:
hostPointer to USB Host instance.
Returns:
SYN_OK on success.
function syn_usb_host_is_ready¶
Check if USB Host has a device enumerated and ready.
Parameters:
hostPointer to USB Host instance.
Returns:
true if host state is READY.
function syn_usb_host_process¶
Process USB Host state machine (call each scheduler tick).
Drives attach detection, bus reset, enumeration, class probing, and detach handling. Non-blocking.
Parameters:
hostPointer to USB Host instance.
Returns:
SYN_OK on success, SYN_BUSY if transfer pending.
function syn_usb_host_register_class¶
Register a host class driver for interface matching.
Parameters:
hostPointer to USB Host instance.clsHost class driver vtable.
Returns:
SYN_OK on success.
Macro Definition Documentation¶
define PT_USB_HOST_WAIT_READY¶
Block a protothread coroutine until a USB device is enumerated and ready.
Parameters:
ptProtothread context.hostPointer to USB Host instance.
define SYN_USB_HOST_ENUM_BUF_SIZE¶
Enumeration descriptor scratch buffer
define SYN_USB_HOST_ENUM_CLASS_PROBE¶
Match & probe class drivers
define SYN_USB_HOST_ENUM_DONE¶
Enumeration complete
define SYN_USB_HOST_ENUM_GET_CFG¶
Read Configuration Descriptor
define SYN_USB_HOST_ENUM_GET_DEV8¶
Enumeration sub-steps (internal to ENUMERATING state) Read first 8 bytes of Device Desc
define SYN_USB_HOST_ENUM_GET_DEV_FULL¶
Read full 18-byte Device Desc
define SYN_USB_HOST_ENUM_SET_ADDR¶
Assign bus address
define SYN_USB_HOST_ENUM_SET_CFG¶
Issue SET_CONFIGURATION
define SYN_USB_HOST_MAX_CLASSES¶
Maximum registered host class drivers
define SYN_USB_HOST_MAX_PIPES¶
Maximum host pipes (EP0 + data pipes)
define SYN_USB_HOST_STATE_ATTACHED¶
Device physically present
define SYN_USB_HOST_STATE_DISCONNECTED¶
USB Host States No device attached
define SYN_USB_HOST_STATE_ENUMERATING¶
Reading descriptors & assigning address
define SYN_USB_HOST_STATE_ERROR¶
Enumeration or transfer error
define SYN_USB_HOST_STATE_READY¶
Device enumerated and class active
define SYN_USB_HOST_STATE_RESET¶
Bus reset in progress
The documentation for this class was generated from the following file src/syntropic/drivers/syn_usb_host.h