]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/infinity60/led.c
fixed two typos
[qmk_firmware.git] / keyboards / infinity60 / led.c
1 /*
2 Copyright 2015 Jun Wako <wakojun@gmail.com>
3 Copyright 2017 jpetermans <tibcmhhm@gmail.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "hal.h"
20
21 #include "led.h"
22
23 #include "led_controller.h"
24
25 /* WARNING! This function needs to be callable from
26  * both regular threads and ISRs, unlocked (during resume-from-sleep).
27  * In particular, I2C functions (interrupt-driven) should NOT be called from here.
28  */
29 void led_set(uint8_t usb_led) {
30     msg_t msg;
31
32     if (usb_led & (1<<USB_LED_NUM_LOCK)) {
33         chSysUnconditionalLock();
34         msg=(1 << 8) | TOGGLE_NUM_LOCK;
35         chMBPostI(&led_mailbox, msg);
36         chSysUnconditionalUnlock();
37     } else {
38         chSysUnconditionalLock();
39         msg=(0 << 8) | TOGGLE_NUM_LOCK;
40         chMBPostI(&led_mailbox, msg);
41         chSysUnconditionalUnlock();
42     }
43     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
44         chSysUnconditionalLock();
45         msg=(1 << 8) | TOGGLE_CAPS_LOCK;
46         chMBPostI(&led_mailbox, msg);
47         chSysUnconditionalUnlock();
48     } else {
49         chSysUnconditionalLock();
50         msg=(0 << 8) | TOGGLE_CAPS_LOCK;
51         chMBPostI(&led_mailbox, msg);
52         chSysUnconditionalUnlock();
53     }
54 }