qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

m65hi_alpha.c (2160B)


      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 #endif
     36 
     37 #ifdef LED_NUM_LOCK_PIN
     38     palSetLineMode(LED_NUM_LOCK_PIN, INDICATOR_PIN_MODE);
     39 #endif
     40 #ifdef LED_CAPS_LOCK_PIN
     41     palSetLineMode(LED_CAPS_LOCK_PIN, INDICATOR_PIN_MODE);
     42 #endif
     43 #ifdef LED_SCROLL_LOCK_PIN
     44     palSetLineMode(LED_SCROLL_LOCK_PIN, INDICATOR_PIN_MODE);
     45 #endif
     46 #ifdef LED_COMPOSE_PIN
     47     palSetLineMode(LED_COMPOSE_PIN, INDICATOR_PIN_MODE);
     48 #endif
     49 #ifdef LED_KANA_PIN
     50     palSetLineMode(LED_KANA_PIN, INDICATOR_PIN_MODE);
     51 #endif
     52 }
     53 
     54 bool led_update_kb(led_t led_state) {
     55     bool res = led_update_user(led_state);
     56     if(res) {
     57         // gpio_write_pin sets the pin high for 1 and low for 0.
     58         // In this example the pins are inverted, setting
     59         // it low/0 turns it on, and high/1 turns the LED off.
     60         // This behavior depends on whether the LED is between the pin
     61         // and VCC or the pin and GND.
     62         gpio_write_pin(LED_CAPS_LOCK_PIN, !led_state.caps_lock);
     63     }
     64     return res;
     65 }