USB Common#

Common parts for both host and device USB stacks.

Modules#

USB_Setup_TypeDef

USB_DeviceDescriptor_TypeDef

USB_ConfigurationDescriptor_TypeDef

USB_InterfaceDescriptor_TypeDef

USB_EndpointDescriptor_TypeDef

USB_StringDescriptor_TypeDef

Enumerations#

enum
USB_STATUS_OK = 0
USB_STATUS_REQ_ERR = -1
USB_STATUS_EP_BUSY = -2
USB_STATUS_REQ_UNHANDLED = -3
USB_STATUS_ILLEGAL = -4
USB_STATUS_EP_STALLED = -5
USB_STATUS_EP_ABORTED = -6
USB_STATUS_EP_ERROR = -7
USB_STATUS_EP_NAK = -8
USB_STATUS_DEVICE_UNCONFIGURED = -9
USB_STATUS_DEVICE_SUSPENDED = -10
USB_STATUS_DEVICE_RESET = -11
USB_STATUS_TIMEOUT = -12
USB_STATUS_DEVICE_REMOVED = -13
USB_STATUS_HC_BUSY = -14
USB_STATUS_DEVICE_MALFUNCTION = -15
USB_STATUS_PORT_OVERCURRENT = -16
}

USB transfer status enumerator.

Typedefs#

typedef unsigned short

Data type used for UTF-16LE formatted USB string descriptors.

typedef int(*
USB_XferCompleteCb_TypeDef)(USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining)

USB transfer callback function.

typedef void(*

USBTIMER callback function.

Functions#

void
USBTIMER_DelayMs(uint32_t msec)

Active wait millisecond delay function.

void
USBTIMER_DelayUs(uint32_t usec)

Active wait microsecond delay function.

void

Activate the hardware timer used to pace the 1 millisecond timer system.

void
USBTIMER_Start(uint32_t id, uint32_t timeout, USBTIMER_Callback_TypeDef callback)

Start a timer.

void
USBTIMER_Stop(uint32_t id)

Stop a timer.

int
USB_PUTCHAR(char c)

Transmit a single char on the debug serial port.

void
USB_PUTS(const char *p)

Transmit a zero terminated string on the debug serial port.

int
USB_PRINTF(const char *format,...)

Transmit "printf" formated data on the debug serial port.

char *

Return an error message string for a given error code.

void
USB_PrintErrorMsgString(char *pre, int error)

Format and print a text string given an error code, prepends an optional user supplied leader string.

Macros#

#define

Silicon Labs Vendor ID, supplied by USB-IF.

#define

Setup request data stage OUT direction value.

#define

Setup request data stage IN direction value.

#define

Setup request data stage direction mask.

#define

Setup request data stage IN direction mask.

#define

Setup request data stage OUT direction mask.

#define

Standard setup request value.

#define

Class setup request value.

#define

Vendor setup request value.

#define

Standard setup request mask.

#define

Class setup request mask.

#define

Vendor setup request mask.

#define

Setup request device recipient value.

#define

Setup request interface recipient value.

#define

Setup request endpoint recipient value.

#define

Setup request other recipient value.

#define

Standard setup request GET_STATUS.

#define

Standard setup request CLEAR_FEATURE.

#define

Standard setup request SET_FEATURE.

#define

Standard setup request SET_ADDRESS.

#define

Standard setup request GET_DESCRIPTOR.

#define

Standard setup request SET_DESCRIPTOR.

#define

Standard setup request GET_CONFIGURATION.

#define

Standard setup request SET_CONFIGURATION.

#define

Standard setup request GET_INTERFACE.

#define

Standard setup request SET_INTERFACE.

#define

Standard setup request SYNCH_FRAME.

#define

HID class setup request GET_REPORT.

#define

HID class setup request GET_IDLE.

#define

HID class setup request SET_REPORT.

#define

HID class setup request SET_IDLE.

#define

HID class setup request SET_PROTOCOL.

#define

CDC class setup request SET_LINE_CODING.

#define

CDC class setup request GET_LINE_CODING.

#define

CDC class setup request SET_CONTROL_LINE_STATE.

#define

MSD class setup request Bulk only transfer reset.

#define

MSD class setup request Get Max LUN.

#define

Audio class setup request GET_CUR.

#define

Audio class setup request GET_CUR.

#define

Audio class setup request SET_CUR.

#define

Audio class setup request SET_MIN.

#define

Audio class setup request GET_MIN.

#define

Audio class setup request SET_MAX.

#define

Audio class setup request GET_MAX.

#define

Audio class setup request SET_RES.

#define

Audio class setup request GET_RES.

#define

Audio class setup request SET_MEM.

#define

Audio class setup request GET_MEM.

#define

Audio class setup request GET_STAT.

#define

DEVICE descriptor value.

#define

CONFIGURATION descriptor value.

#define

STRING descriptor value.

#define

Maximum STRING descriptor bString length.

#define

INTERFACE descriptor value.

#define

ENDPOINT descriptor value.

#define

DEVICE_QUALIFIER descriptor value.

#define

OTHER_SPEED_CONFIGURATION descriptor value.

#define

INTERFACE_POWER descriptor value.

#define

INTERFACE_ASSOCIATION descriptor value.

#define

HID descriptor value.

#define

Smartcard usb-ccid-specific Descriptor Type.

#define

HID REPORT descriptor value.

#define

Audio Class-specific interface Descriptor Type.

#define

Audio Class-specific endpoint Descriptor Type.

#define

HUB descriptor value.

#define

Audio Class-Specific AC Interface Header descriptor.

#define

Audio Class-Specific AC Interface Input Terminal desc.

#define

Audio Class-Specific AC Interface Output Terminal desc.

#define

Audio Class-Specific AC Interface Mixer descriptor.

#define

Audio Class-Specific AC Interface Selector desc.

#define

Audio Class-Specific AC Interface Feature desc.

#define

Audio Class-Specific AC Interface Processing desc.

#define

Audio Class-Specific AC Interface Extension desc.

#define

Audio Class-Specific general descriptor subtype code.

#define

Audio Class-Specific AS Interface General descriptor.

#define

Audio Class-Specific AS Interface Format Type desc.

#define

Device descriptor size.

#define

Configuration descriptor size.

#define

Interface descriptor size.

#define

Endpoint descriptor size.

#define

Device qualifier descriptor size.

#define

Device other speed configuration descriptor size.

#define

INTERFACE_ASSOCIATION descriptor size.

#define

HID descriptor size.

#define

CCID descriptor size.

#define

CDC Header functional descriptor size.

#define

CDC Call Management functional descriptor size.

#define

CDC Abstract Control Management functional descriptor size.

#define

Audio Input Terminal descriptor size.

#define

Audio Output Terminal descriptor size.

#define

Audio Class-Specific general descriptor subtype size.

#define

Audio Class-Specific AS Interface General desc size.

#define

Audio-class standard audio stream descriptor size.

#define

The max size of low speed control endpoints.

#define

The max size of low speed interrupt endpoints.

#define

The max size of full speed control endpoints.

#define

The max size of full speed interrupt endpoints.

#define

The max size of full speed bulk endpoints.

#define

The max size of full speed isochronous endpoints.

#define

Endpoint type control.

#define

Endpoint type isochron.

#define

Endpoint type bulk.

#define

Endpoint type interrupt.

#define
USB_EPSYNC_NO (0 << 2)

Endpoint synchronization type, none.

#define

Endpoint synchronization type, asynchronous.

#define

Endpoint synchronization type, adaptive.

#define

Endpoint synchronization type, synchronous.

#define

Endpoint direction mask.

#define

Setup request packet size.

#define

Endpoint number mask.

#define

English-United States language id.

#define

Maximum allowable device address.

#define

Configuration descriptor attribute macro.

#define

Configuration descriptor attribute macro.

#define

Configuration descriptor attribute macro.

#define

Configuration descriptor transfer type bitmask.

#define

Configuration descriptor power macro.

#define

Standard request GET_STATUS bitmask.

#define

Standard request GET_STATUS bitmask.

#define

Standard request CLEAR/SET_FEATURE bitmask.

#define

Standard request CLEAR/SET_FEATURE bitmask.

#define

HUB class request CLEAR/SET_PORT_FEATURE feature selector.

#define

HUB class request CLEAR/SET_PORT_FEATURE feature selector.

#define

HUB class request CLEAR/SET_PORT_FEATURE feature selector.

#define

HUB class request CLEAR/SET_PORT_FEATURE feature selector.

#define

HUB class request CLEAR/SET_PORT_FEATURE feature selector.

#define

CDC device/interface class code.

#define

CDC Data interface class code.

#define

CDC Abstract Control Model interface subclass code.

#define

CDC class Header Functional Descriptor subtype.

#define

CDC class Call Management Functional Descriptor subtype.

#define

CDC class Abstract Control Management Functional Descriptor subtype.

#define

CDC class Union Functional Descriptor subtype.

#define

HID device/interface class code.

#define

HID keyboard interface protocol code.

#define

HID mouse interface protocol code.

#define

HUB device/interface class code.

#define

MSD device/interface class code.

#define

MSD Bulk Only Transport protocol.

#define

MSD Subclass SCSI transparent command set.

#define

MSD BOT Command status wrapper command passed code.

#define

MSD BOT Command status wrapper command failed code.

#define

MSD BOT Command status wrapper cmd phase error code.

#define

Audio interface class code.

#define

Audio subclass code for control interface.

#define

Audio subclass code for streaming interface.

#define

Audio subclass code for midi streaming interface.

#define

MISCELLANEOUS device class code.

#define

MISCELLANEOUS Common sub class code.

#define

MISCELLANEOUS Interface Association Descriptor protocol code.

#define

Full speed return value for USBH_GetPortSpeed().

#define

Low speed return value for USBH_GetPortSpeed().

#define

Use LFXO as DPLL clock source.

#define

Use HFXO as DPLL clock source.

#define

Macro for creating USB compliant UTF-16LE UNICODE string descriptors.

#define

Macro for creating USB compliant language string descriptors.

#define
UBUF (x, y)

Macro for creating WORD (4 byte) aligned uint8_t array with size which is a multiple of WORD size.

#define

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.

Parameters
TypeDirectionArgument NameDescription
[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


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#

USBTIMER_DelayMs#

void USBTIMER_DelayMs (uint32_t msec)

Active wait millisecond delay function.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
voidN/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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]id

Timer id (0..).


USB_PUTCHAR#

int USB_PUTCHAR (char c)

Transmit a single char on the debug serial port.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
char *[in]pre

Optional leader string to prepend to error message string.

int[in]error

Error code, see USB_Status_TypeDef.


Macro Definition Documentation#

SILABS_USB_VID#

#define SILABS_USB_VID
Value:
0x10C4

Silicon Labs Vendor ID, supplied by USB-IF.


USB_SETUP_DIR_OUT#

#define USB_SETUP_DIR_OUT
Value:
0

Setup request data stage OUT direction value.


USB_SETUP_DIR_IN#

#define USB_SETUP_DIR_IN
Value:
1

Setup request data stage IN direction value.


USB_SETUP_DIR_MASK#

#define USB_SETUP_DIR_MASK
Value:
0x80

Setup request data stage direction mask.


USB_SETUP_DIR_D2H#

#define USB_SETUP_DIR_D2H
Value:
0x80

Setup request data stage IN direction mask.


USB_SETUP_DIR_H2D#

#define USB_SETUP_DIR_H2D
Value:
0x00

Setup request data stage OUT direction mask.


USB_SETUP_TYPE_STANDARD#

#define USB_SETUP_TYPE_STANDARD
Value:
0

Standard setup request value.


USB_SETUP_TYPE_CLASS#

#define USB_SETUP_TYPE_CLASS
Value:
1

Class setup request value.


USB_SETUP_TYPE_VENDOR#

#define USB_SETUP_TYPE_VENDOR
Value:
2

Vendor setup request value.


USB_SETUP_TYPE_STANDARD_MASK#

#define USB_SETUP_TYPE_STANDARD_MASK
Value:
0x00

Standard setup request mask.


USB_SETUP_TYPE_CLASS_MASK#

#define USB_SETUP_TYPE_CLASS_MASK
Value:
0x20

Class setup request mask.


USB_SETUP_TYPE_VENDOR_MASK#

#define USB_SETUP_TYPE_VENDOR_MASK
Value:
0x40

Vendor setup request mask.


USB_SETUP_RECIPIENT_DEVICE#

#define USB_SETUP_RECIPIENT_DEVICE
Value:
0

Setup request device recipient value.


USB_SETUP_RECIPIENT_INTERFACE#

#define USB_SETUP_RECIPIENT_INTERFACE
Value:
1

Setup request interface recipient value.


USB_SETUP_RECIPIENT_ENDPOINT#

#define USB_SETUP_RECIPIENT_ENDPOINT
Value:
2

Setup request endpoint recipient value.


USB_SETUP_RECIPIENT_OTHER#

#define USB_SETUP_RECIPIENT_OTHER
Value:
3

Setup request other recipient value.


GET_STATUS#

#define GET_STATUS
Value:
0

Standard setup request GET_STATUS.


CLEAR_FEATURE#

#define CLEAR_FEATURE
Value:
1

Standard setup request CLEAR_FEATURE.


SET_FEATURE#

#define SET_FEATURE
Value:
3

Standard setup request SET_FEATURE.


SET_ADDRESS#

#define SET_ADDRESS
Value:
5

Standard setup request SET_ADDRESS.


GET_DESCRIPTOR#

#define GET_DESCRIPTOR
Value:
6

Standard setup request GET_DESCRIPTOR.


SET_DESCRIPTOR#

#define SET_DESCRIPTOR
Value:
7

Standard setup request SET_DESCRIPTOR.


GET_CONFIGURATION#

#define GET_CONFIGURATION
Value:
8

Standard setup request GET_CONFIGURATION.


SET_CONFIGURATION#

#define SET_CONFIGURATION
Value:
9

Standard setup request SET_CONFIGURATION.


GET_INTERFACE#

#define GET_INTERFACE
Value:
10

Standard setup request GET_INTERFACE.


SET_INTERFACE#

#define SET_INTERFACE
Value:
11

Standard setup request SET_INTERFACE.


SYNCH_FRAME#

#define SYNCH_FRAME
Value:
12

Standard setup request SYNCH_FRAME.


USB_HID_GET_REPORT#

#define USB_HID_GET_REPORT
Value:
0x01

HID class setup request GET_REPORT.


USB_HID_GET_IDLE#

#define USB_HID_GET_IDLE
Value:
0x02

HID class setup request GET_IDLE.


USB_HID_SET_REPORT#

#define USB_HID_SET_REPORT
Value:
0x09

HID class setup request SET_REPORT.


USB_HID_SET_IDLE#

#define USB_HID_SET_IDLE
Value:
0x0A

HID class setup request SET_IDLE.


USB_HID_SET_PROTOCOL#

#define USB_HID_SET_PROTOCOL
Value:
0x0B

HID class setup request SET_PROTOCOL.


USB_CDC_SETLINECODING#

#define USB_CDC_SETLINECODING
Value:
0x20

CDC class setup request SET_LINE_CODING.


USB_CDC_GETLINECODING#

#define USB_CDC_GETLINECODING
Value:
0x21

CDC class setup request GET_LINE_CODING.


USB_CDC_SETCTRLLINESTATE#

#define USB_CDC_SETCTRLLINESTATE
Value:
0x22

CDC class setup request SET_CONTROL_LINE_STATE.


USB_MSD_BOTRESET#

#define USB_MSD_BOTRESET
Value:
0xFF

MSD class setup request Bulk only transfer reset.


USB_MSD_GETMAXLUN#

#define USB_MSD_GETMAXLUN
Value:
0xFE

MSD class setup request Get Max LUN.


USB_AUDIO_GET_CUR#

#define USB_AUDIO_GET_CUR
Value:
0x81

Audio class setup request GET_CUR.


USB_AUDIO_GET_CUR#

#define USB_AUDIO_GET_CUR
Value:
0x81

Audio class setup request GET_CUR.


USB_AUDIO_SET_CUR#

#define USB_AUDIO_SET_CUR
Value:
0x01

Audio class setup request SET_CUR.


USB_AUDIO_SET_MIN#

#define USB_AUDIO_SET_MIN
Value:
0x02

Audio class setup request SET_MIN.


USB_AUDIO_GET_MIN#

#define USB_AUDIO_GET_MIN
Value:
0x82

Audio class setup request GET_MIN.


USB_AUDIO_SET_MAX#

#define USB_AUDIO_SET_MAX
Value:
0x03

Audio class setup request SET_MAX.


USB_AUDIO_GET_MAX#

#define USB_AUDIO_GET_MAX
Value:
0x83

Audio class setup request GET_MAX.


USB_AUDIO_SET_RES#

#define USB_AUDIO_SET_RES
Value:
0x04

Audio class setup request SET_RES.


USB_AUDIO_GET_RES#

#define USB_AUDIO_GET_RES
Value:
0x84

Audio class setup request GET_RES.


USB_AUDIO_SET_MEM#

#define USB_AUDIO_SET_MEM
Value:
0x05

Audio class setup request SET_MEM.


USB_AUDIO_GET_MEM#

#define USB_AUDIO_GET_MEM
Value:
0x85

Audio class setup request GET_MEM.


USB_AUDIO_GET_STAT#

#define USB_AUDIO_GET_STAT
Value:
0xFF

Audio class setup request GET_STAT.


USB_DEVICE_DESCRIPTOR#

#define USB_DEVICE_DESCRIPTOR
Value:
1

DEVICE descriptor value.


USB_CONFIG_DESCRIPTOR#

#define USB_CONFIG_DESCRIPTOR
Value:
2

CONFIGURATION descriptor value.


USB_STRING_DESCRIPTOR#

#define USB_STRING_DESCRIPTOR
Value:
3

STRING descriptor value.


USB_MAX_STRING_DESCRIPTOR_CHARS#

#define USB_MAX_STRING_DESCRIPTOR_CHARS
Value:
126

Maximum STRING descriptor bString length.


USB_INTERFACE_DESCRIPTOR#

#define USB_INTERFACE_DESCRIPTOR
Value:
4

INTERFACE descriptor value.


USB_ENDPOINT_DESCRIPTOR#

#define USB_ENDPOINT_DESCRIPTOR
Value:
5

ENDPOINT descriptor value.


USB_DEVICE_QUALIFIER_DESCRIPTOR#

#define USB_DEVICE_QUALIFIER_DESCRIPTOR
Value:
6

DEVICE_QUALIFIER descriptor value.


USB_OTHER_SPEED_CONFIG_DESCRIPTOR#

#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR
Value:
7

OTHER_SPEED_CONFIGURATION descriptor value.


USB_INTERFACE_POWER_DESCRIPTOR#

#define USB_INTERFACE_POWER_DESCRIPTOR
Value:
8

INTERFACE_POWER descriptor value.


USB_INTERFACE_ASSOCIATION_DESCRIPTOR#

#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR
Value:
11

INTERFACE_ASSOCIATION descriptor value.


USB_HID_DESCRIPTOR#

#define USB_HID_DESCRIPTOR
Value:
0x21

HID descriptor value.


USB_SMARTCARD_DESCRIPTOR#

#define USB_SMARTCARD_DESCRIPTOR
Value:
0x21

Smartcard usb-ccid-specific Descriptor Type.


USB_HID_REPORT_DESCRIPTOR#

#define USB_HID_REPORT_DESCRIPTOR
Value:
0x22

HID REPORT descriptor value.


USB_CS_INTERFACE_DESCRIPTOR#

#define USB_CS_INTERFACE_DESCRIPTOR
Value:
0x24

Audio Class-specific interface Descriptor Type.


USB_CS_ENDPOINT_DESCRIPTOR#

#define USB_CS_ENDPOINT_DESCRIPTOR
Value:
0x25

Audio Class-specific endpoint Descriptor Type.


USB_HUB_DESCRIPTOR#

#define USB_HUB_DESCRIPTOR
Value:
0x29

HUB descriptor value.


USB_CA_HEADER_DESCRIPTOR#

#define USB_CA_HEADER_DESCRIPTOR
Value:
1

Audio Class-Specific AC Interface Header descriptor.


USB_CA_INPUT_TERMINAL_DESCRIPTOR#

#define USB_CA_INPUT_TERMINAL_DESCRIPTOR
Value:
2

Audio Class-Specific AC Interface Input Terminal desc.


USB_CA_OUTPUT_TERMINAL_DESCRIPTOR#

#define USB_CA_OUTPUT_TERMINAL_DESCRIPTOR
Value:
3

Audio Class-Specific AC Interface Output Terminal desc.


USB_CA_MIXER_UNIT_DESCRIPTOR#

#define USB_CA_MIXER_UNIT_DESCRIPTOR
Value:
4

Audio Class-Specific AC Interface Mixer descriptor.


USB_CA_SELECTOR_UNIT_DESCRIPTOR#

#define USB_CA_SELECTOR_UNIT_DESCRIPTOR
Value:
5

Audio Class-Specific AC Interface Selector desc.


USB_CA_FEATURE_UNIT_DESCRIPTOR#

#define USB_CA_FEATURE_UNIT_DESCRIPTOR
Value:
6

Audio Class-Specific AC Interface Feature desc.


USB_CA_PROCESSING_UNIT_DESCRIPTOR#

#define USB_CA_PROCESSING_UNIT_DESCRIPTOR
Value:
7

Audio Class-Specific AC Interface Processing desc.


USB_CA_EXTENSION_UNIT_DESCRIPTOR#

#define USB_CA_EXTENSION_UNIT_DESCRIPTOR
Value:
8

Audio Class-Specific AC Interface Extension desc.


USB_CA_EP_GENERAL_DESCRIPTOR#

#define USB_CA_EP_GENERAL_DESCRIPTOR
Value:
1

Audio Class-Specific general descriptor subtype code.


USB_CA_AS_GENERAL_DESCRIPTOR#

#define USB_CA_AS_GENERAL_DESCRIPTOR
Value:
1

Audio Class-Specific AS Interface General descriptor.


USB_CA_FORMAT_TYPE_DESCRIPTOR#

#define USB_CA_FORMAT_TYPE_DESCRIPTOR
Value:
2

Audio Class-Specific AS Interface Format Type desc.


USB_DEVICE_DESCSIZE#

#define USB_DEVICE_DESCSIZE
Value:
18

Device descriptor size.


USB_CONFIG_DESCSIZE#

#define USB_CONFIG_DESCSIZE
Value:
9

Configuration descriptor size.


USB_INTERFACE_DESCSIZE#

#define USB_INTERFACE_DESCSIZE
Value:
9

Interface descriptor size.


USB_ENDPOINT_DESCSIZE#

#define USB_ENDPOINT_DESCSIZE
Value:
7

Endpoint descriptor size.


USB_DEVICE_QUALIFIER_DESCSIZE#

#define USB_DEVICE_QUALIFIER_DESCSIZE
Value:
10

Device qualifier descriptor size.


USB_OTHER_SPEED_CONFIG_DESCSIZE#

#define USB_OTHER_SPEED_CONFIG_DESCSIZE
Value:
9

Device other speed configuration descriptor size.


USB_INTERFACE_ASSOCIATION_DESCSIZE#

#define USB_INTERFACE_ASSOCIATION_DESCSIZE
Value:
8

INTERFACE_ASSOCIATION descriptor size.


USB_HID_DESCSIZE#

#define USB_HID_DESCSIZE
Value:
9

HID descriptor size.


USB_SMARTCARD_DESCSIZE#

#define USB_SMARTCARD_DESCSIZE
Value:
54

CCID descriptor size.


USB_CDC_HEADER_FND_DESCSIZE#

#define USB_CDC_HEADER_FND_DESCSIZE
Value:
5

CDC Header functional descriptor size.


USB_CDC_CALLMNG_FND_DESCSIZE#

#define USB_CDC_CALLMNG_FND_DESCSIZE
Value:
5

CDC Call Management functional descriptor size.


USB_CDC_ACM_FND_DESCSIZE#

#define USB_CDC_ACM_FND_DESCSIZE
Value:
4

CDC Abstract Control Management functional descriptor size.


USB_CA_INPUT_TERMINAL_DESCSIZE#

#define USB_CA_INPUT_TERMINAL_DESCSIZE
Value:
12

Audio Input Terminal descriptor size.


USB_CA_OUTPUT_TERMINAL_DESCSIZE#

#define USB_CA_OUTPUT_TERMINAL_DESCSIZE
Value:
9

Audio Output Terminal descriptor size.


USB_CA_EP_GENERAL_DESCSIZE#

#define USB_CA_EP_GENERAL_DESCSIZE
Value:
7

Audio Class-Specific general descriptor subtype size.


USB_CA_AS_GENERAL_DESCSIZE#

#define USB_CA_AS_GENERAL_DESCSIZE
Value:
7

Audio Class-Specific AS Interface General desc size.


USB_CA_STD_AS_ENDPOINT_DESCSZIE#

#define USB_CA_STD_AS_ENDPOINT_DESCSZIE
Value:
9

Audio-class standard audio stream descriptor size.


USB_LS_CTRL_EP_MAXSIZE#

#define USB_LS_CTRL_EP_MAXSIZE
Value:
8

The max size of low speed control endpoints.


USB_LS_INTR_EP_MAXSIZE#

#define USB_LS_INTR_EP_MAXSIZE
Value:
8

The max size of low speed interrupt endpoints.


USB_FS_CTRL_EP_MAXSIZE#

#define USB_FS_CTRL_EP_MAXSIZE
Value:
64

The max size of full speed control endpoints.


USB_FS_INTR_EP_MAXSIZE#

#define USB_FS_INTR_EP_MAXSIZE
Value:
64

The max size of full speed interrupt endpoints.


USB_FS_BULK_EP_MAXSIZE#

#define USB_FS_BULK_EP_MAXSIZE
Value:
64

The max size of full speed bulk endpoints.


USB_FS_ISOC_EP_MAXSIZE#

#define USB_FS_ISOC_EP_MAXSIZE
Value:
1023

The max size of full speed isochronous endpoints.


USB_EPTYPE_CTRL#

#define USB_EPTYPE_CTRL
Value:
0

Endpoint type control.


USB_EPTYPE_ISOC#

#define USB_EPTYPE_ISOC
Value:
1

Endpoint type isochron.


USB_EPTYPE_BULK#

#define USB_EPTYPE_BULK
Value:
2

Endpoint type bulk.


USB_EPTYPE_INTR#

#define USB_EPTYPE_INTR
Value:
3

Endpoint type interrupt.


USB_EPSYNC_NO#

#define USB_EPSYNC_NO
Value:
(0 << 2)

Endpoint synchronization type, none.


USB_EPSYNC_ASYNC#

#define USB_EPSYNC_ASYNC
Value:
(1 << 2)

Endpoint synchronization type, asynchronous.


USB_EPSYNC_ADAPTIVE#

#define USB_EPSYNC_ADAPTIVE
Value:
(2 << 2)

Endpoint synchronization type, adaptive.


USB_EPSYNC_SYNC#

#define USB_EPSYNC_SYNC
Value:
(3 << 2)

Endpoint synchronization type, synchronous.


USB_EP_DIR_IN#

#define USB_EP_DIR_IN
Value:
0x80

Endpoint direction mask.


USB_SETUP_PKT_SIZE#

#define USB_SETUP_PKT_SIZE
Value:
8

Setup request packet size.


USB_EPNUM_MASK#

#define USB_EPNUM_MASK
Value:
0x0F

Endpoint number mask.


USB_LANGID_ENUS#

#define USB_LANGID_ENUS
Value:
0x0409

English-United States language id.


USB_MAX_DEVICE_ADDRESS#

#define USB_MAX_DEVICE_ADDRESS
Value:
127

Maximum allowable device address.


CONFIG_DESC_BM_REMOTEWAKEUP#

#define CONFIG_DESC_BM_REMOTEWAKEUP
Value:
0x20

Configuration descriptor attribute macro.


CONFIG_DESC_BM_SELFPOWERED#

#define CONFIG_DESC_BM_SELFPOWERED
Value:
0x40

Configuration descriptor attribute macro.


CONFIG_DESC_BM_RESERVED_D7#

#define CONFIG_DESC_BM_RESERVED_D7
Value:
0x80

Configuration descriptor attribute macro.


CONFIG_DESC_BM_TRANSFERTYPE#

#define CONFIG_DESC_BM_TRANSFERTYPE
Value:
0x03

Configuration descriptor transfer type bitmask.


CONFIG_DESC_MAXPOWER_mA#

#define CONFIG_DESC_MAXPOWER_mA
Value:
(x)

Configuration descriptor power macro.


DEVICE_IS_SELFPOWERED#

#define DEVICE_IS_SELFPOWERED
Value:
0x0001

Standard request GET_STATUS bitmask.


REMOTE_WAKEUP_ENABLED#

#define REMOTE_WAKEUP_ENABLED
Value:
0x0002

Standard request GET_STATUS bitmask.


USB_FEATURE_ENDPOINT_HALT#

#define USB_FEATURE_ENDPOINT_HALT
Value:
0

Standard request CLEAR/SET_FEATURE bitmask.


USB_FEATURE_DEVICE_REMOTE_WAKEUP#

#define USB_FEATURE_DEVICE_REMOTE_WAKEUP
Value:
1

Standard request CLEAR/SET_FEATURE bitmask.


HUB_FEATURE_PORT_RESET#

#define HUB_FEATURE_PORT_RESET
Value:
4

HUB class request CLEAR/SET_PORT_FEATURE feature selector.


HUB_FEATURE_PORT_POWER#

#define HUB_FEATURE_PORT_POWER
Value:
8

HUB class request CLEAR/SET_PORT_FEATURE feature selector.


HUB_FEATURE_C_PORT_CONNECTION#

#define HUB_FEATURE_C_PORT_CONNECTION
Value:
16

HUB class request CLEAR/SET_PORT_FEATURE feature selector.


HUB_FEATURE_C_PORT_RESET#

#define HUB_FEATURE_C_PORT_RESET
Value:
20

HUB class request CLEAR/SET_PORT_FEATURE feature selector.


HUB_FEATURE_PORT_INDICATOR#

#define HUB_FEATURE_PORT_INDICATOR
Value:
22

HUB class request CLEAR/SET_PORT_FEATURE feature selector.


USB_CLASS_CDC#

#define USB_CLASS_CDC
Value:
2

CDC device/interface class code.


USB_CLASS_CDC_DATA#

#define USB_CLASS_CDC_DATA
Value:
0x0A

CDC Data interface class code.


USB_CLASS_CDC_ACM#

#define USB_CLASS_CDC_ACM
Value:
2

CDC Abstract Control Model interface subclass code.


USB_CLASS_CDC_HFN#

#define USB_CLASS_CDC_HFN
Value:
0

CDC class Header Functional Descriptor subtype.


USB_CLASS_CDC_CMNGFN#

#define USB_CLASS_CDC_CMNGFN
Value:
1

CDC class Call Management Functional Descriptor subtype.


USB_CLASS_CDC_ACMFN#

#define USB_CLASS_CDC_ACMFN
Value:
2

CDC class Abstract Control Management Functional Descriptor subtype.


USB_CLASS_CDC_UNIONFN#

#define USB_CLASS_CDC_UNIONFN
Value:
6

CDC class Union Functional Descriptor subtype.


USB_CLASS_HID#

#define USB_CLASS_HID
Value:
3

HID device/interface class code.


USB_CLASS_HID_KEYBOARD#

#define USB_CLASS_HID_KEYBOARD
Value:
1

HID keyboard interface protocol code.


USB_CLASS_HID_MOUSE#

#define USB_CLASS_HID_MOUSE
Value:
2

HID mouse interface protocol code.


USB_CLASS_HUB#

#define USB_CLASS_HUB
Value:
9

HUB device/interface class code.


USB_CLASS_MSD#

#define USB_CLASS_MSD
Value:
8

MSD device/interface class code.


USB_CLASS_MSD_BOT_TRANSPORT#

#define USB_CLASS_MSD_BOT_TRANSPORT
Value:
0x50

MSD Bulk Only Transport protocol.


USB_CLASS_MSD_SCSI_CMDSET#

#define USB_CLASS_MSD_SCSI_CMDSET
Value:
6

MSD Subclass SCSI transparent command set.


USB_CLASS_MSD_CSW_CMDPASSED#

#define USB_CLASS_MSD_CSW_CMDPASSED
Value:
0

MSD BOT Command status wrapper command passed code.


USB_CLASS_MSD_CSW_CMDFAILED#

#define USB_CLASS_MSD_CSW_CMDFAILED
Value:
1

MSD BOT Command status wrapper command failed code.


USB_CLASS_MSD_CSW_PHASEERROR#

#define USB_CLASS_MSD_CSW_PHASEERROR
Value:
2

MSD BOT Command status wrapper cmd phase error code.


USB_CLASS_AUDIO#

#define USB_CLASS_AUDIO
Value:
1

Audio interface class code.


USB_CLASS_AUDIO_CONTROL#

#define USB_CLASS_AUDIO_CONTROL
Value:
1

Audio subclass code for control interface.


USB_CLASS_AUDIO_STREAMING#

#define USB_CLASS_AUDIO_STREAMING
Value:
2

Audio subclass code for streaming interface.


USB_CLASS_AUDIO_MIDISTREAMING#

#define USB_CLASS_AUDIO_MIDISTREAMING
Value:
3

Audio subclass code for midi streaming interface.


USB_CLASS_MISCELLANEOUS#

#define USB_CLASS_MISCELLANEOUS
Value:
0xEF

MISCELLANEOUS device class code.


USB_CLASS_MISC_COMMON_SUBCLASS#

#define USB_CLASS_MISC_COMMON_SUBCLASS
Value:
2

MISCELLANEOUS Common sub class code.


USB_CLASS_MISC_IAD_PROTOCOL#

#define USB_CLASS_MISC_IAD_PROTOCOL
Value:
1

MISCELLANEOUS Interface Association Descriptor protocol code.


PORT_FULL_SPEED#

#define PORT_FULL_SPEED
Value:
1

Full speed return value for USBH_GetPortSpeed().


PORT_LOW_SPEED#

#define PORT_LOW_SPEED
Value:
2

Low speed return value for USBH_GetPortSpeed().


USB_DPLL_SRC_LFXO#

#define USB_DPLL_SRC_LFXO
Value:
1

Use LFXO as DPLL clock source.


USB_DPLL_SRC_HFXO#

#define USB_DPLL_SRC_HFXO
Value:
2

Use HFXO as DPLL clock source.


STATIC_CONST_STRING_DESC#

#define STATIC_CONST_STRING_DESC
Value:
SL_PACK_START(1) \
typedef struct \
{ \
uint8_t len; \
uint8_t type; \
char16_t name[1 + sizeof((char16_t[]){ __VA_ARGS__ }) / 2]; \
} SL_ATTRIBUTE_PACKED _##_name; \
SL_PACK_END() \
SL_ALIGN(4) \
SL_PACK_START(1) \
static const _##_name _name SL_ATTRIBUTE_ALIGN(4) = \
{ \
.len = sizeof(_##_name) - 2, \
.type = USB_STRING_DESCRIPTOR, \
.name = { __VA_ARGS__ }, \
.name[((sizeof(_##_name) - 2) / 2) - 1] = '\0' \
} \
SL_PACK_END()

Macro for creating USB compliant UTF-16LE UNICODE string descriptors.

Example: STATIC_CONST_STRING_DESC(iManufacturer, 'E','n','e','r','g','y',' ','M','i','c','r','o',' ','A','S'); Note

  • The size of the resulting struct will be two byte larger than a USB string descriptor. This is to accommodate a terminating null char for the string. The value assigned to the 'len' member does not take this into account and is therefore correct usb wise.


STATIC_CONST_STRING_DESC_LANGID#

#define STATIC_CONST_STRING_DESC_LANGID
Value:
SL_PACK_START(1) \
typedef struct \
{ \
uint8_t len; \
uint8_t type; \
uint8_t name[2]; \
} SL_ATTRIBUTE_PACKED _##_name; \
SL_PACK_END() \
SL_ALIGN(4) \
SL_PACK_START(1) \
static const _##_name _name SL_ATTRIBUTE_ALIGN(4) = \
{ \
.len = 4, \
.type = USB_STRING_DESCRIPTOR, \
.name = { y, x } \
} \
SL_PACK_END()

Macro for creating USB compliant language string descriptors.

Example: STATIC_CONST_STRING_DESC_LANGID(langID, 0x04, 0x09);


UBUF#

#define UBUF
Value:
(x, y)

Macro for creating WORD (4 byte) aligned uint8_t array with size which is a multiple of WORD size.

Example: UBUF(rxBuffer, 37); => uint8_t rxBuffer[40];


STATIC_UBUF#

#define STATIC_UBUF
Value:
(x, y)

Macro for creating WORD (4 byte) aligned static uint8_t arrays with size which is a multiple of WORD size.

Example: STATIC_UBUF(rxBuffer, 37); => static uint8_t rxBuffer[40];