Data Structures | |
struct | tUSBHostClassDriver |
Macros | |
#define | USBHCD_PIPE_UNUSED 0x00100000 |
#define | USBHCD_PIPE_CONTROL 0x00130000 |
#define | USBHCD_PIPE_BULK_OUT 0x00210000 |
#define | USBHCD_PIPE_BULK_IN 0x00220000 |
#define | USBHCD_PIPE_INTR_OUT 0x00410000 |
#define | USBHCD_PIPE_INTR_IN 0x00420000 |
#define | USBHCD_PIPE_ISOC_OUT 0x00810000 |
#define | USBHCD_PIPE_ISOC_IN 0x00820000 |
#define | USBHCD_PIPE_ISOC_OUT_DMA 0x01810000 |
#define | USBHCD_PIPE_ISOC_IN_DMA 0x01820000 |
#define | USBHCD_PIPE_BULK_OUT_DMA 0x01210000 |
#define | USBHCD_PIPE_BULK_IN_DMA 0x01220000 |
#define | USBHCD_FAULT_LOW 0x00000010 |
#define | USBHCD_FAULT_HIGH 0x00000030 |
#define | USBHCD_FAULT_VBUS_NONE 0x00000000 |
#define | USBHCD_FAULT_VBUS_TRI 0x00000140 |
#define | USBHCD_FAULT_VBUS_DIS 0x00000400 |
#define | USBHCD_VBUS_MANUAL 0x00000004 |
#define | USBHCD_VBUS_AUTO_LOW 0x00000002 |
#define | USBHCD_VBUS_AUTO_HIGH 0x00000003 |
#define | USBHCD_VBUS_FILTER 0x00010000 |
#define | USBHCD_LPM_AVAIL 0x00000000 |
#define | USBHCD_LPM_ERROR 0x00000001 |
#define | USBHCD_LPM_PENDING 0x00000002 |
#define | DECLARE_EVENT_DRIVER(VarName, pfnOpen, pfnClose, pfnEvent) |
#define | USB_HOST_PWREN_AUTO 0x00000002 |
#define | INT_EVENT_VBUS_ERR 0x01 |
#define | INT_EVENT_CONNECT 0x02 |
#define | INT_EVENT_DISCONNECT 0x04 |
#define | INT_EVENT_POWER_FAULT 0x08 |
#define | INT_EVENT_SOF 0x10 |
#define | INT_EVENT_ENUM 0x20 |
#define | INT_EVENT_LPM_PEND 0x40 |
#define | INT_EVENT_LPM 0x80 |
#define | USBHDEV_FLAG_NOTIFYINT 0x00000001 |
#define | USBHDEV_FLAG_LPMPEND 0x00000002 |
#define | USBHDEV_FLAG_LPMERROR 0x00000004 |
#define | USBHDEV_FLAG_ALLOCATED 0x80000000 |
#define | MAX_NUM_PIPES 15 |
#define | MAX_NUM_DMA_CHANNELS 6 |
#define | USBHCD_DMA_UNUSED 0xff |
#define | EP_PIPE_TYPE_LOW_SPEED 0x02000000 |
#define | EP_PIPE_USE_UDMA 0x01000000 |
#define | EP_PIPE_TYPE_ISOC 0x00800000 |
#define | EP_PIPE_TYPE_INTR 0x00400000 |
#define | EP_PIPE_TYPE_BULK 0x00200000 |
#define | EP_PIPE_TYPE_CONTROL 0x00100000 |
#define | EP_PIPE_TYPE_IN 0x00020000 |
#define | EP_PIPE_TYPE_OUT 0x00010000 |
#define | EP_PIPE_IDX_M 0x0000ffff |
#define | OUT_PIPE_HANDLE(ui32Idx) |
#define | IN_PIPE_HANDLE(ui32Idx) |
#define | EP_OFFSET(Endpoint) (Endpoint - 0x10) |
Typedefs | |
typedef void(* | tHCDPipeCallback) (uint32_t ui32Pipe, uint32_t ui32Event) |
typedef struct tUSBHostDevice | tUSBHostDevice |
Functions | |
void | OTGDeviceDisconnect (uint32_t ui32Index) |
uint32_t | ConfigDescAlloc (tUSBHostDevice *psDevice, uint32_t ui32Size) |
void | ConfigDescFree (tUSBHostDevice *psDevice) |
int32_t | USBHCDEventEnable (uint32_t ui32Index, void *pvEventDriver, uint32_t ui32Event) |
int32_t | USBHCDEventDisable (uint32_t ui32Index, void *pvEventDriver, uint32_t ui32Event) |
uint32_t | USBHCDPipeTransferSizeGet (uint32_t ui32Pipe) |
uint32_t | USBHCDPipeAllocSize (uint32_t ui32Index, uint32_t ui32EndpointType, tUSBHostDevice *psDevice, uint32_t ui32Size, tHCDPipeCallback pfnCallback) |
uint32_t | USBHCDPipeAlloc (uint32_t ui32Index, uint32_t ui32EndpointType, tUSBHostDevice *psDevice, tHCDPipeCallback pfnCallback) |
uint32_t | USBHCDPipeConfig (uint32_t ui32Pipe, uint32_t ui32MaxPayload, uint32_t ui32Interval, uint32_t ui32TargetEndpoint) |
uint32_t | USBHCDPipeStatus (uint32_t ui32Pipe) |
uint32_t | USBHCDPipeWrite (uint32_t ui32Pipe, uint8_t *pui8Data, uint32_t ui32Size) |
uint32_t | USBHCDPipeSchedule (uint32_t ui32Pipe, uint8_t *pui8Data, uint32_t ui32Size) |
uint32_t | USBHCDPipeReadNonBlocking (uint32_t ui32Pipe, uint8_t *pui8Data, uint32_t ui32Size) |
void | USBHCDPipeDataAck (uint32_t ui32Pipe) |
uint32_t | USBHCDPipeRead (uint32_t ui32Pipe, uint8_t *pui8Data, uint32_t ui32Size) |
void | USBHCDPipeFree (uint32_t ui32Pipe) |
void | USBHCDPowerConfigInit (uint32_t ui32Index, uint32_t ui32PwrConfig) |
uint32_t | USBHCDPowerConfigGet (uint32_t ui32Index) |
uint32_t | USBHCDPowerConfigSet (uint32_t ui32Index, uint32_t ui32Config) |
uint32_t | USBHCDPowerAutomatic (uint32_t ui32Index) |
void | USBHCDInit (uint32_t ui32Index, void *pvPool, uint32_t ui32PoolSize) |
void | USBHCDRegisterDrivers (uint32_t ui32Index, const tUSBHostClassDriver *const *ppsHClassDrvs, uint32_t ui32NumDrivers) |
void | USBHCDTerm (uint32_t ui32Index) |
void | USBHCDReset (uint32_t ui32Index) |
void | USBHCDSuspend (uint32_t ui32Index) |
void | USBHCDResume (uint32_t ui32Index) |
uint32_t | USBHCDStringDescriptorGet (tUSBHostDevice *psDevice, uint8_t *pui8Buffer, uint32_t ui32Size, uint32_t ui32LangID, uint32_t ui32StringIndex) |
void | USBHCDSetAddress (uint32_t ui32DevIndex, uint32_t ui32DevAddress) |
void | USBHCDSetConfig (uint32_t ui32Index, uint32_t ui32Device, uint32_t ui32Configuration) |
void | USBHCDSetInterface (uint32_t ui32Index, uint32_t ui32Device, uint32_t ui32Interface, uint32_t ui32AltSetting) |
void | USBHostCheckPipes (void) |
void | USBHostIntHandlerInternal (uint32_t ui32Index, uint32_t ui32Status) |
void | USB0_IRQHostHandler (void) |
void | InternalUSBHCDSendEvent (uint32_t ui32Index, tEventInfo *psEvent, uint32_t ui32EvFlag) |
void | USBHCDMain (void) |
uint32_t | USBHCDControlTransfer (uint32_t ui32Index, tUSBRequest *psSetupPacket, tUSBHostDevice *psDevice, uint8_t *pui8Data, uint32_t ui32Size, uint32_t ui32MaxPacketSize) |
uint32_t | USBHCDHubDeviceConnected (uint32_t ui32Index, uint8_t ui8Hub, uint8_t ui8Port, uint32_t ui32Speed) |
void | USBHCDHubDeviceDisconnected (uint32_t ui32Index, uint32_t ui32DevIndex) |
uint8_t | USBHCDDevHubPort (uint32_t ui32Instance) |
uint8_t | USBHCDDevAddress (uint32_t ui32Instance) |
uint8_t | USBHCDDevClass (uint32_t ui32Instance, uint32_t ui32Interface) |
uint8_t | USBHCDDevSubClass (uint32_t ui32Instance, uint32_t ui32Interface) |
uint8_t | USBHCDDevProtocol (uint32_t ui32Instance, uint32_t ui32Interface) |
bool | USBHCDFeatureSet (uint32_t ui32Index, uint32_t ui32Feature, void *pvFeature) |
uint32_t | USBHCDLPMStatus (tUSBHostDevice *psDevice) |
uint32_t | USBHCDLPMSleep (tUSBHostDevice *psDevice) |
void | USBHCDLPMResume (uint32_t ui32Index) |
Variables | |
tUSBMode | g_iUSBMode |
#define USBHCD_PIPE_UNUSED 0x00100000 |
#define USBHCD_PIPE_CONTROL 0x00130000 |
#define USBHCD_PIPE_BULK_OUT 0x00210000 |
#define USBHCD_PIPE_BULK_IN 0x00220000 |
#define USBHCD_PIPE_INTR_OUT 0x00410000 |
#define USBHCD_PIPE_INTR_IN 0x00420000 |
#define USBHCD_PIPE_ISOC_OUT 0x00810000 |
#define USBHCD_PIPE_ISOC_IN 0x00820000 |
#define USBHCD_PIPE_ISOC_OUT_DMA 0x01810000 |
#define USBHCD_PIPE_ISOC_IN_DMA 0x01820000 |
#define USBHCD_PIPE_BULK_OUT_DMA 0x01210000 |
#define USBHCD_PIPE_BULK_IN_DMA 0x01220000 |
#define USBHCD_FAULT_LOW 0x00000010 |
#define USBHCD_FAULT_HIGH 0x00000030 |
#define USBHCD_FAULT_VBUS_NONE 0x00000000 |
#define USBHCD_FAULT_VBUS_TRI 0x00000140 |
#define USBHCD_FAULT_VBUS_DIS 0x00000400 |
#define USBHCD_VBUS_MANUAL 0x00000004 |
#define USBHCD_VBUS_AUTO_LOW 0x00000002 |
#define USBHCD_VBUS_AUTO_HIGH 0x00000003 |
#define USBHCD_VBUS_FILTER 0x00010000 |
#define USBHCD_LPM_AVAIL 0x00000000 |
Referenced by USBHCDLPMStatus().
#define USBHCD_LPM_ERROR 0x00000001 |
Referenced by USBHCDLPMStatus().
#define USBHCD_LPM_PENDING 0x00000002 |
Referenced by USBHCDLPMStatus().
#define DECLARE_EVENT_DRIVER | ( | VarName, | |
pfnOpen, | |||
pfnClose, | |||
pfnEvent | |||
) |
This macro is used to declare an instance of an Event driver for the USB library.
VarName | is the name of the variable. |
pfnOpen | is the callback for the Open call to this driver. This value is currently reserved and should be set to 0. |
pfnClose | is the callback for the Close call to this driver. This value is currently reserved and should be set to 0. |
pfnEvent | is the callback that will be called for various USB events. |
The first parameter is the actual name of the variable that will be declared by this macro. The second and third parameter are reserved for future functionality and are unused and should be set to zero. The last parameter is the actual callback function and is specified as a function pointer of the type:
//! void (*pfnEvent)(void *pvData); //!
When the \e pfnEvent function is called the void pointer that is passed in as a parameter should be cast to a pointer to a structure of type tEventInfo. This will contain the event that caused the pfnEvent function to be called.
#define USB_HOST_PWREN_AUTO 0x00000002 |
#define INT_EVENT_VBUS_ERR 0x01 |
#define INT_EVENT_CONNECT 0x02 |
#define INT_EVENT_DISCONNECT 0x04 |
#define INT_EVENT_POWER_FAULT 0x08 |
#define INT_EVENT_SOF 0x10 |
#define INT_EVENT_ENUM 0x20 |
#define INT_EVENT_LPM_PEND 0x40 |
#define INT_EVENT_LPM 0x80 |
#define USBHDEV_FLAG_NOTIFYINT 0x00000001 |
#define USBHDEV_FLAG_LPMPEND 0x00000002 |
Referenced by USBHCDLPMStatus().
#define USBHDEV_FLAG_LPMERROR 0x00000004 |
Referenced by USBHCDLPMStatus().
#define USBHDEV_FLAG_ALLOCATED 0x80000000 |
#define MAX_NUM_PIPES 15 |
Referenced by USBHCDPipeAllocSize().
#define MAX_NUM_DMA_CHANNELS 6 |
#define USBHCD_DMA_UNUSED 0xff |
#define EP_PIPE_TYPE_LOW_SPEED 0x02000000 |
#define EP_PIPE_USE_UDMA 0x01000000 |
Referenced by USBHCDPipeSchedule(), and USBHCDPipeWrite().
#define EP_PIPE_TYPE_ISOC 0x00800000 |
#define EP_PIPE_TYPE_INTR 0x00400000 |
#define EP_PIPE_TYPE_BULK 0x00200000 |
#define EP_PIPE_TYPE_CONTROL 0x00100000 |
#define EP_PIPE_TYPE_IN 0x00020000 |
#define EP_PIPE_TYPE_OUT 0x00010000 |
Referenced by USBHCDPipeAllocSize(), USBHCDPipeConfig(), USBHCDPipeFree(), and USBHCDPipeSchedule().
#define EP_PIPE_IDX_M 0x0000ffff |
#define OUT_PIPE_HANDLE | ( | ui32Idx | ) |
#define IN_PIPE_HANDLE | ( | ui32Idx | ) |
#define EP_OFFSET | ( | Endpoint | ) | (Endpoint - 0x10) |
typedef void(* tHCDPipeCallback) (uint32_t ui32Pipe, uint32_t ui32Event) |
typedef struct tUSBHostDevice tUSBHostDevice |
enum tEP0State |
enum tUSBHDeviceState |
void OTGDeviceDisconnect | ( | uint32_t | ui32Index | ) |
References eUSBOTGModeAHost, and g_eOTGModeState.
uint32_t ConfigDescAlloc | ( | tUSBHostDevice * | psDevice, |
uint32_t | ui32Size | ||
) |
void ConfigDescFree | ( | tUSBHostDevice * | psDevice | ) |
int32_t USBHCDEventEnable | ( | uint32_t | ui32Index, |
void * | pvEventDriver, | ||
uint32_t | ui32Event | ||
) |
This function is called to enable a specific USB HCD event notification.
ui32Index | specifies which USB controller to use. |
pvEventDriver | is the event driver structure that was passed into the USBHCDRegisterDrivers() function as part of the array of tUSBHostClassDriver structures. |
ui32Event | is the event to enable. |
This function is called to enable event callbacks for a specific USB HCD event. The requested event is passed in the ui32Event parameter. Not all events can be enables so the function will return zero if the event provided cannot be enabled. The pvEventDriver is a pointer to the event driver structure that the caller passed into the USBHCDRegisterDrivers() function. This structure is typically declared with the DECLARE_EVENT_DRIVER() macro and included as part of the array of pointers to tUSBHostClassDriver structures that is passed to the USBHCDRegisterDrivers() function.
int32_t USBHCDEventDisable | ( | uint32_t | ui32Index, |
void * | pvEventDriver, | ||
uint32_t | ui32Event | ||
) |
This function is called to disable a specific USB HCD event notification.
ui32Index | specifies which USB controller to use. |
pvEventDriver | is the event driver structure that was passed into the USBHCDRegisterDrivers() function as part of the array of tUSBHostClassDriver structures. |
ui32Event | is the event to disable. |
This function is called to disable event callbacks for a specific USB HCD event. The requested event is passed in the ui32Event parameter. Not all events can be enables so the function will return zero if the event provided cannot be enabled. The pvEventDriver is a pointer to the event driver structure that the caller passed into the USBHCDRegisterDrivers() function. This structure is typically declared with the DECLARE_EVENT_DRIVER() macro and included as part of the array of pointers to tUSBHostClassDriver structures that is passed to the USBHCDRegisterDrivers() function.
uint32_t USBHCDPipeTransferSizeGet | ( | uint32_t | ui32Pipe | ) |
This function returns the current byte count of a USB HCD pipe.
ui32Pipe | is the allocated endpoint to modify. |
This call returns the current or last byte count for a transfer using the pipe specified by the ui32Pipe parameter. This is typically used to determine the actual byte count received when a USB_EVENT_RX_AVAILABLE occurs.
References EP_PIPE_IDX_M.
uint32_t USBHCDPipeAllocSize | ( | uint32_t | ui32Index, |
uint32_t | ui32EndpointType, | ||
tUSBHostDevice * | psDevice, | ||
uint32_t | ui32Size, | ||
tHCDPipeCallback | pfnCallback | ||
) |
This function is used to allocate a USB HCD pipe.
ui32Index | specifies which USB controller to use. |
ui32EndpointType | is the type of endpoint that this pipe will be communicating with. |
psDevice | is the device instance associated with this endpoint. |
ui32Size | is the size of the FIFO in bytes. |
pfnCallback | is the function that will be called when events occur on this USB Pipe. |
Since there are a limited number of USB HCD pipes that can be used in the host controller, this function is used to temporarily or permanently acquire one of the endpoints. Unlike the USBHCDPipeAlloc() function this function allows the caller to specify the size of the FIFO allocated to this endpoint in the ui32Size parameter. This function also provides a method to register a callback for status changes on this endpoint. If no callbacks are desired then the pfnCallback function should be set to 0. The callback should be used when using the USBHCDPipeSchedule() function so that the caller is notified when the action is complete.
References EP_PIPE_TYPE_OUT, and MAX_NUM_PIPES.
Referenced by USBHCDPipeAlloc().
uint32_t USBHCDPipeAlloc | ( | uint32_t | ui32Index, |
uint32_t | ui32EndpointType, | ||
tUSBHostDevice * | psDevice, | ||
tHCDPipeCallback | pfnCallback | ||
) |
This function is used to allocate a USB HCD pipe.
ui32Index | specifies which USB controller to use. |
ui32EndpointType | is the type of endpoint that this pipe will be communicating with. |
psDevice | is the device instance associated with this endpoint. |
pfnCallback | is the function that will be called when events occur on this USB Pipe. |
Since there are a limited number of USB HCD pipes that can be used in the host controller, this function is used to temporarily or permanently acquire one of the endpoints. It also provides a method to register a callback for status changes on this endpoint. If no callbacks are desired then the pfnCallback function should be set to 0. The callback should be used when using the USBHCDPipeSchedule() function so that the caller is notified when the action is complete.
References USBHCDPipeAllocSize().
uint32_t USBHCDPipeConfig | ( | uint32_t | ui32Pipe, |
uint32_t | ui32MaxPayload, | ||
uint32_t | ui32Interval, | ||
uint32_t | ui32TargetEndpoint | ||
) |
This function is used to configure a USB HCD pipe.
This should be called after allocating a USB pipe with a call to USBHCDPipeAlloc(). It is used to set the configuration associated with an endpoint like the max payload and target endpoint. The ui32MaxPayload parameter is typically read directly from the devices endpoint descriptor and is expressed in bytes.
Setting the ui32Interval parameter depends on the type of endpoint being configured. For endpoints that do not need to use the ui32Interval parameter ui32Interval should be set to 0. For Bulk ui32Interval is a value from 2-16 and will set the NAK timeout value as 2^(ui32Interval-1) frames. For interrupt endpoints ui32Interval is a value from 1-255 and is the count in frames between polling the endpoint. For isochronous endpoints ui32Interval ranges from 1-16 and is the polling interval in frames represented as 2^(ui32Interval-1) frames.
ui32Pipe | is the allocated endpoint to modify. |
ui32MaxPayload | is maximum data that can be handled per transaction. |
ui32Interval | is the polling interval for data transfers expressed in frames. |
ui32TargetEndpoint | is the target endpoint on the device to communicate with. |
References EP_PIPE_IDX_M, EP_PIPE_TYPE_OUT, and tUSBHostDevice::ui32Flags.
uint32_t USBHCDPipeStatus | ( | uint32_t | ui32Pipe | ) |
This function is used to return the current status of a USB HCD pipe.
This function will return the current status for a given USB pipe. If there is no status to report this call will simply return USBHCD_PIPE_NO_CHANGE.
ui32Pipe | is the USB pipe for this status request. |
uint32_t USBHCDPipeWrite | ( | uint32_t | ui32Pipe, |
uint8_t * | pui8Data, | ||
uint32_t | ui32Size | ||
) |
This function is used to write data to a USB HCD pipe.
ui32Pipe | is the USB pipe to put data into. |
pui8Data | is a pointer to the data to send. |
ui32Size | is the amount of data to send. |
This function will block until it has sent as much data as was requested using the USB pipe's FIFO. The caller should have registered a callback with the USBHCDPipeAlloc() call in order to be informed when the data has been transmitted. The value returned by this function can be less than the ui32Size requested if the USB pipe has less space available than this request is making.
References EP_PIPE_IDX_M, and EP_PIPE_USE_UDMA.
uint32_t USBHCDPipeSchedule | ( | uint32_t | ui32Pipe, |
uint8_t * | pui8Data, | ||
uint32_t | ui32Size | ||
) |
This function is used to schedule and IN transaction on a USB HCD pipe.
ui32Pipe | is the USB pipe to read data from. |
pui8Data | is a pointer to store the data that is received. |
ui32Size | is the size in bytes of the buffer pointed to by pui8Data. |
This function will not block depending on the type of pipe passed in will schedule either a send of data to the device or a read of data from the device. In either case the amount of data will be limited to what will fit in the FIFO for a given endpoint.
References EP_PIPE_IDX_M, EP_PIPE_TYPE_OUT, and EP_PIPE_USE_UDMA.
Referenced by USBHostAudioPlay(), and USBHostAudioRecord().
uint32_t USBHCDPipeReadNonBlocking | ( | uint32_t | ui32Pipe, |
uint8_t * | pui8Data, | ||
uint32_t | ui32Size | ||
) |
This function is used to read data from a USB HCD pipe.
ui32Pipe | is the USB pipe to read data from. |
pui8Data | is a pointer to store the data that is received. |
ui32Size | is the size in bytes of the buffer pointed to by pui8Data. |
This function will not block and will only read as much data as requested or as much data is currently available from the USB pipe. The caller should have registered a callback with the USBHCDPipeAlloc() call in order to be informed when the data has been received. The value returned by this function can be less than the ui32Size requested if the USB pipe has less data available than was requested.
References EP_PIPE_IDX_M.
Referenced by USBHHIDGetReport().
void USBHCDPipeDataAck | ( | uint32_t | ui32Pipe | ) |
This function acknowledges data received via an interrupt IN pipe.
ui32Pipe | is the USB INT pipe whose last packet is to be acknowledged. |
This function is used to acknowledge reception of data on an interrupt IN pipe. A transfer on an interrupt IN endpoint is scheduled via a call to USBHCDPipeSchedule() and the application is notified when data is received using a USB_EVENT_RX_AVAILABLE event. In the handler for this event, the application must call USBHCDPipeDataAck() to have the USB controller ACK the data from the device and complete the transaction.
References EP_PIPE_IDX_M.
uint32_t USBHCDPipeRead | ( | uint32_t | ui32Pipe, |
uint8_t * | pui8Data, | ||
uint32_t | ui32Size | ||
) |
This function is used to read data from a USB HCD pipe.
ui32Pipe | is the USB pipe to read data from. |
pui8Data | is a pointer to store the data that is received. |
ui32Size | is the size in bytes of the buffer pointed to by pui8Data. |
This function will block and will only return when it has read as much data as requested from the USB pipe. The caller must register a callback with the USBHCDPipeAlloc() call in order to be informed when the data has been received. If the caller provides a non-zero pointer in the pui8Data parameter then the data is copied into the buffer before the callback occurs. If the caller provides a zero in pui8Data parameter then the caller is responsible for reading the data out of the FIFO when the USB_EVENT_RX_AVAILABLE callback event occurs. The value returned by this function can be less than the ui32Size requested if the USB pipe has less data available than was requested.
References EP_PIPE_IDX_M.
void USBHCDPipeFree | ( | uint32_t | ui32Pipe | ) |
This function is used to release a USB pipe.
ui32Pipe | is the allocated USB pipe to release. |
This function is used to release a USB pipe that was allocated by a call to USBHCDPipeAlloc() for use by some other device endpoint in the system. Freeing an unallocated or invalid pipe will not generate an error and will instead simply return.
References EP_PIPE_IDX_M, and EP_PIPE_TYPE_OUT.
void USBHCDPowerConfigInit | ( | uint32_t | ui32Index, |
uint32_t | ui32PwrConfig | ||
) |
This function is used to set the power pin and power fault configuration.
ui32Index | specifies which USB controller to use. |
ui32PwrConfig | is the power configuration to use for the application. |
This function must be called before HCDInit() is called so that the power pin configuration can be set before power is enabled. The ui32PwrConfig flags specify the power fault level sensitivity, the power fault action, and the power enable pin level and source.
One of the following can be selected as the power fault level sensitivity:
One of the following can be selected as the power fault action:
One of the following can be selected as the power enable level and source:
If USBHCD_VBUS_MANUAL is used then the application must provide an event driver to receive the USB_EVENT_POWER_ENABLE and USB_EVENT_POWER_DISABLE events and enable and disable power to VBUS when requested by the USB library. The application should respond to a power control callback by enabling or disabling VBUS as soon as possible and before returning from the callback function.
uint32_t USBHCDPowerConfigGet | ( | uint32_t | ui32Index | ) |
This function is used to get the power pin and power fault configuration.
ui32Index | specifies which USB controller to use. |
This function will return the current power control pin configuration as set by the USBHCDPowerConfigInit() function or the defaults if not yet set. See the USBHCDPowerConfigInit() documentation for the meaning of the bits that are returned by this function.
Referenced by USBDualModeInit().
uint32_t USBHCDPowerConfigSet | ( | uint32_t | ui32Index, |
uint32_t | ui32Config | ||
) |
This function is used to set the power pin and power fault configuration.
ui32Index | specifies which USB controller to use. |
ui32Config | specifies which USB power configuration to use. |
This function will set the current power control pin configuration as set by the USBHCDPowerConfigInit() function or the defaults if not yet set. See the USBHCDPowerConfigInit() documentation for the meaning of the bits that are set by this function.
uint32_t USBHCDPowerAutomatic | ( | uint32_t | ui32Index | ) |
This function returns if the current power settings will automatically handle enabling and disabling VBUS power.
ui32Index | specifies which USB controller to query. |
This function returns if the current power control pin configuration will automatically apply power or whether it will be left to the application to turn on power when it is notified.
Referenced by USB0_IRQOTGModeHandler(), and USBDualModeInit().
void USBHCDInit | ( | uint32_t | ui32Index, |
void * | pvPool, | ||
uint32_t | ui32PoolSize | ||
) |
This function is used to initialize the HCD code.
ui32Index | specifies which USB controller to use. |
pvPool | is a pointer to the data to use as a memory pool for this controller. |
ui32PoolSize | is the size in bytes of the buffer passed in as pvPool. |
This function will perform all the necessary operations to allow the USB host controller to begin enumeration and communication with devices. This function should typically be called once at the start of an application once all of the device and class drivers are ready for normal operation. This call will start up the USB host controller and any connected device will immediately start the enumeration sequence.
The USBStackModeSet() function can be called with eUSBModeHost in order to cause the USB library to force the USB operating mode to a host controller. This allows the application to used the USBVBUS and USBID pins as GPIOs on devices that support forcing OTG to operate as a host only controller. By default the USB library will assume that the USBVBUS and USBID pins are configured as USB pins and not GPIOs.
The memory pool passed to this function must be at least as large as a typical configuration descriptor for devices that are to be supported. This value is application-dependent however it should never be less than 32 bytes and, in most cases, should be at least 64 bytes. If there is not sufficient memory to load a configuration descriptor from a device, the device will not be recognized by the USB library's host controller driver.
References eUSBModeDevice, eUSBModeForceDevice, eUSBModeHost, eUSBModeNone, and g_iUSBMode.
void USBHCDRegisterDrivers | ( | uint32_t | ui32Index, |
const tUSBHostClassDriver *const * | ppsHClassDrvs, | ||
uint32_t | ui32NumDrivers | ||
) |
This function is used to initialize the HCD class driver list.
ui32Index | specifies which USB controller to use. |
ppsHClassDrvs | is an array of host class drivers that are supported on this controller. |
ui32NumDrivers | is the number of entries in the pHostClassDrivers array. |
This function will set the host classes supported by the host controller specified by the ui32Index parameter. This function should be called before enabling the host controller driver with the USBHCDInit() function.
void USBHCDTerm | ( | uint32_t | ui32Index | ) |
This function is used to terminate the HCD code.
ui32Index | specifies which USB controller to release. |
This function will clean up the USB host controller and disable it in preparation for shutdown or a switch to USB device mode. Once this call is made, USBHCDInit() may be called to reinitialize the controller and prepare for host mode operation.
void USBHCDReset | ( | uint32_t | ui32Index | ) |
This function generates reset signaling on the USB bus.
ui32Index | specifies which USB controller to use. |
This function handles sending out reset signaling on the USB bus. After returning from this function, any attached device on the USB bus should have returned to it's reset state.
void USBHCDSuspend | ( | uint32_t | ui32Index | ) |
This function will generate suspend signaling on the USB bus.
ui32Index | specifies which USB controller to use. |
This function is used to generate suspend signaling on the USB bus. In order to leave the suspended state, the application should call USBHCDResume().
void USBHCDResume | ( | uint32_t | ui32Index | ) |
This function will generate resume signaling on the USB bus.
ui32Index | specifies which USB controller to use. |
This function is used to generate resume signaling on the USB bus in order to cause USB devices to leave their suspended state. This call should not be made unless a preceding call to USBHCDSuspend() has been made.
uint32_t USBHCDStringDescriptorGet | ( | tUSBHostDevice * | psDevice, |
uint8_t * | pui8Buffer, | ||
uint32_t | ui32Size, | ||
uint32_t | ui32LangID, | ||
uint32_t | ui32StringIndex | ||
) |
This function issues a request for a string descriptor from a device.
psDevice | is the device for this request. |
pui8Buffer | is the pointer to the buffer to store the requested string descriptor. |
ui32Size | is the size of the buffer passed in the buffer that will be used for this request. |
ui32LangID | is the ID of the language for the requested string. |
ui32StringIndex | is the index for the request. |
This function will request a string descriptor from the device of the type specified in the ui32DescriptorType parameter. The pui8Descriptor pointer is the location where the request results will be stored. The ui32Size should be passed in to indicate the size of the pui8Descriptor buffer. The ui32DevAddress parameter is used to specify the device address to communicate with on the USB bus. This value should be specified as 0 for any non-configured device on the USB bus and be changed to the address set by a call to USBHCDSetAddress().
References tUSBHostDevice::sDeviceDescriptor, USB_DTYPE_STRING, USB_RTYPE_DEVICE, USB_RTYPE_DIR_IN, USB_RTYPE_STANDARD, USBHCDControlTransfer(), and USBREQ_GET_DESCRIPTOR.
void USBHCDSetAddress | ( | uint32_t | ui32DevIndex, |
uint32_t | ui32DevAddress | ||
) |
This function is used to send the set address command to a device.
ui32DevIndex | is the index of the device whose address is to be set. This value must be 0 to indicate that the device is connected directly to the host controller. Higher values indicate devices connected via a hub. |
ui32DevAddress | is the new device address to use for a device. |
The USBHCDSetAddress() function is used to set the USB device address, once a device has been discovered on the bus. This call is typically issued following a USB reset triggered by a call the USBHCDReset(). The address passed into this function via the ui32DevAddress parameter is used for all further communications with the device after this function returns.
References USB_RTYPE_DEVICE, USB_RTYPE_DIR_OUT, USB_RTYPE_STANDARD, USBHCDControlTransfer(), and USBREQ_SET_ADDRESS.
void USBHCDSetConfig | ( | uint32_t | ui32Index, |
uint32_t | ui32Device, | ||
uint32_t | ui32Configuration | ||
) |
This function is used to set the current configuration for a device.
ui32Index | specifies which USB controller to use. |
ui32Device | is the USB device for this function. |
ui32Configuration | is one of the devices valid configurations. |
This function is used to set the current device configuration for a USB device. The ui32Configuration value must be one of the configuration indexes that was returned in the configuration descriptor from the device, or a value of 0. If 0 is passed in, the device will return to it's addressed state and no longer be in a configured state. If the value is non-zero then the device will change to the requested configuration.
References USB_RTYPE_DEVICE, USB_RTYPE_DIR_OUT, USB_RTYPE_STANDARD, USBHCDControlTransfer(), and USBREQ_SET_CONFIG.
void USBHCDSetInterface | ( | uint32_t | ui32Index, |
uint32_t | ui32Device, | ||
uint32_t | ui32Interface, | ||
uint32_t | ui32AltSetting | ||
) |
This function is used to set the current interface and alternate setting for an interface on a device.
ui32Index | specifies which USB controller to use. |
ui32Device | is the USB device for this function. |
ui32Interface | is one of the valid interface numbers for a device. |
ui32AltSetting | is one of the valid alternate interfaces for the ui32Interface number. |
This function is used to change the alternate setting for one of the valid interfaces on a USB device. The ui32Device specifies the device instance that was returned when the device was connected. This call will set the USB device's interface based on the ui32Interface and ui32AltSetting.
Example: Set the USB device interface 2 to alternate setting 1.
//! USBHCDSetInterface(0, ui32Device, 2, 1); //!
\return None.
References tUSBHostDevice::ui32Interface, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USB_RTYPE_STANDARD, USBHCDControlTransfer(), and USBREQ_SET_INTERFACE.
Referenced by USBHostAudioPlay(), and USBHostAudioRecord().
void USBHostCheckPipes | ( | void | ) |
void USBHostIntHandlerInternal | ( | uint32_t | ui32Index, |
uint32_t | ui32Status | ||
) |
Referenced by USB0_IRQHostHandler(), and USB0DualModeIntHandler().
void USB0_IRQHostHandler | ( | void | ) |
The USB host mode interrupt handler for controller index 0.
This the main USB interrupt handler entry point. This handler will branch the interrupt off to the appropriate handlers depending on the current status of the USB controller. This function must be placed in the interrupt table in order for the USB Library host stack to function.
References USBHostIntHandlerInternal().
void InternalUSBHCDSendEvent | ( | uint32_t | ui32Index, |
tEventInfo * | psEvent, | ||
uint32_t | ui32EvFlag | ||
) |
Referenced by USB0_IRQOTGModeHandler().
void USBHCDMain | ( | void | ) |
This function is the main routine for the Host Controller Driver.
This function is the main routine for the host controller driver, and must be called periodically by the main application outside of a callback context. This allows for a simple cooperative system to access the the host controller driver interface without the need for an RTOS. All time critical operations are handled in interrupt context but all blocking operations are run from the this function to allow them to block and wait for completion without holding off other interrupts.
uint32_t USBHCDControlTransfer | ( | uint32_t | ui32Index, |
tUSBRequest * | psSetupPacket, | ||
tUSBHostDevice * | psDevice, | ||
uint8_t * | pui8Data, | ||
uint32_t | ui32Size, | ||
uint32_t | ui32MaxPacketSize | ||
) |
This function completes a control transaction to a device.
ui32Index | is the controller index to use for this transfer. |
psSetupPacket | is the setup request to be sent. |
psDevice | is the device instance pointer for this request. |
pui8Data | is the data to send for OUT requests or the receive buffer for IN requests. |
ui32Size | is the size of the buffer in pui8Data. |
ui32MaxPacketSize | is the maximum packet size for the device for this request. |
This function handles the state changes necessary to send a control transaction to a device. This function should not be called from within an interrupt callback as it is a blocking function.
Referenced by USBHCDSetAddress(), USBHCDSetConfig(), USBHCDSetInterface(), USBHCDStringDescriptorGet(), USBHHIDGetReportDescriptor(), USBHHIDSetIdle(), USBHHIDSetProtocol(), USBHHIDSetReport(), and USBHostAudioVolumeSet().
uint32_t USBHCDHubDeviceConnected | ( | uint32_t | ui32Index, |
uint8_t | ui8Hub, | ||
uint8_t | ui8Port, | ||
uint32_t | ui32Speed | ||
) |
References DEBUG_OUTPUT, and MAX_USB_DEVICES.
void USBHCDHubDeviceDisconnected | ( | uint32_t | ui32Index, |
uint32_t | ui32DevIndex | ||
) |
References DEBUG_OUTPUT, and MAX_USB_DEVICES.
uint8_t USBHCDDevHubPort | ( | uint32_t | ui32Instance | ) |
This function returns the USB hub port for the requested device instance.
ui32Instance | is a unique value indicating which device to query. |
This function returns the USB hub port for the device that is associated with the ui32Instance parameter. The caller must use the value for ui32Instance was passed to the application when it receives a USB_EVENT_CONNECTED event. The function returns the USB hub port for the interface number specified by the ui32Interface parameter.
uint8_t USBHCDDevAddress | ( | uint32_t | ui32Instance | ) |
This function will return the USB address for the requested device instance.
ui32Instance | is a unique value indicating which device to query. |
This function returns the USB address for the device that is associated with the ui32Instance parameter. The caller must use a value for ui32Instance have been passed to the application when it receives a USB_EVENT_CONNECTED event. The function will return the USB address for the interface number specified by the ui32Interface parameter.
uint8_t USBHCDDevClass | ( | uint32_t | ui32Instance, |
uint32_t | ui32Interface | ||
) |
This function will return the USB class for the requested device instance.
ui32Instance | is a unique value indicating which device to query. |
ui32Interface | is the interface number to query for the USB class. |
This function returns the USB class for the device that is associated with the ui32Instance parameter. The caller must use a value for ui32Instance have been passed to the application when it receives a USB_EVENT_CONNECTED event. The function will return the USB class for the interface number specified by the ui32Interface parameter. If ui32Interface is set to 0xFFFFFFFF then the function will return the USB class for the first interface that is found in the device's USB descriptors.
uint8_t USBHCDDevSubClass | ( | uint32_t | ui32Instance, |
uint32_t | ui32Interface | ||
) |
This function will return the USB subclass for the requested device instance.
ui32Instance | is a unique value indicating which device to query. |
ui32Interface | is the interface number to query for the USB subclass. |
This function returns the USB subclass for the device that is associated with the ui32Instance parameter. The caller must use a value for ui32Instance have been passed to the application when it receives a USB_EVENT_CONNECTED event. The function will return the USB subclass for the interface number specified by the ui32Interface parameter. If ui32Interface is set to 0xFFFFFFFF then the function will return the USB subclass for the first interface that is found in the device's USB descriptors.
uint8_t USBHCDDevProtocol | ( | uint32_t | ui32Instance, |
uint32_t | ui32Interface | ||
) |
This function returns the USB protocol for the requested device instance.
ui32Instance | is a unique value indicating which device to query. |
ui32Interface | is the interface number to query for the USB protocol. |
This function returns the USB protocol for the device that is associated with the ui32Instance parameter. The caller must use a value for ui32Instance have been passed to the application when it receives a USB_EVENT_CONNECTED event. The function will return the USB protocol for the interface number specified by the ui32Interface parameter. If ui32Interface is set to 0xFFFFFFFF then the function will return the USB protocol for the first interface that is found in the device's USB descriptors.
bool USBHCDFeatureSet | ( | uint32_t | ui32Index, |
uint32_t | ui32Feature, | ||
void * | pvFeature | ||
) |
This function sets one of the USBLIB_FEATURE_ requests.
ui32Index | is the index of the USB controller to access. |
ui32Feature | is one of the USBLIB_FEATURE_ defines. |
pvFeature | is a pointer to the data for the USBLIB_FEATURE request. |
This function sends the requested feature request to the USB library. Not all features are supported by all devices so see the documentation for the USBLIB_FEATURE_ to determine if the feature is supported.
References USBLIB_FEATURE_CPUCLK.
Referenced by USBOTGFeatureSet().
uint32_t USBHCDLPMStatus | ( | tUSBHostDevice * | psDevice | ) |
This function returns the current status of an LPM request.
psDevice | is the device to query. |
This function returns the current status of LPM requests for a given device. This is called to determine if a previous request completed successfully or if there was an error.
References tUSBHostDevice::ui32Flags, USBHCD_LPM_AVAIL, USBHCD_LPM_ERROR, USBHCD_LPM_PENDING, USBHDEV_FLAG_LPMERROR, and USBHDEV_FLAG_LPMPEND.
Referenced by USBHHIDLPMStatus(), USBHHubLPMStatus(), USBHMSCLPMStatus(), and USBHostAudioLPMStatus().
uint32_t USBHCDLPMSleep | ( | tUSBHostDevice * | psDevice | ) |
This function generates an LPM request for a device to enter L1 sleep state.
psDevice | is the device to query. |
This function sends a request to a device to enter the LPM L1 sleep state. The caller must check the return value to see if the request can be attempted at this time. If another LPM transaction is busy on another device this function will return USBHCD_LPM_PENDING or USBHCD_LPM_AVAIL if the LPM request was scheduled to be sent. The caller should check the USBHCDLPMStatus() function to determine if the request has completed.
Referenced by USBHHIDLPMSleep(), USBHHubLPMSleep(), USBHMSCLPMSleep(), and USBHostAudioLPMSleep().
void USBHCDLPMResume | ( | uint32_t | ui32Index | ) |
This function generates an LPM request for a device to exit L1 sleep state.
ui32Index | specifies which USB controller to use. |
This function will start LPM resume signaling on the USB bus. This wakes all devices and is similar to USBHCDResume() call but is triggered by an LPM request.
tUSBMode g_iUSBMode |
Referenced by USB0DualModeIntHandler(), USBHCDInit(), USBOTGModeInit(), and USBStackModeSet().