USB Common#
Common parts for both host and device USB stacks.
Modules#
USB_ConfigurationDescriptor_TypeDef
USB_InterfaceDescriptor_TypeDef
USB_EndpointDescriptor_TypeDef
Enumerations#
USB transfer status enumerator.
Typedefs#
Data type used for UTF-16LE formatted USB string descriptors.
USB transfer callback function.
USBTIMER callback function.
Functions#
Transmit a single char on the debug serial port.
Transmit a zero terminated string on the debug serial port.
Transmit "printf" formated data on the debug serial port.
Return an error message string for a given error code.
Format and print a text string given an error code, prepends an optional user supplied leader string.
Active wait millisecond delay function.
Active wait microsecond delay function.
Activate the hardware timer used to pace the 1 millisecond timer system.
Start a timer.
Stop a timer.
Macros#
Silicon Labs Vendor ID, supplied by USB-IF.
Setup request data stage OUT direction value.
Setup request data stage IN direction value.
Setup request data stage direction mask.
Setup request data stage IN direction mask.
Setup request data stage OUT direction mask.
Standard setup request value.
Class setup request value.
Vendor setup request value.
Standard setup request mask.
Class setup request mask.
Vendor setup request mask.
Setup request device recipient value.
Setup request interface recipient value.
Setup request endpoint recipient value.
Setup request other recipient value.
Standard setup request GET_STATUS.
Standard setup request CLEAR_FEATURE.
Standard setup request SET_FEATURE.
Standard setup request SET_ADDRESS.
Standard setup request GET_DESCRIPTOR.
Standard setup request SET_DESCRIPTOR.
Standard setup request GET_CONFIGURATION.
Standard setup request SET_CONFIGURATION.
Standard setup request GET_INTERFACE.
Standard setup request SET_INTERFACE.
Standard setup request SYNCH_FRAME.
HID class setup request GET_REPORT.
HID class setup request GET_IDLE.
HID class setup request SET_REPORT.
HID class setup request SET_IDLE.
HID class setup request SET_PROTOCOL.
CDC class setup request SET_LINE_CODING.
CDC class setup request GET_LINE_CODING.
CDC class setup request SET_CONTROL_LINE_STATE.
MSD class setup request Bulk only transfer reset.
MSD class setup request Get Max LUN.
Audio class setup request GET_CUR.
Audio class setup request GET_CUR.
Audio class setup request SET_CUR.
Audio class setup request SET_MIN.
Audio class setup request GET_MIN.
Audio class setup request SET_MAX.
Audio class setup request GET_MAX.
Audio class setup request SET_RES.
Audio class setup request GET_RES.
Audio class setup request SET_MEM.
Audio class setup request GET_MEM.
Audio class setup request GET_STAT.
DEVICE descriptor value.
CONFIGURATION descriptor value.
STRING descriptor value.
Maximum STRING descriptor bString length.
INTERFACE descriptor value.
ENDPOINT descriptor value.
DEVICE_QUALIFIER descriptor value.
OTHER_SPEED_CONFIGURATION descriptor value.
INTERFACE_POWER descriptor value.
INTERFACE_ASSOCIATION descriptor value.
HID descriptor value.
Smartcard usb-ccid-specific Descriptor Type.
HID REPORT descriptor value.
Audio Class-specific interface Descriptor Type.
Audio Class-specific endpoint Descriptor Type.
HUB descriptor value.
Audio Class-Specific AC Interface Header descriptor.
Audio Class-Specific AC Interface Input Terminal desc.
Audio Class-Specific AC Interface Output Terminal desc.
Audio Class-Specific AC Interface Mixer descriptor.
Audio Class-Specific AC Interface Selector desc.
Audio Class-Specific AC Interface Feature desc.
Audio Class-Specific AC Interface Processing desc.
Audio Class-Specific AC Interface Extension desc.
Audio Class-Specific general descriptor subtype code.
Audio Class-Specific AS Interface General descriptor.
Audio Class-Specific AS Interface Format Type desc.
Device descriptor size.
Configuration descriptor size.
Interface descriptor size.
Endpoint descriptor size.
Device qualifier descriptor size.
Device other speed configuration descriptor size.
INTERFACE_ASSOCIATION descriptor size.
HID descriptor size.
CCID descriptor size.
CDC Header functional descriptor size.
CDC Call Management functional descriptor size.
CDC Abstract Control Management functional descriptor size.
Audio Input Terminal descriptor size.
Audio Output Terminal descriptor size.
Audio Class-Specific general descriptor subtype size.
Audio Class-Specific AS Interface General desc size.
Audio-class standard audio stream descriptor size.
The max size of low speed control endpoints.
The max size of low speed interrupt endpoints.
The max size of full speed control endpoints.
The max size of full speed interrupt endpoints.
The max size of full speed bulk endpoints.
The max size of full speed isochronous endpoints.
Endpoint type control.
Endpoint type isochron.
Endpoint type bulk.
Endpoint type interrupt.
Endpoint synchronization type, none.
Endpoint synchronization type, asynchronous.
Endpoint synchronization type, adaptive.
Endpoint synchronization type, synchronous.
Endpoint direction mask.
Setup request packet size.
Endpoint number mask.
English-United States language id.
Maximum allowable device address.
Configuration descriptor attribute macro.
Configuration descriptor attribute macro.
Configuration descriptor attribute macro.
Configuration descriptor transfer type bitmask.
Configuration descriptor power macro.
Standard request GET_STATUS bitmask.
Standard request GET_STATUS bitmask.
Standard request CLEAR/SET_FEATURE bitmask.
Standard request CLEAR/SET_FEATURE bitmask.
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
CDC device/interface class code.
CDC Data interface class code.
CDC Abstract Control Model interface subclass code.
CDC class Header Functional Descriptor subtype.
CDC class Call Management Functional Descriptor subtype.
CDC class Abstract Control Management Functional Descriptor subtype.
CDC class Union Functional Descriptor subtype.
HID device/interface class code.
HID keyboard interface protocol code.
HID mouse interface protocol code.
HUB device/interface class code.
MSD device/interface class code.
MSD Bulk Only Transport protocol.
MSD Subclass SCSI transparent command set.
MSD BOT Command status wrapper command passed code.
MSD BOT Command status wrapper command failed code.
MSD BOT Command status wrapper cmd phase error code.
Audio interface class code.
Audio subclass code for control interface.
Audio subclass code for streaming interface.
Audio subclass code for midi streaming interface.
MISCELLANEOUS device class code.
MISCELLANEOUS Common sub class code.
MISCELLANEOUS Interface Association Descriptor protocol code.
Full speed return value for USBH_GetPortSpeed().
Low speed return value for USBH_GetPortSpeed().
Use LFXO as DPLL clock source.
Use HFXO as DPLL clock source.
Macro for creating USB compliant UTF-16LE UNICODE string descriptors.
Macro for creating USB compliant language string descriptors.
Macro for creating WORD (4 byte) aligned uint8_t array with size which is a multiple of WORD size.
Macro for creating WORD (4 byte) aligned static uint8_t arrays with size which is a multiple of WORD size.
Enumeration Documentation#
USB_Status_TypeDef#
USB_Status_TypeDef
USB transfer status enumerator.
Enumerator | |
---|---|
USB_STATUS_OK | No errors detected. |
USB_STATUS_REQ_ERR | Setup request error. |
USB_STATUS_EP_BUSY | Endpoint is busy. |
USB_STATUS_REQ_UNHANDLED | Setup request not handled. |
USB_STATUS_ILLEGAL | Illegal operation attempted. |
USB_STATUS_EP_STALLED | Endpoint is stalled. |
USB_STATUS_EP_ABORTED | Endpoint transfer was aborted. |
USB_STATUS_EP_ERROR | Endpoint transfer error. |
USB_STATUS_EP_NAK | Endpoint NAK'ed transfer request. |
USB_STATUS_DEVICE_UNCONFIGURED | Device is unconfigured. |
USB_STATUS_DEVICE_SUSPENDED | Device is suspended. |
USB_STATUS_DEVICE_RESET | Device is/was reset. |
USB_STATUS_TIMEOUT | Transfer timeout. |
USB_STATUS_DEVICE_REMOVED | Device was removed. |
USB_STATUS_HC_BUSY | Host channel is busy. |
USB_STATUS_DEVICE_MALFUNCTION | Malfunctioning device attached. |
USB_STATUS_PORT_OVERCURRENT | VBUS shortcircuit/overcurrent failure. |
Typedef Documentation#
char16_t#
typedef unsigned short char16_t
Data type used for UTF-16LE formatted USB string descriptors.
USB_XferCompleteCb_TypeDef#
typedef int(* USB_XferCompleteCb_TypeDef) (USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining) )(USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining)
USB transfer callback function.
Type | Direction | Argument Name | Description |
---|---|---|---|
[in] | status | The transfer status. See USB_Status_TypeDef. | |
[in] | xferred | Number of bytes actually transferred. | |
[in] | remaining | Number of bytes not transferred. |
The callback function is called when a transfer has completed. An application should check the status, xferred and optionally the remaining parameters before deciding if the transfer is usable. In the case where the transfer is part of a control request data stage, the callback function should return an appropriate USB_Status_TypeDef status.
Returns
USB_STATUS_OK on success, else an appropriate error code.
USBTIMER_Callback_TypeDef#
typedef void(* USBTIMER_Callback_TypeDef) (void) )(void)
USBTIMER callback function.
The callback function is called when an USBTIMER has expired. The callback is done with interrupts disabled.
Function Documentation#
USB_PUTCHAR#
int USB_PUTCHAR (char c)
Transmit a single char on the debug serial port.
Type | Direction | Argument Name | Description |
---|---|---|---|
char | [in] | c | Char to transmit. |
Note
This function is enabled with #define DEBUG_USB_API when configuring the protocol stack in "usbconfig.h". This is convenient when debugging code, no need to remove use of this function when debugging has completed.
Returns
The char transmitted.
USB_PUTS#
void USB_PUTS (const char * p)
Transmit a zero terminated string on the debug serial port.
Type | Direction | Argument Name | Description |
---|---|---|---|
const char * | [in] | p | Pointer to string to transmit. |
Note
This function is enabled with #define DEBUG_USB_API when configuring the protocol stack in "usbconfig.h". This is convenient when debugging code, no need to remove use of this function when debugging has completed.
USB_PRINTF#
int USB_PRINTF (const char * format, ... )
Transmit "printf" formated data on the debug serial port.
Type | Direction | Argument Name | Description |
---|---|---|---|
const char * | [in] | format | Format string (as in printf). No floating point format support. |
... | N/A |
Note
This function is enabled with #define USB_USE_PRINTF when configuring the protocol stack in "usbconfig.h". This is convenient when debugging code, no need to remove use of this function when debugging has completed.
Returns
Number of chars transmitted.
USB_GetErrorMsgString#
char * USB_GetErrorMsgString (int error)
Return an error message string for a given error code.
Type | Direction | Argument Name | Description |
---|---|---|---|
int | [in] | error | Error code, see USB_Status_TypeDef. |
Returns
Error message string pointer.
USB_PrintErrorMsgString#
void USB_PrintErrorMsgString (char * pre, int error)
Format and print a text string given an error code, prepends an optional user supplied leader string.
Type | Direction | Argument Name | Description |
---|---|---|---|
char * | [in] | pre | Optional leader string to prepend to error message string. |
int | [in] | error | Error code, see USB_Status_TypeDef. |
USBTIMER_DelayMs#
void USBTIMER_DelayMs (uint32_t msec)
Active wait millisecond delay function.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | msec | Number of milliseconds to wait. |
Can also be used inside interrupt handlers.
USBTIMER_DelayUs#
void USBTIMER_DelayUs (uint32_t usec)
Active wait microsecond delay function.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | usec | Number of microseconds to wait. |
Can also be used inside interrupt handlers.
USBTIMER_Init#
void USBTIMER_Init (void )
Activate the hardware timer used to pace the 1 millisecond timer system.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Call this function whenever the HFPERCLK frequency is changed. This function is initially called by HOST and DEVICE stack xxxx_Init() functions.
USBTIMER_Start#
void USBTIMER_Start (uint32_t id, uint32_t timeout, USBTIMER_Callback_TypeDef callback)
Start a timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | id | Timer id (0..). |
uint32_t | [in] | timeout | Number of milliseconds before timer will elapse. |
USBTIMER_Callback_TypeDef | [in] | callback | Function to be called on timer elapse, ref. USBTIMER_Callback_TypeDef. |
If the timer is already running, it will be restarted with new timeout.
USBTIMER_Stop#
void USBTIMER_Stop (uint32_t id)
Stop a timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | id | Timer id (0..). |