Changed over the AVR8 USB controller interrupt management macros to be inlined functi...
[pub/USBasp.git] / LUFA / Drivers / USB / Core / Host.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2011.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
20
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
28 this software.
29 */
30
31 /** \file
32 * \brief Common USB Host definitions for all architectures.
33 * \copydetails Group_Host
34 *
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.
37 */
38
39 /** \ingroup Group_USB
40 * \defgroup Group_Host Host Management
41 * \brief USB Host management definitions for USB host mode.
42 *
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.
45 *
46 * @{
47 */
48
49 #ifndef __USBHOST_H__
50 #define __USBHOST_H__
51
52 /* Includes: */
53 #include "../../../Common/Common.h"
54
55 /* Preprocessor Checks: */
56 #if !defined(__INCLUDE_FROM_USB_DRIVER)
57 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
58 #endif
59
60 /* Public Interface - May be used in end-application: */
61 /* Enums: */
62 /** Enum for the various states of the USB Host state machine. Only some states are
63 * implemented in the LUFA library - other states are left to the user to implement.
64 *
65 * For information on each possible USB host state, refer to the USB 2.0 specification.
66 * Several of the USB host states are broken up further into multiple smaller sub-states,
67 * so that they can be internally implemented inside the library in an efficient manner.
68 *
69 * \see \ref USB_HostState, which stores the current host state machine state.
70 */
71 enum USB_Host_States_t
72 {
73 HOST_STATE_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be
74 * used by the library to wait until the attached device is
75 * removed by the user - useful for when an error occurs or
76 * further communication with the device is not needed. This
77 * allows for other code to run while the state machine is
78 * effectively disabled.
79 */
80 HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates
81 * that the stack is waiting for an interval to elapse before
82 * continuing with the next step of the device enumeration
83 * process.
84 *
85 * \note Do not manually change to this state in the user code.
86 */
87 HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates
88 * that the host state machine is waiting for a device to be
89 * attached so that it can start the enumeration process.
90 *
91 * \note Do not manually change to this state in the user code.
92 */
93 HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates
94 * that a device has been attached, and the library's internals
95 * are being configured to begin the enumeration process.
96 *
97 * \note Do not manually change to this state in the user code.
98 */
99 HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates
100 * that the stack is waiting for the initial settling period to
101 * elapse before beginning the enumeration process.
102 *
103 * \note Do not manually change to this state in the user code.
104 */
105 HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. This state indicates
106 * that the stack is waiting for a connection event from the USB
107 * controller to indicate a valid USB device has been attached to
108 * the bus and is ready to be enumerated.
109 *
110 * \note Do not manually change to this state in the user code.
111 */
112 HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates
113 * that a valid USB device has been attached, and that it is
114 * will now be reset to ensure it is ready for enumeration.
115 *
116 * \note Do not manually change to this state in the user code.
117 */
118 HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates
119 * that the attached device is currently powered and reset, and
120 * that the control pipe is now being configured by the stack.
121 *
122 * \note Do not manually change to this state in the user code.
123 */
124 HOST_STATE_Default = 8, /**< Internally implemented by the library. This state indicates
125 * that the stack is currently retrieving the control endpoint's
126 * size from the device, so that the control pipe can be altered
127 * to match.
128 *
129 * \note Do not manually change to this state in the user code.
130 */
131 HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. This state indicates that
132 * the control pipe is being reconfigured to match the retrieved
133 * control endpoint size from the device, and the device's USB bus
134 * address is being set.
135 *
136 * \note Do not manually change to this state in the user code.
137 */
138 HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. This state indicates that
139 * the device's address has now been set, and the stack is has now
140 * completed the device enumeration process. This state causes the
141 * stack to change the current USB device address to that set for
142 * the connected device, before progressing to the user-implemented
143 * \ref HOST_STATE_Addressed state for further communications.
144 *
145 * \note Do not manually change to this state in the user code.
146 */
147 HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should
148 * set the device configuration before progressing to the
149 * \ref HOST_STATE_Configured state. Other processing (such as the
150 * retrieval and processing of the device descriptor) should also
151 * be placed in this state.
152 */
153 HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the
154 * actual work performed on the attached device and changed to the
155 * \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.
156 */
157 HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained
158 * while the bus is suspended, and changed to either the \ref HOST_STATE_Configured
159 * (after resuming the bus with the USB_Host_ResumeBus() macro) or the
160 * \ref HOST_STATE_WaitForDeviceRemoval states as needed.
161 */
162 };
163
164 /* Architecture Includes: */
165 #if (ARCH == ARCH_AVR8)
166 #include "AVR8/Host_AVR8.h"
167 #elif (ARCH == ARCH_UC3B)
168 #include "UC3B/Host_UC3B.h"
169 #endif
170
171 #endif
172
173 /** @} */
174