Data Structures | |
struct | tUSBAudioFormat |
struct | tHIDInstance |
struct | PACKED |
USB_CDC_GET/SET_LINE_CODING request-specific data. More... | |
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 | |
tUSBHostAudioInstance * | USBHostAudioOpen (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) |
tHIDInstance * | USBHHIDOpen (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) |
tHubInstance * | USBHHubOpen (tUSBHHubCallback pfnCallback) |
void | USBHHubClose (tHubInstance *psHubInstance) |
void | USBHHubInit (void) |
uint32_t | USBHHubLPMSleep (tHubInstance *psHubInstance) |
uint32_t | USBHHubLPMStatus (tHubInstance *psHubInstance) |
int32_t | USBHMSCDriveReady (tUSBHMSCInstance *psMSCInstance) |
tUSBHMSCInstance * | USBHMSCDriveOpen (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) |
#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 |
Referenced by USBHostAudioPlay().
#define AUDIO_FLAG_IN_ACTIVE 2 |
Referenced by USBHostAudioRecord().
#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.
#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.
#define USBH_AUDIO_FORMAT_IN 0x00000001 |
#define USBH_AUDIO_FORMAT_OUT 0x00000000 |
#define MAX_HID_DEVICES MAX_USB_DEVICES |
Referenced by USBHHIDOpen().
#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.
#define USBH_EVENT_HID_KB_REL USBH_HID_EVENT_BASE + 17 |
The HID keyboard detected a key being released.
#define USBH_EVENT_HID_KB_MOD USBH_HID_EVENT_BASE + 18 |
The HID keyboard detected one of the keyboard modifiers being pressed.
#define USBH_EVENT_HID_MS_PRESS USBH_HID_EVENT_BASE + 32 |
A button was pressed on a HID mouse.
#define USBH_EVENT_HID_MS_REL USBH_HID_EVENT_BASE + 33 |
A button was released on a HID mouse.
#define USBH_EVENT_HID_MS_X USBH_HID_EVENT_BASE + 34 |
The HID mouse detected movement in the X direction.
#define USBH_EVENT_HID_MS_Y USBH_HID_EVENT_BASE + 35 |
The HID mouse detected movement in the Y direction.
#define USBLIB_HUB_ACTIVE 0x00000001 |
Referenced by USBHHubMain().
#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 |
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) |
enum tHIDSubClassProtocol |
The following values are used to register callbacks to the USB HOST HID device class layer.
tUSBHostAudioInstance * USBHostAudioOpen | ( | uint32_t | ui32Index, |
tUSBHostAudioCallback | pfnCallback | ||
) |
This function should be called before any devices are present to enable the host audio class driver.
ui32Index | is the audio device to open (currently only 0 is supported). |
pfnCallback | is 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.
void USBHostAudioClose | ( | tUSBHostAudioInstance * | psAudioInstance | ) |
This function should be called to release an audio device instance.
psAudioInstance | is 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.
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.
psAudioInstance | is an instance of the USB audio device. |
ui32Interface | is the interface number to use to query the current volume setting. |
ui32Channel | is 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.
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.
psAudioInstance | is an instance of the USB audio device. |
ui32Interface | is the interface number to use to query the maximum volume control value. |
ui32Channel | is 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.
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.
psAudioInstance | is an instance of the USB audio device. |
ui32Interface | is the interface number to use to query the minimum volume control value. |
ui32Channel | is 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.
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.
psAudioInstance | is an instance of the USB audio device. |
ui32Interface | is the interface number to use to query the resolution for the volume control. |
ui32Channel | is 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.
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.
psAudioInstance | is an instance of the USB audio device. |
ui32Interface | is the interface number to use to set the current volume setting. |
ui32Channel | is the 0 based channel number to query. |
ui32Value | is 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.
References USB_AC_SET_CUR, USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and VOLUME_CONTROL.
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.
psAudioInstance | is the device instance for this call. |
ui32SampleRate | is the sample rate of the audio stream. |
ui32Bits | is the number of bits per sample in the audio stream. |
ui32Channels | is the number of channels in the audio stream. |
ui32Flags | is 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.
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.
psAudioInstance | specifies the device instance for this call. |
ui32SampleRate | is the sample rate in Hz. |
ui32Bits | is the number of bits per sample. |
ui32Channels | is then number of audio channels. |
ui32Flags | is 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().
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.
psAudioInstance | specifies the device instance for this call. |
pvBuffer | is the audio buffer to send. |
ui32Size | is the size of the buffer in bytes. |
pfnCallback | is 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.
References AUDIO_FLAG_OUT_ACTIVE, USBHCDPipeSchedule(), and USBHCDSetInterface().
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.
psAudioInstance | specifies the device instance for this call. |
pvBuffer | is the audio buffer to send. |
ui32Size | is the size of the buffer in bytes. |
pfnCallback | is 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.
References AUDIO_FLAG_IN_ACTIVE, USBHCDPipeSchedule(), and USBHCDSetInterface().
uint32_t USBHostAudioLPMSleep | ( | tUSBHostAudioInstance * | psAudioInstance | ) |
This function forwards an LPM request for a device to enter L1 sleep state.
psAudioInstance | is 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.
References USBHCDLPMSleep().
uint32_t USBHostAudioLPMStatus | ( | tUSBHostAudioInstance * | psAudioInstance | ) |
This function returns the current status of an LPM request.
psAudioInstance | is 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.
References USBHCDLPMStatus().
tHIDInstance* USBHHIDOpen | ( | tHIDSubClassProtocol | iDeviceType, |
tUSBCallback | pfnCallback, | ||
void * | pvCBData | ||
) |
This function is used to open an instance of a HID device.
iDeviceType | is the type of device that should be loaded for this instance of the HID device. |
pfnCallback | is the function that will be called whenever changes are detected for this device. |
pvCBData | is 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.
References eUSBHHIDClassNone, tHIDInstance::iDeviceType, MAX_HID_DEVICES, tHIDInstance::pfnCallback, and tHIDInstance::pvCBData.
Referenced by USBHKeyboardOpen(), and USBHMouseOpen().
void USBHHIDClose | ( | tHIDInstance * | psHIDInstance | ) |
This function is used to release an instance of a HID device.
psHIDInstance | is 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().
References eUSBHHIDClassNone, tHIDInstance::iDeviceType, and tHIDInstance::pfnCallback.
Referenced by USBHKeyboardClose(), and USBHMouseClose().
uint32_t USBHHIDSetIdle | ( | tHIDInstance * | psHIDInstance, |
uint8_t | ui8Duration, | ||
uint8_t | ui8ReportID | ||
) |
This function is used to set the idle timeout for a HID device.
psHIDInstance | is the value that was returned from the call to USBHHIDOpen(). |
ui8Duration | is the duration of the timeout in milliseconds. |
ui8ReportID | is 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.
References tHIDInstance::psDevice, USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_SET_IDLE.
Referenced by USBHKeyboardInit(), USBHKeyboardPollRateSet(), and USBHMouseInit().
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.
psHIDInstance | is the value that was returned from the call to USBHHIDOpen(). |
pui8Buffer | is the memory buffer to use to store the report descriptor. |
ui32Size | is 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.
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().
uint32_t USBHHIDSetProtocol | ( | tHIDInstance * | psHIDInstance, |
uint32_t | ui32BootProtocol | ||
) |
This function is used to set or clear the boot protocol state of a device.
psHIDInstance | is the value that was returned from the call to USBHHIDOpen(). |
ui32BootProtocol | is 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.
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().
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.
psHIDInstance | is the value that was returned from the call to USBHHIDOpen(). |
ui32Interface | is the interface to retrieve the report from. |
pui8Data | is the memory buffer to use to store the report. |
ui32Size | is 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.
References tHIDInstance::ui32IntInPipe, and USBHCDPipeReadNonBlocking().
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.
psHIDInstance | is the value that was returned from the call to USBHHIDOpen(). |
ui32Interface | is the interface to send the report to. |
pui8Data | is the memory buffer to use to store the report. |
ui32Size | is 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.
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().
uint32_t USBHHIDLPMSleep | ( | tHIDInstance * | psHIDInstance | ) |
This function forwards an LPM request for a device to enter L1 sleep state.
psHIDInstance | is 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.
References tHIDInstance::psDevice, and USBHCDLPMSleep().
Referenced by USBHKeyboardLPMSleep(), and USBHMouseLPMSleep().
uint32_t USBHHIDLPMStatus | ( | tHIDInstance * | psHIDInstance | ) |
This function returns the current status of an LPM request.
psHIDInstance | is 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.
References tHIDInstance::psDevice, and USBHCDLPMStatus().
Referenced by USBHKeyboardLPMStatus(), and USBHMouseLPMStatus().
void USBHHubMain | ( | void | ) |
References ePortConnected, and USBLIB_HUB_ACTIVE.
void USBHHubEnumerationComplete | ( | uint8_t | ui8Hub, |
uint8_t | ui8Port | ||
) |
Informs the hub class driver that a downstream device has been enumerated.
ui8Hub | is the address of the hub to which the downstream device is attached. |
ui8Port | is 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.
References DEBUG_OUTPUT, and ePortEnumerated.
void USBHHubEnumerationError | ( | uint8_t | ui8Hub, |
uint8_t | ui8Port | ||
) |
Informs the hub class driver that a downstream device failed to enumerate.
ui8Hub | is the address of the hub to which the downstream device is attached. |
ui8Port | is 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.
References DEBUG_OUTPUT, and ePortError.
tHubInstance* USBHHubOpen | ( | tUSBHHubCallback | pfnCallback | ) |
This function is used to enable the host hub class driver before any devices are present.
pfnCallback | is 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.
References DEBUG_OUTPUT.
void USBHHubClose | ( | tHubInstance * | psHubInstance | ) |
This function is used to release a hub device instance.
psHubInstance | is 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.
References DEBUG_OUTPUT.
void USBHHubInit | ( | void | ) |
uint32_t USBHHubLPMSleep | ( | tHubInstance * | psHubInstance | ) |
This function forwards an LPM request for a device to enter L1 sleep state.
psHubInstance | is 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.
References USBHCDLPMSleep().
uint32_t USBHHubLPMStatus | ( | tHubInstance * | psHubInstance | ) |
This function returns the current status of an LPM request.
psHubInstance | is 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.
References USBHCDLPMStatus().
int32_t USBHMSCDriveReady | ( | tUSBHMSCInstance * | psMSCInstance | ) |
This function checks if a drive is ready to be accessed.
psMSCInstance | is 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.
References SCSI_INQUIRY_DATA_SZ.
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.
ui32Drive | is the drive number to open. |
pfnCallback | is 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.
void USBHMSCDriveClose | ( | tUSBHMSCInstance * | psMSCInstance | ) |
This function should be called to release a drive instance.
psMSCInstance | is 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().
int32_t USBHMSCBlockRead | ( | tUSBHMSCInstance * | psMSCInstance, |
uint32_t | ui32LBA, | ||
uint8_t * | pui8Data, | ||
uint32_t | ui32NumBlocks | ||
) |
This function performs a block read to an MSC device.
psMSCInstance | is the device instance to use for this read. |
ui32LBA | is the logical block address to read on the device. |
pui8Data | is a pointer to the returned data buffer. |
ui32NumBlocks | is 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.
References SCSI_CMD_STATUS_PASS, and USBHSCSIRead10().
int32_t USBHMSCBlockWrite | ( | tUSBHMSCInstance * | psMSCInstance, |
uint32_t | ui32LBA, | ||
uint8_t * | pui8Data, | ||
uint32_t | ui32NumBlocks | ||
) |
This function performs a block write to an MSC device.
psMSCInstance | is the device instance to use for this write. |
ui32LBA | is the logical block address to write on the device. |
pui8Data | is a pointer to the data to write out. |
ui32NumBlocks | is 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.
References SCSI_CMD_STATUS_PASS, and USBHSCSIWrite10().
uint32_t USBHMSCLPMSleep | ( | tUSBHMSCInstance * | psMSCInstance | ) |
This function forwards an LPM request for a device to enter L1 sleep state.
psMSCInstance | is 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.
References USBHCDLPMSleep().
uint32_t USBHMSCLPMStatus | ( | tUSBHMSCInstance * | psMSCInstance | ) |
This function returns the current status of an LPM request.
psMSCInstance | is 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.
References USBHCDLPMStatus().
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
pui8Data | is the data buffer to return the results into. |
pui32Size | is 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.
References CBWFLAGS_DIR_IN, SCSI_INQUIRY_CMD, and SCSI_INQUIRY_DATA_SZ.
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
pui8Data | is the data buffer to return the results into. |
pui32Size | is 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.
References CBWFLAGS_DIR_IN, SCSI_READ_CAPACITY, and SCSI_READ_CAPACITY_SZ.
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
pui8Data | is the data buffer to return the results into. |
pui32Size | is 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.
References CBWFLAGS_DIR_IN, and SCSI_READ_CAPACITIES.
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
ui32Flags | is a combination of flags defining the exact query that is to be made. |
pui8Data | is the data buffer to return the results into. |
pui32Size | is 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:
One of these following values must also be specified to determine the page code for the request:
The last value is optional and supports the following global flag:
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.
uint32_t USBHSCSITestUnitReady | ( | uint32_t | ui32InPipe, |
uint32_t | ui32OutPipe | ||
) |
This function issues a SCSI Test Unit Ready command to a device.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is 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.
References CBWFLAGS_DIR_IN, and SCSI_TEST_UNIT_READY.
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
pui8Data | is the data buffer to return the results into. |
pui32Size | is 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.
References CBWFLAGS_DIR_IN, and SCSI_REQUEST_SENSE.
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
ui32LBA | is the logical block address to read. |
pui8Data | is the data buffer to return the data. |
pui32Size | is the size of the buffer on entry and number of bytes read on exit. |
ui32NumBlocks | is 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.
References CBWFLAGS_DIR_IN, and SCSI_READ_10.
Referenced by USBHMSCBlockRead().
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.
ui32InPipe | is the USB IN pipe to use for this command. |
ui32OutPipe | is the USB OUT pipe to use for this command. |
ui32LBA | is the logical block address to read. |
pui8Data | is the data buffer to write out. |
pui32Size | is the size of the buffer. |
ui32NumBlocks | is the number of contiguous blocks to write to the device. |
References CBWFLAGS_DIR_OUT, and SCSI_WRITE_10.
Referenced by USBHMSCBlockWrite().
const tUSBHostClassDriver g_sUSBHostAudioClassDriver |
This constant global structure defines the Audio Class Driver that is provided with the USB library.
const tUSBHostClassDriver g_sUSBHIDClassDriver |
This constant global structure defines the HID Class Driver that is provided with the USB library.
const tUSBHostClassDriver g_sUSBHubClassDriver |
This constant global structure defines the Hub Class Driver that is provided with the USB library.
const tUSBHostClassDriver g_sUSBHostMSCClassDriver |
This constant global structure defines the Mass Storage Class Driver that is provided with the USB library.