kmac.c (1558B)
1 /* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se> 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 #include "quantum.h" 17 18 #define F_ROW_MASK 0b01 19 #define WASD_MASK 0b10 20 21 void backlight_init_ports(void) { 22 gpio_set_pin_output(B1); 23 gpio_set_pin_output(B2); 24 gpio_set_pin_output(B3); 25 gpio_set_pin_output(B4); 26 gpio_set_pin_output(D7); 27 } 28 29 /* Backlight pin configuration 30 * F-row: High PB1 31 * W: Low PB4 32 * A: Low PB2 33 * S: Low PB3 34 * D: Low PD7 35 */ 36 void backlight_set(uint8_t level) { 37 // F-row 38 if (level & F_ROW_MASK) { 39 gpio_write_pin_high(B1); 40 } else { 41 gpio_write_pin_low(B1); 42 } 43 44 // WASD 45 if (level & WASD_MASK) { 46 gpio_write_pin_low(B2); 47 gpio_write_pin_low(B3); 48 gpio_write_pin_low(B4); 49 gpio_write_pin_low(D7); 50 } else { 51 gpio_write_pin_high(B2); 52 gpio_write_pin_high(B3); 53 gpio_write_pin_high(B4); 54 gpio_write_pin_high(D7); 55 } 56 }