]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h
Squashed 'tmk_core/' changes from b9e0ea0..caca2c0
[tmk_keyboard.git] / protocol / lufa / LUFA-120730 / LUFA / Drivers / USB / Core / XMEGA / USBInterrupt_XMEGA.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2012.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2012 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 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 return;
78 case USB_INT_SOFI:
79 USB.INTCTRLA |= USB_SOFIE_bm;
80 return;
81 }
82 }
83
84 static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
85 static inline void USB_INT_Disable(const uint8_t Interrupt)
86 {
87 switch (Interrupt)
88 {
89 case USB_INT_BUSEVENTI:
90 USB.INTCTRLA &= ~USB_BUSEVIE_bm;
91 return;
92 case USB_INT_SOFI:
93 USB.INTCTRLA &= ~USB_SOFIE_bm;
94 return;
95 }
96 }
97
98 static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
99 static inline void USB_INT_Clear(const uint8_t Interrupt)
100 {
101 switch (Interrupt)
102 {
103 case USB_INT_BUSEVENTI_Suspend:
104 USB.INTFLAGSACLR = USB_SUSPENDIF_bm;
105 return;
106 case USB_INT_BUSEVENTI_Resume:
107 USB.INTFLAGSACLR = USB_RESUMEIF_bm;
108 return;
109 case USB_INT_BUSEVENTI_Reset:
110 USB.INTFLAGSACLR = USB_RSTIF_bm;
111 return;
112 case USB_INT_SOFI:
113 USB.INTFLAGSACLR = USB_SOFIF_bm;
114 return;
115 }
116 }
117
118 static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
119 static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
120 {
121 switch (Interrupt)
122 {
123 case USB_INT_BUSEVENTI:
124 return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false);
125 case USB_INT_SOFI:
126 return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false);
127 }
128
129 return false;
130 }
131
132 static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
133 static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
134 {
135 switch (Interrupt)
136 {
137 case USB_INT_BUSEVENTI_Suspend:
138 return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false);
139 case USB_INT_BUSEVENTI_Resume:
140 return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false);
141 case USB_INT_BUSEVENTI_Reset:
142 return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false);
143 case USB_INT_SOFI:
144 return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false);
145 }
146
147 return false;
148 }
149
150 /* Includes: */
151 #include "../USBMode.h"
152 #include "../Events.h"
153 #include "../USBController.h"
154
155 /* Function Prototypes: */
156 void USB_INT_ClearAllInterrupts(void);
157 void USB_INT_DisableAllInterrupts(void);
158 #endif
159
160 /* Disable C linkage for C++ Compilers: */
161 #if defined(__cplusplus)
162 }
163 #endif
164
165 #endif
166
Imprint / Impressum