USB Module¶
The Texas Instruments USB Library is a set of data types and functions for creating USB device, host, or dual mode applications. The contents of the USB library and its associated header files fall into four main groups: general purpose functions, device mode specific functions, host mode specific functions, and mode detection and control functions. The set of general purpose functions are those that are be used in device, host, and dual mode applications. These include functions to parse USB descriptors and configure features of the USB library. The device specific functions provide the class-independent features required by all USB device applications such as host connection signalling and responding to standard descriptor requests. The USB library also contains a set of modules that handle the class specific requests from the USB host as well as a layer to interact with an application. The USB library provides a set of lower level class-independent host functions required by all USB host applications such as device detection and enumeration, and endpoint management. This lower layer remains mostly invisible to the application, but can be exposed to the application via class specific USB host modules. Like the device mode layer, the host mode class specific modules provide an interface to allow the lower level USB library code to communicate directly over the USB bus and also has a higher level interface that interacts with the application.
-
group
usb_api
Defines
-
USB_VBUS_VALID
0x0001¶
-
USB_ID_HOST
0x0002¶
-
USB_ID_DEVICE
0x0000¶
-
USB_PFLT_ACTIVE
0x0004¶
-
USB_INTCTRL_ALL
0x000003FF¶
-
USB_INTCTRL_STATUS
0x000000FF¶
-
USB_INTCTRL_VBUS_ERR
0x00000080¶
-
USB_INTCTRL_SESSION
0x00000040¶
-
USB_INTCTRL_SESSION_END
0x00000040¶
-
USB_INTCTRL_DISCONNECT
0x00000020¶
-
USB_INTCTRL_CONNECT
0x00000010¶
-
USB_INTCTRL_SOF
0x00000008¶
-
USB_INTCTRL_BABBLE
0x00000004¶
-
USB_INTCTRL_RESET
0x00000004¶
-
USB_INTCTRL_RESUME
0x00000002¶
-
USB_INTCTRL_SUSPEND
0x00000001¶
-
USB_INTCTRL_MODE_DETECT
0x00000200¶
-
USB_INTCTRL_POWER_FAULT
0x00000100¶
-
USB_INTEP_ALL
0xFFFFFFFF¶
-
USB_INTEP_HOST_IN
0xFFFE0000¶
-
USB_INTEP_HOST_IN_15
0x80000000¶
-
USB_INTEP_HOST_IN_14
0x40000000¶
-
USB_INTEP_HOST_IN_13
0x20000000¶
-
USB_INTEP_HOST_IN_12
0x10000000¶
-
USB_INTEP_HOST_IN_11
0x08000000¶
-
USB_INTEP_HOST_IN_10
0x04000000¶
-
USB_INTEP_HOST_IN_9
0x02000000¶
-
USB_INTEP_HOST_IN_8
0x01000000¶
-
USB_INTEP_HOST_IN_7
0x00800000¶
-
USB_INTEP_HOST_IN_6
0x00400000¶
-
USB_INTEP_HOST_IN_5
0x00200000¶
-
USB_INTEP_HOST_IN_4
0x00100000¶
-
USB_INTEP_HOST_IN_3
0x00080000¶
-
USB_INTEP_HOST_IN_2
0x00040000¶
-
USB_INTEP_HOST_IN_1
0x00020000¶
-
USB_INTEP_DEV_OUT
0xFFFE0000¶
-
USB_INTEP_DEV_OUT_15
0x80000000¶
-
USB_INTEP_DEV_OUT_14
0x40000000¶
-
USB_INTEP_DEV_OUT_13
0x20000000¶
-
USB_INTEP_DEV_OUT_12
0x10000000¶
-
USB_INTEP_DEV_OUT_11
0x08000000¶
-
USB_INTEP_DEV_OUT_10
0x04000000¶
-
USB_INTEP_DEV_OUT_9
0x02000000¶
-
USB_INTEP_DEV_OUT_8
0x01000000¶
-
USB_INTEP_DEV_OUT_7
0x00800000¶
-
USB_INTEP_DEV_OUT_6
0x00400000¶
-
USB_INTEP_DEV_OUT_5
0x00200000¶
-
USB_INTEP_DEV_OUT_4
0x00100000¶
-
USB_INTEP_DEV_OUT_3
0x00080000¶
-
USB_INTEP_DEV_OUT_2
0x00040000¶
-
USB_INTEP_DEV_OUT_1
0x00020000¶
-
USB_INTEP_HOST_OUT
0x0000FFFE¶
-
USB_INTEP_HOST_OUT_15
0x00008000¶
-
USB_INTEP_HOST_OUT_14
0x00004000¶
-
USB_INTEP_HOST_OUT_13
0x00002000¶
-
USB_INTEP_HOST_OUT_12
0x00001000¶
-
USB_INTEP_HOST_OUT_11
0x00000800¶
-
USB_INTEP_HOST_OUT_10
0x00000400¶
-
USB_INTEP_HOST_OUT_9
0x00000200¶
-
USB_INTEP_HOST_OUT_8
0x00000100¶
-
USB_INTEP_HOST_OUT_7
0x00000080¶
-
USB_INTEP_HOST_OUT_6
0x00000040¶
-
USB_INTEP_HOST_OUT_5
0x00000020¶
-
USB_INTEP_HOST_OUT_4
0x00000010¶
-
USB_INTEP_HOST_OUT_3
0x00000008¶
-
USB_INTEP_HOST_OUT_2
0x00000004¶
-
USB_INTEP_HOST_OUT_1
0x00000002¶
-
USB_INTEP_DEV_IN
0x0000FFFE¶
-
USB_INTEP_DEV_IN_15
0x00008000¶
-
USB_INTEP_DEV_IN_14
0x00004000¶
-
USB_INTEP_DEV_IN_13
0x00002000¶
-
USB_INTEP_DEV_IN_12
0x00001000¶
-
USB_INTEP_DEV_IN_11
0x00000800¶
-
USB_INTEP_DEV_IN_10
0x00000400¶
-
USB_INTEP_DEV_IN_9
0x00000200¶
-
USB_INTEP_DEV_IN_8
0x00000100¶
-
USB_INTEP_DEV_IN_7
0x00000080¶
-
USB_INTEP_DEV_IN_6
0x00000040¶
-
USB_INTEP_DEV_IN_5
0x00000020¶
-
USB_INTEP_DEV_IN_4
0x00000010¶
-
USB_INTEP_DEV_IN_3
0x00000008¶
-
USB_INTEP_DEV_IN_2
0x00000004¶
-
USB_INTEP_DEV_IN_1
0x00000002¶
-
USB_INTEP_0
0x00000001¶
-
USB_UNDEF_SPEED
0x80000000¶
-
USB_FULL_SPEED
0x00000001¶
-
USB_LOW_SPEED
0x00000000¶
-
USB_HOST_IN_STATUS
0xFFFF0000¶
-
USB_HOST_IN_PID_ERROR
0x10000000¶
-
USB_HOST_IN_NOT_COMP
0x01000000¶
-
USB_HOST_IN_STALL
0x00400000¶
-
USB_HOST_IN_DATA_ERROR
0x00080000¶
-
USB_HOST_IN_NAK_TO
0x00080000¶
-
USB_HOST_IN_ERROR
0x00040000¶
-
USB_HOST_IN_FIFO_FULL
0x00020000¶
-
USB_HOST_IN_PKTRDY
0x00010000¶
-
USB_HOST_OUT_STATUS
0x0000FFFF¶
-
USB_HOST_OUT_NAK_TO
0x00000080¶
-
USB_HOST_OUT_NOT_COMP
0x00000080¶
-
USB_HOST_OUT_STALL
0x00000020¶
-
USB_HOST_OUT_ERROR
0x00000004¶
-
USB_HOST_OUT_FIFO_NE
0x00000002¶
-
USB_HOST_OUT_PKTPEND
0x00000001¶
-
USB_HOST_EP0_NAK_TO
0x00000080¶
-
USB_HOST_EP0_STATUS
0x00000040¶
-
USB_HOST_EP0_ERROR
0x00000010¶
-
USB_HOST_EP0_RX_STALL
0x00000004¶
-
USB_HOST_EP0_RXPKTRDY
0x00000001¶
-
USB_DEV_RX_PID_ERROR
0x01000000¶
-
USB_DEV_RX_SENT_STALL
0x00400000¶
-
USB_DEV_RX_DATA_ERROR
0x00080000¶
-
USB_DEV_RX_OVERRUN
0x00040000¶
-
USB_DEV_RX_FIFO_FULL
0x00020000¶
-
USB_DEV_RX_PKT_RDY
0x00010000¶
-
USB_DEV_TX_NOT_COMP
0x00000080¶
-
USB_DEV_TX_SENT_STALL
0x00000020¶
-
USB_DEV_TX_UNDERRUN
0x00000004¶
-
USB_DEV_TX_FIFO_NE
0x00000002¶
-
USB_DEV_TX_TXPKTRDY
0x00000001¶
-
USB_DEV_EP0_SETUP_END
0x00000010¶
-
USB_DEV_EP0_SENT_STALL
0x00000004¶
-
USB_DEV_EP0_IN_PKTPEND
0x00000002¶
-
USB_DEV_EP0_OUT_PKTRDY
0x00000001¶
-
USB_EP_AUTO_SET
0x00000001¶
-
USB_EP_AUTO_REQUEST
0x00000002¶
-
USB_EP_AUTO_CLEAR
0x00000004¶
-
USB_EP_DMA_MODE_0
0x00000008¶
-
USB_EP_DMA_MODE_1
0x00000010¶
-
USB_EP_MODE_ISOC
0x00000000¶
-
USB_EP_MODE_BULK
0x00000100¶
-
USB_EP_MODE_INT
0x00000200¶
-
USB_EP_MODE_CTRL
0x00000300¶
-
USB_EP_MODE_MASK
0x00000300¶
-
USB_EP_SPEED_LOW
0x00000000¶
-
USB_EP_SPEED_FULL
0x00001000¶
-
USB_EP_HOST_IN
0x00000000¶
-
USB_EP_HOST_OUT
0x00002000¶
-
USB_EP_DEV_IN
0x00002000¶
-
USB_EP_DEV_OUT
0x00000000¶
-
USB_HOST_PWRFLT_LOW
0x00000010¶
-
USB_HOST_PWRFLT_HIGH
0x00000030¶
-
USB_HOST_PWRFLT_EP_NONE
0x00000000¶
-
USB_HOST_PWRFLT_EP_TRI
0x00000140¶
-
USB_HOST_PWRFLT_EP_LOW
0x00000240¶
-
USB_HOST_PWRFLT_EP_HIGH
0x00000340¶
-
USB_HOST_PWREN_MAN_LOW
0x00000000¶
-
USB_HOST_PWREN_MAN_HIGH
0x00000001¶
-
USB_HOST_PWREN_AUTOLOW
0x00000002¶
-
USB_HOST_PWREN_AUTOHIGH
0x00000003¶
-
USB_HOST_PWREN_FILTER
0x00010000¶
-
MAX_PACKET_SIZE_EP0
64¶
-
USB_EP_0
0x00000000¶
-
USB_EP_1
0x00000010¶
-
USB_EP_2
0x00000020¶
-
USB_EP_3
0x00000030¶
-
USB_EP_4
0x00000040¶
-
USB_EP_5
0x00000050¶
-
USB_EP_6
0x00000060¶
-
USB_EP_7
0x00000070¶
-
USB_EP_8
0x00000080¶
-
USB_EP_9
0x00000090¶
-
USB_EP_10
0x000000A0¶
-
USB_EP_11
0x000000B0¶
-
USB_EP_12
0x000000C0¶
-
USB_EP_13
0x000000D0¶
-
USB_EP_14
0x000000E0¶
-
USB_EP_15
0x000000F0¶
-
NUM_USB_EP
16¶
-
IndexToUSBEP
(x) (((uint32_t)(x) << 4) & 0xFF)¶
-
USBEPToIndex
(x) ((x) >> 4)¶
-
USB_FIFO_SZ_8
0x00000000¶
-
USB_FIFO_SZ_16
0x00000001¶
-
USB_FIFO_SZ_32
0x00000002¶
-
USB_FIFO_SZ_64
0x00000003¶
-
USB_FIFO_SZ_128
0x00000004¶
-
USB_FIFO_SZ_256
0x00000005¶
-
USB_FIFO_SZ_512
0x00000006¶
-
USB_FIFO_SZ_1024
0x00000007¶
-
USB_FIFO_SZ_2048
0x00000008¶
-
USB_FIFO_SZ_4096
0x00000009¶
-
USB_FIFO_SZ_8_DB
0x00000010¶
-
USB_FIFO_SZ_16_DB
0x00000011¶
-
USB_FIFO_SZ_32_DB
0x00000012¶
-
USB_FIFO_SZ_64_DB
0x00000013¶
-
USB_FIFO_SZ_128_DB
0x00000014¶
-
USB_FIFO_SZ_256_DB
0x00000015¶
-
USB_FIFO_SZ_512_DB
0x00000016¶
-
USB_FIFO_SZ_1024_DB
0x00000017¶
-
USB_FIFO_SZ_2048_DB
0x00000018¶
-
USB_FIFO_SIZE_DB_FLAG
0x00000010¶
-
USBFIFOSizeToBytes
(x) ((uint32_t)8 << (x))¶
-
USB_TRANS_OUT
0x00000102¶
-
USB_TRANS_IN
0x00000102¶
-
USB_TRANS_IN_LAST
0x0000010a¶
-
USB_TRANS_SETUP
0x0000110a¶
-
USB_TRANS_STATUS
0x00000142¶
-
USB_DUAL_MODE_HOST
0x00000001¶
-
USB_DUAL_MODE_DEVICE
0x00000081¶
-
USB_DUAL_MODE_NONE
0x00000080¶
-
USB_OTG_MODE_ASIDE_HOST
0x0000001d¶
-
USB_OTG_MODE_ASIDE_NPWR
0x00000001¶
-
USB_OTG_MODE_ASIDE_SESS
0x00000009¶
-
USB_OTG_MODE_ASIDE_AVAL
0x00000011¶
-
USB_OTG_MODE_ASIDE_DEV
0x00000019¶
-
USB_OTG_MODE_BSIDE_HOST
0x0000009d¶
-
USB_OTG_MODE_BSIDE_DEV
0x00000099¶
-
USB_OTG_MODE_BSIDE_NPWR
0x00000081¶
-
USB_OTG_MODE_NONE
0x00000080¶
-
USB_INT_ALL
0xFF030E0F¶
-
USB_INT_STATUS
0xFF000000¶
-
USB_INT_VBUS_ERR
0x80000000¶
-
USB_INT_SESSION_START
0x40000000¶
-
USB_INT_SESSION_END
0x20000000¶
-
USB_INT_DISCONNECT
0x20000000¶
-
USB_INT_CONNECT
0x10000000¶
-
USB_INT_SOF
0x08000000¶
-
USB_INT_BABBLE
0x04000000¶
-
USB_INT_RESET
0x04000000¶
-
USB_INT_RESUME
0x02000000¶
-
USB_INT_SUSPEND
0x01000000¶
-
USB_INT_MODE_DETECT
0x00020000¶
-
USB_INT_POWER_FAULT
0x00010000¶
-
USB_INT_HOST_IN
0x00000E00¶
-
USB_INT_DEV_OUT
0x00000E00¶
-
USB_INT_HOST_IN_EP3
0x00000800¶
-
USB_INT_HOST_IN_EP2
0x00000400¶
-
USB_INT_HOST_IN_EP1
0x00000200¶
-
USB_INT_DEV_OUT_EP3
0x00000800¶
-
USB_INT_DEV_OUT_EP2
0x00000400¶
-
USB_INT_DEV_OUT_EP1
0x00000200¶
-
USB_INT_HOST_OUT
0x0000000E¶
-
USB_INT_DEV_IN
0x0000000E¶
-
USB_INT_HOST_OUT_EP3
0x00000008¶
-
USB_INT_HOST_OUT_EP2
0x00000004¶
-
USB_INT_HOST_OUT_EP1
0x00000002¶
-
USB_INT_DEV_IN_EP3
0x00000008¶
-
USB_INT_DEV_IN_EP2
0x00000004¶
-
USB_INT_DEV_IN_EP1
0x00000002¶
-
USB_INT_EP0
0x00000001¶
Functions
-
uint32_t
USBDevAddrGet
(uint32_t ui32Base)¶ Returns the current device address in device mode.
This function returns the current device address. This address was set by a call to
USBDevAddrSet().- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in device mode.
- Return
The current device address.
-
void
USBDevAddrSet
(uint32_t ui32Base, uint32_t ui32Address)¶ Sets the address in device mode.
This function configures the device address on the USB bus. This address was likely received via a SET ADDRESS command from the host controller.
- Parameters
ui32Base
: specifies the USB module base address.ui32Address
: is the address to use for a device.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevConnect
(uint32_t ui32Base)¶ Connects the USB controller to the bus in device mode.
This function causes the soft connect feature of the USB controller to be enabled. Call
USBDevDisconnect() to remove the USB device from the bus.- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevDisconnect
(uint32_t ui32Base)¶ Removes the USB controller from the bus in device mode.
This function causes the soft connect feature of the USB controller to remove the device from the USB bus. A call to
USBDevConnect() is needed to reconnect to the bus.- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevEndpointConfigSet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32MaxPacketSize, uint32_t ui32Flags)¶ Sets the configuration for an endpoint.
This function sets the basic configuration for an endpoint in device mode. Endpoint zero does not have a dynamic configuration, so this function must not be called for endpoint zero. The
ui32Flags parameter determines some of the configuration while the other parameters provide the rest.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32MaxPacketSize
: is the maximum packet size for this endpoint.ui32Flags
: are used to configure other endpoint settings.
The USB_EP_MODE_ flags define what the type is for the given endpoint.
USB_EP_MODE_CTRL is a control endpoint.
USB_EP_MODE_ISOC is an isochronous endpoint.
USB_EP_MODE_BULK is a bulk endpoint.
USB_EP_MODE_INT is an interrupt endpoint.
The USB_EP_DMA_MODE_ flags determine the type of DMA access to the endpoint data FIFOs. The choice of the DMA mode depends on how the DMA controller is configured and how it is being used. See the `Using USB with the uDMA Controller’ section for more information on DMA configuration.
When configuring an IN endpoint, the USB_EP_AUTO_SET bit can be specified to cause the automatic transmission of data on the USB bus as soon as ui32MaxPacketSize bytes of data are written into the FIFO for this endpoint. This option is commonly used with DMA as no interaction is required to start the transmission of data.
When configuring an OUT endpoint, the USB_EP_AUTO_REQUEST bit is specified to trigger the request for more data once the FIFO has been drained enough to receive ui32MaxPacketSize more bytes of data. Also for OUT endpoints, the USB_EP_AUTO_CLEAR bit can be used to clear the data packet ready flag automatically once the data has been read from the FIFO. If this option is not used, this flag must be manually cleared via a call to USBDevEndpointStatusClear(). Both of these settings can be used to remove the need for extra calls when using the controller in DMA mode.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevEndpointConfigGet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t *pui32MaxPacketSize, uint32_t *pui32Flags)¶ Gets the current configuration for an endpoint.
This function returns the basic configuration for an endpoint in device mode. The values returned in
*pui32MaxPacketSize and *pui32Flags are equivalent to the ui32MaxPacketSize and ui32Flags previously passed to USBDevEndpointConfigSet() for this endpoint.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.pui32MaxPacketSize
: is a pointer which is written with the maximum packet size for this endpoint.pui32Flags
: is a pointer which is written with the current endpoint settings. On entry to the function, this pointer must contain either USB_EP_DEV_IN or USB_EP_DEV_OUT to indicate whether the IN or OUT endpoint is to be queried.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevEndpointDataAck
(uint32_t ui32Base, uint32_t ui32Endpoint, bool bIsLastPacket)¶ Acknowledge that data was read from the given endpoint’s FIFO in device mode.
This function acknowledges that the data was read from the endpoint’s FIFO. The
bIsLastPacket parameter is set to a true value if this is the last in a series of data packets on endpoint zero. The bIsLastPacket parameter is not used for endpoints other than endpoint zero. This call can be used if processing is required between reading the data and acknowledging that the data has been read.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.bIsLastPacket
: indicates if this packet is the last one.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevEndpointStall
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Stalls the specified endpoint in device mode.
This function causes the endpoint number passed in to go into a stall condition. If the
ui32Flags parameter is USB_EP_DEV_IN, then the stall is issued on the IN portion of this endpoint. If the ui32Flags parameter is USB_EP_DEV_OUT, then the stall is issued on the OUT portion of this endpoint.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: specifies the endpoint to stall.ui32Flags
: specifies whether to stall the IN or OUT endpoint.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevEndpointStallClear
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Clears the stall condition on the specified endpoint in device mode.
This function causes the endpoint number passed in to exit the stall condition. If the
ui32Flags parameter is USB_EP_DEV_IN, then the stall is cleared on the IN portion of this endpoint. If the ui32Flags parameter is USB_EP_DEV_OUT, then the stall is cleared on the OUT portion of this endpoint.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: specifies which endpoint to remove the stall condition.ui32Flags
: specifies whether to remove the stall condition from the IN or the OUT portion of this endpoint.
- Note
This function must only be called in device mode.
- Return
None.
-
void
USBDevEndpointStatusClear
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Clears the status bits in this endpoint in device mode.
This function clears the status of any bits that are passed in the
ui32Flags parameter. The ui32Flags parameter can take the value returned from the USBEndpointStatus() call.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: are the status bits that are cleared.
- Note
This function must only be called in device mode.
- Return
None.
-
uint32_t
USBEndpointDataAvail
(uint32_t ui32Base, uint32_t ui32Endpoint)¶ Determine the number of bytes of data available in a given endpoint’s FIFO.
This function returns the number of bytes of data currently available in the FIFO for the given receive (OUT) endpoint. It may be used prior to calling
USBEndpointDataGet() to determine the size of buffer required to hold the newly-received packet.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.
- Return
This call returns the number of bytes available in a given endpoint FIFO.
-
void
USBEndpointDMAEnable
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Enable DMA on a given endpoint.
This function enables DMA on a given endpoint and configures the mode according to the values in the
ui32Flags parameter. The ui32Flags parameter must have USB_EP_DEV_IN or USB_EP_DEV_OUT set. Once this function is called the only DMA or error interrupts are generated by the USB controller.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: specifies which direction and what mode to use when enabling DMA.
- Note
If this function is called when an endpoint is configured in DMA mode 0 the USB controller does not generate an interrupt.
- Return
None.
-
void
USBEndpointDMADisable
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Disable DMA on a given endpoint.
This function disables DMA on a given endpoint to allow non-DMA USB transactions to generate interrupts normally. The
ui32Flags parameter must be USB_EP_DEV_IN or USB_EP_DEV_OUT; all other bits are ignored.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: specifies which direction to disable.
- Return
None.
-
void
USBEndpointDMAConfigSet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Config)¶ Configure the DMA settings for an endpoint.
This function configures the DMA settings for a given endpoint without changing other options that may already be configured. In order for the DMA transfer to be enabled, the
USBEndpointDMAEnable() function must be called before starting the DMA transfer. The configuration options are passed in the ui32Config parameter and can have the values described below.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Config
: specifies the configuration options for an endpoint.
One of the following values to specify direction:
USB_EP_HOST_OUT or USB_EP_DEV_IN - This setting is used with DMA transfers from memory to the USB controller.
USB_EP_HOST_IN or USB_EP_DEV_OUT - This setting is used with DMA transfers from the USB controller to memory.
One of the following values:
USB_EP_DMA_MODE_0(default) - This setting is typically used for transfers that do not span multiple packets or when interrupts are required for each packet.
USB_EP_DMA_MODE_1 - This setting is typically used for transfers that span multiple packets and do not require interrupts between packets.
Values only used with USB_EP_HOST_OUT or USB_EP_DEV_IN:
USB_EP_AUTO_SET - This setting is used to allow transmit DMA transfers to automatically be sent when a full packet is loaded into a FIFO. This is needed with USB_EP_DMA_MODE_1 to ensure that packets go out when the FIFO becomes full and the DMA has more data to send.
Values only used with USB_EP_HOST_IN or USB_EP_DEV_OUT:
USB_EP_AUTO_CLEAR - This setting is used to allow receive DMA transfers to automatically be acknowledged as they are received. This is needed with USB_EP_DMA_MODE_1 to ensure that packets continue to be received and acknowledged when the FIFO is emptied by the DMA transfer.
Values only used with USB_EP_HOST_IN:
USB_EP_AUTO_REQUEST - This setting is used to allow receive DMA transfers to automatically request a new IN transaction when the previous transfer has emptied the FIFO. This is typically used in conjunction with USB_EP_AUTO_CLEAR so that receive DMA transfers can continue without interrupting the main processor.
Example: Set endpoint 1 receive endpoint to automatically acknowledge request and automatically generate a new IN request in host mode.
//! // //! // Configure endpoint 1 for receiving multiple packets using DMA. //! // //! USBEndpointDMAConfigSet(USBA_BASE, USB_EP_1, USB_EP_HOST_IN | //! USB_EP_DMA_MODE_1 | //! USB_EP_AUTO_CLEAR | //! USB_EP_AUTO_REQUEST); //!
//! // //! // Configure endpoint 1 for transmitting multiple packets using DMA. //! // //! USBEndpointDMAConfigSet(USBA_BASE, USB_EP_2, USB_EP_HOST_OUT | //! USB_EP_DMA_MODE_1 | //! USB_EP_AUTO_SET); //!\b Example: Set endpoint 2 transmit endpoint to automatically send each packet in host mode when spanning multiple packets. \verbatim
\return None.
-
int32_t
USBEndpointDataGet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint8_t *pui8Data, uint32_t *pui32Size)¶ Retrieves data from the given endpoint’s FIFO.
This function returns the data from the FIFO for the given endpoint. The
pui32Size parameter indicates the size of the buffer passed in the pui32Data parameter. The data in the pui32Size parameter is changed to match the amount of data returned in the pui8Data parameter. If a zero-byte packet is received, this call does not return an error but instead just returns a zero in the pui32Size parameter. The only error case occurs when there is no data packet available.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.pui8Data
: is a pointer to the data area used to return the data from the FIFO.pui32Size
: is initially the size of the buffer passed into this call via the pui8Data parameter. It is set to the amount of data returned in the buffer.
- Return
This call returns 0, or -1 if no packet was received.
-
int32_t
USBEndpointDataPut
(uint32_t ui32Base, uint32_t ui32Endpoint, uint8_t *pui8Data, uint32_t ui32Size)¶ Puts data into the given endpoint’s FIFO.
This function puts the data from the
pui8Data parameter into the FIFO for this endpoint. If a packet is already pending for transmission, then this call does not put any of the data into the FIFO and returns -1. Care must be taken to not write more data than can fit into the FIFO allocated by the call to USBFIFOConfigSet().- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.pui8Data
: is a pointer to the data area used as the source for the data to put into the FIFO.ui32Size
: is the amount of data to put into the FIFO.
- Return
This call returns 0 on success, or -1 to indicate that the FIFO is in use and cannot be written.
-
int32_t
USBEndpointDataSend
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32TransType)¶ Starts the transfer of data from an endpoint’s FIFO.
This function starts the transfer of data from the FIFO for a given endpoint. This function is called if the
USB_EP_AUTO_SET bit was not enabled for the endpoint. Setting the ui32TransType parameter allows the appropriate signaling on the USB bus for the type of transaction being requested. The ui32TransType parameter must be one of the following:- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32TransType
: is set to indicate what type of data is being sent.
USB_TRANS_OUT for OUT transaction on any endpoint in host mode.
USB_TRANS_IN for IN transaction on any endpoint in device mode.
USB_TRANS_IN_LAST for the last IN transaction on endpoint zero in a sequence of IN transactions.
USB_TRANS_SETUP for setup transactions on endpoint zero.
USB_TRANS_STATUS for status results on endpoint zero.
- Return
This call returns 0 on success, or -1 if a transmission is already in progress.
-
void
USBEndpointDataToggleClear
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Sets the data toggle on an endpoint to zero.
This function causes the USB controller to clear the data toggle for an endpoint. This call is not valid for endpoint zero and can be made with host or device controllers.
- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: specifies the endpoint to reset the data toggle.ui32Flags
: specifies whether to access the IN or OUT endpoint.
The ui32Flags parameter must be one of USB_EP_HOST_OUT, USB_EP_HOST_IN, USB_EP_DEV_OUT, or USB_EP_DEV_IN.
- Return
None.
-
void
USBEndpointPacketCountSet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Count)¶ Sets the number of packets to request when transferring multiple bulk packets.
This function sets the number of consecutive bulk packets to request when transferring multiple bulk packets with DMA.
- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint index to target for this write.ui32Count
: is the number of packets to request.
- Note
This feature is not available on all Tiva devices. Please check the data sheet to determine if the USB controller has a DMA controller or if it must use the uDMA controller for DMA transfers.
- Return
None.
-
uint32_t
USBEndpointStatus
(uint32_t ui32Base, uint32_t ui32Endpoint)¶ Returns the current status of an endpoint.
This function returns the status of a given endpoint. If any of these status bits must be cleared, then the
USBDevEndpointStatusClear() or the USBHostEndpointStatusClear() functions must be called.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.
The following are the status flags for host mode:
USB_HOST_IN_PID_ERROR - PID error on the given endpoint.
USB_HOST_IN_NOT_COMP - The device failed to respond to an IN request.
USB_HOST_IN_STALL - A stall was received on an IN endpoint.
USB_HOST_IN_DATA_ERROR - There was a CRC or bit-stuff error on an IN endpoint in Isochronous mode.
USB_HOST_IN_NAK_TO - NAKs received on this IN endpoint for more than the specified timeout period.
USB_HOST_IN_ERROR - Failed to communicate with a device using this IN endpoint.
USB_HOST_IN_FIFO_FULL - This IN endpoint’s FIFO is full.
USB_HOST_IN_PKTRDY - Data packet ready on this IN endpoint.
USB_HOST_OUT_NAK_TO - NAKs received on this OUT endpoint for more than the specified timeout period.
USB_HOST_OUT_NOT_COMP - The device failed to respond to an OUT request.
USB_HOST_OUT_STALL - A stall was received on this OUT endpoint.
USB_HOST_OUT_ERROR - Failed to communicate with a device using this OUT endpoint.
USB_HOST_OUT_FIFO_NE - This endpoint’s OUT FIFO is not empty.
USB_HOST_OUT_PKTPEND - The data transfer on this OUT endpoint has not completed.
USB_HOST_EP0_NAK_TO - NAKs received on endpoint zero for more than the specified timeout period.
USB_HOST_EP0_ERROR - The device failed to respond to a request on endpoint zero.
USB_HOST_EP0_IN_STALL - A stall was received on endpoint zero for an IN transaction.
USB_HOST_EP0_IN_PKTRDY - Data packet ready on endpoint zero for an IN transaction.
The following are the status flags for device mode:
USB_DEV_OUT_SENT_STALL - A stall was sent on this OUT endpoint.
USB_DEV_OUT_DATA_ERROR - There was a CRC or bit-stuff error on an OUT endpoint.
USB_DEV_OUT_OVERRUN - An OUT packet was not loaded due to a full FIFO.
USB_DEV_OUT_FIFO_FULL - The OUT endpoint’s FIFO is full.
USB_DEV_OUT_PKTRDY - There is a data packet ready in the OUT endpoint’s FIFO.
USB_DEV_IN_NOT_COMP - A larger packet was split up, more data to come.
USB_DEV_IN_SENT_STALL - A stall was sent on this IN endpoint.
USB_DEV_IN_UNDERRUN - Data was requested on the IN endpoint and no data was ready.
USB_DEV_IN_FIFO_NE - The IN endpoint’s FIFO is not empty.
USB_DEV_IN_PKTPEND - The data transfer on this IN endpoint has not completed.
USB_DEV_EP0_SETUP_END - A control transaction ended before Data End condition was sent.
USB_DEV_EP0_SENT_STALL - A stall was sent on endpoint zero.
USB_DEV_EP0_IN_PKTPEND - The data transfer on endpoint zero has not completed.
USB_DEV_EP0_OUT_PKTRDY - There is a data packet ready in endpoint zero’s OUT FIFO.
- Return
The current status flags for the endpoint depending on mode.
-
uint32_t
USBFIFOAddrGet
(uint32_t ui32Base, uint32_t ui32Endpoint)¶ Returns the absolute FIFO address for a given endpoint.
This function returns the actual physical address of the FIFO. This address is needed when the USB is going to be used with the uDMA controller and the source or destination address must be set to the physical FIFO address for a given endpoint.
- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: specifies which endpoint’s FIFO address to return.
- Return
None.
-
void
USBFIFOConfigGet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t *pui32FIFOAddress, uint32_t *pui32FIFOSize, uint32_t ui32Flags)¶ Returns the FIFO configuration for an endpoint.
This function returns the starting address and size of the FIFO for a given endpoint. Endpoint zero does not have a dynamically configurable FIFO, so this function must not be called for endpoint zero. The
ui32Flags parameter specifies whether the endpoint’s OUT or IN FIFO must be read. If in host mode, the ui32Flags parameter must be USB_EP_HOST_OUT or USB_EP_HOST_IN, and if in device mode, the ui32Flags parameter must be either USB_EP_DEV_OUT or USB_EP_DEV_IN.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.pui32FIFOAddress
: is the starting address for the FIFO.pui32FIFOSize
: is the size of the FIFO as specified by one of the USB_FIFO_SZ_ values.ui32Flags
: specifies what information to retrieve from the FIFO configuration.
- Return
None.
-
void
USBFIFOConfigSet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32FIFOAddress, uint32_t ui32FIFOSize, uint32_t ui32Flags)¶ Sets the FIFO configuration for an endpoint.
This function configures the starting FIFO RAM address and size of the FIFO for a given endpoint. Endpoint zero does not have a dynamically configurable FIFO, so this function must not be called for endpoint zero. The
ui32FIFOSize parameter must be one of the values in the USB_FIFO_SZ_ values.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32FIFOAddress
: is the starting address for the FIFO.ui32FIFOSize
: is the size of the FIFO specified by one of the USB_FIFO_SZ_ values.ui32Flags
: specifies what information to set in the FIFO configuration.
The ui32FIFOAddress value must be a multiple of 8 bytes and directly indicates the starting address in the USB controller’s FIFO RAM. For example, a value of 64 indicates that the FIFO starts 64 bytes into the USB controller’s FIFO memory. The ui32Flags value specifies whether the endpoint’s OUT or IN FIFO must be configured. If in host mode, use USB_EP_HOST_OUT or USB_EP_HOST_IN, and if in device mode, use USB_EP_DEV_OUT or USB_EP_DEV_IN.
- Return
None.
-
void
USBFIFOFlush
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Forces a flush of an endpoint’s FIFO.
This function forces the USB controller to flush out the data in the FIFO. The function can be called with either host or device controllers and requires the
ui32Flags parameter be one of USB_EP_HOST_OUT, USB_EP_HOST_IN, USB_EP_DEV_OUT, or USB_EP_DEV_IN.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: specifies if the IN or OUT endpoint is accessed.
- Return
None.
-
uint32_t
USBFrameNumberGet
(uint32_t ui32Base)¶ Get the current frame number.
This function returns the last frame number received.
- Parameters
ui32Base
: specifies the USB module base address.
- Return
The last frame number received.
-
uint32_t
USBHostAddrGet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Gets the current functional device address for an endpoint.
This function returns the current functional address that an endpoint is using to communicate with a device. The
ui32Flags parameter determines if the IN or OUT endpoint’s device address is returned.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: determines if this is an IN or an OUT endpoint.
- Note
This function must only be called in host mode.
- Return
Returns the current function address being used by an endpoint.
-
void
USBHostAddrSet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Addr, uint32_t ui32Flags)¶ Sets the functional address for the device that is connected to an endpoint in host mode.
This function configures the functional address for a device that is using this endpoint for communication. This
ui32Addr parameter is the address of the target device that this endpoint is communicating with. The ui32Flags parameter indicates if the IN or OUT endpoint is set.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Addr
: is the functional address for the controller to use for this endpoint.ui32Flags
: determines if this is an IN or an OUT endpoint.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostEndpointConfig
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32MaxPacketSize, uint32_t ui32NAKPollInterval, uint32_t ui32TargetEndpoint, uint32_t ui32Flags)¶ Sets the base configuration for a host endpoint.
This function sets the basic configuration for the transmit or receive portion of an endpoint in host mode. The
ui32Flags parameter determines some of the configuration while the other parameters provide the rest. The ui32Flags parameter determines whether this is an IN endpoint (USB_EP_HOST_IN or USB_EP_DEV_IN) or an OUT endpoint (USB_EP_HOST_OUT or USB_EP_DEV_OUT), whether this is a Full speed endpoint (USB_EP_SPEED_FULL) or a Low speed endpoint (USB_EP_SPEED_LOW).- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32MaxPayload
: is the maximum payload for this endpoint.ui32NAKPollInterval
: is the either the NAK timeout limit or the polling interval, depending on the type of endpoint.ui32TargetEndpoint
: is the endpoint that the host endpoint is targeting.ui32Flags
: are used to configure other endpoint settings.
The USB_EP_MODE_ flags control the type of the endpoint.
USB_EP_MODE_CTRL is a control endpoint.
USB_EP_MODE_ISOC is an isochronous endpoint.
USB_EP_MODE_BULK is a bulk endpoint.
USB_EP_MODE_INT is an interrupt endpoint.
The ui32NAKPollInterval parameter has different meanings based on the USB_EP_MODE value and whether or not this call is being made for endpoint zero or another endpoint. For endpoint zero or any Bulk endpoints, this value always indicates the number of frames to allow a device to NAK before considering it a timeout. If this endpoint is an isochronous or interrupt endpoint, this value is the polling interval for this endpoint.
For interrupt endpoints, the polling interval is the number of frames between interrupt IN requests to an endpoint and has a range of 1 to 255. For isochronous endpoints this value represents a polling interval of 2 ^ (ui32NAKPollInterval - 1) frames. When used as a NAK timeout, the ui32NAKPollInterval value specifies 2 ^ (ui32NAKPollInterval - 1) frames before issuing a time out.
The USB_EP_DMA_MODE_ flags enable the type of DMA used to access the endpoint’s data FIFOs. The choice of the DMA mode depends on how the DMA controller is configured and how it is being used. See the `Using USB with the uDMA Controller’ section for more information on DMA configuration.
When configuring the OUT portion of an endpoint, the USB_EP_AUTO_SET bit is specified to cause the transmission of data on the USB bus to start as soon as the number of bytes specified by ui32MaxPayload has been written into the OUT FIFO for this endpoint.
When configuring the IN portion of an endpoint, the USB_EP_AUTO_REQUEST bit can be specified to trigger the request for more data once the FIFO has been drained enough to fit ui32MaxPayload bytes. The USB_EP_AUTO_CLEAR bit can be used to clear the data packet ready flag automatically once the data has been read from the FIFO. If this option is not used, this flag must be manually cleared via a call to USBDevEndpointStatusClear() or USBHostEndpointStatusClear().
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostEndpointDataAck
(uint32_t ui32Base, uint32_t ui32Endpoint)¶ Acknowledge that data was read from the given endpoint’s FIFO in host mode.
This function acknowledges that the data was read from the endpoint’s FIFO. This call is used if processing is required between reading the data and acknowledging that the data has been read.
- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostEndpointDataToggle
(uint32_t ui32Base, uint32_t ui32Endpoint, bool bDataToggle, uint32_t ui32Flags)¶ Sets the value data toggle on an endpoint in host mode.
This function is used to force the state of the data toggle in host mode. If the value passed in the
bDataToggle parameter is false, then the data toggle is set to the DATA0 state, and if it is true it is set to the DATA1 state. The ui32Flags parameter can be USB_EP_HOST_IN or USB_EP_HOST_OUT to access the desired portion of this endpoint. The ui32Flags parameter is ignored for endpoint zero.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: specifies the endpoint to reset the data toggle.bDataToggle
: specifies whether to set the state to DATA0 or DATA1.ui32Flags
: specifies whether to set the IN or OUT endpoint.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostEndpointStatusClear
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Clears the status bits in this endpoint in host mode.
This function clears the status of any bits that are passed in the
ui32Flags parameter. The ui32Flags parameter can take the value returned from the USBEndpointStatus() call.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: are the status bits that are cleared.
- Note
This function must only be called in host mode.
- Return
None.
-
uint32_t
USBHostHubAddrGet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)¶ Gets the current device hub address for this endpoint.
This function returns the current hub address that an endpoint is using to communicate with a device. The
ui32Flags parameter determines if the device address for the IN or OUT endpoint is returned.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Flags
: determines if this is an IN or an OUT endpoint.
- Note
This function must only be called in host mode.
- Return
This function returns the current hub address being used by an endpoint.
-
void
USBHostHubAddrSet
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Addr, uint32_t ui32Flags)¶ Sets the hub address for the device that is connected to an endpoint.
This function configures the hub address for a device that is using this endpoint for communication. The
ui32Flags parameter determines if the device address for the IN or the OUT endpoint is configured by this call and sets the speed of the downstream device. Valid values are one of USB_EP_HOST_OUT or USB_EP_HOST_IN optionally ORed with USB_EP_SPEED_LOW.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.ui32Addr
: is the hub address and port for the device using this endpoint. The hub address must be defined in bits 0 through 6 with the port number in bits 8 through 14.ui32Flags
: determines if this is an IN or an OUT endpoint.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostPwrDisable
(uint32_t ui32Base)¶ Disables the external power pin.
This function disables the USBnEPEN signal, which disables an external power supply in host mode operation.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostPwrEnable
(uint32_t ui32Base)¶ Enables the external power pin.
This function enables the USBnEPEN signal, which enables an external power supply in host mode operation.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostPwrConfig
(uint32_t ui32Base, uint32_t ui32Flags)¶ Sets the configuration for USB power fault.
This function controls how the USB controller uses its external power control pins (USBnPFLT and USBnEPEN). The flags specify the power fault level sensitivity, the power fault action, and the power enable level and source.
- Parameters
ui32Base
: specifies the USB module base address.ui32Flags
: specifies the configuration of the power fault.
One of the following can be selected as the power fault level sensitivity:
USB_HOST_PWRFLT_LOW - An external power fault is indicated by the pin being driven low.
USB_HOST_PWRFLT_HIGH - An external power fault is indicated by the pin being driven high.
One of the following can be selected as the power fault action:
USB_HOST_PWRFLT_EP_NONE - No automatic action when power fault detected.
USB_HOST_PWRFLT_EP_TRI - Automatically tri-state the USBnEPEN pin on a power fault.
USB_HOST_PWRFLT_EP_LOW - Automatically drive USBnEPEN pin low on a power fault.
USB_HOST_PWRFLT_EP_HIGH - Automatically drive USBnEPEN pin high on a power fault.
One of the following can be selected as the power enable level and source:
USB_HOST_PWREN_MAN_LOW - USBnEPEN is driven low by the USB controller when USBHostPwrEnable() is called.
USB_HOST_PWREN_MAN_HIGH - USBnEPEN is driven high by the USB controller when USBHostPwrEnable() is called.
USB_HOST_PWREN_AUTOLOW - USBnEPEN is driven low by the USB controller automatically if USBOTGSessionRequest() has enabled a session.
USB_HOST_PWREN_AUTOHIGH - USBnEPEN is driven high by the USB controller automatically if USBOTGSessionRequest() has enabled a session.
On devices that support the VBUS glitch filter, the USB_HOST_PWREN_FILTER can be added to ignore small, short drops in VBUS level caused by high power consumption. This feature is mainly used to avoid causing VBUS errors caused by devices with high in-rush current.
- Note
This function must only be called on microcontrollers that support host mode or OTG operation.
- Return
None.
-
void
USBHostPwrFaultDisable
(uint32_t ui32Base)¶ Disables power fault detection.
This function disables power fault detection in the USB controller.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostPwrFaultEnable
(uint32_t ui32Base)¶ Enables power fault detection.
This function enables power fault detection in the USB controller. If the USBnPFLT pin is not in use, this function must not be used.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostRequestIN
(uint32_t ui32Base, uint32_t ui32Endpoint)¶ Schedules a request for an IN transaction on an endpoint in host mode.
This function schedules a request for an IN transaction. When the USB device being communicated with responds with the data, the data can be retrieved by calling
USBEndpointDataGet() or via a DMA transfer.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.
- Note
This function must only be called in host mode and only for IN endpoints.
- Return
None.
-
void
USBHostRequestINClear
(uint32_t ui32Base, uint32_t ui32Endpoint)¶ Clears a scheduled IN transaction for an endpoint in host mode.
This function clears a previously scheduled IN transaction if it is still pending. This function is used to safely disable any scheduled IN transactions if the endpoint specified by
ui32Endpoint is reconfigured for communications with other devices.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: is the endpoint to access.
- Note
This function must only be called in host mode and only for IN endpoints.
- Return
None.
-
void
USBHostRequestStatus
(uint32_t ui32Base)¶ Issues a request for a status IN transaction on endpoint zero.
This function is used to cause a request for a status IN transaction from a device on endpoint zero. This function can only be used with endpoint zero as that is the only control endpoint that supports this ability. This function is used to complete the last phase of a control transaction to a device and an interrupt is signaled when the status packet has been received.
- Parameters
ui32Base
: specifies the USB module base address.
- Return
None.
-
void
USBHostReset
(uint32_t ui32Base, bool bStart)¶ Handles the USB bus reset condition.
When this function is called with the
bStart parameter set to true, this function causes the start of a reset condition on the USB bus. The caller must then delay at least 20ms before calling this function again with the bStart parameter set to false.- Parameters
ui32Base
: specifies the USB module base address.bStart
: specifies whether to start or stop signaling reset on the USB bus.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBHostResume
(uint32_t ui32Base, bool bStart)¶ Handles the USB bus resume condition.
When in device mode, this function brings the USB controller out of the suspend state. This call must first be made with the
bStart parameter set to true to start resume signaling. The device application must then delay at least 10ms but not more than 15ms before calling this function with the bStart parameter set to false.- Parameters
ui32Base
: specifies the USB module base address.bStart
: specifies if the USB controller is entering or leaving the resume signaling state.
When in host mode, this function signals devices to leave the suspend state. This call must first be made with the bStart parameter set to true to start resume signaling. The host application must then delay at least 20ms before calling this function with the bStart parameter set to false. This action causes the controller to complete the resume signaling on the USB bus.
- Return
None.
-
uint32_t
USBHostSpeedGet
(uint32_t ui32Base)¶ Returns the current speed of the USB device connected.
This function returns the current speed of the USB bus in host mode.
- Parameters
ui32Base
: specifies the USB module base address.
Example: Get the USB connection speed.
//! // //! // Get the connection speed of the device connected to the USB controller. //! // //! USBHostSpeedGet(USBA_BASE); //!
\note This function must only be called in host mode. \return Returns one of the following: \b USB_LOW_SPEED, \b USB_FULL_SPEED, or \b USB_UNDEF_SPEED.
-
void
USBHostSuspend
(uint32_t ui32Base)¶ Puts the USB bus in a suspended state.
When used in host mode, this function puts the USB bus in the suspended state.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called in host mode.
- Return
None.
-
void
USBIntDisableControl
(uint32_t ui32Base, uint32_t ui32IntFlags)¶ Disables control interrupts on a given USB controller.
This function disables the control interrupts for the USB controller specified by the
ui32Base parameter. The ui32Flags parameter specifies which control interrupts to disable. The flags passed in the ui32Flags parameters must be the definitions that start with USB_INTCTRL_* and not any other USB_INT flags.- Parameters
ui32Base
: specifies the USB module base address.ui32Flags
: specifies which control interrupts to disable.
- Return
None.
-
void
USBIntEnableControl
(uint32_t ui32Base, uint32_t ui32IntFlags)¶ Enables control interrupts on a given USB controller.
This function enables the control interrupts for the USB controller specified by the
ui32Base parameter. The ui32Flags parameter specifies which control interrupts to enable. The flags passed in the ui32Flags parameters must be the definitions that start with USB_INTCTRL_* and not any other USB_INT flags.- Parameters
ui32Base
: specifies the USB module base address.ui32Flags
: specifies which control interrupts to enable.
- Return
None.
-
uint32_t
USBIntStatus
(uint32_t ui32Base, uint32_t *ui32IntStatusEP)¶ Returns the control interrupt status on a given USB controller.
This function reads control interrupt status for a USB controller. This call returns the current status for control interrupts only, the endpoint interrupt status is retrieved by calling
USBIntStatusEndpoint(). The bit values returned are compared against the USB_INTCTRL_* values.- Parameters
ui32Base
: specifies the USB module base address.ui32IntStatusEP
: is a pointer to the variable which holds the endpoint interrupt status from RXIS And TXIS.
The following are the meanings of all USB_INCTRL_ flags and the modes for which they are valid. These values apply to any calls to USBIntStatusControl(), USBIntEnableControl(), and USBIntDisableControl(). Some of these flags are only valid in the following modes as indicated in the parentheses: Host, Device, and OTG.
USB_INTCTRL_ALL - A full mask of all control interrupt sources.
USB_INTCTRL_VBUS_ERR - A VBUS error has occurred (Host Only).
USB_INTCTRL_SESSION - Session Start Detected on A-side of cable (OTG Only).
USB_INTCTRL_SESSION_END - Session End Detected (Device Only)
USB_INTCTRL_DISCONNECT - Device Disconnect Detected (Host Only)
USB_INTCTRL_CONNECT - Device Connect Detected (Host Only)
USB_INTCTRL_SOF - Start of Frame Detected.
USB_INTCTRL_BABBLE - USB controller detected a device signaling past the end of a frame (Host Only)
USB_INTCTRL_RESET - Reset signaling detected by device (Device Only)
USB_INTCTRL_RESUME - Resume signaling detected.
USB_INTCTRL_SUSPEND - Suspend signaling detected by device (Device Only)
USB_INTCTRL_MODE_DETECT - OTG cable mode detection has completed (OTG Only)
USB_INTCTRL_POWER_FAULT - Power Fault detected (Host Only)
- Note
This call clears the source of all of the control status interrupts.
- Return
Returns the status of the control interrupts for a USB controller. This is the value of USBIS.
-
uint32_t
USBIntStatusControl
(uint32_t ui32Base)¶ Returns the control interrupt status on a given USB controller.
This function reads control interrupt status for a USB controller. This call returns the current status for control interrupts only, the endpoint interrupt status is retrieved by calling
USBIntStatusEndpoint(). The bit values returned are compared against the USB_INTCTRL_* values.- Parameters
ui32Base
: specifies the USB module base address.
The following are the meanings of all USB_INCTRL_ flags and the modes for which they are valid. These values apply to any calls to USBIntStatusControl(), USBIntEnableControl(), and USBIntDisableControl(). Some of these flags are only valid in the following modes as indicated in the parentheses: Host, Device, and OTG.
USB_INTCTRL_ALL - A full mask of all control interrupt sources.
USB_INTCTRL_VBUS_ERR - A VBUS error has occurred (Host Only).
USB_INTCTRL_SESSION - Session Start Detected on A-side of cable (OTG Only).
USB_INTCTRL_SESSION_END - Session End Detected (Device Only)
USB_INTCTRL_DISCONNECT - Device Disconnect Detected (Host Only)
USB_INTCTRL_CONNECT - Device Connect Detected (Host Only)
USB_INTCTRL_SOF - Start of Frame Detected.
USB_INTCTRL_BABBLE - USB controller detected a device signaling past the end of a frame (Host Only)
USB_INTCTRL_RESET - Reset signaling detected by device (Device Only)
USB_INTCTRL_RESUME - Resume signaling detected.
USB_INTCTRL_SUSPEND - Suspend signaling detected by device (Device Only)
USB_INTCTRL_MODE_DETECT - OTG cable mode detection has completed (OTG Only)
USB_INTCTRL_POWER_FAULT - Power Fault detected (Host Only)
- Note
This call clears the source of all of the control status interrupts.
- Return
Returns the status of the control interrupts for a USB controller.
-
void
USBIntDisableEndpoint
(uint32_t ui32Base, uint32_t ui32IntFlags)¶ Disables endpoint interrupts on a given USB controller.
This function disables endpoint interrupts for the USB controller specified by the
ui32Base parameter. The ui32Flags parameter specifies which endpoint interrupts to disable. The flags passed in the ui32Flags parameters must be the definitions that start with USB_INTEP_* and not any other USB_INT flags.- Parameters
ui32Base
: specifies the USB module base address.ui32Flags
: specifies which endpoint interrupts to disable.
- Return
None.
-
void
USBIntEnableEndpoint
(uint32_t ui32Base, uint32_t ui32IntFlags)¶ Enables endpoint interrupts on a given USB controller.
This function enables endpoint interrupts for the USB controller specified by the
ui32Base parameter. The ui32Flags parameter specifies which endpoint interrupts to enable. The flags passed in the ui32Flags parameters must be the definitions that start with USB_INTEP_* and not any other USB_INT flags.- Parameters
ui32Base
: specifies the USB module base address.ui32Flags
: specifies which endpoint interrupts to enable.
- Return
None.
-
uint32_t
USBIntStatusEndpoint
(uint32_t ui32Base)¶ Returns the endpoint interrupt status on a given USB controller.
This function reads endpoint interrupt status for a USB controller. This call returns the current status for endpoint interrupts only, the control interrupt status is retrieved by calling
USBIntStatusControl(). The bit values returned are compared against the USB_INTEP_* values. These values are grouped into classes for USB_INTEP_HOST_* and USB_INTEP_DEV_* values to handle both host and device modes with all endpoints.- Parameters
ui32Base
: specifies the USB module base address.
- Note
This call clears the source of all of the endpoint interrupts.
- Return
Returns the status of the endpoint interrupts for a USB controller.
-
void
USBOTGSessionRequest
(uint32_t ui32Base, bool bStart)¶ Starts or ends a session.
This function is used in OTG mode to start a session request or end a session. If the
bStart parameter is set to true, then this function starts a session and if it is false it ends a session.- Parameters
ui32Base
: specifies the USB module base address.bStart
: specifies if this call starts or ends a session.
- Return
None.
-
uint32_t
USBModeGet
(uint32_t ui32Base)¶ Returns the current operating mode of the controller.
This function returns the current operating mode on USB controllers with OTG or Dual mode functionality.
- Parameters
ui32Base
: specifies the USB module base address.
For OTG controllers:
The function returns one of the following values on OTG controllers: USB_OTG_MODE_ASIDE_HOST, USB_OTG_MODE_ASIDE_DEV, USB_OTG_MODE_BSIDE_HOST, USB_OTG_MODE_BSIDE_DEV, USB_OTG_MODE_NONE.
USB_OTG_MODE_ASIDE_HOST indicates that the controller is in host mode on the A-side of the cable.
USB_OTG_MODE_ASIDE_DEV indicates that the controller is in device mode on the A-side of the cable.
USB_OTG_MODE_BSIDE_HOST indicates that the controller is in host mode on the B-side of the cable.
USB_OTG_MODE_BSIDE_DEV indicates that the controller is in device mode on the B-side of the cable. If an OTG session request is started with no cable in place, this mode is the default.
USB_OTG_MODE_NONE indicates that the controller is not attempting to determine its role in the system.
For Dual Mode controllers:
The function returns one of the following values: USB_DUAL_MODE_HOST, USB_DUAL_MODE_DEVICE, or USB_DUAL_MODE_NONE.
USB_DUAL_MODE_HOST indicates that the controller is acting as a host.
USB_DUAL_MODE_DEVICE indicates that the controller acting as a device.
USB_DUAL_MODE_NONE indicates that the controller is not active as either a host or device.
- Return
Returns USB_OTG_MODE_ASIDE_HOST, USB_OTG_MODE_ASIDE_DEV, USB_OTG_MODE_BSIDE_HOST, USB_OTG_MODE_BSIDE_DEV, USB_OTG_MODE_NONE, USB_DUAL_MODE_HOST, USB_DUAL_MODE_DEVICE, or USB_DUAL_MODE_NONE.
-
void
USBEndpointDMAChannel
(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Channel)¶ Sets the DMA channel to use for a given endpoint.
This function is used to configure which DMA channel to use with a given endpoint. Receive DMA channels can only be used with receive endpoints and transmit DMA channels can only be used with transmit endpoints. As a result, the 3 receive and 3 transmit DMA channels can be mapped to any endpoint other than 0. The values that are passed into the
ui32Channel value are the UDMA_CHANNEL_USBEP* values defined in udma.h.- Parameters
ui32Base
: specifies the USB module base address.ui32Endpoint
: specifies which endpoint’s FIFO address to return.ui32Channel
: specifies which DMA channel to use for which endpoint.
- Note
This function only has an effect on microcontrollers that have the ability to change the DMA channel for an endpoint. Calling this function on other devices has no effect.
- Return
None.
-
void
USBHostMode
(uint32_t ui32Base)¶ Change the mode of the USB controller to host.
This function changes the mode of the USB controller to host mode.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called on microcontrollers that support OTG operation and have the DEVMODOTG bit in the USBGPCS register.
- Return
None.
-
void
USBDevMode
(uint32_t ui32Base)¶ Change the mode of the USB controller to device.
This function changes the mode of the USB controller to device mode.
- Parameters
ui32Base
: specifies the USB module base address.
- Note
This function must only be called on microcontrollers that support OTG operation and have the DEVMODOTG bit in the USBGPCS register.
- Return
None.
-
void
USBOTGMode
(uint32_t ui32Base)¶ Change the mode of the USB controller to OTG.
This function changes the mode of the USB controller to OTG mode. This function is only valid on microcontrollers that have the OTG capabilities.
- Parameters
ui32Base
: specifies the USB module base address.
- Return
None.
-
void
USBPHYPowerOff
(uint32_t ui32Base)¶ Powers off the USB PHY.
This function powers off the USB PHY, reducing the current consuption of the device. While in the powered-off state, the USB controller is unable to operate.
- Parameters
ui32Base
: specifies the USB module base address.
- Return
None.
-
void
USBPHYPowerOn
(uint32_t ui32Base)¶ Powers on the USB PHY.
This function powers on the USB PHY, enabling it return to normal operation. By default, the PHY is powered on, so this function must only be called if
USBPHYPowerOff() has previously been called.- Parameters
ui32Base
: specifies the USB module base address.
- Return
None.
-
uint32_t
USBNumEndpointsGet
(uint32_t ui32Base)¶ Returns the number of USB endpoint pairs on the device.
This function returns the number of endpoint pairs supported by the USB controller corresponding to the passed base address. The value returned is the number of IN or OUT endpoints available and does not include endpoint 0 (the control endpoint). For example, if 15 is returned, there are 15 IN and 15 OUT endpoints available in addition to endpoint 0.
- Parameters
ui32Base
: specifies the USB module base address.
- Return
Returns the number of IN or OUT endpoints available.
-
The code for this module is contained in driverlib/usb.c, with driverlib/usb.h containing the API declarations for use by applications.