2 Copyright 2017 Jack Humbert
\r
4 This program is free software: you can redistribute it and/or modify
\r
5 it under the terms of the GNU General Public License as published by
\r
6 the Free Software Foundation, either version 2 of the License, or
\r
7 (at your option) any later version.
\r
9 This program is distributed in the hope that it will be useful,
\r
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 GNU General Public License for more details.
\r
14 You should have received a copy of the GNU General Public License
\r
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
19 * \brief General driver header for QMK-powered keyboards.
\r
20 * \copydetails Group_LEDs_QMK
\r
22 * \note This file should not be included directly. It is automatically included as needed by the LEDs driver
\r
23 * dispatch header located in LUFA/Drivers/Board/LEDs.h.
\r
26 /** \ingroup Group_LEDs
\r
27 * \defgroup Group_LEDs_QMK QMK
\r
28 * \brief General driver header for QMK-powered keyboards.
\r
30 * General driver header for QMK-powered keyboards (http://qmk.fm).
\r
34 * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
\r
35 * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORT(QMK_LED).6</td></tr>
\r
41 #ifndef __LEDS_QMK_H__
\r
42 #define __LEDS_QMK_H__
\r
45 #include "../../../../Common/Common.h"
\r
47 /* Enable C linkage for C++ Compilers: */
\r
48 #if defined(__cplusplus)
\r
52 /* Preprocessor Checks: */
\r
53 #if !defined(__INCLUDE_FROM_LEDS_H)
\r
54 #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
\r
106 #define QMK_ESC_COL F1
\r
107 #define QMK_ESC_ROW D5
\r
109 #define QMK_SPEAKER C6
\r
111 #define DDR(pin) _SFR_IO8(((pin) >> 4) + 1)
\r
112 #define PORT(pin) _SFR_IO8(((pin) >> 4) + 2)
\r
113 #define PIN(pin) _SFR_IO8((pin) >> 4)
\r
114 #define NUM(pin) _BV((pin) & 0xF)
\r
116 /* Public Interface - May be used in end-application: */
\r
118 /** LED mask for the first LED on the board. */
\r
119 #define LEDS_LED1 NUM(QMK_LED)
\r
120 #define LEDS_LED2 NUM(QMK_SPEAKER)
\r
122 /** LED mask for all the LEDs on the board. */
\r
123 #define LEDS_ALL_LEDS LEDS_LED1 | LEDS_LED2
\r
125 /** LED mask for none of the board LEDs. */
\r
126 #define LEDS_NO_LEDS 0
\r
128 /* Inline Functions: */
\r
129 #if !defined(__DOXYGEN__)
\r
130 static inline void LEDs_Init(void)
\r
132 DDR(QMK_LED) |= LEDS_LED1;
\r
133 PORT(QMK_LED) |= LEDS_LED1;
\r
135 DDR(QMK_SPEAKER) |= LEDS_LED2;
\r
136 PORT(QMK_SPEAKER) |= LEDS_LED2;
\r
139 static inline void LEDs_Disable(void)
\r
141 DDR(QMK_LED) &= ~LEDS_LED1;
\r
142 PORT(QMK_LED) &= ~LEDS_LED2;
\r
144 DDR(QMK_SPEAKER) &= ~LEDS_LED1;
\r
145 PORT(QMK_SPEAKER) &= ~LEDS_LED2;
\r
148 static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
\r
150 PORT(QMK_LED) &= (LEDS_LED1 & ~LEDMask);
\r
151 PORT(QMK_SPEAKER) &= (LEDS_LED2 & ~LEDMask);
\r
154 static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
\r
156 PORT(QMK_LED) |= (LEDS_LED1 & LEDMask);
\r
157 PORT(QMK_SPEAKER) |= (LEDS_LED2 & LEDMask);
\r
160 static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
\r
162 PORT(QMK_LED) = ((PORT(QMK_LED) | LEDS_LED1) & ~LEDMask);
\r
163 PORT(QMK_SPEAKER) = ((PORT(QMK_SPEAKER) | LEDS_LED2) & ~LEDMask);
\r
166 static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
\r
167 const uint8_t ActiveMask)
\r
169 PORT(QMK_LED) = ((PORT(QMK_LED) | (LEDS_LED1 & LEDMask)) & ~ActiveMask);
\r
170 PORT(QMK_SPEAKER) = ((PORT(QMK_SPEAKER) | (LEDS_LED1 & LEDMask)) & ~ActiveMask);
\r
173 static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
\r
175 PIN(QMK_LED) = (LEDS_LED1 & LEDMask);
\r
176 PIN(QMK_SPEAKER) = (LEDS_LED2 & LEDMask);
\r
179 static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
\r
180 static inline uint8_t LEDs_GetLEDs(void)
\r
182 return (~PORT(QMK_LED) & LEDS_LED1) | (~(PORT(QMK_SPEAKER) & LEDS_LED2));
\r
186 /* Disable C linkage for C++ Compilers: */
\r
187 #if defined(__cplusplus)
\r