X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/663f449c10b9a77a429aaa81066ce2b43ca6dc39..b462f2d457ec2f0cfa22a1c3db198cb22f6809a1:/LUFA/Drivers/USB/LowLevel/Host.h diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 62921e866..08b21f688 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -47,6 +47,8 @@ #include "../../../Common/Common.h" #include "../HighLevel/USBInterrupt.h" + #include "../HighLevel/StdDescriptors.h" + #include "Pipe.h" /* Enable C linkage for C++ Compilers: */ #if defined(__cplusplus) @@ -60,7 +62,7 @@ * and that the address used is not important (other than the fact that it is non-zero), a * fixed value is specified by the library. */ - #define USB_HOST_DEVICEADDRESS 1 + #define USB_HOST_DEVICEADDRESS 1 #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__) /** Constant for the maximum software timeout period of sent USB control transactions to an attached @@ -68,7 +70,7 @@ * library will return a timeout error code. * * This value may be overridden in the user project makefile as the value of the - * USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch. + * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch. */ #define USB_HOST_TIMEOUT_MS 1000 #endif @@ -95,7 +97,7 @@ */ static inline void USB_Host_ResetBus(void); - /** Determines if a previously issued bus reset (via the USB_Host_ResetBus() macro) has + /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has * completed. * * \return Boolean true if no bus reset is currently being sent, false otherwise. @@ -114,7 +116,7 @@ */ static inline void USB_Host_SuspendBus(void); - /** Determines if the USB bus has been suspended via the use of the USB_Host_SuspendBus() macro, + /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro, * false otherwise. While suspended, no USB communications can occur until the bus is resumed, * except for the Remote Wakeup event from the device if supported. * @@ -173,14 +175,49 @@ #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true) #endif + /* Function Prototypes: */ + /** Convenience function. This routine sends a SetConfiguration 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. + * + * \note After this routine returns, the control pipe will be selected. + * + * \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(uint8_t ConfigNumber); + + /** Convenience function. This routine sends a GetDescriptor 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. + * + * \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* DeviceDescriptorPtr); + + /** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \param[in] EndpointIndex Index of the endpoint to clear + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_ClearPipeStall(uint8_t EndpointIndex); + /* Enums: */ /** Enum for the various states of the USB Host state machine. Only some states are * implemented in the LUFA library - other states are left to the user to implement. * * For information on each state, refer to the USB 2.0 specification. Some states have * - * \see USBTask.h for information on the global variable USB_HostState, which stores the - * current host state machine state. + * \see \ref USB_HostState, which stores the current host state machine state. */ enum USB_Host_States_t { @@ -200,28 +237,28 @@ HOST_STATE_Suspended = 13, /**< May be implemented by the user project. */ }; - /** Enum for the error codes for the USB_HostError event. + /** Enum for the error codes for the \ref EVENT_USB_HostError() event. * - * \see Events.h for more information on this event. + * \see \ref Group_Events for more information on this event. */ enum USB_Host_ErrorCodes_t { HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This - * error may be the result of an attached device drawing + * error may be the result of an attached device drawing * too much current from the VBUS line, or due to the * AVR's power source being unable to supply sufficient * current. */ }; - /** Enum for the error codes for the USB_DeviceEnumerationFailed event. + /** Enum for the error codes for the \ref EVENT_USB_DeviceEnumerationFailed() event. * - * \see Events.h for more information on this event. + * \see \ref Group_Events for more information on this event. */ enum USB_Host_EnumerationErrorCodes_t { HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid - * ErrorCode parameter value for the USB_DeviceEnumerationFailed + * ErrorCode parameter value for the \ref EVENT_USB_DeviceEnumerationFailed() * event. */ HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed @@ -245,7 +282,7 @@ #define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE #define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE - #define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE + #define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE #define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE #define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE @@ -266,8 +303,12 @@ }; /* Function Prototypes: */ + void USB_Host_ProcessNextHostState(void); uint8_t USB_Host_WaitMS(uint8_t MS); - void USB_Host_ResetDevice(void); + + #if defined(INCLUDE_FROM_HOST_C) + static void USB_Host_ResetDevice(void); + #endif #endif /* Disable C linkage for C++ Compilers: */