X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/3702ba1fb31f265360a0e4cf1736465e44389103..fc31973daffea3506051ce51a5f79383ce0867d6:/LUFA/Drivers/USB/LowLevel/Host.h diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 82a90d2df..97d908dea 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -28,6 +28,15 @@ this software. */ +/** \file + * \brief USB host mode definitions. + * + * This file contains structures, function prototypes and macros related to USB host mode. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + /** \ingroup Group_USB * @defgroup Group_Host Host Management * @@ -41,20 +50,14 @@ #define __USBHOST_H__ /* Includes: */ - #if defined(__AVR32__) - #include - #include - #include - #elif defined(__AVR__) - #include - #include - #include - #endif - + #include + #include + #include + #include "../../../Common/Common.h" - #include "../HighLevel/USBInterrupt.h" #include "../HighLevel/StdDescriptors.h" #include "Pipe.h" + #include "USBInterrupt.h" /* Enable C linkage for C++ Compilers: */ #if defined(__cplusplus) @@ -165,29 +168,25 @@ */ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void); #else - #if defined(__AVR32__) - #define USB_Host_ResetBus() MACROS{ AVR32_USBB.UHCON.reset = true; }MACROE - #define USB_Host_IsBusResetComplete() AVR32_USBB.UHCON.reset - #define USB_Host_ResumeBus() MACROS{ AVR32_USBB.UHCON.sofen = true; }MACROE - #define USB_Host_SuspendBus() MACROS{ AVR32_USBB.UHCON.sofen = false; }MACROE - #define USB_Host_IsBusSuspended() AVR32_USBB.UHCON.sofen - #define USB_Host_IsDeviceFullSpeed() (AVR32_USBB.USBSTA.speed == 0) - #define USB_Host_IsRemoteWakeupSent() AVR32_USBB.UHINT.rxrsmi - #define USB_Host_ClearRemoteWakeupSent() MACROS{ AVR32_USBB.UHINTCLR.rxrsmic = true; }MACROE - #define USB_Host_ResumeFromWakeupRequest() MACROS{ AVR32_USBB.UHCON.resume = true; }MACROE - #define USB_Host_IsResumeFromWakeupRequestSent() AVR32_USBB.UHCON.resume - #elif defined(__AVR__) - #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE - #define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true) - #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE - #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE - #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true) - #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false) - #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false) - #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE - #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE - #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true) - #endif + #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE + + #define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true) + + #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE + + #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE + + #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true) + + #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false) + + #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false) + + #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE + + #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE + + #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true) #endif /* Function Prototypes: */ @@ -230,7 +229,7 @@ * * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. */ - uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, uint8_t BufferLength); + 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 ClearFeature request to the attached device. * @@ -246,7 +245,9 @@ /** 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 + * For information on each possible USB host state, refer to the USB 2.0 specification. + * Several of the USB host states are broken up further into multiple smaller sub-states, + * so that they can be internally implemented inside the library in an efficient manner. * * \see \ref USB_HostState, which stores the current host state machine state. */ @@ -385,36 +386,20 @@ /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ - #if defined(__AVR32__) - #define USB_Host_HostMode_On() MACROS{ AVR32_USBB.USBCON.uimod = false; }MACROE - #define USB_Host_HostMode_Off() MACROS{ AVR32_USBB.USBCON.uimod = true; }MACROE + #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_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }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 - #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE + #define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE + #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE - #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE - #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE + #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE + #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE - #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE - #elif defined(__AVR__) - #define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE - #define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE + #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }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 - #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE - - #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE - #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE - - #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE - #endif - /* Enums: */ enum USB_Host_WaitMSErrorCodes_t {