Files
qmk/keyboards/infinity60/led.c
T

55 lines
1.7 KiB
C
Raw Normal View History

2016-07-01 17:04:53 +03:00
/*
2017-08-21 17:01:53 -07:00
Copyright 2015 Jun Wako <wakojun@gmail.com>
Copyright 2017 jpetermans <tibcmhhm@gmail.com>
2016-07-01 17:04:53 +03:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <hal.h>
2016-07-01 17:04:53 +03:00
#include "led.h"
2017-04-06 13:45:15 -07:00
#include "led_controller.h"
2016-07-01 17:04:53 +03:00
2017-04-06 13:45:15 -07:00
/* WARNING! This function needs to be callable from
* both regular threads and ISRs, unlocked (during resume-from-sleep).
* In particular, I2C functions (interrupt-driven) should NOT be called from here.
*/
2016-07-01 17:04:53 +03:00
void led_set(uint8_t usb_led) {
2017-04-12 23:32:38 -07:00
msg_t msg;
2017-04-12 23:32:38 -07:00
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
2017-04-06 13:45:15 -07:00
chSysUnconditionalLock();
2017-05-10 15:53:59 -07:00
msg=(1 << 8) | TOGGLE_NUM_LOCK;
2017-04-12 23:32:38 -07:00
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
} else {
chSysUnconditionalLock();
2017-05-10 15:53:59 -07:00
msg=(0 << 8) | TOGGLE_NUM_LOCK;
2017-04-12 23:32:38 -07:00
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
}
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
chSysUnconditionalLock();
2017-05-10 15:53:59 -07:00
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
2017-04-12 23:32:38 -07:00
chMBPostI(&led_mailbox, msg);
2017-04-06 13:45:15 -07:00
chSysUnconditionalUnlock();
} else {
chSysUnconditionalLock();
2017-05-10 15:53:59 -07:00
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
2017-04-12 23:32:38 -07:00
chMBPostI(&led_mailbox, msg);
2017-04-06 13:45:15 -07:00
chSysUnconditionalUnlock();
}
2016-07-01 17:04:53 +03:00
}