Statistics
| Branch: | Tag: | Revision:

root / LUFA / Drivers / USB / Core / USBMode.h @ 978b99e5

History | View | Annotate | Download (8.72 KB)

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 USB mode and feature support definitions.
33
 *  \copydetails Group_USBMode
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_USBMode USB Mode Tokens
41
 *  \brief USB mode and feature support definitions.
42
 *
43
 *  This file defines macros indicating the type of USB controller the library is being compiled for, and its
44
 *  capabilities. These macros may then be referenced in the user application to selectively enable or disable
45
 *  code sections depending on if they are defined or not.
46
 *
47
 *  After the inclusion of the master USB driver header, one or more of the following tokens may be defined, to
48
 *  allow the user code to conditionally enable or disable code based on the USB controller family and allowable
49
 *  USB modes. These tokens may be tested against to eliminate code relating to a USB mode which is not enabled for
50
 *  the given compilation.
51
 *
52
 *  @{
53
 */
54

    
55
#ifndef __USBMODE_H__
56
#define __USBMODE_H__
57

    
58
        /* Enable C linkage for C++ Compilers: */
59
                #if defined(__cplusplus)
60
                        extern "C" {
61
                #endif
62

    
63
        /* Preprocessor Checks: */
64
                #if !defined(__INCLUDE_FROM_USB_DRIVER)
65
                        #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
66
                #endif
67

    
68
        /* Public Interface - May be used in end-application: */
69
        #if defined(__DOXYGEN__)
70
                /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller
71
                 *  (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined.
72
                 */
73
                #define USB_SERIES_2_AVR
74

    
75
                /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller
76
                 *  (i.e. ATMEGAxxU4) when defined.
77
                 */
78
                #define USB_SERIES_4_AVR
79

    
80
                /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller
81
                 *  (i.e. AT90USBxxx6) when defined.
82
                 */
83
                #define USB_SERIES_6_AVR
84

    
85
                /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller
86
                 *  (i.e. AT90USBxxx7) when defined.
87
                 */
88
                #define USB_SERIES_7_AVR
89

    
90
                /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller
91
                 *  (i.e. AT32UC3A0*) when defined.
92
                 */
93
                #define USB_SERIES_UC3A0_AVR
94
                
95
                /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller
96
                 *  (i.e. AT32UC3A1*) when defined.
97
                 */
98
                #define USB_SERIES_UC3A1_AVR
99

    
100
                /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller
101
                 *  (i.e. AT32UC3A3*) when defined.
102
                 */
103
                #define USB_SERIES_UC3A3_AVR
104

    
105
                /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller
106
                 *  (i.e. AT32UC3B0*) when defined.
107
                 */
108
                #define USB_SERIES_UC3B0_AVR
109

    
110
                /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller
111
                 *  (i.e. AT32UC3B1*) when defined.
112
                 */
113
                #define USB_SERIES_UC3B1_AVR
114

    
115
                /** Indicates that the target microcontroller and compilation settings allow for the
116
                 *  target to be configured in USB Device mode when defined.
117
                 */
118
                #define USB_CAN_BE_DEVICE
119

    
120
                /** Indicates that the target microcontroller and compilation settings allow for the
121
                 *  target to be configured in USB Host mode when defined.
122
                 */
123
                #define USB_CAN_BE_HOST
124

    
125
                /** Indicates that the target microcontroller and compilation settings allow for the
126
                 *  target to be configured in either USB Device or Host mode when defined.
127
                 */
128
                #define USB_CAN_BE_BOTH
129
        #else
130
                /* Macros: */
131
                        #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__)  || \
132
                             defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
133
                                #define USB_SERIES_2_AVR
134
                                #define USB_CAN_BE_DEVICE
135
                        #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__))
136
                                #define USB_SERIES_4_AVR
137
                                #define USB_CAN_BE_DEVICE
138
                        #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
139
                                #define USB_SERIES_6_AVR
140
                                #define USB_CAN_BE_DEVICE
141
                        #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
142
                                #define USB_SERIES_7_AVR
143
                                #define USB_CAN_BE_DEVICE
144
                                #define USB_CAN_BE_HOST
145
                        #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \
146
                               defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__))
147
                                #define USB_SERIES_UC3A0_AVR32
148
                                #define USB_CAN_BE_DEVICE
149
                                #define USB_CAN_BE_HOST
150
                        #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \
151
                               defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__))
152
                                #define USB_SERIES_UC3A1_AVR32
153
                                #define USB_CAN_BE_DEVICE
154
                                #define USB_CAN_BE_HOST
155
                        #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \
156
                               defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \
157
                               defined(__AVR32_UC3A364__)  || defined(__AVR32_UC3A364S__))
158
                                #define USB_SERIES_UC3A3_AVR32
159
                                #define USB_CAN_BE_DEVICE
160
                                #define USB_CAN_BE_HOST
161
                        #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \
162
                               defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \
163
                               defined(__AVR32_UC3A464__)  || defined(__AVR32_UC3A464S__))
164
                                #define USB_SERIES_UC3A4_AVR32
165
                                #define USB_CAN_BE_DEVICE
166
                                #define USB_CAN_BE_HOST
167
                        #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \
168
                               defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__))
169
                                #define USB_SERIES_UC3B0_AVR32
170
                                #define USB_CAN_BE_DEVICE
171
                                #define USB_CAN_BE_HOST
172
                        #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \
173
                               defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__))
174
                                #define USB_SERIES_UC3B1_AVR32
175
                                #define USB_CAN_BE_DEVICE
176
                                #define USB_CAN_BE_HOST
177
                        #elif (defined(__AVR_ATxmega128A1U__) || defined(__AVR_ATxmega64A1U__))
178
                                #define USB_SERIES_A1U_XMEGA
179
                                #define USB_CAN_BE_DEVICE
180
                        #elif (defined(__AVR_ATxmega64A3U__) || defined(__AVR_ATxmega128A3U__) || \
181
                               defined(__AVR_ATxmega192A3U__) || defined(__AVR_ATxmega256A3U__))
182
                                #define USB_SERIES_A3U_XMEGA
183
                                #define USB_CAN_BE_DEVICE
184
                        #elif (defined(__AVR_ATxmega256A3BU__))
185
                                #define USB_SERIES_A3BU_XMEGA
186
                                #define USB_CAN_BE_DEVICE
187
                        #elif (defined(__AVR_ATxmega16A4U__) || defined(__AVR_ATxmega32A4U__))
188
                                #define USB_SERIES_A4U_XMEGA
189
                                #define USB_CAN_BE_DEVICE
190
                        #endif
191
                        
192
                        #if (defined(USB_CAN_BE_DEVICE) && defined(USB_CAN_BE_HOST))
193
                                #define USB_CAN_BE_BOTH
194
                        #endif
195

    
196
                        #if defined(USB_HOST_ONLY)
197
                                #if !defined(USB_CAN_BE_HOST)
198
                                        #error USB_HOST_ONLY is not available for the currently selected microcontroller model.
199
                                #else
200
                                        #undef USB_CAN_BE_DEVICE
201
                                        #undef USB_CAN_BE_BOTH
202
                                #endif
203
                        #endif
204

    
205
                        #if defined(USB_DEVICE_ONLY)
206
                                #if !defined(USB_CAN_BE_DEVICE)
207
                                        #error USB_DEVICE_ONLY is not available for the currently selected microcontroller model.
208
                                #else
209
                                        #undef USB_CAN_BE_HOST
210
                                        #undef USB_CAN_BE_BOTH
211
                                #endif
212
                        #endif
213
                        
214
                        #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
215
                                #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
216
                        #endif
217

    
218
                        #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST))
219
                                #error The currently selected device or architecture is not supported under the USB component of the library.
220
                        #endif
221
        #endif
222

    
223
        /* Disable C linkage for C++ Compilers: */
224
                #if defined(__cplusplus)
225
                        }
226
                #endif
227

    
228
#endif
229

    
230
/** @} */