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