3      Copyright (C) Dean Camera, 2011. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  32  *  \brief Common USB Host definitions for all architectures. 
  33  *  \copydetails Group_Host 
  35  *  \note This file should not be included directly. It is automatically included as needed by the USB driver 
  36  *        dispatch header located in LUFA/Drivers/USB/USB.h. 
  39 /** \ingroup Group_USB 
  40  *  \defgroup Group_Host Host Management 
  41  *  \brief USB Host management definitions for USB host mode. 
  43  *  USB Host mode related macros and enums. This module contains macros and enums which are used when 
  44  *  the USB controller is initialized in host mode. 
  53                 #include "../../../Common/Common.h" 
  56         /* Preprocessor Checks: */ 
  57                 #if !defined(__INCLUDE_FROM_USB_DRIVER) 
  58                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. 
  61         /* Public Interface - May be used in end-application: */ 
  63                         /** Enum for the various states of the USB Host state machine. Only some states are 
  64                          *  implemented in the LUFA library - other states are left to the user to implement. 
  66                          *  For information on each possible USB host state, refer to the USB 2.0 specification. 
  67                          *  Several of the USB host states are broken up further into multiple smaller sub-states, 
  68                          *  so that they can be internally implemented inside the library in an efficient manner. 
  70                          *  \see \ref USB_HostState, which stores the current host state machine state. 
  72                         enum USB_Host_States_t
 
  74                                 HOST_STATE_WaitForDeviceRemoval         
= 0,  /**< Internally implemented by the library. This state can be 
  75                                                                                *   used by the library to wait until the attached device is 
  76                                                                                *   removed by the user - useful for when an error occurs or 
  77                                                                                *   further communication with the device is not needed. This 
  78                                                                                *   allows for other code to run while the state machine is 
  79                                                                                *   effectively disabled. 
  81                                 HOST_STATE_WaitForDevice                
= 1,  /**< Internally implemented by the library. This state indicates 
  82                                                                                *   that the stack is waiting for an interval to elapse before 
  83                                                                                *   continuing with the next step of the device enumeration 
  86                                                                                *   \note Do not manually change to this state in the user code. 
  88                                 HOST_STATE_Unattached                   
= 2,  /**< Internally implemented by the library. This state indicates 
  89                                                                                *   that the host state machine is waiting for a device to be 
  90                                                                                *   attached so that it can start the enumeration process. 
  92                                                                                *   \note Do not manually change to this state in the user code. 
  94                                 HOST_STATE_Powered                      
= 3,  /**< Internally implemented by the library. This state indicates 
  95                                                                                *   that a device has been attached, and the library's internals 
  96                                                                                *   are being configured to begin the enumeration process. 
  98                                                                                *   \note Do not manually change to this state in the user code. 
 100                                 HOST_STATE_Powered_WaitForDeviceSettle  
= 4,  /**< Internally implemented by the library. This state indicates 
 101                                                                                *   that the stack is waiting for the initial settling period to 
 102                                                                                *   elapse before beginning the enumeration process. 
 104                                                                                *   \note Do not manually change to this state in the user code. 
 106                                 HOST_STATE_Powered_WaitForConnect       
= 5,  /**< Internally implemented by the library. This state indicates 
 107                                                                                *   that the stack is waiting for a connection event from the USB 
 108                                                                                *   controller to indicate a valid USB device has been attached to 
 109                                                                                *   the bus and is ready to be enumerated. 
 111                                                                                *   \note Do not manually change to this state in the user code. 
 113                                 HOST_STATE_Powered_DoReset              
= 6,  /**< Internally implemented by the library. This state indicates 
 114                                                                                *   that a valid USB device has been attached, and that it is 
 115                                                                                *   will now be reset to ensure it is ready for enumeration. 
 117                                                                                *   \note Do not manually change to this state in the user code. 
 119                                 HOST_STATE_Powered_ConfigPipe           
= 7,  /**< Internally implemented by the library. This state indicates 
 120                                                                                *   that the attached device is currently powered and reset, and 
 121                                                                                *   that the control pipe is now being configured by the stack. 
 123                                                                                *   \note Do not manually change to this state in the user code. 
 125                                 HOST_STATE_Default                      
= 8,  /**< Internally implemented by the library. This state indicates 
 126                                                                                *   that the stack is currently retrieving the control endpoint's 
 127                                                                                *   size from the device, so that the control pipe can be altered 
 130                                                                                *   \note Do not manually change to this state in the user code. 
 132                                 HOST_STATE_Default_PostReset            
= 9,  /**< Internally implemented by the library. This state indicates that 
 133                                                                                *   the control pipe is being reconfigured to match the retrieved 
 134                                                                                *   control endpoint size from the device, and the device's USB bus 
 135                                                                                *   address is being set. 
 137                                                                                *   \note Do not manually change to this state in the user code. 
 139                                 HOST_STATE_Default_PostAddressSet       
= 10, /**< Internally implemented by the library. This state indicates that 
 140                                                                                *   the device's address has now been set, and the stack is has now 
 141                                                                                *   completed the device enumeration process. This state causes the 
 142                                                                                *   stack to change the current USB device address to that set for 
 143                                                                                *   the connected device, before progressing to the user-implemented 
 144                                                                                *   \ref HOST_STATE_Addressed state for further communications. 
 146                                                                                *   \note Do not manually change to this state in the user code. 
 148                                 HOST_STATE_Addressed                    
= 11, /**< May be implemented by the user project. This state should 
 149                                                                                *   set the device configuration before progressing to the 
 150                                                                                *   \ref HOST_STATE_Configured state. Other processing (such as the 
 151                                                                                *   retrieval and processing of the device descriptor) should also 
 152                                                                                *   be placed in this state. 
 154                                 HOST_STATE_Configured                   
= 12, /**< May be implemented by the user project. This state should implement the 
 155                                                                                *   actual work performed on the attached device and changed to the 
 156                                                                                *   \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed. 
 158                                 HOST_STATE_Suspended                    
= 15, /**< May be implemented by the user project. This state should be maintained 
 159                                                                                *   while the bus is suspended, and changed to either the \ref HOST_STATE_Configured 
 160                                                                                *   (after resuming the bus with the USB_Host_ResumeBus() macro) or the 
 161                                                                                *   \ref HOST_STATE_WaitForDeviceRemoval states as needed. 
 165         /* Architecture Includes: */ 
 166                 #if (ARCH == ARCH_AVR8) 
 167                         #include "AVR8/Host_AVR8.h" 
 168                 #elif (ARCH == ARCH_UC3) 
 169                         #include "UC3/Host_UC3.h"