]> git.donarmstrong.com Git - qmk_firmware.git/blob - protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h
Change TOP_DIR to TMK_DIR in makefiles
[qmk_firmware.git] / protocol / lufa / LUFA-120730 / LUFA / Drivers / USB / Core / XMEGA / USBInterrupt_XMEGA.h
1 /*\r
2              LUFA Library\r
3      Copyright (C) Dean Camera, 2012.\r
4 \r
5   dean [at] fourwalledcubicle [dot] com\r
6            www.lufa-lib.org\r
7 */\r
8 \r
9 /*\r
10   Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
11 \r
12   Permission to use, copy, modify, distribute, and sell this\r
13   software and its documentation for any purpose is hereby granted\r
14   without fee, provided that the above copyright notice appear in\r
15   all copies and that both that the copyright notice and this\r
16   permission notice and warranty disclaimer appear in supporting\r
17   documentation, and that the name of the author not be used in\r
18   advertising or publicity pertaining to distribution of the\r
19   software without specific, written prior permission.\r
20 \r
21   The author disclaim all warranties with regard to this\r
22   software, including all implied warranties of merchantability\r
23   and fitness.  In no event shall the author be liable for any\r
24   special, indirect or consequential damages or any damages\r
25   whatsoever resulting from loss of use, data or profits, whether\r
26   in an action of contract, negligence or other tortious action,\r
27   arising out of or in connection with the use or performance of\r
28   this software.\r
29 */\r
30 \r
31 /** \file\r
32  *  \brief USB Controller Interrupt definitions for the AVR XMEGA microcontrollers.\r
33  *\r
34  *  This file contains definitions required for the correct handling of low level USB service routine interrupts\r
35  *  from the USB controller.\r
36  *\r
37  *  \note This file should not be included directly. It is automatically included as needed by the USB driver\r
38  *        dispatch header located in LUFA/Drivers/USB/USB.h.\r
39  */\r
40 \r
41 #ifndef __USBINTERRUPT_XMEGA_H__\r
42 #define __USBINTERRUPT_XMEGA_H__\r
43 \r
44         /* Includes: */\r
45                 #include "../../../../Common/Common.h"\r
46 \r
47         /* Enable C linkage for C++ Compilers: */\r
48                 #if defined(__cplusplus)\r
49                         extern "C" {\r
50                 #endif\r
51 \r
52         /* Preprocessor Checks: */\r
53                 #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
54                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
55                 #endif\r
56 \r
57         /* Private Interface - For use in library only: */\r
58         #if !defined(__DOXYGEN__)\r
59                 /* Enums: */\r
60                         enum USB_Interrupts_t\r
61                         {\r
62                                 USB_INT_BUSEVENTI         = 1,\r
63                                 USB_INT_BUSEVENTI_Suspend = 2,\r
64                                 USB_INT_BUSEVENTI_Resume  = 3,\r
65                                 USB_INT_BUSEVENTI_Reset   = 4,\r
66                                 USB_INT_SOFI              = 5,\r
67                         };\r
68 \r
69                 /* Inline Functions: */\r
70                         static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
71                         static inline void USB_INT_Enable(const uint8_t Interrupt)\r
72                         {\r
73                                 switch (Interrupt)\r
74                                 {\r
75                                         case USB_INT_BUSEVENTI:\r
76                                                 USB.INTCTRLA |= USB_BUSEVIE_bm;\r
77                                                 return;\r
78                                         case USB_INT_SOFI:\r
79                                                 USB.INTCTRLA |= USB_SOFIE_bm;\r
80                                                 return;\r
81                                 }\r
82                         }\r
83 \r
84                         static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
85                         static inline void USB_INT_Disable(const uint8_t Interrupt)\r
86                         {\r
87                                 switch (Interrupt)\r
88                                 {\r
89                                         case USB_INT_BUSEVENTI:\r
90                                                 USB.INTCTRLA &= ~USB_BUSEVIE_bm;\r
91                                                 return;\r
92                                         case USB_INT_SOFI:\r
93                                                 USB.INTCTRLA &= ~USB_SOFIE_bm;\r
94                                                 return;\r
95                                 }\r
96                         }\r
97 \r
98                         static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
99                         static inline void USB_INT_Clear(const uint8_t Interrupt)\r
100                         {\r
101                                 switch (Interrupt)\r
102                                 {\r
103                                         case USB_INT_BUSEVENTI_Suspend:\r
104                                                 USB.INTFLAGSACLR = USB_SUSPENDIF_bm;\r
105                                                 return;\r
106                                         case USB_INT_BUSEVENTI_Resume:\r
107                                                 USB.INTFLAGSACLR = USB_RESUMEIF_bm;\r
108                                                 return;\r
109                                         case USB_INT_BUSEVENTI_Reset:\r
110                                                 USB.INTFLAGSACLR = USB_RSTIF_bm;\r
111                                                 return;\r
112                                         case USB_INT_SOFI:\r
113                                                 USB.INTFLAGSACLR = USB_SOFIF_bm;\r
114                                                 return;\r
115                                 }\r
116                         }\r
117 \r
118                         static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
119                         static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)\r
120                         {\r
121                                 switch (Interrupt)\r
122                                 {\r
123                                         case USB_INT_BUSEVENTI:\r
124                                                 return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false);\r
125                                         case USB_INT_SOFI:\r
126                                                 return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false);\r
127                                 }\r
128 \r
129                                 return false;\r
130                         }\r
131 \r
132                         static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
133                         static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)\r
134                         {\r
135                                 switch (Interrupt)\r
136                                 {\r
137                                         case USB_INT_BUSEVENTI_Suspend:\r
138                                                 return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false);\r
139                                         case USB_INT_BUSEVENTI_Resume:\r
140                                                 return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false);\r
141                                         case USB_INT_BUSEVENTI_Reset:\r
142                                                 return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false);\r
143                                         case USB_INT_SOFI:\r
144                                                 return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false);\r
145                                 }\r
146 \r
147                                 return false;\r
148                         }\r
149 \r
150                 /* Includes: */\r
151                         #include "../USBMode.h"\r
152                         #include "../Events.h"\r
153                         #include "../USBController.h"\r
154 \r
155                 /* Function Prototypes: */\r
156                         void USB_INT_ClearAllInterrupts(void);\r
157                         void USB_INT_DisableAllInterrupts(void);\r
158         #endif\r
159 \r
160         /* Disable C linkage for C++ Compilers: */\r
161                 #if defined(__cplusplus)\r
162                         }\r
163                 #endif\r
164 \r
165 #endif\r
166 \r