USBLibAPIGuide  1.00.00.01
Data Structures | Macros | Typedefs | Enumerations | Functions
usblib.h File Reference
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for usblib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 
struct  tCustomHandlers
 
struct  tConfigSection
 
struct  tConfigHeader
 
struct  tEventInfo
 
struct  tLPMFeature
 
struct  tUSBRingBufObject
 
struct  tUSBBufferVars
 
struct  tUSBBuffer
 

Macros

#define MAX_USB_DEVICES   5
 
#define USBLIB_NUM_EP   8
 
#define USB_LANG_CHINESE_PRC   0x0804
 
#define USB_LANG_CHINESE_TAIWAN   0x0404
 
#define USB_LANG_EN_US   0x0409
 
#define USB_LANG_EN_UK   0x0809
 
#define USB_LANG_EN_AUS   0x0C09
 
#define USB_LANG_EN_CA   0x1009
 
#define USB_LANG_EN_NZ   0x1409
 
#define USB_LANG_FRENCH   0x040C
 
#define USB_LANG_GERMAN   0x0407
 
#define USB_LANG_HINDI   0x0439
 
#define USB_LANG_ITALIAN   0x0410
 
#define USB_LANG_JAPANESE   0x0411
 
#define USB_LANG_KOREAN   0x0412
 
#define USB_LANG_ES_TRAD   0x040A
 
#define USB_LANG_ES_MODERN   0x0C0A
 
#define USB_LANG_SWAHILI   0x0441
 
#define USB_LANG_URDU_IN   0x0820
 
#define USB_LANG_URDU_PK   0x0420
 
#define USB_RTYPE_DIR_IN   0x80
 
#define USB_RTYPE_DIR_OUT   0x00
 
#define USB_RTYPE_TYPE_M   0x60
 
#define USB_RTYPE_VENDOR   0x40
 
#define USB_RTYPE_CLASS   0x20
 
#define USB_RTYPE_STANDARD   0x00
 
#define USB_RTYPE_RECIPIENT_M   0x1f
 
#define USB_RTYPE_OTHER   0x03
 
#define USB_RTYPE_ENDPOINT   0x02
 
#define USB_RTYPE_INTERFACE   0x01
 
#define USB_RTYPE_DEVICE   0x00
 
#define USBREQ_GET_STATUS   0x00
 
#define USBREQ_CLEAR_FEATURE   0x01
 
#define USBREQ_SET_FEATURE   0x03
 
#define USBREQ_SET_ADDRESS   0x05
 
#define USBREQ_GET_DESCRIPTOR   0x06
 
#define USBREQ_SET_DESCRIPTOR   0x07
 
#define USBREQ_GET_CONFIG   0x08
 
#define USBREQ_SET_CONFIG   0x09
 
#define USBREQ_GET_INTERFACE   0x0a
 
#define USBREQ_SET_INTERFACE   0x0b
 
#define USBREQ_SYNC_FRAME   0x0c
 
#define USB_STATUS_SELF_PWR   0x0001
 
#define USB_STATUS_BUS_PWR   0x0000
 
#define USB_STATUS_PWR_M   0x0001
 
#define USB_STATUS_REMOTE_WAKE   0x0002
 
#define USB_FEATURE_EP_HALT   0x0000
 
#define USB_FEATURE_REMOTE_WAKE   0x0001
 
#define USB_FEATURE_TEST_MODE   0x0002
 
#define USB_REQ_EP_NUM_M   0x007F
 
#define USB_REQ_EP_DIR_M   0x0080
 
#define USB_REQ_EP_DIR_IN   0x0080
 
#define USB_REQ_EP_DIR_OUT   0x0000
 
#define USB_DTYPE_DEVICE   1
 
#define USB_DTYPE_CONFIGURATION   2
 
#define USB_DTYPE_STRING   3
 
#define USB_DTYPE_INTERFACE   4
 
#define USB_DTYPE_ENDPOINT   5
 
#define USB_DTYPE_DEVICE_QUAL   6
 
#define USB_DTYPE_OSPEED_CONF   7
 
#define USB_DTYPE_INTERFACE_PWR   8
 
#define USB_DTYPE_OTG   9
 
#define USB_DTYPE_INTERFACE_ASC   11
 
#define USB_DTYPE_CS_INTERFACE   36
 
#define USB_DTYPE_HUB   41
 
#define USB_CLASS_DEVICE   0x00
 
#define USB_CLASS_AUDIO   0x01
 
#define USB_CLASS_CDC   0x02
 
#define USB_CLASS_HID   0x03
 
#define USB_CLASS_PHYSICAL   0x05
 
#define USB_CLASS_IMAGE   0x06
 
#define USB_CLASS_PRINTER   0x07
 
#define USB_CLASS_MASS_STORAGE   0x08
 
#define USB_CLASS_HUB   0x09
 
#define USB_CLASS_CDC_DATA   0x0a
 
#define USB_CLASS_SMART_CARD   0x0b
 
#define USB_CLASS_SECURITY   0x0d
 
#define USB_CLASS_VIDEO   0x0e
 
#define USB_CLASS_HEALTHCARE   0x0f
 
#define USB_CLASS_DIAG_DEVICE   0xdc
 
#define USB_CLASS_WIRELESS   0xe0
 
#define USB_CLASS_MISC   0xef
 
#define USB_CLASS_APP_SPECIFIC   0xfe
 
#define USB_CLASS_VEND_SPECIFIC   0xff
 
#define USB_CLASS_EVENTS   0xffffffff
 
#define USB_SUBCLASS_UNDEFINED   0x00
 
#define USB_PROTOCOL_UNDEFINED   0x00
 
#define USB_MISC_SUBCLASS_SYNC   0x01
 
#define USB_MISC_SUBCLASS_COMMON   0x02
 
#define USB_MISC_PROTOCOL_IAD   0x01
 
#define USB_HUB_PROTOCOL_FS   0x00
 
#define USB_HUB_PROTOCOL_SINGLE   0x01
 
#define USB_HUB_PROTOCOL_MULTI   0x02
 
#define USB_CONF_ATTR_PWR_M   0xC0
 
#define USB_CONF_ATTR_SELF_PWR   0xC0
 
#define USB_CONF_ATTR_BUS_PWR   0x80
 
#define USB_CONF_ATTR_RWAKE   0xA0
 
#define USB_EP_DESC_OUT   0x00
 
#define USB_EP_DESC_IN   0x80
 
#define USB_EP_DESC_NUM_M   0x0f
 
#define USB_EP_MAX_PACKET_COUNT_M   0x07FF
 
#define USB_EP_ATTR_CONTROL   0x00
 
#define USB_EP_ATTR_ISOC   0x01
 
#define USB_EP_ATTR_BULK   0x02
 
#define USB_EP_ATTR_INT   0x03
 
#define USB_EP_ATTR_TYPE_M   0x03
 
#define USB_EP_ATTR_ISOC_M   0x0c
 
#define USB_EP_ATTR_ISOC_NOSYNC   0x00
 
#define USB_EP_ATTR_ISOC_ASYNC   0x04
 
#define USB_EP_ATTR_ISOC_ADAPT   0x08
 
#define USB_EP_ATTR_ISOC_SYNC   0x0c
 
#define USB_EP_ATTR_USAGE_M   0x30
 
#define USB_EP_ATTR_USAGE_DATA   0x00
 
#define USB_EP_ATTR_USAGE_FEEDBACK   0x10
 
#define USB_EP_ATTR_USAGE_IMPFEEDBACK   0x20
 
#define USBShort(ui16Value)   (ui16Value & 0xff), (ui16Value >> 8)
 
#define USB3Byte(ui32Value)
 
#define USBLong(ui32Value)
 
#define NEXT_USB_DESCRIPTOR(ptr)
 
#define USB_DESC_ANY   0xFFFFFFFF
 
#define USBERR_HOST_IN_PID_ERROR   0x01000000
 The host received an invalid PID in a transaction. More...
 
#define USBERR_HOST_IN_NOT_COMP   0x00100000
 The host did not receive a response from a device. More...
 
#define USBERR_HOST_IN_STALL   0x00400000
 The host received a stall on an IN endpoint. More...
 
#define USBERR_HOST_IN_DATA_ERROR   0x00080000
 The host detected a CRC or bit-stuffing error (isochronous mode). More...
 
#define USBERR_HOST_IN_NAK_TO   0x00080000
 
#define USBERR_HOST_IN_ERROR   0x00040000
 The host failed to communicate with a device via an IN endpoint. More...
 
#define USBERR_HOST_IN_FIFO_FULL   0x00020000
 The host receive FIFO is full. More...
 
#define USBERR_HOST_OUT_NAK_TO   0x00000080
 
#define USBERR_HOST_OUT_NOT_COMP   0x00000080
 The host did not receive a response from a device (isochronous mode). More...
 
#define USBERR_HOST_OUT_STALL   0x00000020
 The host received a stall on an OUT endpoint. More...
 
#define USBERR_HOST_OUT_ERROR   0x00000004
 The host failed to communicate with a device via an OUT endpoint. More...
 
#define USBERR_HOST_EP0_NAK_TO   0x00000080
 
#define USBERR_HOST_EP0_ERROR   0x00000010
 The host failed to communicate with a device via an endpoint zero. More...
 
#define USBERR_DEV_RX_DATA_ERROR   0x00080000
 The device detected a CRC error in received data. More...
 
#define USBERR_DEV_RX_OVERRUN   0x00040000
 
#define USBERR_DEV_RX_FIFO_FULL   0x00020000
 The device receive FIFO is full. More...
 
#define USB_EVENT_BASE   0x0000
 
#define USB_CLASS_EVENT_BASE   0x8000
 
#define USBD_CDC_EVENT_BASE   (USB_CLASS_EVENT_BASE + 0)
 
#define USBD_HID_EVENT_BASE   (USB_CLASS_EVENT_BASE + 0x1000)
 
#define USBD_HID_KEYB_EVENT_BASE   (USBD_HID_EVENT_BASE + 0x100)
 
#define USBD_BULK_EVENT_BASE   (USB_CLASS_EVENT_BASE + 0x2000)
 
#define USBD_MSC_EVENT_BASE   (USB_CLASS_EVENT_BASE + 0x3000)
 
#define USBD_AUDIO_EVENT_BASE   (USB_CLASS_EVENT_BASE + 0x4000)
 
#define USBD_DFU_EVENT_BASE   (USB_CLASS_EVENT_BASE + 0x5000)
 
#define USBH_CDC_EVENT_BASE   (USBD_CDC_EVENT_BASE + 0x800)
 
#define USBH_HID_EVENT_BASE   (USBD_HID_EVENT_BASE + 0x800)
 
#define USBH_BULK_EVENT_BASE   (USBD_BULK_EVENT_BASE + 0x800)
 
#define USBH_MSC_EVENT_BASE   (USBD_MSC_EVENT_BASE + 0x800)
 
#define USBH_AUDIO_EVENT_BASE   (USBD_AUDIO_EVENT_BASE + 0x800)
 
#define USB_EVENT_CONNECTED   (USB_EVENT_BASE + 0)
 
#define USB_EVENT_DISCONNECTED   (USB_EVENT_BASE + 1)
 
#define USB_EVENT_RX_AVAILABLE   (USB_EVENT_BASE + 2)
 
#define USB_EVENT_DATA_REMAINING   (USB_EVENT_BASE + 3)
 
#define USB_EVENT_REQUEST_BUFFER   (USB_EVENT_BASE + 4)
 
#define USB_EVENT_TX_COMPLETE   (USB_EVENT_BASE + 5)
 
#define USB_EVENT_ERROR   (USB_EVENT_BASE + 6)
 
#define USB_EVENT_SUSPEND   (USB_EVENT_BASE + 7)
 The bus has entered suspend state. More...
 
#define USB_EVENT_RESUME   (USB_EVENT_BASE + 8)
 The bus has left suspend state. More...
 
#define USB_EVENT_SCHEDULER   (USB_EVENT_BASE + 9)
 A scheduler event has occurred. More...
 
#define USB_EVENT_STALL   (USB_EVENT_BASE + 10)
 A device or host has detected a stall condition. More...
 
#define USB_EVENT_POWER_FAULT   (USB_EVENT_BASE + 11)
 The host detected a power fault condition. More...
 
#define USB_EVENT_POWER_ENABLE   (USB_EVENT_BASE + 12)
 
#define USB_EVENT_POWER_DISABLE   (USB_EVENT_BASE + 13)
 
#define USB_EVENT_COMP_IFACE_CHANGE   (USB_EVENT_BASE + 14)
 
#define USB_EVENT_COMP_EP_CHANGE   (USB_EVENT_BASE + 15)
 
#define USB_EVENT_COMP_STR_CHANGE   (USB_EVENT_BASE + 16)
 
#define USB_EVENT_COMP_CONFIG   (USB_EVENT_BASE + 17)
 
#define USB_EVENT_UNKNOWN_CONNECTED   (USB_EVENT_BASE + 18)
 
#define USB_EVENT_SOF   (USB_EVENT_BASE + 19)
 
#define USB_EVENT_LPM_SLEEP   (USB_EVENT_BASE + 20)
 This event occurs when a device enters LPM sleep mode. More...
 
#define USB_EVENT_LPM_RESUME   (USB_EVENT_BASE + 21)
 This event occurs when a device is resumed from LPM sleep mode. More...
 
#define USB_EVENT_LPM_ERROR   (USB_EVENT_BASE + 22)
 
#define USB_EVENT_CONFIG_CHANGE   (USB_EVENT_BASE + 23)
 This event occurs when a device has been issued a configuration change. More...
 
#define USBLIB_FEATURE_LPM   0x00000001
 
#define USBLIB_FEATURE_LPM_RMT_WAKE   0x00000002
 
#define USBLIB_FEATURE_LPM_EN   0x00000001
 
#define USBLIB_FEATURE_LPM_DIS   0x00000000
 
#define USBLIB_FEATURE_CPUCLK   0x00000002
 
#define USBLIB_FEATURE_USBPLL   0x00000003
 
#define USBLIB_FEATURE_USBULPI   0x00000004
 
#define USBLIB_FEATURE_ULPI_NONE   0x00000000
 
#define USBLIB_FEATURE_ULPI_HS   0x00000010
 
#define USBLIB_FEATURE_ULPI_FS   0x00000020
 
#define USBLIB_FEATURE_POWER   0x00000005
 
#define USBLIB_FEATURE_POWER_SELF   0x00000001
 
#define USBLIB_FEATURE_POWER_BUS   0x00000000
 
#define USBLIB_FEATURE_REMOTE_WAKE   0x00000002
 

Typedefs

typedef void(* tStdRequest) (void *pvInstance, tUSBRequest *pUSBRequest)
 
typedef void(* tInfoCallback) (void *pvInstance, uint32_t ui32Info)
 
typedef void(* tInterfaceCallback) (void *pvInstance, uint8_t ui8InterfaceNum, uint8_t ui8AlternateSetting)
 
typedef void(* tUSBIntHandler) (void *pvInstance)
 
typedef void(* tUSBEPIntHandler) (void *pvInstance, uint32_t ui32Status)
 
typedef void(* tUSBDeviceHandler) (void *pvInstance, uint32_t ui32Request, void *pvRequestData)
 
typedef struct tUSBDMAInstance tUSBDMAInstance
 
typedef void(* tUSBModeCallback) (uint32_t ui32Index, tUSBMode iMode)
 
typedef uint32_t(* tUSBCallback) (void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
 
typedef uint32_t(* tUSBPacketTransfer) (void *pvHandle, uint8_t *pi8Data, uint32_t ui32Length, bool bLast)
 
typedef uint32_t(* tUSBPacketAvailable) (void *pvHandle)
 

Enumerations

enum  tUSBMode {
  eUSBModeDevice = 0, eUSBModeHost, eUSBModeOTG, eUSBModeNone,
  eUSBModeForceHost, eUSBModeForceDevice
}
 

Functions

uint32_t USBDescGetNum (tDescriptorHeader *psDesc, uint32_t ui32Size, uint32_t ui32Type)
 
tDescriptorHeader * USBDescGet (tDescriptorHeader *psDesc, uint32_t ui32Size, uint32_t ui32Type, uint32_t ui32Index)
 
uint32_t USBDescGetNumAlternateInterfaces (tConfigDescriptor *psConfig, uint8_t ui8InterfaceNumber)
 
tInterfaceDescriptor * USBDescGetInterface (tConfigDescriptor *psConfig, uint32_t ui32Index, uint32_t ui32Alt)
 
tEndpointDescriptor * USBDescGetInterfaceEndpoint (tInterfaceDescriptor *psInterface, uint32_t ui32Index, uint32_t ui32Size)
 
const tUSBBufferUSBBufferInit (tUSBBuffer *psBuffer)
 
void USBBufferZeroLengthPacketInsert (const tUSBBuffer *psBuffer, bool bSendZLP)
 
void USBBufferInfoGet (const tUSBBuffer *psBuffer, tUSBRingBufObject *psRingBuf)
 
void * USBBufferCallbackDataSet (tUSBBuffer *psBuffer, void *pvCBData)
 
uint32_t USBBufferWrite (const tUSBBuffer *psBuffer, const uint8_t *pui8Data, uint32_t ui32Length)
 
void USBBufferDataWritten (const tUSBBuffer *psBuffer, uint32_t ui32Length)
 
void USBBufferDataRemoved (const tUSBBuffer *psBuffer, uint32_t ui32Length)
 
void USBBufferFlush (const tUSBBuffer *psBuffer)
 
uint32_t USBBufferRead (const tUSBBuffer *psBuffer, uint8_t *pui8Data, uint32_t ui32Length)
 
uint32_t USBBufferDataAvailable (const tUSBBuffer *psBuffer)
 
uint32_t USBBufferSpaceAvailable (const tUSBBuffer *psBuffer)
 
uint32_t USBBufferEventCallback (void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
 
bool USBRingBufFull (tUSBRingBufObject *psUSBRingBuf)
 
bool USBRingBufEmpty (tUSBRingBufObject *psUSBRingBuf)
 
void USBRingBufFlush (tUSBRingBufObject *psUSBRingBuf)
 
uint32_t USBRingBufUsed (tUSBRingBufObject *psUSBRingBuf)
 
uint32_t USBRingBufFree (tUSBRingBufObject *psUSBRingBuf)
 
uint32_t USBRingBufContigUsed (tUSBRingBufObject *psUSBRingBuf)
 
uint32_t USBRingBufContigFree (tUSBRingBufObject *psUSBRingBuf)
 
uint32_t USBRingBufSize (tUSBRingBufObject *psUSBRingBuf)
 
uint8_t USBRingBufReadOne (tUSBRingBufObject *psUSBRingBuf)
 
void USBRingBufRead (tUSBRingBufObject *psUSBRingBuf, uint8_t *pui8Data, uint32_t ui32Length)
 
void USBRingBufWriteOne (tUSBRingBufObject *psUSBRingBuf, uint8_t ui8Data)
 
void USBRingBufWrite (tUSBRingBufObject *psUSBRingBuf, const uint8_t *pui8Data, uint32_t ui32Length)
 
void USBRingBufAdvanceWrite (tUSBRingBufObject *psUSBRingBuf, uint32_t ui32NumBytes)
 
void USBRingBufAdvanceRead (tUSBRingBufObject *psUSBRingBuf, uint32_t ui32NumBytes)
 
void USBRingBufInit (tUSBRingBufObject *psUSBRingBuf, uint8_t *pui8Buf, uint32_t ui32Size)
 
void USBStackModeSet (uint32_t ui32Index, tUSBMode iUSBMode, tUSBModeCallback pfnCallback)
 
void USBDualModeInit (uint32_t ui32Index)
 
void USBDualModeTerm (uint32_t ui32Index)
 
void USBOTGMain (uint32_t ui32MsTicks)
 
void USBOTGPollRate (uint32_t ui32Index, uint32_t ui32PollRate)
 
void USBOTGModeInit (uint32_t ui32Index, uint32_t ui32PollRate, void *pHostData, uint32_t ui32HostDataSize)
 
void USBOTGModeTerm (uint32_t ui32Index)
 
void USB0_IRQOTGModeHandler (void)
 
bool USBOTGFeatureSet (uint32_t ui32Index, uint32_t ui32Feature, void *pvFeature)
 
void USB0DualModeIntHandler (void)
 

Macro Definition Documentation

§ MAX_USB_DEVICES

#define MAX_USB_DEVICES   5

§ USBLIB_NUM_EP

#define USBLIB_NUM_EP   8

§ USB_LANG_CHINESE_PRC

#define USB_LANG_CHINESE_PRC   0x0804

§ USB_LANG_CHINESE_TAIWAN

#define USB_LANG_CHINESE_TAIWAN   0x0404

§ USB_LANG_EN_US

#define USB_LANG_EN_US   0x0409

§ USB_LANG_EN_UK

#define USB_LANG_EN_UK   0x0809

§ USB_LANG_EN_AUS

#define USB_LANG_EN_AUS   0x0C09

§ USB_LANG_EN_CA

#define USB_LANG_EN_CA   0x1009

§ USB_LANG_EN_NZ

#define USB_LANG_EN_NZ   0x1409

§ USB_LANG_FRENCH

#define USB_LANG_FRENCH   0x040C

§ USB_LANG_GERMAN

#define USB_LANG_GERMAN   0x0407

§ USB_LANG_HINDI

#define USB_LANG_HINDI   0x0439

§ USB_LANG_ITALIAN

#define USB_LANG_ITALIAN   0x0410

§ USB_LANG_JAPANESE

#define USB_LANG_JAPANESE   0x0411

§ USB_LANG_KOREAN

#define USB_LANG_KOREAN   0x0412

§ USB_LANG_ES_TRAD

#define USB_LANG_ES_TRAD   0x040A

§ USB_LANG_ES_MODERN

#define USB_LANG_ES_MODERN   0x0C0A

§ USB_LANG_SWAHILI

#define USB_LANG_SWAHILI   0x0441

§ USB_LANG_URDU_IN

#define USB_LANG_URDU_IN   0x0820

§ USB_LANG_URDU_PK

#define USB_LANG_URDU_PK   0x0420
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale