]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBController.h
merging tmk
[qmk_firmware.git] / tmk_core / protocol / lufa / LUFA-git / LUFA / Drivers / USB / Core / USBController.h
1 /*
2              LUFA Library
3      Copyright (C) Dean Camera, 2014.
4
5   dean [at] fourwalledcubicle [dot] com
6            www.lufa-lib.org
7 */
8
9 /*
10   Copyright 2014  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 disclaims 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 Controller definitions for all architectures.
33  *  \copydetails Group_USBManagement
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_USBManagement USB Interface Management
41  *  \brief USB Controller definitions for general USB controller management.
42  *
43  *  Functions, macros, variables, enums and types related to the setup and management of the USB interface.
44  *
45  *  @{
46  */
47
48 #ifndef __USBCONTROLLER_H__
49 #define __USBCONTROLLER_H__
50
51         /* Includes: */
52                 #include "../../../Common/Common.h"
53                 #include "USBMode.h"
54
55         /* Enable C linkage for C++ Compilers: */
56                 #if defined(__cplusplus)
57                         extern "C" {
58                 #endif
59
60         /* Preprocessor Checks and Defines: */
61                 #if !defined(__INCLUDE_FROM_USB_DRIVER)
62                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
63                 #endif
64
65         /* Defines: */
66                 /** \name Endpoint Direction Masks */
67                 //@{
68                 /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
69                  *  direction for comparing with the \c ENDPOINT_DIR_* masks.
70                  */
71                 #define ENDPOINT_DIR_MASK                  0x80
72
73                 /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with
74                  *  the index of the address within a device to obtain the full endpoint address.
75                  */
76                 #define ENDPOINT_DIR_OUT                   0x00
77
78                 /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with
79                  *  the index of the address within a device to obtain the full endpoint address.
80                  */
81                 #define ENDPOINT_DIR_IN                    0x80
82                 //@}
83
84                 /** \name Pipe Direction Masks */
85                 //@{
86                 /** Pipe direction mask, for masking against pipe addresses to retrieve the pipe's
87                  *  direction for comparing with the \c PIPE_DIR_* masks.
88                  */
89                 #define PIPE_DIR_MASK                      0x80
90
91                 /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with
92                  *  the index of the address within a device to obtain the full endpoint address.
93                  */
94                 #define PIPE_DIR_OUT                       0x00
95
96                 /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with
97                  *  the index of the address within a device to obtain the full endpoint address.
98                  */
99                 #define PIPE_DIR_IN                        0x80
100                 //@}
101
102                 /** \name Endpoint/Pipe Type Masks */
103                 //@{
104                 /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
105                  *  with the \c EP_TYPE_* masks to determine the exact type of the endpoint.
106                  */
107                 #define EP_TYPE_MASK                       0x03
108
109                 /** Mask for a CONTROL type endpoint or pipe.
110                  *
111                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
112                  */
113                 #define EP_TYPE_CONTROL                    0x00
114
115                 /** Mask for an ISOCHRONOUS type endpoint or pipe.
116                  *
117                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
118                  */
119                 #define EP_TYPE_ISOCHRONOUS                0x01
120
121                 /** Mask for a BULK type endpoint or pipe.
122                  *
123                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
124                  */
125                 #define EP_TYPE_BULK                       0x02
126
127                 /** Mask for an INTERRUPT type endpoint or pipe.
128                  *
129                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
130                  */
131                 #define EP_TYPE_INTERRUPT                  0x03
132                 //@}
133
134         /* Enums: */
135                 /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
136                  *  user application via \ref USB_CurrentMode.
137                  */
138                 enum USB_Modes_t
139                 {
140                         USB_MODE_None   = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
141                         USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
142                         USB_MODE_Host   = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */
143                         USB_MODE_UID    = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the
144                                               *   USB connector.
145                                               */
146                 };
147
148         /* Architecture Includes: */
149                 #if (ARCH == ARCH_AVR8)
150                         #include "AVR8/USBController_AVR8.h"
151                 #elif (ARCH == ARCH_UC3)
152                         #include "UC3/USBController_UC3.h"
153                 #elif (ARCH == ARCH_XMEGA)
154                         #include "XMEGA/USBController_XMEGA.h"
155                 #endif
156
157         /* Disable C linkage for C++ Compilers: */
158                 #if defined(__cplusplus)
159                         }
160                 #endif
161
162 #endif
163
164 /** @} */
165