]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h
Squashed 'tmk_core/' content from commit 05caacc
[tmk_keyboard.git] / protocol / lufa / LUFA-120730 / LUFA / Drivers / Board / AVR8 / USB2AX / LEDs.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 Board specific LED driver header for the Paranoid Studio USB2AX.
33 * \copydetails Group_LEDs_USB2AX
34 *
35 * \note This file should not be included directly. It is automatically included as needed by the LEDs driver
36 * dispatch header located in LUFA/Drivers/Board/LEDs.h.
37 */
38
39 /** \ingroup Group_LEDs
40 * \defgroup Group_LEDs_USB2AX_V3 USB2AX_V3
41 * \brief Board specific LED driver header for the Paranoid Studio USB2AX revision 3.
42 *
43 * See \ref Group_LEDs_USB2AX for more details.
44 */
45
46 /** \ingroup Group_LEDs
47 * \defgroup Group_LEDs_USB2AX USB2AX
48 * \brief Board specific LED driver header for the Paranoid Studio USB2AX.
49 *
50 * \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.
51 *
52 * Board specific LED driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
53 *
54 * <b>USB2AX</b>:
55 * <table>
56 * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
57 * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTC.6</td></tr>
58 * </table>
59 *
60 * <b>USB2AX_V3</b>:
61 * <table>
62 * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
63 * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.1</td></tr>
64 * </table>
65 *
66 * @{
67 */
68
69 #ifndef __LEDS_USB2AX_H__
70 #define __LEDS_USB2AX_H__
71
72 /* Includes: */
73 #include "../../../../Common/Common.h"
74
75 /* Enable C linkage for C++ Compilers: */
76 #if defined(__cplusplus)
77 extern "C" {
78 #endif
79
80 /* Preprocessor Checks: */
81 #if !defined(__INCLUDE_FROM_LEDS_H)
82 #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
83 #endif
84
85 /* Private Interface - For use in library only: */
86 #if !defined(__DOXYGEN__)
87 /* Macros: */
88 #if (BOARD == BOARD_USB2AX)
89 #define USB2AX_LEDS_LED1 (1 << 6)
90 #else
91 #define USB2AX_LEDS_LED1 (1 << 1)
92 #endif
93 #endif
94
95 /* Public Interface - May be used in end-application: */
96 /* Macros: */
97 /** LED mask for the first LED on the board. */
98 #define LEDS_LED1 USB2AX_LEDS_LED1
99
100 /** LED mask for all the LEDs on the board. */
101 #define LEDS_ALL_LEDS LEDS_LED1
102
103 /** LED mask for none of the board LEDs. */
104 #define LEDS_NO_LEDS 0
105
106 /* Inline Functions: */
107 #if !defined(__DOXYGEN__)
108 static inline void LEDs_Init(void)
109 {
110 #if (BOARD == BOARD_USB2AX)
111 DDRC |= LEDS_ALL_LEDS;
112 PORTC &= ~LEDS_ALL_LEDS;
113 #else
114 DDRD |= LEDS_ALL_LEDS;
115 PORTD &= ~LEDS_ALL_LEDS;
116 #endif
117 }
118
119 static inline void LEDs_Disable(void)
120 {
121 #if (BOARD == BOARD_USB2AX)
122 DDRC &= ~LEDS_ALL_LEDS;
123 PORTC &= ~LEDS_ALL_LEDS;
124 #else
125 DDRD &= ~LEDS_ALL_LEDS;
126 PORTD &= ~LEDS_ALL_LEDS;
127 #endif
128 }
129
130 static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
131 {
132 #if (BOARD == BOARD_USB2AX)
133 PORTC |= LEDMask;
134 #else
135 PORTD |= LEDMask;
136 #endif
137 }
138
139 static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
140 {
141 #if (BOARD == BOARD_USB2AX)
142 PORTC &= ~LEDMask;
143 #else
144 PORTD &= ~LEDMask;
145 #endif
146 }
147
148 static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
149 {
150 #if (BOARD == BOARD_USB2AX)
151 PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask);
152 #else
153 PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
154 #endif
155 }
156
157 static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
158 const uint8_t ActiveMask)
159 {
160 #if (BOARD == BOARD_USB2AX)
161 PORTC = ((PORTC & ~LEDMask) | ActiveMask);
162 #else
163 PORTD = ((PORTD & ~LEDMask) | ActiveMask);
164 #endif
165 }
166
167 static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
168 {
169 #if (BOARD == BOARD_USB2AX)
170 PINC = LEDMask;
171 #else
172 PIND = LEDMask;
173 #endif
174 }
175
176 static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
177 static inline uint8_t LEDs_GetLEDs(void)
178 {
179 #if (BOARD == BOARD_USB2AX)
180 return (PORTC & LEDS_ALL_LEDS);
181 #else
182 return (PORTD & LEDS_ALL_LEDS);
183 #endif
184 }
185 #endif
186
187 /* Disable C linkage for C++ Compilers: */
188 #if defined(__cplusplus)
189 }
190 #endif
191
192 #endif
193
194 /** @} */
195
196
Imprint / Impressum