USB Common API
Sample API functions for using USB.
Data Structures |
|
struct | USB_Setup_TypeDef |
USB Setup request package.
|
|
struct | USB_DeviceDescriptor_TypeDef |
USB Device Descriptor.
|
|
struct | USB_ConfigurationDescriptor_TypeDef |
USB Configuration Descriptor.
|
|
struct | USB_InterfaceDescriptor_TypeDef |
USB Interface Descriptor.
|
|
struct | USB_EndpointDescriptor_TypeDef |
USB Endpoint Descriptor.
|
|
struct | USB_StringDescriptor_TypeDef |
USB String Descriptor.
|
Typedefs |
|
typedef int(* | USB_XferCompleteCb_TypeDef ) ( USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining) |
USB transfer callback function.
|
|
typedef void(* | USBTIMER_Callback_TypeDef ) (void) |
USBTIMER callback function.
|
Enumerations |
|
enum |
USB_Status_TypeDef
{
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.
|
Functions |
|
void | USBTIMER_DelayMs (uint32_t msec) |
void | USBTIMER_DelayUs (uint32_t usec) |
void | USBTIMER_Init (void) |
void | USBTIMER_Start (uint32_t id, uint32_t timeout, USBTIMER_Callback_TypeDef callback) |
void | USBTIMER_Stop (uint32_t id) |
Detailed Description
See
em_usb.h
for source code.
Macro Definition Documentation
#define CLEAR_FEATURE 1 |
Standard setup request CLEAR_FEATURE.
#define CONFIG_DESC_BM_REMOTEWAKEUP 0x20 |
Configuration descriptor attribute macro.
#define CONFIG_DESC_BM_RESERVED_D7 0x80 |
Configuration descriptor attribute macro.
#define CONFIG_DESC_BM_SELFPOWERED 0x40 |
Configuration descriptor attribute macro.
#define CONFIG_DESC_BM_TRANSFERTYPE 0x03 |
Configuration descriptor transfer type bitmask.
Referenced by USBD_Init() .
#define CONFIG_DESC_MAXPOWER_mA | ( |
x
|
) | (((x) + 1) / 2) |
Configuration descriptor power macro.
#define DEVICE_IS_SELFPOWERED 0x0001 |
Standard request GET_STATUS bitmask.
#define GET_CONFIGURATION 8 |
Standard setup request GET_CONFIGURATION.
#define GET_DESCRIPTOR 6 |
Standard setup request GET_DESCRIPTOR.
#define GET_INTERFACE 10 |
Standard setup request GET_INTERFACE.
#define GET_STATUS 0 |
Standard setup request GET_STATUS.
#define HUB_FEATURE_C_PORT_CONNECTION 16 |
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
#define HUB_FEATURE_C_PORT_RESET 20 |
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
#define HUB_FEATURE_PORT_INDICATOR 22 |
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
#define HUB_FEATURE_PORT_POWER 8 |
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
#define HUB_FEATURE_PORT_RESET 4 |
HUB class request CLEAR/SET_PORT_FEATURE feature selector.
#define nibble2Ascii | ( |
n
|
) | ((n) + (((n) < 10) ? '0' : 'A' - 10)); |
#define PORT_FULL_SPEED 1 |
Full speed return value for USBH_GetPortSpeed().
#define PORT_LOW_SPEED 2 |
Low speed return value for USBH_GetPortSpeed().
#define REMOTE_WAKEUP_ENABLED 0x0002 |
Standard request GET_STATUS bitmask.
#define SET_ADDRESS 5 |
Standard setup request SET_ADDRESS.
#define SET_CONFIGURATION 9 |
Standard setup request SET_CONFIGURATION.
#define SET_DESCRIPTOR 7 |
Standard setup request SET_DESCRIPTOR.
#define SET_FEATURE 3 |
Standard setup request SET_FEATURE.
#define SET_INTERFACE 11 |
Standard setup request SET_INTERFACE.
#define STATIC_CONST_STRING_DESC | ( |
_name,
|
|
...
|
|||
) |
#define STATIC_CONST_STRING_DESC_LANGID | ( |
_name,
|
|
x,
|
|||
y
|
|||
) |
Macro for creating USB compliant language string descriptors.
Example:
STATIC_CONST_STRING_DESC_LANGID( langID, 0x04, 0x09 )
;
#define STATIC_UBUF | ( |
x,
|
|
y
|
|||
) | EFM32_ALIGN(4) static uint8_t x[((y) + 3) & ~3] |
#define SYNCH_FRAME 12 |
Standard setup request SYNCH_FRAME.
#define UBUF | ( |
x,
|
|
y
|
|||
) | EFM32_ALIGN(4) uint8_t x[((y) + 3) & ~3] |
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 ];
#define USB_CDC_ACM_FND_DESCSIZE 4 |
CDC Abstract Control Management functional descriptor size.
#define USB_CDC_CALLMNG_FND_DESCSIZE 5 |
CDC Call Management functional descriptor size.
#define USB_CDC_GETLINECODING 0x21 |
CDC class setup request GET_LINE_CODING.
#define USB_CDC_HEADER_FND_DESCSIZE 5 |
CDC Header functional descriptor size.
#define USB_CDC_SETCTRLLINESTATE 0x22 |
CDC class setup request SET_CONTROL_LINE_STATE.
#define USB_CDC_SETLINECODING 0x20 |
CDC class setup request SET_LINE_CODING.
#define USB_CLASS_CDC 2 |
CDC device/interface class code.
#define USB_CLASS_CDC_ACM 2 |
CDC Abstract Control Model interface subclass code.
#define USB_CLASS_CDC_ACMFN 2 |
CDC class Abstract Control Management Functional Descriptor subtype.
#define USB_CLASS_CDC_CMNGFN 1 |
CDC class Call Management Functional Descriptor subtype.
#define USB_CLASS_CDC_DATA 0x0A |
CDC Data interface class code.
#define USB_CLASS_CDC_HFN 0 |
CDC class Header Functional Descriptor subtype.
#define USB_CLASS_CDC_UNIONFN 6 |
CDC class Union Functional Descriptor subtype.
#define USB_CLASS_HID 3 |
HID device/interface class code.
#define USB_CLASS_HID_KEYBOARD 1 |
HID keyboard interface protocol code.
#define USB_CLASS_HID_MOUSE 2 |
HID mouse interface protocol code.
#define USB_CLASS_HUB 9 |
HUB device/interface class code.
#define USB_CLASS_MSD 8 |
MSD device/interface class code.
#define USB_CLASS_MSD_BOT_TRANSPORT 0x50 |
MSD Bulk Only Transport protocol.
#define USB_CLASS_MSD_CSW_CMDFAILED 1 |
MSD BOT Command status wrapper command failed code.
#define USB_CLASS_MSD_CSW_CMDPASSED 0 |
MSD BOT Command status wrapper command passed code.
#define USB_CLASS_MSD_CSW_PHASEERROR 2 |
MSD BOT Command status wrapper cmd phase error code.
#define USB_CLASS_MSD_SCSI_CMDSET 6 |
MSD Subclass SCSI transparent command set.
#define USB_CONFIG_DESCRIPTOR 2 |
CONFIGURATION descriptor value.
#define USB_CONFIG_DESCSIZE 9 |
Configuration descriptor size.
#define USB_CS_INTERFACE_DESCRIPTOR 0x24 |
Audio Class-specific Descriptor Type.
#define USB_DEVICE_DESCRIPTOR 1 |
DEVICE descriptor value.
#define USB_DEVICE_DESCSIZE 18 |
Device descriptor size.
#define USB_DEVICE_QUALIFIER_DESCRIPTOR 6 |
DEVICE_QUALIFIER descriptor value.
#define USB_DEVICE_QUALIFIER_DESCSIZE 10 |
Device qualifier descriptor size.
#define USB_ENDPOINT_DESCRIPTOR 5 |
ENDPOINT descriptor value.
Referenced by USBD_Init() .
#define USB_ENDPOINT_DESCSIZE 7 |
Endpoint descriptor size.
#define USB_EP0_SIZE 8 |
The size of endpoint 0.
Referenced by USBD_Init() .
#define USB_EP1_SIZE 8 |
The size of endpoint 1.
#define USB_EP2_SIZE 8 |
The size of endpoint 2.
#define USB_EP3_SIZE 64 |
The size of endpoint 3.
#define USB_EP4_SIZE 32 |
The size of endpoint 4.
#define USB_EP5_SIZE 64 |
The size of endpoint 5.
#define USB_EP6_SIZE 512 |
The size of endpoint 6.
#define USB_EP_DIR_IN 0x80 |
Endpoint direction mask.
#define USB_EPNUM_MASK 0x0F |
Endpoint number mask.
Referenced by USBD_Init() .
#define USB_EPTYPE_BULK 2 |
Endpoint type bulk.
#define USB_EPTYPE_CTRL 0 |
Endpoint type control.
Referenced by USBD_Init() .
#define USB_EPTYPE_INTR 3 |
Endpoint type interrupt.
#define USB_EPTYPE_ISOC 1 |
Endpoint type isochron.
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 |
Standard request CLEAR/SET_FEATURE bitmask.
#define USB_FEATURE_ENDPOINT_HALT 0 |
Standard request CLEAR/SET_FEATURE bitmask.
#define USB_HID_DESCRIPTOR 0x21 |
HID descriptor value.
#define USB_HID_DESCSIZE 9 |
HID descriptor size.
#define USB_HID_GET_IDLE 0x02 |
HID class setup request GET_IDLE.
#define USB_HID_GET_REPORT 0x01 |
HID class setup request GET_REPORT.
#define USB_HID_REPORT_DESCRIPTOR 0x22 |
HID REPORT descriptor value.
#define USB_HID_SET_IDLE 0x0A |
HID class setup request SET_IDLE.
#define USB_HID_SET_PROTOCOL 0x0B |
HID class setup request SET_PROTOCOL.
#define USB_HID_SET_REPORT 0x09 |
HID class setup request SET_REPORT.
#define USB_HUB_DESCRIPTOR 0x29 |
HUB descriptor value.
#define USB_INTERFACE_DESCRIPTOR 4 |
INTERFACE descriptor value.
#define USB_INTERFACE_DESCSIZE 9 |
Interface descriptor size.
#define USB_INTERFACE_POWER_DESCRIPTOR 8 |
INTERFACE_POWER descriptor value.
#define USB_LANGID_ENUS 0x0409 |
English-United States language id.
#define USB_MAX_DEVICE_ADDRESS 127 |
Maximum allowable device address.
#define USB_MAX_EP_SIZE 64 |
The max size of any full speed endpoint.
#define USB_MSD_BOTRESET 0xFF |
MSD class setup request Bulk only transfer reset.
#define USB_MSD_GETMAXLUN 0xFE |
MSD class setup request Get Max LUN.
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR 7 |
OTHER_SPEED_CONFIGURATION descriptor value.
#define USB_OTHER_SPEED_CONFIG_DESCSIZE 9 |
Device other speed configuration descriptor size.
#define USB_SETUP_DIR_D2H 0x80 |
Setup request data stage IN direction mask.
#define USB_SETUP_DIR_H2D 0x00 |
Setup request data stage OUT direction mask.
#define USB_SETUP_DIR_IN 1 |
Setup request data stage IN direction value.
#define USB_SETUP_DIR_MASK 0x80 |
Setup request data stage direction mask.
Referenced by USBD_Init() .
#define USB_SETUP_DIR_OUT 0 |
Setup request data stage OUT direction value.
#define USB_SETUP_PKT_SIZE 8 |
Setup request packet size.
#define USB_SETUP_RECIPIENT_DEVICE 0 |
Setup request device recipient value.
#define USB_SETUP_RECIPIENT_ENDPOINT 2 |
Setup request endpoint recipient value.
#define USB_SETUP_RECIPIENT_INTERFACE 1 |
Setup request interface recipient value.
#define USB_SETUP_RECIPIENT_OTHER 3 |
Setup request other recipient value.
#define USB_SETUP_TYPE_CLASS 1 |
Class setup request value.
#define USB_SETUP_TYPE_CLASS_MASK 0x20 |
Class setup request mask.
#define USB_SETUP_TYPE_STANDARD 0 |
Standard setup request value.
#define USB_SETUP_TYPE_STANDARD_MASK 0x00 |
Standard setup request mask.
#define USB_SETUP_TYPE_VENDOR 2 |
Vendor setup request value.
#define USB_SETUP_TYPE_VENDOR_MASK 0x40 |
Vendor setup request mask.
#define USB_STRING_DESCRIPTOR 3 |
STRING descriptor value.
Typedef Documentation
typedef int(* USB_XferCompleteCb_TypeDef) ( USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining) |
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.
- Parameters
-
[in] status
The transfer status. See USB_Status_TypeDef . [in] xferred
Number of bytes actually transferred. [in] remaining
Number of bytes not transferred.
- Returns
- USB_STATUS_OK on success, else an appropriate error code.
typedef void(* USBTIMER_Callback_TypeDef) (void) |
The callback function is called when an USBTIMER has expired. The callback is done with interrupts disabled.
Enumeration Type Documentation
enum USB_Status_TypeDef |
Function Documentation
void USBTIMER_DelayMs | ( | uint32_t |
msec
|
) |
void USBTIMER_DelayUs | ( | uint32_t |
usec
|
) |
void USBTIMER_Init | ( | void |
|
) |
Referenced by USBD_Init() .
void USBTIMER_Start | ( | uint32_t |
id,
|
uint32_t |
timeout,
|
||
USBTIMER_Callback_TypeDef |
callback
|
||
) |
void USBTIMER_Stop | ( | uint32_t |
id
|
) |