File syn_usb.h¶
FileList > drivers > syn_usb.h
Go to the source code of this file
Zero-Heap Modular USB 2.0 Device Core Protocol Engine.
#include "syntropic/common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "syntropic/pt/syn_pt.h"
Classes¶
| Type | Name |
|---|---|
| struct | SYN_USB_ClassDriver |
| struct | SYN_USB_Device |
| struct | SYN_USB_SetupPacket |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_usb_init (SYN_USB_Device * dev, const uint8_t * device_desc) Initialize USB Device Core with standard 18-byte Device Descriptor. |
| bool | syn_usb_is_configured (const SYN_USB_Device * dev) Check if USB device is in CONFIGURED state. |
| SYN_Status | syn_usb_process_setup (SYN_USB_Device * dev, const SYN_USB_SetupPacket * pkt, uint8_t * resp, uint16_t * rlen) Process Control Setup packet from Host (EP0). |
| SYN_Status | syn_usb_register_class (SYN_USB_Device * dev, const SYN_USB_ClassDriver * cls, const uint8_t * iface_desc, uint16_t iface_desc_len) Register a class driver and append its interface descriptors. |
| SYN_Status | syn_usb_set_raw_config_desc (SYN_USB_Device * dev, const uint8_t * desc, uint16_t len) Set raw configuration descriptor pointer (overrides auto-assembly). |
| SYN_Status | syn_usb_set_string_desc (SYN_USB_Device * dev, uint8_t index, const uint8_t * desc) Set string descriptor pointer for a given index. |
Macros¶
Public Functions Documentation¶
function syn_usb_init¶
Initialize USB Device Core with standard 18-byte Device Descriptor.
Parameters:
devPointer to USB device instance.device_descPointer to 18-byte standard USB device descriptor.
Returns:
SYN_OK on success.
function syn_usb_is_configured¶
Check if USB device is in CONFIGURED state.
Parameters:
devPointer to USB device context.
Returns:
true if device is configured.
function syn_usb_process_setup¶
Process Control Setup packet from Host (EP0).
SYN_Status syn_usb_process_setup (
SYN_USB_Device * dev,
const SYN_USB_SetupPacket * pkt,
uint8_t * resp,
uint16_t * rlen
)
Parameters:
devPointer to USB device context.pktPointer to received Setup Packet.respOutput buffer for data stage response.rlenOutput pointer to receive response byte length.
Returns:
SYN_OK on success.
function syn_usb_register_class¶
Register a class driver and append its interface descriptors.
SYN_Status syn_usb_register_class (
SYN_USB_Device * dev,
const SYN_USB_ClassDriver * cls,
const uint8_t * iface_desc,
uint16_t iface_desc_len
)
Parameters:
devPointer to USB device context.clsClass driver vtable and binding context.iface_descPointer to class interface descriptor payload.iface_desc_lenLength of interface descriptor payload.
Returns:
SYN_OK on success.
function syn_usb_set_raw_config_desc¶
Set raw configuration descriptor pointer (overrides auto-assembly).
Parameters:
devPointer to USB device context.descPointer to raw configuration descriptor.lenLength in bytes.
Returns:
SYN_OK on success.
function syn_usb_set_string_desc¶
Set string descriptor pointer for a given index.
Parameters:
devPointer to USB device context.indexString index (0=Language ID, 1=Manufacturer, 2=Product, etc).descPointer to UNICODE string descriptor.
Returns:
SYN_OK on success.
Macro Definition Documentation¶
define PT_USB_WAIT_CONFIGURED¶
Block a protothread coroutine until USB device reaches CONFIGURED state.
Parameters:
ptProtothread context.devPointer to USB device instance.
define SYN_USB_DESC_TYPE_CONFIGURATION¶
Configuration Descriptor Type (0x02)
define SYN_USB_DESC_TYPE_DEVICE¶
Descriptor Types Device Descriptor Type (0x01)
define SYN_USB_DESC_TYPE_ENDPOINT¶
Endpoint Descriptor Type (0x05)
define SYN_USB_DESC_TYPE_INTERFACE¶
Interface Descriptor Type (0x04)
define SYN_USB_DESC_TYPE_STRING¶
String Descriptor Type (0x03)
define SYN_USB_EP0_BUF_SIZE¶
EP0 control buffer size
define SYN_USB_MAX_CLASSES¶
Maximum registered class drivers
define SYN_USB_MAX_CONFIG_DESC¶
Maximum auto-assembled configuration descriptor buffer capacity
define SYN_USB_MAX_STRING_DESCS¶
Maximum string descriptor slots
define SYN_USB_REQ_CLEAR_FEATURE¶
USB Request Clear Feature (0x01)
define SYN_USB_REQ_GET_CONFIGURATION¶
USB Request Get Configuration (0x08)
define SYN_USB_REQ_GET_DESCRIPTOR¶
USB Request Get Descriptor (0x06)
define SYN_USB_REQ_GET_STATUS¶
Standard USB Request Codes per USB 2.0 Spec Table 9-4 USB Request Get Status (0x00)
define SYN_USB_REQ_SET_ADDRESS¶
USB Request Set Address (0x05)
define SYN_USB_REQ_SET_CONFIGURATION¶
USB Request Set Configuration (0x09)
define SYN_USB_REQ_SET_DESCRIPTOR¶
USB Request Set Descriptor (0x07)
define SYN_USB_REQ_SET_FEATURE¶
USB Request Set Feature (0x03)
define SYN_USB_STATE_ADDRESS¶
USB Address state
define SYN_USB_STATE_CONFIGURED¶
USB Configured state
define SYN_USB_STATE_DEFAULT¶
USB Device States per USB 2.0 Spec ยง9.1.1 USB Default state
The documentation for this class was generated from the following file src/syntropic/drivers/syn_usb.h