]> git.donarmstrong.com Git - qmk_firmware.git/blob - protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Buttons.h
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[qmk_firmware.git] / protocol / lufa / LUFA-git / LUFA / Drivers / Board / AVR8 / MICROPENDOUS / Buttons.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 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_REV1 MICROPENDOUS_REV1
83  *  \brief Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).
84  *
85  *  See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
86  */
87
88 /** \ingroup Group_Buttons
89  *  \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2
90  *  \brief Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).
91  *
92  *  See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
93  */
94
95 /** \ingroup Group_Buttons
96  *  \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2
97  *  \brief Board specific Buttons driver header for the Micropendous 32U2.
98  *
99  *  \note There are multiple supported Micropendous boards, compile with <code>BOARD = MICROPENDOUS_{VERSION}</code>.
100  *
101  *  Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).
102  *
103  *  <b>BOARD_MICROPENDOUS_1 and BOARD_MICROPENDOUS_32U2</b>:
104  *  <table>
105  *    <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
106  *    <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
107  *  </table>
108  *
109  *  <b>Other Revisions</b>:
110  *  <table>
111  *    <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
112  *    <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>
113  *  </table>
114  *
115  *  @{
116  */
117
118 #ifndef __BUTTONS_MICROPENDOUS_H__
119 #define __BUTTONS_MICROPENDOUS_H__
120
121         /* Includes: */
122                 #include "../../../../Common/Common.h"
123
124         /* Enable C linkage for C++ Compilers: */
125                 #if defined(__cplusplus)
126                         extern "C" {
127                 #endif
128
129         /* Preprocessor Checks: */
130                 #if !defined(__INCLUDE_FROM_BUTTONS_H)
131                         #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
132                 #endif
133
134         /* Private Interface - For use in library only: */
135         #if !defined(__DOXYGEN__)
136                 #if (BOARD == BOARD_MICROPENDOUS_32U2)
137                         #define _BOARD_BUTTON1_MASK             (1 << 7)
138                         #define _BOARD_BUTTON_PORTLETTER        D
139                 #elif (BOARD == BOARD_MICROPENDOUS_A)
140                         #define _BOARD_BUTTON1_MASK             (1 << 2)
141                         #define _BOARD_BUTTON_PORTLETTER        E
142                 #elif (BOARD == BOARD_MICROPENDOUS_1)
143                         #define _BOARD_BUTTON1_MASK             (1 << 7)
144                         #define _BOARD_BUTTON_PORTLETTER        D
145                 #elif (BOARD == BOARD_MICROPENDOUS_2)
146                         #define _BOARD_BUTTON1_MASK             (1 << 2)
147                         #define _BOARD_BUTTON_PORTLETTER        E
148                 #elif (BOARD == BOARD_MICROPENDOUS_3)
149                         #define _BOARD_BUTTON1_MASK             (1 << 2)
150                         #define _BOARD_BUTTON_PORTLETTER        E
151                 #elif (BOARD == BOARD_MICROPENDOUS_4)
152                         #define _BOARD_BUTTON1_MASK             (1 << 2)
153                         #define _BOARD_BUTTON_PORTLETTER        E
154                 #elif (BOARD == BOARD_MICROPENDOUS_DIP)
155                         #define _BOARD_BUTTON1_MASK             (1 << 2)
156                         #define _BOARD_BUTTON_PORTLETTER        E
157                 #elif (BOARD == BOARD_MICROPENDOUS_REV1)
158                         #define _BOARD_BUTTON1_MASK             (1 << 2)
159                         #define _BOARD_BUTTON_PORTLETTER        E
160                 #elif (BOARD == BOARD_MICROPENDOUS_REV2)
161                         #define _BOARD_BUTTON1_MASK             (1 << 2)
162                         #define _BOARD_BUTTON_PORTLETTER        E
163                 #endif
164
165                 #define _BOARD_BUTTON_PORT                  CONCAT_EXPANDED(PORT, _BOARD_BUTTON_PORTLETTER)
166                 #define _BOARD_BUTTON_PIN                   CONCAT_EXPANDED(PIN,  _BOARD_BUTTON_PORTLETTER)
167                 #define _BOARD_BUTTON_DDR                   CONCAT_EXPANDED(DDR,  _BOARD_BUTTON_PORTLETTER)
168         #endif
169
170         /* Public Interface - May be used in end-application: */
171                 /* Macros: */
172                         /** Button mask for the first button on the board. */
173                         #define BUTTONS_BUTTON1     _BOARD_BUTTON1_MASK
174
175                 /* Inline Functions: */
176                 #if !defined(__DOXYGEN__)
177                         static inline void Buttons_Init(void)
178                         {
179                                 _BOARD_BUTTON_DDR  &= ~BUTTONS_BUTTON1;
180                                 _BOARD_BUTTON_PORT |=  BUTTONS_BUTTON1;
181                         }
182
183                         static inline void Buttons_Disable(void)
184                         {
185                                 _BOARD_BUTTON_DDR  &= ~BUTTONS_BUTTON1;
186                                 _BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1;
187                         }
188
189                         static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
190                         static inline uint8_t Buttons_GetStatus(void)
191                         {
192                                 return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
193                         }
194                 #endif
195
196         /* Disable C linkage for C++ Compilers: */
197                 #if defined(__cplusplus)
198                         }
199                 #endif
200
201 #endif
202
203 /** @} */
204
205