]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[tmk_keyboard.git] / protocol / lufa / LUFA-git / LUFA / Drivers / USB / Core / XMEGA / USBInterrupt_XMEGA.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 USB Controller Interrupt definitions for the AVR XMEGA microcontrollers.
33 *
34 * This file contains definitions required for the correct handling of low level USB service routine interrupts
35 * from the USB controller.
36 *
37 * \note This file should not be included directly. It is automatically included as needed by the USB driver
38 * dispatch header located in LUFA/Drivers/USB/USB.h.
39 */
40
41 #ifndef __USBINTERRUPT_XMEGA_H__
42 #define __USBINTERRUPT_XMEGA_H__
43
44 /* Includes: */
45 #include "../../../../Common/Common.h"
46
47 /* Enable C linkage for C++ Compilers: */
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif
51
52 /* Preprocessor Checks: */
53 #if !defined(__INCLUDE_FROM_USB_DRIVER)
54 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
55 #endif
56
57 /* Private Interface - For use in library only: */
58 #if !defined(__DOXYGEN__)
59 /* Enums: */
60 enum USB_Interrupts_t
61 {
62 USB_INT_BUSEVENTI = 1,
63 USB_INT_BUSEVENTI_Suspend = 2,
64 USB_INT_BUSEVENTI_Resume = 3,
65 USB_INT_BUSEVENTI_Reset = 4,
66 USB_INT_SOFI = 5,
67 };
68
69 /* Inline Functions: */
70 static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
71 static inline void USB_INT_Enable(const uint8_t Interrupt)
72 {
73 switch (Interrupt)
74 {
75 case USB_INT_BUSEVENTI:
76 USB.INTCTRLA |= USB_BUSEVIE_bm;
77 break;
78 case USB_INT_SOFI:
79 USB.INTCTRLA |= USB_SOFIE_bm;
80 break;
81 default:
82 break;
83 }
84 }
85
86 static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
87 static inline void USB_INT_Disable(const uint8_t Interrupt)
88 {
89 switch (Interrupt)
90 {
91 case USB_INT_BUSEVENTI:
92 USB.INTCTRLA &= ~USB_BUSEVIE_bm;
93 break;
94 case USB_INT_SOFI:
95 USB.INTCTRLA &= ~USB_SOFIE_bm;
96 break;
97 default:
98 break;
99 }
100 }
101
102 static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
103 static inline void USB_INT_Clear(const uint8_t Interrupt)
104 {
105 switch (Interrupt)
106 {
107 case USB_INT_BUSEVENTI_Suspend:
108 USB.INTFLAGSACLR = USB_SUSPENDIF_bm;
109 break;
110 case USB_INT_BUSEVENTI_Resume:
111 USB.INTFLAGSACLR = USB_RESUMEIF_bm;
112 break;
113 case USB_INT_BUSEVENTI_Reset:
114 USB.INTFLAGSACLR = USB_RSTIF_bm;
115 break;
116 case USB_INT_SOFI:
117 USB.INTFLAGSACLR = USB_SOFIF_bm;
118 break;
119 default:
120 break;
121 }
122 }
123
124 static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
125 static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
126 {
127 switch (Interrupt)
128 {
129 case USB_INT_BUSEVENTI:
130 return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false);
131 case USB_INT_SOFI:
132 return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false);
133 default:
134 return false;
135 }
136 }
137
138 static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
139 static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
140 {
141 switch (Interrupt)
142 {
143 case USB_INT_BUSEVENTI_Suspend:
144 return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false);
145 case USB_INT_BUSEVENTI_Resume:
146 return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false);
147 case USB_INT_BUSEVENTI_Reset:
148 return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false);
149 case USB_INT_SOFI:
150 return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false);
151 default:
152 return false;
153 }
154 }
155
156 /* Includes: */
157 #include "../USBMode.h"
158 #include "../Events.h"
159 #include "../USBController.h"
160
161 /* Function Prototypes: */
162 void USB_INT_ClearAllInterrupts(void);
163 void USB_INT_DisableAllInterrupts(void);
164 #endif
165
166 /* Disable C linkage for C++ Compilers: */
167 #if defined(__cplusplus)
168 }
169 #endif
170
171 #endif
172
Imprint / Impressum