Fixed incorrect comparison in the descriptor callback routine of the TeensyHID bootlo...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Host.h
index 82a90d2..97d908d 100644 (file)
   this software.\r
 */\r
 \r
+/** \file\r
+ *  \brief USB host mode definitions.\r
+ *\r
+ *  This file contains structures, function prototypes and macros related to USB host mode.\r
+ *\r
+ *  \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ *        dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
 /** \ingroup Group_USB\r
  *  @defgroup Group_Host Host Management\r
  *\r
 #define __USBHOST_H__\r
 \r
        /* Includes: */\r
-               #if defined(__AVR32__)\r
-                       #include <avr32/io.h>\r
-                       #include <stdint.h>\r
-                       #include <stdbool.h>\r
-               #elif defined(__AVR__)\r
-                       #include <avr/io.h>\r
-                       #include <stdbool.h>\r
-                       #include <util/delay.h>\r
-               #endif\r
-               \r
+               #include <avr/io.h>\r
+               #include <stdbool.h>\r
+               #include <util/delay.h>\r
+\r
                #include "../../../Common/Common.h"\r
-               #include "../HighLevel/USBInterrupt.h"\r
                #include "../HighLevel/StdDescriptors.h"\r
                #include "Pipe.h"\r
+               #include "USBInterrupt.h"\r
 \r
        /* Enable C linkage for C++ Compilers: */\r
                #if defined(__cplusplus)\r
                                 */\r
                                static inline bool USB_Host_IsResumeFromWakeupRequestSent(void);\r
                        #else\r
-                               #if defined(__AVR32__)\r
-                                       #define USB_Host_ResetBus()                MACROS{ AVR32_USBB.UHCON.reset = true;   }MACROE\r
-                                       #define USB_Host_IsBusResetComplete()              AVR32_USBB.UHCON.reset\r
-                                       #define USB_Host_ResumeBus()               MACROS{ AVR32_USBB.UHCON.sofen = true;   }MACROE \r
-                                       #define USB_Host_SuspendBus()              MACROS{ AVR32_USBB.UHCON.sofen = false;  }MACROE \r
-                                       #define USB_Host_IsBusSuspended()                  AVR32_USBB.UHCON.sofen\r
-                                       #define USB_Host_IsDeviceFullSpeed()              (AVR32_USBB.USBSTA.speed == 0)   \r
-                                       #define USB_Host_IsRemoteWakeupSent()              AVR32_USBB.UHINT.rxrsmi\r
-                                       #define USB_Host_ClearRemoteWakeupSent()   MACROS{ AVR32_USBB.UHINTCLR.rxrsmic = true; }MACROE\r
-                                       #define USB_Host_ResumeFromWakeupRequest() MACROS{ AVR32_USBB.UHCON.resume = true;     }MACROE\r
-                                       #define USB_Host_IsResumeFromWakeupRequestSent()   AVR32_USBB.UHCON.resume                      \r
-                               #elif defined(__AVR__)\r
-                                       #define USB_Host_ResetBus()                MACROS{ UHCON |=  (1 << RESET);          }MACROE\r
-                                       #define USB_Host_IsBusResetComplete()            ((UHCON &   (1 << RESET))  ? false : true)\r
-                                       #define USB_Host_ResumeBus()               MACROS{ UHCON |=  (1 << SOFEN);          }MACROE \r
-                                       #define USB_Host_SuspendBus()              MACROS{ UHCON &= ~(1 << SOFEN);          }MACROE \r
-                                       #define USB_Host_IsBusSuspended()                ((UHCON &   (1 << SOFEN))  ? false : true)\r
-                                       #define USB_Host_IsDeviceFullSpeed()             ((USBSTA &  (1 << SPEED))  ? true : false)\r
-                                       #define USB_Host_IsRemoteWakeupSent()            ((UHINT &   (1 << RXRSMI)) ? true : false)\r
-                                       #define USB_Host_ClearRemoteWakeupSent()   MACROS{ UHINT &= ~(1 << RXRSMI);         }MACROE\r
-                                       #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |=  (1 << RESUME);         }MACROE\r
-                                       #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON &   (1 << RESUME)) ? false : true)\r
-                               #endif\r
+                               #define USB_Host_ResetBus()                MACROS{ UHCON |=  (1 << RESET);          }MACROE\r
+\r
+                               #define USB_Host_IsBusResetComplete()      ((UHCON &   (1 << RESET)) ? false : true)\r
+\r
+                               #define USB_Host_ResumeBus()               MACROS{ UHCON |=  (1 << SOFEN);          }MACROE \r
+\r
+                               #define USB_Host_SuspendBus()              MACROS{ UHCON &= ~(1 << SOFEN);          }MACROE \r
+                               \r
+                               #define USB_Host_IsBusSuspended()                ((UHCON &   (1 << SOFEN)) ? false : true)\r
+                       \r
+                               #define USB_Host_IsDeviceFullSpeed()             ((USBSTA &  (1 << SPEED)) ? true : false)\r
+\r
+                               #define USB_Host_IsRemoteWakeupSent()            ((UHINT &   (1 << RXRSMI)) ? true : false)\r
+\r
+                               #define USB_Host_ClearRemoteWakeupSent()   MACROS{ UHINT &= ~(1 << RXRSMI);         }MACROE\r
+\r
+                               #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |=  (1 << RESUME);         }MACROE\r
+                               \r
+                               #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON &   (1 << RESUME)) ? false : true)\r
                        #endif\r
 \r
                /* Function Prototypes: */\r
                         *\r
                         *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
                         */\r
-                       uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, uint8_t BufferLength);\r
+                       uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, void* const Buffer, const uint8_t BufferLength);\r
                        \r
                        /** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device.\r
                         *\r
                        /** Enum for the various states of the USB Host state machine. Only some states are\r
                         *  implemented in the LUFA library - other states are left to the user to implement.\r
                         *\r
-                        *  For information on each state, refer to the USB 2.0 specification. Some states have\r
+                        *  For information on each possible USB host state, refer to the USB 2.0 specification.\r
+                        *  Several of the USB host states are broken up further into multiple smaller sub-states,\r
+                        *  so that they can be internally implemented inside the library in an efficient manner.\r
                         *\r
                         *  \see \ref USB_HostState, which stores the current host state machine state.\r
                         */\r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Macros: */\r
-                       #if defined(__AVR32__)\r
-                               #define USB_Host_HostMode_On()          MACROS{ AVR32_USBB.USBCON.uimod = false;  }MACROE\r
-                               #define USB_Host_HostMode_Off()         MACROS{ AVR32_USBB.USBCON.uimod = true;   }MACROE\r
+                       #define USB_Host_HostMode_On()          MACROS{ USBCON |=  (1 << HOST);           }MACROE\r
+                       #define USB_Host_HostMode_Off()         MACROS{ USBCON &= ~(1 << HOST);           }MACROE\r
 \r
-                               #define USB_Host_VBUS_Auto_Enable()     MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |=  (1 << UVCONE);                   }MACROE\r
-                               #define USB_Host_VBUS_Manual_Enable()   MACROS{ OTGCON |=  (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
+                       #define USB_Host_VBUS_Auto_Enable()     MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |=  (1 << UVCONE);                   }MACROE\r
+                       #define USB_Host_VBUS_Manual_Enable()   MACROS{ OTGCON |=  (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
 \r
-                               #define USB_Host_VBUS_Auto_On()         MACROS{ OTGCON |= (1 << VBUSREQ);         }MACROE\r
-                               #define USB_Host_VBUS_Manual_On()       MACROS{ PORTE  |= (1 << 7);               }MACROE\r
+                       #define USB_Host_VBUS_Auto_On()         MACROS{ OTGCON |= (1 << VBUSREQ);         }MACROE\r
+                       #define USB_Host_VBUS_Manual_On()       MACROS{ PORTE  |= (1 << 7);               }MACROE\r
 \r
-                               #define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE\r
-                               #define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE\r
+                       #define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE\r
+                       #define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE\r
 \r
-                               #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE                       \r
-                       #elif defined(__AVR__)\r
-                               #define USB_Host_HostMode_On()          MACROS{ USBCON |=  (1 << HOST);           }MACROE\r
-                               #define USB_Host_HostMode_Off()         MACROS{ USBCON &= ~(1 << HOST);           }MACROE\r
+                       #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE\r
 \r
-                               #define USB_Host_VBUS_Auto_Enable()     MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |=  (1 << UVCONE);                   }MACROE\r
-                               #define USB_Host_VBUS_Manual_Enable()   MACROS{ OTGCON |=  (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
-\r
-                               #define USB_Host_VBUS_Auto_On()         MACROS{ OTGCON |= (1 << VBUSREQ);         }MACROE\r
-                               #define USB_Host_VBUS_Manual_On()       MACROS{ PORTE  |= (1 << 7);               }MACROE\r
-\r
-                               #define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE\r
-                               #define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE\r
-\r
-                               #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE\r
-                       #endif\r
-                       \r
                /* Enums: */\r
                        enum USB_Host_WaitMSErrorCodes_t\r
                        {\r