m65s.c (2161B)
1 /* 2 Copyright 2020 Álvaro "Gondolindrim" Volpato <alvaro.volpato@usp.br> 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 "quantum.h" 19 20 void board_init(void) { 21 gpio_set_pin_input(B10); 22 } 23 24 void led_init_ports(void) { 25 26 /** If the OPENDRAIN_INDICATORS option is not defined in config.h, the indicator 27 pins default to push-pull output. Else, they are defined as open-drain. The 28 pin mode configuration is done through the INDICATOR_PIN_MODE which is 29 attributed right at the beggining. **/ 30 31 #ifndef OPENDRAIN_INDICATORS 32 # define INDICATOR_PIN_MODE PAL_MODE_OUTPUT_PUSHPULL 33 #else 34 # define INDICATOR_PIN_MODE PAL_MODE_OUTPUT_OPENDRAIN 35 36 #endif 37 38 #ifdef LED_NUM_LOCK_PIN 39 palSetLineMode(LED_NUM_LOCK_PIN, INDICATOR_PIN_MODE); 40 #endif 41 #ifdef LED_CAPS_LOCK_PIN 42 palSetLineMode(LED_CAPS_LOCK_PIN, INDICATOR_PIN_MODE); 43 #endif 44 #ifdef LED_SCROLL_LOCK_PIN 45 palSetLineMode(LED_SCROLL_LOCK_PIN, INDICATOR_PIN_MODE); 46 #endif 47 #ifdef LED_COMPOSE_PIN 48 palSetLineMode(LED_COMPOSE_PIN, INDICATOR_PIN_MODE); 49 #endif 50 #ifdef LED_KANA_PIN 51 palSetLineMode(LED_KANA_PIN, INDICATOR_PIN_MODE); 52 #endif 53 } 54 55 bool led_update_kb(led_t led_state) { 56 bool res = led_update_user(led_state); 57 if(res) { 58 // gpio_write_pin sets the pin high for 1 and low for 0. 59 // In this example the pins are inverted, setting 60 // it low/0 turns it on, and high/1 turns the LED off. 61 // This behavior depends on whether the LED is between the pin 62 // and VCC or the pin and GND. 63 gpio_write_pin(LED_CAPS_LOCK_PIN, !led_state.caps_lock); 64 } 65 return res; 66 }