Minor corrections to the XMEGA USB controller implementation.
[pub/USBasp.git] / LUFA / Drivers / Board / AVR8 / MICROPENDOUS / Buttons.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 Board specific Buttons driver header for the Micropendous series boards.
33 * \copydetails Group_Buttons_MICROPENDOUS_32U2
34 *
35 * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
36 * dispatch header located in LUFA/Drivers/Board/Buttons.h.
37 */
38
39 /** \ingroup Group_Buttons
40 * \defgroup Group_Buttons_MICROPENDOUS_A MICROPENDOUS_A
41 * \brief Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA).
42 *
43 * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
44 */
45
46 /** \ingroup Group_Buttons
47 * \defgroup Group_Buttons_MICROPENDOUS_1 MICROPENDOUS_1
48 * \brief Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1).
49 *
50 * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
51 */
52
53 /** \ingroup Group_Buttons
54 * \defgroup Group_Buttons_MICROPENDOUS_2 MICROPENDOUS_2
55 * \brief Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2).
56 *
57 * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
58 */
59
60 /** \ingroup Group_Buttons
61 * \defgroup Group_Buttons_MICROPENDOUS_3 MICROPENDOUS_3
62 * \brief Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3).
63 *
64 * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
65 */
66
67 /** \ingroup Group_Buttons
68 * \defgroup Group_Buttons_MICROPENDOUS_4 MICROPENDOUS_4
69 * \brief Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4).
70 *
71 * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
72 */
73
74 /** \ingroup Group_Buttons
75 * \defgroup Group_Buttons_MICROPENDOUS_DIP MICROPENDOUS_DIP
76 * \brief Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP).
77 *
78 * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
79 */
80
81 /** \ingroup Group_Buttons
82 * \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2
83 * \brief Board specific Buttons driver header for the Micropendous 32U2.
84 *
85 * \note There are multiple supported Micropendous boards, compile with <code>BOARD = MICROPENDOUS_{VERSION}</code>.
86 *
87 * Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).
88 *
89 * @{
90 */
91
92 #ifndef __BUTTONS_MICROPENDOUS_H__
93 #define __BUTTONS_MICROPENDOUS_H__
94
95 /* Includes: */
96 #include "../../../../Common/Common.h"
97
98 /* Enable C linkage for C++ Compilers: */
99 #if defined(__cplusplus)
100 extern "C" {
101 #endif
102
103 /* Preprocessor Checks: */
104 #if !defined(__INCLUDE_FROM_BUTTONS_H)
105 #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
106 #endif
107
108 /* Private Interface - For use in library only: */
109 #if !defined(__DOXYGEN__)
110 #if (BOARD == BOARD_MICROPENDOUS_32U2)
111 #define _BOARD_BUTTON1_MASK (1 << 7)
112 #define _BOARD_BUTTON_PORTLETTER D
113 #elif (BOARD == BOARD_MICROPENDOUS_A)
114 #define _BOARD_BUTTON1_MASK (1 << 2)
115 #define _BOARD_BUTTON_PORTLETTER E
116 #elif (BOARD == BOARD_MICROPENDOUS_1)
117 #define _BOARD_BUTTON1_MASK (1 << 7)
118 #define _BOARD_BUTTON_PORTLETTER D
119 #elif (BOARD == BOARD_MICROPENDOUS_2)
120 #define _BOARD_BUTTON1_MASK (1 << 2)
121 #define _BOARD_BUTTON_PORTLETTER E
122 #elif (BOARD == BOARD_MICROPENDOUS_3)
123 #define _BOARD_BUTTON1_MASK (1 << 2)
124 #define _BOARD_BUTTON_PORTLETTER E
125 #elif (BOARD == BOARD_MICROPENDOUS_4)
126 #define _BOARD_BUTTON1_MASK (1 << 2)
127 #define _BOARD_BUTTON_PORTLETTER E
128 #elif (BOARD == BOARD_MICROPENDOUS_DIP)
129 #define _BOARD_BUTTON1_MASK (1 << 2)
130 #define _BOARD_BUTTON_PORTLETTER E
131 #endif
132
133 #define _BOARD_BUTTON_CONCAT2(Reg, Letter) Reg ## Letter
134 #define _BOARD_BUTTON_CONCAT(Reg, Letter) _BOARD_BUTTON_CONCAT2(Reg, Letter)
135
136 #define _BOARD_BUTTON_PORT _BOARD_BUTTON_CONCAT(PORT, _BOARD_BUTTON_PORTLETTER)
137 #define _BOARD_BUTTON_PIN _BOARD_BUTTON_CONCAT(PIN, _BOARD_BUTTON_PORTLETTER)
138 #define _BOARD_BUTTON_DDR _BOARD_BUTTON_CONCAT(DDR, _BOARD_BUTTON_PORTLETTER)
139 #endif
140
141 /* Public Interface - May be used in end-application: */
142 /* Macros: */
143 /** Button mask for the first button on the board. */
144 #define BUTTONS_BUTTON1 _BOARD_BUTTON1_MASK
145
146 /* Inline Functions: */
147 #if !defined(__DOXYGEN__)
148 static inline void Buttons_Init(void)
149 {
150 _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
151 _BOARD_BUTTON_PORT |= BUTTONS_BUTTON1;
152 }
153
154 static inline void Buttons_Disable(void)
155 {
156 _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
157 _BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1;
158 }
159
160 static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
161 static inline uint8_t Buttons_GetStatus(void)
162 {
163 return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
164 }
165 #endif
166
167 /* Disable C linkage for C++ Compilers: */
168 #if defined(__cplusplus)
169 }
170 #endif
171
172 #endif
173
174 /** @} */
175
176