]> git.donarmstrong.com Git - qmk_firmware.git/blob - protocol/lufa/LUFA-120730/LUFA/Drivers/Board/LEDs.h
Change TOP_DIR to TMK_DIR in makefiles
[qmk_firmware.git] / protocol / lufa / LUFA-120730 / LUFA / Drivers / Board / LEDs.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 LED board hardware driver.\r
33  *\r
34  *  This file is the master dispatch header file for the board-specific LED driver, for boards containing user\r
35  *  controllable LEDs.\r
36  *\r
37  *  User code should include this file, which will in turn include the correct LED driver header file for the\r
38  *  currently selected board.\r
39  *\r
40  *  If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/LEDs.h file in the user project\r
41  *  directory.\r
42  *\r
43  *  For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
44  */\r
45 \r
46 /** \ingroup Group_BoardDrivers\r
47  *  \defgroup Group_LEDs LEDs Driver - LUFA/Drivers/Board/LEDs.h\r
48  *  \brief LED board hardware driver.\r
49  *\r
50  *  \section Sec_Dependencies Module Source Dependencies\r
51  *  The following files must be built with any user project that uses this module:\r
52  *    - None\r
53  *\r
54  *  \section Sec_ModDescription Module Description\r
55  *  Hardware LEDs driver. This provides an easy to use driver for the hardware LEDs present on many boards. It\r
56  *  provides an interface to configure, test and change the status of all the board LEDs.\r
57  *\r
58  *  If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/LEDs.h file in the user project\r
59  *  directory. Otherwise, it will include the appropriate built in board driver header file. If the BOARD value\r
60  *  is set to \c BOARD_NONE, this driver is silently disabled.\r
61  *\r
62  *  For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
63  *\r
64  *  \note To make code as compatible as possible, it is assumed that all boards carry a minimum of four LEDs. If\r
65  *        a board contains less than four LEDs, the remaining LED masks are defined to 0 so as to have no effect.\r
66  *        If other behavior is desired, either alias the remaining LED masks to existing LED masks via the -D\r
67  *        switch in the project makefile, or alias them to nothing in the makefile to cause compilation errors when\r
68  *        a non-existing LED is referenced in application code. Note that this means that it is possible to make\r
69  *        compatible code for a board with no LEDs by making a board LED driver (see \ref Page_WritingBoardDrivers)\r
70  *        which contains only stub functions and defines no LEDs.\r
71  *\r
72  *  \section Sec_ExampleUsage Example Usage\r
73  *  The following snippet is an example of how this module may be used within a typical\r
74  *  application.\r
75  *\r
76  *  \code\r
77  *      // Initialize the board LED driver before first use\r
78  *      LEDs_Init();\r
79  *      \r
80  *      // Turn on each of the four LEDs in turn\r
81  *      LEDs_SetAllLEDs(LEDS_LED1);\r
82  *      Delay_MS(500);\r
83  *      LEDs_SetAllLEDs(LEDS_LED2);\r
84  *      Delay_MS(500);\r
85  *      LEDs_SetAllLEDs(LEDS_LED3);\r
86  *      Delay_MS(500);\r
87  *      LEDs_SetAllLEDs(LEDS_LED4);\r
88  *      Delay_MS(500);\r
89  *      \r
90  *      // Turn on all LEDs\r
91  *      LEDs_SetAllLEDs(LEDS_ALL_LEDS);\r
92  *      Delay_MS(1000);\r
93  *      \r
94  *      // Turn on LED 1, turn off LED 2, leaving LEDs 3 and 4 in their current state\r
95  *      LEDs_ChangeLEDs((LEDS_LED1 | LEDS_LED2), LEDS_LED1);\r
96  *  \endcode\r
97  *\r
98  *  @{\r
99  */\r
100 \r
101 #ifndef __LEDS_H__\r
102 #define __LEDS_H__\r
103 \r
104         /* Macros: */\r
105                 #define __INCLUDE_FROM_LEDS_H\r
106 \r
107         /* Includes: */\r
108                 #include "../../Common/Common.h"\r
109 \r
110                 #if (BOARD == BOARD_NONE)\r
111                         static inline void LEDs_Init(void) {};\r
112                         static inline void LEDs_Disable(void) {};\r
113                         static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask) {};\r
114                         static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask) {};\r
115                         static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask) {};\r
116                         static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask, const uint_reg_t ActiveMask) {};\r
117                         static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask) {};\r
118                         static inline uint_reg_t LEDs_GetLEDs(void) { return 0; }\r
119                 #elif (BOARD == BOARD_USBKEY)\r
120                         #include "AVR8/USBKEY/LEDs.h"\r
121                 #elif (BOARD == BOARD_STK525)\r
122                         #include "AVR8/STK525/LEDs.h"\r
123                 #elif (BOARD == BOARD_STK526)\r
124                         #include "AVR8/STK526/LEDs.h"\r
125                 #elif (BOARD == BOARD_RZUSBSTICK)\r
126                         #include "AVR8/RZUSBSTICK/LEDs.h"\r
127                 #elif (BOARD == BOARD_ATAVRUSBRF01)\r
128                         #include "AVR8/ATAVRUSBRF01/LEDs.h"\r
129                 #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))\r
130                         #include "AVR8/XPLAIN/LEDs.h"\r
131                 #elif (BOARD == BOARD_BUMBLEB)\r
132                         #include "AVR8/BUMBLEB/LEDs.h"\r
133                 #elif (BOARD == BOARD_EVK527)\r
134                         #include "AVR8/EVK527/LEDs.h"\r
135                 #elif ((BOARD == BOARD_TEENSY) || (BOARD == BOARD_TEENSY2))\r
136                         #include "AVR8/TEENSY/LEDs.h"\r
137                 #elif (BOARD == BOARD_USBTINYMKII)\r
138                         #include "AVR8/USBTINYMKII/LEDs.h"\r
139                 #elif (BOARD == BOARD_BENITO)\r
140                         #include "AVR8/BENITO/LEDs.h"\r
141                 #elif (BOARD == BOARD_JMDBU2)\r
142                         #include "AVR8/JMDBU2/LEDs.h"\r
143                 #elif (BOARD == BOARD_OLIMEX162)\r
144                         #include "AVR8/OLIMEX162/LEDs.h"\r
145                 #elif (BOARD == BOARD_USBFOO)\r
146                         #include "AVR8/USBFOO/LEDs.h"\r
147                 #elif (BOARD == BOARD_UDIP)\r
148                         #include "AVR8/UDIP/LEDs.h"\r
149                 #elif (BOARD == BOARD_BUI)\r
150                         #include "AVR8/BUI/LEDs.h"\r
151                 #elif (BOARD == BOARD_UNO)\r
152                         #include "AVR8/UNO/LEDs.h"\r
153                 #elif (BOARD == BOARD_CULV3)\r
154                         #include "AVR8/CULV3/LEDs.h"\r
155                 #elif (BOARD == BOARD_BLACKCAT)\r
156                         #include "AVR8/BLACKCAT/LEDs.h"\r
157                 #elif (BOARD == BOARD_MAXIMUS)\r
158                         #include "AVR8/MAXIMUS/LEDs.h"\r
159                 #elif (BOARD == BOARD_MINIMUS)\r
160                         #include "AVR8/MINIMUS/LEDs.h"\r
161                 #elif (BOARD == BOARD_ADAFRUITU4)\r
162                         #include "AVR8/ADAFRUITU4/LEDs.h"\r
163                 #elif (BOARD == BOARD_MICROSIN162)\r
164                         #include "AVR8/MICROSIN162/LEDs.h"\r
165                 #elif (BOARD == BOARD_SPARKFUN8U2)\r
166                         #include "AVR8/SPARKFUN8U2/LEDs.h"\r
167                 #elif (BOARD == BOARD_EVK1101)\r
168                         #include "UC3/EVK1101/LEDs.h"\r
169                 #elif (BOARD == BOARD_TUL)\r
170                         #include "AVR8/TUL/LEDs.h"\r
171                 #elif (BOARD == BOARD_EVK1100)\r
172                         #include "UC3/EVK1100/LEDs.h"\r
173                 #elif (BOARD == BOARD_EVK1104)\r
174                         #include "UC3/EVK1104/LEDs.h"\r
175                 #elif (BOARD == BOARD_A3BU_XPLAINED)\r
176                         #include "XMEGA/A3BU_XPLAINED/LEDs.h"\r
177                 #elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3))\r
178                         #include "AVR8/USB2AX/LEDs.h"\r
179                 #elif ((BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \\r
180                        (BOARD == BOARD_MICROPENDOUS_32U2))\r
181                         #include "AVR8/MICROPENDOUS/LEDs.h"\r
182                 #elif (BOARD == BOARD_B1_XPLAINED)\r
183                         #include "XMEGA/B1_XPLAINED/LEDs.h"\r
184                 #elif (BOARD == BOARD_MULTIO)\r
185                         #include "AVR8/MULTIO/LEDs.h"\r
186                 #elif (BOARD == BOARD_BIGMULTIO)\r
187                         #include "AVR8/BIGMULTIO/LEDs.h"\r
188                 #elif (BOARD == BOARD_DUCE)\r
189                         #include "AVR8/DUCE/LEDs.h"\r
190                 #elif (BOARD == BOARD_OLIMEX32U4)\r
191                         #include "AVR8/OLIMEX32U4/LEDs.h"               \r
192                 #elif (BOARD == BOARD_OLIMEXT32U4)\r
193                         #include "AVR8/OLIMEXT32U4/LEDs.h"              \r
194                 #elif (BOARD == BOARD_OLIMEXISPMK2)\r
195                         #include "AVR8/OLIMEXISPMK2/LEDs.h"             \r
196                 #else\r
197                         #include "Board/LEDs.h"\r
198                 #endif\r
199 \r
200         /* Preprocessor Checks: */\r
201                 #if !defined(__DOXYGEN__)\r
202                         #if !defined(LEDS_LED1)\r
203                                 #define LEDS_LED1      0\r
204                         #endif\r
205 \r
206                         #if !defined(LEDS_LED2)\r
207                                 #define LEDS_LED2      0\r
208                         #endif\r
209 \r
210                         #if !defined(LEDS_LED3)\r
211                                 #define LEDS_LED3      0\r
212                         #endif\r
213 \r
214                         #if !defined(LEDS_LED4)\r
215                                 #define LEDS_LED4      0\r
216                         #endif\r
217                 #endif\r
218 \r
219         /* Pseudo-Functions for Doxygen: */\r
220         #if defined(__DOXYGEN__)\r
221                 /** Initializes the board LED driver so that the LEDs can be controlled. This sets the appropriate port\r
222                  *  I/O pins as outputs, and sets the LEDs to default to off.\r
223                  */\r
224                 static inline void LEDs_Init(void);\r
225 \r
226                 /** Disables the board LED driver, releasing the I/O pins back to their default high-impedance input mode. */\r
227                 static inline void LEDs_Disable(void);\r
228 \r
229                 /** Turns on the LEDs specified in the given LED mask.\r
230                  *\r
231                  *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
232                  */\r
233                 static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask);\r
234 \r
235                 /** Turns off the LEDs specified in the given LED mask.\r
236                  *\r
237                  *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
238                  */\r
239                 static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask);\r
240 \r
241                 /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED\r
242                  *  mask.\r
243                  *\r
244                  *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
245                  */\r
246                 static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask);\r
247 \r
248                 /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs\r
249                  *  specified in both the LED and active masks.\r
250                  *\r
251                  *  \param[in] LEDMask     Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
252                  *  \param[in] ActiveMask  Mask of whether the LEDs in the LED mask should be turned on or off.\r
253                  */\r
254                 static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask,\r
255                                                    const uint_reg_t ActiveMask);\r
256 \r
257                 /** Toggles all LEDs in the LED mask, leaving all others in their current states.\r
258                  *\r
259                  *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
260                  */\r
261                 static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask);\r
262 \r
263                 /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the\r
264                  *  corresponding LED is on.\r
265                  *\r
266                  *  \return Mask of the board LEDs which are currently turned on.\r
267                  */\r
268                 static inline uint_reg_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
269         #endif\r
270 \r
271 #endif\r
272 \r
273 /** @} */\r
274 \r