Updated all host mode demos and projects to use the EVENT_USB_Host_DeviceEnumerationComplete() event callback for device configuration instead of manual host state machine manipulations in the main application task.

Added new USB_Host_ConfigurationNumber global variable to indicate the selected configuration in an attached device.

Renamed global state variables that are specific to a certain USB mode to clearly indicate which mode the variable relates to, by changing the USB_* prefix to USB_Device_* or USB_Host_*.

Removed the HOST_STATE_WaitForDeviceRemoval and HOST_STATE_Suspended host state machine states, as these are no longer required.

Altered the USB_Host_SetDeviceConfiguration() function to update the new USB_Host_ConfigurationNumber global as required.

Moved out the Host mode standard request convenience/helper functions from the architecture specific Host driver files to the architecture agnostic HostStandardReq.c driver file.
This commit is contained in:
Dean Camera 2011-07-08 07:25:56 +00:00
parent bcb627e1a1
commit 137ce280c1
96 changed files with 3053 additions and 3656 deletions

View file

@ -77,6 +77,19 @@
HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */
};
/* Global Variables: */
/** Indicates the currently set configuration number of the attached device. This indicates the currently
* selected configuration value if one has been set sucessfully, or 0 if no configuration has been selected.
*
* To set a device configuration, call the \ref USB_Host_SetDeviceConfiguration() function.
*
* \note This variable should be treated as read-only in the user application, and never manually
* changed in value.
*
* \ingroup Group_Host
*/
extern uint8_t USB_Host_ConfigurationNumber;
/* Function Prototypes: */
/** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device,
* and transfers the data stored in the buffer to the device, or from the device to the buffer
@ -91,6 +104,85 @@
*/
uint8_t USB_Host_SendControlRequest(void* const BufferPtr);
/** Convenience function. This routine sends a SET CONFIGURATION standard request to the attached
* device, with the given configuration index. This can be used to easily set the device
* configuration without creating and sending the request manually.
*
* This routine will automatically update the \ref USB_HostState and \ref USB_Host_ConfigurationNumber
* state variables according to the given function parameters and the result of the request.
*
* \note After this routine returns, the control pipe will be selected.
*
* \ingroup Group_PipeControlReq
*
* \param[in] ConfigNumber Configuration index to send to the device.
*
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);
/** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached
* device, requesting the device descriptor. This can be used to easily retrieve information
* about the device such as its VID, PID and power requirements.
*
* \note After this routine returns, the control pipe will be selected.
*
* \ingroup Group_PipeControlReq
*
* \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where
* the read data is to be stored.
*
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);
/** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached
* device, requesting the string descriptor of the specified index. This can be used to easily
* retrieve string descriptors from the device by index, after the index is obtained from the
* Device or Configuration descriptors.
*
* \note After this routine returns, the control pipe will be selected.
*
* \ingroup Group_PipeControlReq
*
* \param[in] Index Index of the string index to retrieve.
* \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is
* to be stored.
* \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.
*
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
void* const Buffer,
const uint8_t BufferLength);
/** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device.
*
* \note After this routine returns, the control pipe will be selected.
*
* \ingroup Group_PipeControlReq
*
* \param[in] EndpointIndex Index of the endpoint to clear, including the endpoint's direction.
*
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex);
/** Selects a given alternative setting for the specified interface, via a SET INTERFACE standard request to
* the attached device.
*
* \note After this routine returns, the control pipe will be selected.
*
* \ingroup Group_PipeControlReq
*
* \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered.
* \param[in] AltSetting Index of the interface's alternative setting which is to be selected.
*
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex,
const uint8_t AltSetting);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Enums: */