]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/infinity_ergodox/led.c
77195bb358e3663cfa69aa822710a42e5211798b
[qmk_firmware.git] / keyboards / infinity_ergodox / led.c
1 /*
2 Copyright 2012 Jun Wako <wakojun@gmail.com>
3
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.
8
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.
13
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/>.
16 */
17
18 #include "hal.h"
19
20 #include "led.h"
21
22
23 void led_set(uint8_t usb_led) {
24 // The LCD backlight functionality conflicts with this simple
25 // red backlight
26 #if !defined(LCD_BACKLIGHT_ENABLE) && defined(STATUS_LED_ENABLE)
27     // PTC1: LCD Backlight Red(0:on/1:off)
28     GPIOC->PDDR |= (1<<1);
29     PORTC->PCR[1] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
30     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
31         GPIOC->PCOR |= (1<<1);
32     } else {
33         GPIOC->PSOR |= (1<<1);
34     }
35 #elif !defined(LCD_BACKLIGHT_ENABLE)
36     (void)usb_led;
37     GPIOC->PDDR |= (1<<1);
38     PORTC->PCR[1] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
39     GPIOC->PSOR |= (1<<1);
40     GPIOC->PDDR |= (1<<2);
41     PORTC->PCR[2] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
42     GPIOC->PSOR |= (1<<2);
43     GPIOC->PDDR |= (1<<3);
44     PORTC->PCR[3] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
45     GPIOC->PSOR |= (1<<3);
46 #else
47     (void)usb_led;
48 #endif
49 }