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