Initial restructuring of the core USB driver module to support multiple architectures...
[pub/USBasp.git] / LUFA / Drivers / USB / Core / USBMode.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 USB mode and capability macros.
33 *
34 * This file defines macros indicating the type of USB controller the library is being compiled for, and its
35 * capabilities. These macros may then be referenced in the user application to selectively enable or disable
36 * code sections depending on if they are defined or not.
37 *
38 * \note This file should not be included directly. It is automatically included as needed by the USB driver
39 * dispatch header located in LUFA/Drivers/USB/USB.h.
40 */
41
42 /** \ingroup Group_USB
43 * \defgroup Group_USBMode USB Mode Tokens
44 *
45 * After the inclusion of the master USB driver header, one or more of the following
46 * tokens may be defined, to allow the user code to conditionally enable or disable
47 * code based on the USB controller family and allowable USB modes. These tokens may
48 * be tested against to eliminate code relating to a USB mode which is not enabled for
49 * the given compilation.
50 *
51 * @{
52 */
53
54 #ifndef __USBMODE_H__
55 #define __USBMODE_H__
56
57 /* Preprocessor Checks: */
58 #if !defined(__INCLUDE_FROM_USB_DRIVER)
59 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
60 #endif
61
62 /* Public Interface - May be used in end-application: */
63 #if defined(__DOXYGEN__)
64 /** Indicates that the target AVR microcontroller belongs to the Series 2 USB controller
65 * (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined.
66 */
67 #define USB_SERIES_2_AVR
68
69 /** Indicates that the target AVR microcontroller belongs to the Series 4 USB controller
70 * (i.e. ATMEGAxxU4) when defined.
71 */
72 #define USB_SERIES_4_AVR
73
74 /** Indicates that the target AVR microcontroller belongs to the Series 6 USB controller
75 * (i.e. AT90USBxxx6) when defined.
76 */
77 #define USB_SERIES_6_AVR
78
79 /** Indicates that the target AVR microcontroller belongs to the Series 7 USB controller
80 * (i.e. AT90USBxxx7) when defined.
81 */
82 #define USB_SERIES_7_AVR
83
84 /** Indicates that the target AVR microcontroller and compilation settings allow for the
85 * target to be configured in USB Device mode when defined.
86 */
87 #define USB_CAN_BE_DEVICE
88
89 /** Indicates that the target AVR microcontroller and compilation settings allow for the
90 * target to be configured in USB Host mode when defined.
91 */
92 #define USB_CAN_BE_HOST
93
94 /** Indicates that the target AVR microcontroller and compilation settings allow for the
95 * target to be configured in either USB Device or Host mode when defined.
96 */
97 #define USB_CAN_BE_BOTH
98 #else
99 /* Macros: */
100 #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
101 defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
102 #define USB_SERIES_2_AVR
103 #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__))
104 #define USB_SERIES_4_AVR
105 #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
106 #define USB_SERIES_6_AVR
107 #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
108 #define USB_SERIES_7_AVR
109 #endif
110
111 #if !defined(USB_SERIES_7_AVR)
112 #if defined(USB_HOST_ONLY)
113 #error USB_HOST_ONLY is not available for the currently selected USB AVR model.
114 #endif
115
116 #if !defined(USB_DEVICE_ONLY)
117 #define USB_DEVICE_ONLY
118 #endif
119 #endif
120
121 #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))
122 #define USB_CAN_BE_BOTH
123 #define USB_CAN_BE_HOST
124 #define USB_CAN_BE_DEVICE
125 #elif defined(USB_HOST_ONLY)
126 #define USB_CAN_BE_HOST
127 #elif defined(USB_DEVICE_ONLY)
128 #define USB_CAN_BE_DEVICE
129 #endif
130
131 #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
132 #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
133 #endif
134 #endif
135
136 #endif
137
138 /** @} */