USBLibAPIGuide  1.00.00.01
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Usblib_host_class
Collaboration diagram for Usblib_host_class:

Data Structures

struct  tUSBAudioFormat
 
struct  tHIDInstance
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 

Macros

#define INTERFACE_NUM_M   0x000000FF
 
#define INTERFACE_ALTSETTING_M   0x0000FF00
 
#define INTERFACE_ALTSETTING_S   8
 
#define INVALID_INTERFACE   0xffffffff
 
#define AUDIO_FLAG_OUT_ACTIVE   1
 
#define AUDIO_FLAG_IN_ACTIVE   2
 
#define USBH_AUDIO_EVENT_OPEN   (USBH_AUDIO_EVENT_BASE + 0)
 
#define USBH_AUDIO_EVENT_CLOSE   (USBH_AUDIO_EVENT_BASE + 1)
 
#define USBH_AUDIO_FORMAT_IN   0x00000001
 
#define USBH_AUDIO_FORMAT_OUT   0x00000000
 
#define MAX_HID_DEVICES   MAX_USB_DEVICES
 
#define USBH_EVENT_HID_SETRPT   USBH_HID_EVENT_BASE + 0
 
#define USBH_EVENT_HID_REPORT   USBH_HID_EVENT_BASE + 1
 
#define USBH_EVENT_HID_KB_PRESS   USBH_HID_EVENT_BASE + 16
 The HID keyboard detected a key being pressed. More...
 
#define USBH_EVENT_HID_KB_REL   USBH_HID_EVENT_BASE + 17
 The HID keyboard detected a key being released. More...
 
#define USBH_EVENT_HID_KB_MOD   USBH_HID_EVENT_BASE + 18
 The HID keyboard detected one of the keyboard modifiers being pressed. More...
 
#define USBH_EVENT_HID_MS_PRESS   USBH_HID_EVENT_BASE + 32
 A button was pressed on a HID mouse. More...
 
#define USBH_EVENT_HID_MS_REL   USBH_HID_EVENT_BASE + 33
 A button was released on a HID mouse. More...
 
#define USBH_EVENT_HID_MS_X   USBH_HID_EVENT_BASE + 34
 The HID mouse detected movement in the X direction. More...
 
#define USBH_EVENT_HID_MS_Y   USBH_HID_EVENT_BASE + 35
 The HID mouse detected movement in the Y direction. More...
 
#define USBLIB_HUB_ACTIVE   0x00000001
 
#define USBLIB_HUB_HS   0x00000002
 
#define USBLIB_HUB_MULTI_TT   0x00000004
 
#define MSC_EVENT_OPEN   1
 
#define MSC_EVENT_CLOSE   2
 
#define CBW_TAG_VALUE   0x54231990
 

Typedefs

typedef struct tUSBHostAudioInstance tUSBHostAudioInstance
 
typedef void(* tUSBHostAudioCallback) (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
 
typedef struct tHIDInstance tHIDInstance
 
typedef struct tUSBHMSCInstance tUSBHMSCInstance
 
typedef void(* tUSBHMSCCallback) (tUSBHMSCInstance *psMSCInstance, uint32_t ui32Event, void *pvEventData)
 

Enumerations

enum  tHIDSubClassProtocol { eUSBHHIDClassNone = 0, eUSBHHIDClassKeyboard, eUSBHHIDClassMouse, eUSBHHIDClassVendor }
 

Functions

tUSBHostAudioInstanceUSBHostAudioOpen (uint32_t ui32Index, tUSBHostAudioCallback pfnCallback)
 
void USBHostAudioClose (tUSBHostAudioInstance *psAudioInstance)
 
uint32_t USBHostAudioVolumeGet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Interface, uint32_t ui32Channel)
 
uint32_t USBHostAudioVolumeMaxGet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Interface, uint32_t ui32Channel)
 
uint32_t USBHostAudioVolumeMinGet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Interface, uint32_t ui32Channel)
 
uint32_t USBHostAudioVolumeResGet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Interface, uint32_t ui32Channel)
 
void USBHostAudioVolumeSet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Interface, uint32_t ui32Channel, uint32_t ui32Value)
 
uint32_t USBHostAudioFormatGet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32SampleRate, uint32_t ui32Bits, uint32_t ui32Channels, uint32_t ui32Flags)
 
uint32_t USBHostAudioFormatSet (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32SampleRate, uint32_t ui32Bits, uint32_t ui32Channels, uint32_t ui32Flags)
 
int32_t USBHostAudioPlay (tUSBHostAudioInstance *psAudioInstance, void *pvBuffer, uint32_t ui32Size, tUSBHostAudioCallback pfnCallback)
 
int32_t USBHostAudioRecord (tUSBHostAudioInstance *psAudioInstance, void *pvBuffer, uint32_t ui32Size, tUSBHostAudioCallback pfnCallback)
 
uint32_t USBHostAudioLPMSleep (tUSBHostAudioInstance *psAudioInstance)
 
uint32_t USBHostAudioLPMStatus (tUSBHostAudioInstance *psAudioInstance)
 
tHIDInstanceUSBHHIDOpen (tHIDSubClassProtocol iDeviceType, tUSBCallback pfnCallback, void *pvCBData)
 
void USBHHIDClose (tHIDInstance *psHIDInstance)
 
uint32_t USBHHIDSetIdle (tHIDInstance *psHIDInstance, uint8_t ui8Duration, uint8_t ui8ReportID)
 
uint32_t USBHHIDGetReportDescriptor (tHIDInstance *psHIDInstance, uint8_t *pui8Buffer, uint32_t ui32Size)
 
uint32_t USBHHIDSetProtocol (tHIDInstance *psHIDInstance, uint32_t ui32BootProtocol)
 
uint32_t USBHHIDGetReport (tHIDInstance *psHIDInstance, uint32_t ui32Interface, uint8_t *pui8Data, uint32_t ui32Size)
 
uint32_t USBHHIDSetReport (tHIDInstance *psHIDInstance, uint32_t ui32Interface, uint8_t *pui8Data, uint32_t ui32Size)
 
uint32_t USBHHIDLPMSleep (tHIDInstance *psHIDInstance)
 
uint32_t USBHHIDLPMStatus (tHIDInstance *psHIDInstance)
 
void USBHHubMain (void)
 
void USBHHubEnumerationComplete (uint8_t ui8Hub, uint8_t ui8Port)
 
void USBHHubEnumerationError (uint8_t ui8Hub, uint8_t ui8Port)
 
tHubInstanceUSBHHubOpen (tUSBHHubCallback pfnCallback)
 
void USBHHubClose (tHubInstance *psHubInstance)
 
void USBHHubInit (void)
 
uint32_t USBHHubLPMSleep (tHubInstance *psHubInstance)
 
uint32_t USBHHubLPMStatus (tHubInstance *psHubInstance)
 
int32_t USBHMSCDriveReady (tUSBHMSCInstance *psMSCInstance)
 
tUSBHMSCInstanceUSBHMSCDriveOpen (uint32_t ui32Drive, tUSBHMSCCallback pfnCallback)
 
void USBHMSCDriveClose (tUSBHMSCInstance *psMSCInstance)
 
int32_t USBHMSCBlockRead (tUSBHMSCInstance *psMSCInstance, uint32_t ui32LBA, uint8_t *pui8Data, uint32_t ui32NumBlocks)
 
int32_t USBHMSCBlockWrite (tUSBHMSCInstance *psMSCInstance, uint32_t ui32LBA, uint8_t *pui8Data, uint32_t ui32NumBlocks)
 
uint32_t USBHMSCLPMSleep (tUSBHMSCInstance *psMSCInstance)
 
uint32_t USBHMSCLPMStatus (tUSBHMSCInstance *psMSCInstance)
 
uint32_t USBHSCSIInquiry (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint8_t *pui8Data, uint32_t *pui32Size)
 
uint32_t USBHSCSIReadCapacity (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint8_t *pui8Data, uint32_t *pui32Size)
 
uint32_t USBHSCSIReadCapacities (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint8_t *pui8Data, uint32_t *pui32Size)
 
uint32_t USBHSCSIModeSense6 (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint32_t ui32Flags, uint8_t *pui8Data, uint32_t *pui32Size)
 
uint32_t USBHSCSITestUnitReady (uint32_t ui32InPipe, uint32_t ui32OutPipe)
 
uint32_t USBHSCSIRequestSense (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint8_t *pui8Data, uint32_t *pui32Size)
 
uint32_t USBHSCSIRead10 (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint32_t ui32LBA, uint8_t *pui8Data, uint32_t *pui32Size, uint32_t ui32NumBlocks)
 
uint32_t USBHSCSIWrite10 (uint32_t ui32InPipe, uint32_t ui32OutPipe, uint32_t ui32LBA, uint8_t *pui8Data, uint32_t *pui32Size, uint32_t ui32NumBlocks)
 

Variables

const tUSBHostClassDriver g_sUSBHostAudioClassDriver
 
const tUSBHostClassDriver g_sUSBHIDClassDriver
 
const tUSBHostClassDriver g_sUSBHubClassDriver
 
const tUSBHostClassDriver g_sUSBHostMSCClassDriver
 

Detailed Description

Macro Definition Documentation

§ INTERFACE_NUM_M

#define INTERFACE_NUM_M   0x000000FF

§ INTERFACE_ALTSETTING_M

#define INTERFACE_ALTSETTING_M   0x0000FF00

§ INTERFACE_ALTSETTING_S

#define INTERFACE_ALTSETTING_S   8

§ INVALID_INTERFACE

#define INVALID_INTERFACE   0xffffffff

§ AUDIO_FLAG_OUT_ACTIVE

#define AUDIO_FLAG_OUT_ACTIVE   1

Referenced by USBHostAudioPlay().

§ AUDIO_FLAG_IN_ACTIVE

#define AUDIO_FLAG_IN_ACTIVE   2

Referenced by USBHostAudioRecord().

§ USBH_AUDIO_EVENT_OPEN

#define USBH_AUDIO_EVENT_OPEN   (USBH_AUDIO_EVENT_BASE + 0)

This USB host audio event indicates that the device is connected and ready to send or receive buffers. The pvBuffer and ui32Param values are not used in this event.

§ USBH_AUDIO_EVENT_CLOSE

#define USBH_AUDIO_EVENT_CLOSE   (USBH_AUDIO_EVENT_BASE + 1)

This USB host audio event indicates that the previously connected device has been disconnected. The pvBuffer and ui32Param values are not used in this event.

§ USBH_AUDIO_FORMAT_IN

#define USBH_AUDIO_FORMAT_IN   0x00000001

§ USBH_AUDIO_FORMAT_OUT

#define USBH_AUDIO_FORMAT_OUT   0x00000000

§ MAX_HID_DEVICES

#define MAX_HID_DEVICES   MAX_USB_DEVICES

Referenced by USBHHIDOpen().

§ USBH_EVENT_HID_SETRPT

#define USBH_EVENT_HID_SETRPT   USBH_HID_EVENT_BASE + 0

§ USBH_EVENT_HID_REPORT

#define USBH_EVENT_HID_REPORT   USBH_HID_EVENT_BASE + 1

§ USBH_EVENT_HID_KB_PRESS

#define USBH_EVENT_HID_KB_PRESS   USBH_HID_EVENT_BASE + 16

The HID keyboard detected a key being pressed.

§ USBH_EVENT_HID_KB_REL

#define USBH_EVENT_HID_KB_REL   USBH_HID_EVENT_BASE + 17

The HID keyboard detected a key being released.

§ USBH_EVENT_HID_KB_MOD

#define USBH_EVENT_HID_KB_MOD   USBH_HID_EVENT_BASE + 18

The HID keyboard detected one of the keyboard modifiers being pressed.

§ USBH_EVENT_HID_MS_PRESS

#define USBH_EVENT_HID_MS_PRESS   USBH_HID_EVENT_BASE + 32

A button was pressed on a HID mouse.

§ USBH_EVENT_HID_MS_REL

#define USBH_EVENT_HID_MS_REL   USBH_HID_EVENT_BASE + 33

A button was released on a HID mouse.

§ USBH_EVENT_HID_MS_X

#define USBH_EVENT_HID_MS_X   USBH_HID_EVENT_BASE + 34

The HID mouse detected movement in the X direction.

§ USBH_EVENT_HID_MS_Y

#define USBH_EVENT_HID_MS_Y   USBH_HID_EVENT_BASE + 35

The HID mouse detected movement in the Y direction.

§ USBLIB_HUB_ACTIVE

#define USBLIB_HUB_ACTIVE   0x00000001

Referenced by USBHHubMain().

§ USBLIB_HUB_HS

#define USBLIB_HUB_HS   0x00000002

§ USBLIB_HUB_MULTI_TT

#define USBLIB_HUB_MULTI_TT   0x00000004

§ MSC_EVENT_OPEN

#define MSC_EVENT_OPEN   1

§ MSC_EVENT_CLOSE

#define MSC_EVENT_CLOSE   2

§ CBW_TAG_VALUE

#define CBW_TAG_VALUE   0x54231990

Typedef Documentation

§ tUSBHostAudioInstance

typedef struct tUSBHostAudioInstance tUSBHostAudioInstance

§ tUSBHostAudioCallback

typedef void(* tUSBHostAudioCallback) (tUSBHostAudioInstance *psAudioInstance, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)

§ tHIDInstance

typedef struct tHIDInstance tHIDInstance

§ tUSBHMSCInstance

typedef struct tUSBHMSCInstance tUSBHMSCInstance

§ tUSBHMSCCallback

typedef void(* tUSBHMSCCallback) (tUSBHMSCInstance *psMSCInstance, uint32_t ui32Event, void *pvEventData)

Enumeration Type Documentation

§ tHIDSubClassProtocol

The following values are used to register callbacks to the USB HOST HID device class layer.

Enumerator
eUSBHHIDClassNone 

No device should be used. This value should not be used by applications.

eUSBHHIDClassKeyboard 

This is a keyboard device.

eUSBHHIDClassMouse 

This is a mouse device.

eUSBHHIDClassVendor 

This is a vendor specific device.

Function Documentation

§ USBHostAudioOpen()

tUSBHostAudioInstance * USBHostAudioOpen ( uint32_t  ui32Index,
tUSBHostAudioCallback  pfnCallback 
)

This function should be called before any devices are present to enable the host audio class driver.

Parameters
ui32Indexis the audio device to open (currently only 0 is supported).
pfnCallbackis the driver call back for host audio events.

This function is called to open an instance of a host audio device and should provide a valid callback function for host audio events in the pfnCallback parameter. This function must be called before the USB host code can successfully enumerate an audio device.

Returns
This function returns the driver instance to use for the other host audio functions. If there is no instance available at the time of this call, this function returns zero.

§ USBHostAudioClose()

void USBHostAudioClose ( tUSBHostAudioInstance psAudioInstance)

This function should be called to release an audio device instance.

Parameters
psAudioInstanceis the device instance that is to be released.

This function is called when a host audio device needs to be released. This could be in preparation for shutdown or a switch to USB device mode, for example. Following this call, the audio device is available and can be opened again using a call to USBHostAudioOpen(). After calling this function, the host audio driver will no longer provide any callbacks or accept calls to other audio driver APIs.

Returns
None.

§ USBHostAudioVolumeGet()

uint32_t USBHostAudioVolumeGet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32Interface,
uint32_t  ui32Channel 
)

This function is used to get the current volume setting for a given audio device.

Parameters
psAudioInstanceis an instance of the USB audio device.
ui32Interfaceis the interface number to use to query the current volume setting.
ui32Channelis the 0 based channel number to query.

The function is used to retrieve the current volume setting for an audio device on the channel specified by ui32Channel. The ui32Interface is ignored for now and should be set to 0 to access the default audio control interface. The ui32Channel value starts with 0 which is the master audio volume control interface. The remaining ui32Channel values provide access to various other audio channels, with 1 and 2 being left and right audio channels.

Note
On devices that do not support volume control interfaces, this call returns 0, indicating a 0db setting.
Returns
Returns the current volume setting for the requested interface.

§ USBHostAudioVolumeMaxGet()

uint32_t USBHostAudioVolumeMaxGet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32Interface,
uint32_t  ui32Channel 
)

This function is used to get the maximum volume setting for a given audio device.

Parameters
psAudioInstanceis an instance of the USB audio device.
ui32Interfaceis the interface number to use to query the maximum volume control value.
ui32Channelis the 0 based channel number to query.

The function is used to retrieve the maximum volume setting for an audio device on the channel specified by ui32Channel. The ui32Interface is ignored for now and should be set to 0 to access the default audio control interface. The ui32Channel value starts with 0 which is the master audio volume control interface. The remaining ui32Channel values provide access to various other audio channels, with 1 and 2 being left and right audio channels.

Note
On devices that do not support volume control interfaces, this call returns 0, indicating a 0db setting.
Returns
Returns the maximum volume setting for the requested interface.

§ USBHostAudioVolumeMinGet()

uint32_t USBHostAudioVolumeMinGet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32Interface,
uint32_t  ui32Channel 
)

This function is used to get the minimum volume setting for a given audio device.

Parameters
psAudioInstanceis an instance of the USB audio device.
ui32Interfaceis the interface number to use to query the minimum volume control value.
ui32Channelis the 0 based channel number to query.

The function is used to retrieve the minimum volume setting for an audio device on the channel specified by ui32Channel. The ui32Interface is ignored for now and should be set to 0 to access the default audio control interface. The ui32Channel value starts with 0 which is the master audio volume control interface. The remaining ui32Channel values provide access to various other audio channels, with 1 and 2 being left and right audio channels.

Note
On devices that do not support volume control interfaces, this call returns 0, indicating a 0db setting.
Returns
Returns the minimum volume setting for the requested interface.

§ USBHostAudioVolumeResGet()

uint32_t USBHostAudioVolumeResGet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32Interface,
uint32_t  ui32Channel 
)

This function is used to get the volume control resolution for a given audio device.

Parameters
psAudioInstanceis an instance of the USB audio device.
ui32Interfaceis the interface number to use to query the resolution for the volume control.
ui32Channelis the 0 based channel number to query.

The function is used to retrieve the volume control resolution for an audio device on the channel specified by ui32Channel. The ui32Interface is ignored for now and should be set to 0 to access the default audio control interface. The ui32Channel value starts with 0 which is the master audio volume control interface. The remaining ui32Channel values provide access to various other audio channels, with 1 and 2 being left and right audio channels.

Note
On devices that do not support volume control interfaces, this call returns 0, indicating a 0db setting.
Returns
Returns the volume control resolution for the requested interface.

§ USBHostAudioVolumeSet()

void USBHostAudioVolumeSet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32Interface,
uint32_t  ui32Channel,
uint32_t  ui32Value 
)

This function is used to set the current volume setting for a given audio device.

Parameters
psAudioInstanceis an instance of the USB audio device.
ui32Interfaceis the interface number to use to set the current volume setting.
ui32Channelis the 0 based channel number to query.
ui32Valueis the value to write to the USB audio device.

The function is used to set the current volume setting for an audio device on the channel specified by ui32Channel. The ui32Interface is ignored for now and should be set to 0 to access the default audio control interface. The ui32Channel value starts with 0 which is the master audio volume control interface. The remaining ui32Channel values provide access to various other audio channels, with 1 and 2 being left and right audio channels.

Note
On devices that do not support volume control interfaces, this call returns 0, indicating a 0db setting.
Returns
None.

References USB_AC_SET_CUR, USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and VOLUME_CONTROL.

§ USBHostAudioFormatGet()

uint32_t USBHostAudioFormatGet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32SampleRate,
uint32_t  ui32Bits,
uint32_t  ui32Channels,
uint32_t  ui32Flags 
)

This function is called to determine if an audio format is supported by the connected USB Audio device.

Parameters
psAudioInstanceis the device instance for this call.
ui32SampleRateis the sample rate of the audio stream.
ui32Bitsis the number of bits per sample in the audio stream.
ui32Channelsis the number of channels in the audio stream.
ui32Flagsis a set of flags to determine what type of interface to retrieve.

This function is called when an application needs to determine which audio formats are supported by a USB audio device that has been connected. The psAudioInstance value that is used with this call is the value that was returned from the USBHostAudioOpen() function. This call checks the USB audio device to determine if it can support the values provided in the ui32SampleRate, ui32Bits, and ui32Channels values. The ui32Flags currently only supports either the USBH_AUDIO_FORMAT_IN or USBH_AUDIO_FORMAT_OUT values that indicates if a request is for an audio input and an audio output. If the format is supported this function returns zero, and this function returns a non-zero value if the format is not supported. This function does not set the current output or input format.

Returns
A value of zero indicates the supplied format is supported and a non-zero value indicates that the format is not supported.

§ USBHostAudioFormatSet()

uint32_t USBHostAudioFormatSet ( tUSBHostAudioInstance psAudioInstance,
uint32_t  ui32SampleRate,
uint32_t  ui32Bits,
uint32_t  ui32Channels,
uint32_t  ui32Flags 
)

This function is called to set the current sample rate on an audio interface.

Parameters
psAudioInstancespecifies the device instance for this call.
ui32SampleRateis the sample rate in Hz.
ui32Bitsis the number of bits per sample.
ui32Channelsis then number of audio channels.
ui32Flagsis a set of flags that determine the access type.

This function is called when to set the current audio output or input format for a USB audio device. The psAudioInstance value that is used with this call is the value that was returned from the USBHostAudioOpen() function. The application can use this call to insure that the audio format is supported and set the format at the same time. If the application is just checking for supported rates, then it should call the USBHostAudioFormatGet().

Note
This function must be called before attempting to send or receive audio with the USBHostAudioPlay() or USBHostAudioRecord() functions.
Returns
A non-zero value indicates the supplied format is not supported and a zero value indicates that the format was supported and has been configured.

§ USBHostAudioPlay()

int32_t USBHostAudioPlay ( tUSBHostAudioInstance psAudioInstance,
void *  pvBuffer,
uint32_t  ui32Size,
tUSBHostAudioCallback  pfnCallback 
)

This function is called to send an audio buffer to the USB audio device.

Parameters
psAudioInstancespecifies the device instance for this call.
pvBufferis the audio buffer to send.
ui32Sizeis the size of the buffer in bytes.
pfnCallbackis a pointer to a callback function that is called when the buffer can be used again.

This function is called when an application needs to schedule a new buffer for output to the USB audio device. Since this call schedules the transfer and returns immediately, the application should provide a pfnCallback function to be notified when the buffer can be used again by the application. The pfnCallback function provided is called with the pvBuffer parameter set to the pvBuffer provided by this call, the ui32Param can be ignored and the ui32Event parameter is USB_EVENT_TX_COMPLETE.

Returns
This function returns the number of bytes that were scheduled to be sent. If this function returns zero then there was no USB audio device present or the request could not be satisfied at this time.

References AUDIO_FLAG_OUT_ACTIVE, USBHCDPipeSchedule(), and USBHCDSetInterface().

§ USBHostAudioRecord()

int32_t USBHostAudioRecord ( tUSBHostAudioInstance psAudioInstance,
void *  pvBuffer,
uint32_t  ui32Size,
tUSBHostAudioCallback  pfnCallback 
)

This function is called to provide an audio buffer to the USB audio device for audio input.

Parameters
psAudioInstancespecifies the device instance for this call.
pvBufferis the audio buffer to send.
ui32Sizeis the size of the buffer in bytes.
pfnCallbackis a pointer to a callback function that is called when the buffer has been filled.

This function is called when an application needs to schedule a new buffer for input from the USB audio device. Since this call schedules the transfer and returns immediately, the application should provide a pfnCallback function to be notified when the buffer has been filled with audio data. When the pfnCallback function is called, the pvBuffer parameter is set to pvBuffer provided in this call, the ui32Param is the number of valid bytes in the pvBuffer and the ui32Event is set to USB_EVENT_RX_AVAILABLE.

Returns
This function returns the number of bytes that were scheduled to be sent. If this function returns zero then there was no USB audio device present or the device does not support audio input.

References AUDIO_FLAG_IN_ACTIVE, USBHCDPipeSchedule(), and USBHCDSetInterface().

§ USBHostAudioLPMSleep()

uint32_t USBHostAudioLPMSleep ( tUSBHostAudioInstance psAudioInstance)

This function forwards an LPM request for a device to enter L1 sleep state.

Parameters
psAudioInstanceis the audio device instance that was returned from the call to USBHostAudioOpen().

This function forwards a request from an application to the audio device class to request that a device 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 this or another device, then this function returns USBHCD_LPM_PENDING. If the LPM request was scheduled to be sent the function returns USBHCD_LPM_AVAIL. The caller should check the USBHCDLPMStatus() function to determine if the request completed successfully or if there was an error.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - The transition to L1 state is scheduled to be sent.
  • USBHCD_LPM_PENDING - There is already an LPM request pending.

References USBHCDLPMSleep().

§ USBHostAudioLPMStatus()

uint32_t USBHostAudioLPMStatus ( tUSBHostAudioInstance psAudioInstance)

This function returns the current status of an LPM request.

Parameters
psAudioInstanceis the audio device instance that was returned from the call to USBHostAudioOpen().

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.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - There are no pending LPM requests on this specific device or the last request completed successfully.
  • USBHCD_LPM_ERROR - The last LPM request for this device did not complete successfully.
  • USBHCD_LPM_PENDING - The last LPM request has not completed.

References USBHCDLPMStatus().

§ USBHHIDOpen()

tHIDInstance* USBHHIDOpen ( tHIDSubClassProtocol  iDeviceType,
tUSBCallback  pfnCallback,
void *  pvCBData 
)

This function is used to open an instance of a HID device.

Parameters
iDeviceTypeis the type of device that should be loaded for this instance of the HID device.
pfnCallbackis the function that will be called whenever changes are detected for this device.
pvCBDatais the data that will be returned in when the pfnCallback function is called.

This function creates an instance of an specific type of HID device. The iDeviceType parameter is one subclass/protocol values of the types specified in enumerated types tHIDSubClassProtocol. Only devices that enumerate with this type will be called back via the pfnCallback function. The pfnCallback parameter is the callback function for any events that occur for this device type. The pfnCallback function must point to a valid function of type tUSBCallback for this call to complete successfully. To release this device instance the caller of USBHHIDOpen() should call USBHHIDClose() and pass in the value returned from the USBHHIDOpen() call.

Returns
This function returns and instance value that should be used with any other APIs that require an instance value. If a value of 0 is returned then the device instance could not be created.

References eUSBHHIDClassNone, tHIDInstance::iDeviceType, MAX_HID_DEVICES, tHIDInstance::pfnCallback, and tHIDInstance::pvCBData.

Referenced by USBHKeyboardOpen(), and USBHMouseOpen().

§ USBHHIDClose()

void USBHHIDClose ( tHIDInstance psHIDInstance)

This function is used to release an instance of a HID device.

Parameters
psHIDInstanceis the instance value for a HID device to release.

This function releases an instance of a HID device that was created by a call to USBHHIDOpen(). This call is required to allow other HID devices to be enumerated after another HID device has been disconnected. The psHIDInstance parameter should hold the value that was returned from the previous call to USBHHIDOpen().

Returns
None.

References eUSBHHIDClassNone, tHIDInstance::iDeviceType, and tHIDInstance::pfnCallback.

Referenced by USBHKeyboardClose(), and USBHMouseClose().

§ USBHHIDSetIdle()

uint32_t USBHHIDSetIdle ( tHIDInstance psHIDInstance,
uint8_t  ui8Duration,
uint8_t  ui8ReportID 
)

This function is used to set the idle timeout for a HID device.

Parameters
psHIDInstanceis the value that was returned from the call to USBHHIDOpen().
ui8Durationis the duration of the timeout in milliseconds.
ui8ReportIDis the report identifier to set the timeout on.

This function will send the Set Idle command to a HID device to set the idle timeout for a given report. The length of the timeout is specified by the ui8Duration parameter and the report the timeout for is in the ui8ReportID value.

Returns
Always returns 0.

References tHIDInstance::psDevice, USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_SET_IDLE.

Referenced by USBHKeyboardInit(), USBHKeyboardPollRateSet(), and USBHMouseInit().

§ USBHHIDGetReportDescriptor()

uint32_t USBHHIDGetReportDescriptor ( tHIDInstance psHIDInstance,
uint8_t *  pui8Buffer,
uint32_t  ui32Size 
)

This function can be used to retrieve the report descriptor for a given device instance.

Parameters
psHIDInstanceis the value that was returned from the call to USBHHIDOpen().
pui8Bufferis the memory buffer to use to store the report descriptor.
ui32Sizeis the size in bytes of the buffer pointed to by pui8Buffer.

This function is used to return a report descriptor from a HID device instance so that it can determine how to interpret reports that are returned from the device indicated by the psHIDInstance parameter. This call is blocking and will return the number of bytes read into the pui8Buffer.

Returns
Returns the number of bytes read into the pui8Buffer.

References tHIDInstance::psDevice, tUSBHostDevice::sDeviceDescriptor, USB_HID_DTYPE_REPORT, USB_RTYPE_DIR_IN, USB_RTYPE_INTERFACE, USB_RTYPE_STANDARD, USBHCDControlTransfer(), and USBREQ_GET_DESCRIPTOR.

Referenced by USBHKeyboardInit(), and USBHMouseInit().

§ USBHHIDSetProtocol()

uint32_t USBHHIDSetProtocol ( tHIDInstance psHIDInstance,
uint32_t  ui32BootProtocol 
)

This function is used to set or clear the boot protocol state of a device.

Parameters
psHIDInstanceis the value that was returned from the call to USBHHIDOpen().
ui32BootProtocolis either zero or non-zero to indicate which protocol to use for the device.

A USB host device can use this function to set the protocol for a connected HID device. This is commonly used to set keyboards and mice into their simplified boot protocol modes to fix the report structure to a know state.

Returns
This function returns 0.

References tHIDInstance::psDevice, tUSBHostDevice::sDeviceDescriptor, USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_SET_PROTOCOL.

Referenced by USBHKeyboardInit(), and USBHMouseInit().

§ USBHHIDGetReport()

uint32_t USBHHIDGetReport ( tHIDInstance psHIDInstance,
uint32_t  ui32Interface,
uint8_t *  pui8Data,
uint32_t  ui32Size 
)

This function is used to retrieve a report from a HID device.

Parameters
psHIDInstanceis the value that was returned from the call to USBHHIDOpen().
ui32Interfaceis the interface to retrieve the report from.
pui8Datais the memory buffer to use to store the report.
ui32Sizeis the size in bytes of the buffer pointed to by pui8Buffer.

This function is used to retrieve a report from a USB pipe. It is usually called when the USB HID layer has detected a new data available in a USB pipe. The USB HID host device code will receive a USB_EVENT_RX_AVAILABLE event when data is available, allowing the callback function to retrieve the data.

Returns
Returns the number of bytes read from report.

References tHIDInstance::ui32IntInPipe, and USBHCDPipeReadNonBlocking().

§ USBHHIDSetReport()

uint32_t USBHHIDSetReport ( tHIDInstance psHIDInstance,
uint32_t  ui32Interface,
uint8_t *  pui8Data,
uint32_t  ui32Size 
)

This function is used to send a report to a HID device.

Parameters
psHIDInstanceis the value that was returned from the call to USBHHIDOpen().
ui32Interfaceis the interface to send the report to.
pui8Datais the memory buffer to use to store the report.
ui32Sizeis the size in bytes of the buffer pointed to by pui8Buffer.

This function is used to send a report to a USB HID device. It can be only be called from outside the callback context as this function will not return from the call until the data has been sent successfully.

Returns
Returns the number of bytes sent to the device.

References tHIDInstance::psDevice, tUSBHostDevice::sDeviceDescriptor, USB_HID_REPORT_OUTPUT, USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_SET_REPORT.

Referenced by USBHKeyboardInit(), and USBHKeyboardModifierSet().

§ USBHHIDLPMSleep()

uint32_t USBHHIDLPMSleep ( tHIDInstance psHIDInstance)

This function forwards an LPM request for a device to enter L1 sleep state.

Parameters
psHIDInstanceis the HID instance that was returned from the call to USBHHIDOpen().

This function forwards a request from a HID device class to the host controller to request that a device 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 this or another device, then this function returns USBHCD_LPM_PENDING. If the LPM request was scheduled to be sent the function returns USBHCD_LPM_AVAIL. The caller should check the USBHCDLPMStatus() function to determine if the request completed successfully or if there was an error.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - The transition to L1 state is scheduled to be sent.
  • USBHCD_LPM_PENDING - There is already an LPM request pending.

References tHIDInstance::psDevice, and USBHCDLPMSleep().

Referenced by USBHKeyboardLPMSleep(), and USBHMouseLPMSleep().

§ USBHHIDLPMStatus()

uint32_t USBHHIDLPMStatus ( tHIDInstance psHIDInstance)

This function returns the current status of an LPM request.

Parameters
psHIDInstanceis the HID instance that was returned from the call to USBHHIDOpen().

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.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - There are no pending LPM requests on this specific device or the last request completed successfully.
  • USBHCD_LPM_ERROR - The last LPM request for this device did not complete successfully.
  • USBHCD_LPM_PENDING - The last LPM request has not completed.

References tHIDInstance::psDevice, and USBHCDLPMStatus().

Referenced by USBHKeyboardLPMStatus(), and USBHMouseLPMStatus().

§ USBHHubMain()

void USBHHubMain ( void  )

§ USBHHubEnumerationComplete()

void USBHHubEnumerationComplete ( uint8_t  ui8Hub,
uint8_t  ui8Port 
)

Informs the hub class driver that a downstream device has been enumerated.

Parameters
ui8Hubis the address of the hub to which the downstream device is attached.
ui8Portis the port on the hub to which the downstream device is attached.

This function is called by the host controller driver to inform the hub class driver that a downstream device has been enumerated successfully. The hub driver then moves on and continues enumeration of any other newly connected devices.

Returns
None.

References DEBUG_OUTPUT, and ePortEnumerated.

§ USBHHubEnumerationError()

void USBHHubEnumerationError ( uint8_t  ui8Hub,
uint8_t  ui8Port 
)

Informs the hub class driver that a downstream device failed to enumerate.

Parameters
ui8Hubis the address of the hub to which the downstream device is attached.
ui8Portis the port on the hub to which the downstream device is attached.

This function is called by the host controller driver to inform the hub class driver that an attempt to enumerate a downstream device has failed. The hub driver then cleans up and continues enumeration of any other newly connected devices.

Returns
None.

References DEBUG_OUTPUT, and ePortError.

§ USBHHubOpen()

tHubInstance* USBHHubOpen ( tUSBHHubCallback  pfnCallback)

This function is used to enable the host hub class driver before any devices are present.

Parameters
pfnCallbackis the driver call back for host hub events.

This function is called to open an instance of a host hub device and provides a valid callback function for host hub events in the pfnCallback parameter. This function must be called before the USB host code can successfully enumerate a hub device or any devices attached to the hub. The pui8HubPool is memory provided to the hub class to manage the devices that are connected to the hub. The ui32PoolSize is the number of bytes and should be at least 32 bytes per device including the hub device itself. A simple formula for providing memory to the hub class is MAX_USB_DEVICES * 32 bytes of data to allow for proper enumeration of connected devices. The value for MAX_USB_DEVICES is defined in the usblib.h file and controls the number of devices supported by the USB library. The ui32NumHubs parameter defaults to one and only one buffer of size tHubInstance is required to be passed in the psHubInstance parameter.

Note
Changing the value of MAX_USB_DEVICES requires a rebuild of the USB library to have an effect on the library.
Returns
This function returns the driver instance to use for the other host hub functions. If there is no instance available at the time of this call, this function returns zero.

References DEBUG_OUTPUT.

§ USBHHubClose()

void USBHHubClose ( tHubInstance psHubInstance)

This function is used to release a hub device instance.

Parameters
psHubInstanceis the hub device instance that is to be released.

This function is called when an instance of the hub device must be released. This function is typically made in preparation for shutdown or a switch to function as a USB device when in OTG mode. Following this call, the hub device is no longer available, but it can be opened again using a call to USBHHubOpen(). After calling USBHHubClose(), the host hub driver no longer provides any callbacks or accepts calls to other hub driver APIs.

Returns
None.

References DEBUG_OUTPUT.

§ USBHHubInit()

void USBHHubInit ( void  )

§ USBHHubLPMSleep()

uint32_t USBHHubLPMSleep ( tHubInstance psHubInstance)

This function forwards an LPM request for a device to enter L1 sleep state.

Parameters
psHubInstanceis the hub device instance that was returned from the call to USBHHubOpen().

This function forwards a request from an application to the hub device class to request that a device 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 this or another device, then this function returns USBHCD_LPM_PENDING. If the LPM request was scheduled to be sent the function returns USBHCD_LPM_AVAIL. The caller should check the USBHCDLPMStatus() function to determine if the request completed successfully or if there was an error.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - The transition to L1 state is scheduled to be sent.
  • USBHCD_LPM_PENDING - There is already an LPM request pending.

References USBHCDLPMSleep().

§ USBHHubLPMStatus()

uint32_t USBHHubLPMStatus ( tHubInstance psHubInstance)

This function returns the current status of an LPM request.

Parameters
psHubInstanceis the hub device instance that was returned from the call to USBHHubOpen().

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.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - There are no pending LPM requests on this specific device or the last request completed successfully.
  • USBHCD_LPM_ERROR - The last LPM request for this device did not complete successfully.
  • USBHCD_LPM_PENDING - The last LPM request has not completed.

References USBHCDLPMStatus().

§ USBHMSCDriveReady()

int32_t USBHMSCDriveReady ( tUSBHMSCInstance psMSCInstance)

This function checks if a drive is ready to be accessed.

Parameters
psMSCInstanceis the device instance to use for this read.

This function checks if the current device is ready to be accessed. It uses the psMSCInstance parameter to determine which device to check and returns zero when the device is ready. Any non-zero return code indicates that the device was not ready.

Returns
This function returns zero if the device is ready and it returns a other value if the device is not ready or if an error occurred.

References SCSI_INQUIRY_DATA_SZ.

§ USBHMSCDriveOpen()

tUSBHMSCInstance * USBHMSCDriveOpen ( uint32_t  ui32Drive,
tUSBHMSCCallback  pfnCallback 
)

This function should be called before any devices are present to enable the mass storage device class driver.

Parameters
ui32Driveis the drive number to open.
pfnCallbackis the driver callback for any mass storage events.

This function is called to open an instance of a mass storage device. It should be called before any devices are connected to allow for proper notification of drive connection and disconnection. The ui32Drive parameter is a zero based index of the drives present in the system. There are a constant number of drives, and this number should only be greater than 0 if there is a USB hub present in the system. The application should also provide the pfnCallback to be notified of mass storage related events like device enumeration and device removal.

Returns
This function will return the driver instance to use for the other mass storage functions. If there is no driver available at the time of this call, this function will return zero.

§ USBHMSCDriveClose()

void USBHMSCDriveClose ( tUSBHMSCInstance psMSCInstance)

This function should be called to release a drive instance.

Parameters
psMSCInstanceis the device instance that is to be released.

This function is called when an MSC drive is to be released in preparation for shutdown or a switch to USB device mode, for example. Following this call, the drive is available for other clients who may open it again using a call to USBHMSCDriveOpen().

Returns
None.

§ USBHMSCBlockRead()

int32_t USBHMSCBlockRead ( tUSBHMSCInstance psMSCInstance,
uint32_t  ui32LBA,
uint8_t *  pui8Data,
uint32_t  ui32NumBlocks 
)

This function performs a block read to an MSC device.

Parameters
psMSCInstanceis the device instance to use for this read.
ui32LBAis the logical block address to read on the device.
pui8Datais a pointer to the returned data buffer.
ui32NumBlocksis the number of blocks to read from the device.

This function will perform a block sized read from the device associated with the psMSCInstance parameter. The ui32LBA parameter specifies the logical block address to read on the device. This function will only perform ui32NumBlocks block sized reads. In most cases this is a read of 512 bytes of data. The *pui8Data buffer should be at least ui32NumBlocks * 512 bytes in size.

Returns
The function returns zero for success and any negative value indicates a failure.

References SCSI_CMD_STATUS_PASS, and USBHSCSIRead10().

§ USBHMSCBlockWrite()

int32_t USBHMSCBlockWrite ( tUSBHMSCInstance psMSCInstance,
uint32_t  ui32LBA,
uint8_t *  pui8Data,
uint32_t  ui32NumBlocks 
)

This function performs a block write to an MSC device.

Parameters
psMSCInstanceis the device instance to use for this write.
ui32LBAis the logical block address to write on the device.
pui8Datais a pointer to the data to write out.
ui32NumBlocksis the number of blocks to write to the device.

This function will perform a block sized write to the device associated with the psMSCInstance parameter. The ui32LBA parameter specifies the logical block address to write on the device. This function will only perform ui32NumBlocks block sized writes. In most cases this is a write of 512 bytes of data. The *pui8Data buffer should contain at least ui32NumBlocks * 512 bytes in size to prevent unwanted data being written to the device.

Returns
The function returns zero for success and any negative value indicates a failure.

References SCSI_CMD_STATUS_PASS, and USBHSCSIWrite10().

§ USBHMSCLPMSleep()

uint32_t USBHMSCLPMSleep ( tUSBHMSCInstance psMSCInstance)

This function forwards an LPM request for a device to enter L1 sleep state.

Parameters
psMSCInstanceis the host mass storage class instance that was returned from the call to USBHMSCDriveOpen().

This function forwards a request from an application to the mass storage device class to request that a device 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 this or another device, then this function returns USBHCD_LPM_PENDING. If the LPM request was scheduled to be sent the function returns USBHCD_LPM_AVAIL. The caller should check the USBHCDLPMStatus() function to determine if the request completed successfully or if there was an error.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - The transition to L1 state is scheduled to be sent.
  • USBHCD_LPM_PENDING - There is already an LPM request pending.

References USBHCDLPMSleep().

§ USBHMSCLPMStatus()

uint32_t USBHMSCLPMStatus ( tUSBHMSCInstance psMSCInstance)

This function returns the current status of an LPM request.

Parameters
psMSCInstanceis the host mass storage class instance that was returned from the call to USBHMSCDriveOpen().

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.

Returns
This function returns the following values:
  • USBHCD_LPM_AVAIL - There are no pending LPM requests on this specific device or the last request completed successfully.
  • USBHCD_LPM_ERROR - The last LPM request for this device did not complete successfully.
  • USBHCD_LPM_PENDING - The last LPM request has not completed.

References USBHCDLPMStatus().

§ USBHSCSIInquiry()

uint32_t USBHSCSIInquiry ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint8_t *  pui8Data,
uint32_t *  pui32Size 
)

This will issue the SCSI inquiry command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
pui8Datais the data buffer to return the results into.
pui32Sizeis the size of buffer that was passed in on entry and the number of bytes returned.

This function should be used to issue a SCSI Inquiry command to a mass storage device. To allow for multiple devices, the ui32InPipe and ui32OutPipe parameters indicate which USB pipes to use for this call.

Note
The pui8Data buffer pointer should have at least SCSI_INQUIRY_DATA_SZ bytes of data or this function will overflow the buffer.
Returns
This function returns the SCSI status from the command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_IN, SCSI_INQUIRY_CMD, and SCSI_INQUIRY_DATA_SZ.

§ USBHSCSIReadCapacity()

uint32_t USBHSCSIReadCapacity ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint8_t *  pui8Data,
uint32_t *  pui32Size 
)

This will issue the SCSI read capacity command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
pui8Datais the data buffer to return the results into.
pui32Sizeis the size of buffer that was passed in on entry and the number of bytes returned.

This function should be used to issue a SCSI Read Capacity command to a mass storage device that is connected. To allow for multiple devices, the ui32InPipe and ui32OutPipe parameters indicate which USB pipes to use for this call.

Note
The pui8Data buffer pointer should have at least SCSI_READ_CAPACITY_SZ bytes of data or this function will overflow the buffer.
Returns
This function returns the SCSI status from the command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_IN, SCSI_READ_CAPACITY, and SCSI_READ_CAPACITY_SZ.

§ USBHSCSIReadCapacities()

uint32_t USBHSCSIReadCapacities ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint8_t *  pui8Data,
uint32_t *  pui32Size 
)

This will issue the SCSI read capacities command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
pui8Datais the data buffer to return the results into.
pui32Sizeis the size of buffer that was passed in on entry and the number of bytes returned.

This function should be used to issue a SCSI Read Capacities command to a mass storage device that is connected. To allow for multiple devices, the ui32InPipe and ui32OutPipe parameters indicate which USB pipes to use for this call.

Returns
This function returns the SCSI status from the command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_IN, and SCSI_READ_CAPACITIES.

§ USBHSCSIModeSense6()

uint32_t USBHSCSIModeSense6 ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint32_t  ui32Flags,
uint8_t *  pui8Data,
uint32_t *  pui32Size 
)

This will issue the SCSI Mode Sense(6) command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
ui32Flagsis a combination of flags defining the exact query that is to be made.
pui8Datais the data buffer to return the results into.
pui32Sizeis the size of the buffer on entry and number of bytes read on exit.

This function should be used to issue a SCSI Mode Sense(6) command to a mass storage device. To allow for multiple devices,the ui32InPipe and ui32OutPipe parameters indicate which USB pipes to use for this call. The call will return at most the number of bytes in the pui32Size parameter, however it can return less and change the pui32Size parameter to the number of valid bytes in the *pui32Size buffer.

The ui32Flags parameter is a combination of the following three sets of definitions:

One of the following values must be specified:

  • SCSI_MS_PC_CURRENT request for current settings.
  • SCSI_MS_PC_CHANGEABLE request for changeable settings.
  • SCSI_MS_PC_DEFAULT request for default settings.
  • SCSI_MS_PC_SAVED request for the saved values.

One of these following values must also be specified to determine the page code for the request:

  • SCSI_MS_PC_VENDOR is the vendor specific page code.
  • SCSI_MS_PC_DISCO is the disconnect/reconnect page code.
  • SCSI_MS_PC_CONTROL is the control page code.
  • SCSI_MS_PC_LUN is the protocol specific LUN page code.
  • SCSI_MS_PC_PORT is the protocol specific port page code.
  • SCSI_MS_PC_POWER is the power condition page code.
  • SCSI_MS_PC_INFORM is the informational exceptions page code.
  • SCSI_MS_PC_ALL will request all pages codes supported by the device.

The last value is optional and supports the following global flag:

  • SCSI_MS_DBD disables returning block descriptors.

Example: Request for all current settings.

//! SCSIModeSense6(ui32InPipe, ui32OutPipe,
//!                SCSI_MS_PC_CURRENT | SCSI_MS_PC_ALL,
//!                pui8Data, pui32Size);
//! 
\return This function returns the SCSI status from the command.  The value
will be either \b SCSI_CMD_STATUS_PASS or \b SCSI_CMD_STATUS_FAIL.  

References CBWFLAGS_DIR_IN, and SCSI_MODE_SENSE_6.

§ USBHSCSITestUnitReady()

uint32_t USBHSCSITestUnitReady ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe 
)

This function issues a SCSI Test Unit Ready command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.

This function is used to issue a SCSI Test Unit Ready command to a device. This call will simply return the results of issuing this command.

Returns
This function returns the results of the SCSI Test Unit Ready command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_IN, and SCSI_TEST_UNIT_READY.

§ USBHSCSIRequestSense()

uint32_t USBHSCSIRequestSense ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint8_t *  pui8Data,
uint32_t *  pui32Size 
)

This function issues a SCSI Request Sense command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
pui8Datais the data buffer to return the results into.
pui32Sizeis the size of the buffer on entry and number of bytes read on exit.

This function is used to issue a SCSI Request Sense command to a device. It will return the data in the buffer pointed to by pui8Data. The parameter pui32Size should have the allocation size in bytes of the buffer pointed to by pui8Data.

Returns
This function returns the results of the SCSI Request Sense command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_IN, and SCSI_REQUEST_SENSE.

§ USBHSCSIRead10()

uint32_t USBHSCSIRead10 ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint32_t  ui32LBA,
uint8_t *  pui8Data,
uint32_t *  pui32Size,
uint32_t  ui32NumBlocks 
)

This function issues a SCSI Read(10) command to a device.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
ui32LBAis the logical block address to read.
pui8Datais the data buffer to return the data.
pui32Sizeis the size of the buffer on entry and number of bytes read on exit.
ui32NumBlocksis the number of contiguous blocks to read from the device.

This function is used to issue a SCSI Read(10) command to a device. The ui32LBA parameter specifies the logical block address to read from the device. The data from this block will be returned in the buffer pointed to by pui8Data. The parameter pui32Size should indicate enough space to hold a full block size, or only the first pui32Size bytes of the LBA are returned.

Returns
This function returns the results of the SCSI Read(10) command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_IN, and SCSI_READ_10.

Referenced by USBHMSCBlockRead().

§ USBHSCSIWrite10()

uint32_t USBHSCSIWrite10 ( uint32_t  ui32InPipe,
uint32_t  ui32OutPipe,
uint32_t  ui32LBA,
uint8_t *  pui8Data,
uint32_t *  pui32Size,
uint32_t  ui32NumBlocks 
)

This function issues a SCSI Write(10) command to a device.

This function is used to issue a SCSI Write(10) command to a device. The ui32LBA parameter specifies the logical block address on the device. The data to write to this block should be in the buffer pointed to by pui8Data parameter. The parameter pui32Size should indicate the amount of data to write to the specified LBA.

Parameters
ui32InPipeis the USB IN pipe to use for this command.
ui32OutPipeis the USB OUT pipe to use for this command.
ui32LBAis the logical block address to read.
pui8Datais the data buffer to write out.
pui32Sizeis the size of the buffer.
ui32NumBlocksis the number of contiguous blocks to write to the device.
Returns
This function returns the results of the SCSI Write(10) command. The value will be either SCSI_CMD_STATUS_PASS or SCSI_CMD_STATUS_FAIL.

References CBWFLAGS_DIR_OUT, and SCSI_WRITE_10.

Referenced by USBHMSCBlockWrite().

Variable Documentation

§ g_sUSBHostAudioClassDriver

const tUSBHostClassDriver g_sUSBHostAudioClassDriver
Initial value:
=
{
USBAudioOpen,
USBAudioClose,
0
}
#define USB_CLASS_AUDIO
Definition: usblib.h:420

This constant global structure defines the Audio Class Driver that is provided with the USB library.

§ g_sUSBHIDClassDriver

const tUSBHostClassDriver g_sUSBHIDClassDriver
Initial value:
=
{
HIDDriverOpen,
HIDDriverClose,
0
}
#define USB_CLASS_HID
Definition: usblib.h:422

This constant global structure defines the HID Class Driver that is provided with the USB library.

§ g_sUSBHubClassDriver

const tUSBHostClassDriver g_sUSBHubClassDriver
Initial value:
=
{
HubDriverOpen,
HubDriverClose,
0
}
#define USB_CLASS_HUB
Definition: usblib.h:427

This constant global structure defines the Hub Class Driver that is provided with the USB library.

§ g_sUSBHostMSCClassDriver

const tUSBHostClassDriver g_sUSBHostMSCClassDriver
Initial value:
=
{
USBHMSCOpen,
USBHMSCClose,
0
}
#define USB_CLASS_MASS_STORAGE
Definition: usblib.h:426

This constant global structure defines the Mass Storage Class Driver that is provided with the USB library.

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