diff --git a/keyboards/zsa/ergodox_ez/ergodox_ez.c b/keyboards/zsa/ergodox_ez/ergodox_ez.c index df1ab27cbcfe..21436e28971a 100644 --- a/keyboards/zsa/ergodox_ez/ergodox_ez.c +++ b/keyboards/zsa/ergodox_ez/ergodox_ez.c @@ -20,19 +20,20 @@ along with this program. If not, see . #include "ergodox_ez.h" #include "bootmagic.h" +#include "gpio.h" keyboard_config_t keyboard_config; __attribute__((weak)) void keyboard_post_init_sub(void) { - setPinOutput(ERGODOX_LED_1_PIN); - setPinOutput(ERGODOX_LED_2_PIN); - setPinOutput(ERGODOX_LED_3_PIN); + gpio_set_pin_output(ERGODOX_LED_1_PIN); + gpio_set_pin_output(ERGODOX_LED_2_PIN); + gpio_set_pin_output(ERGODOX_LED_3_PIN); } void keyboard_post_init_kb(void) { keyboard_post_init_sub(); #ifdef ERGODOX_LED_SHUTOFF_PIN - setPinOutput(ERGODOX_LED_SHUTOFF_PIN); + gpio_set_pin_output(ERGODOX_LED_SHUTOFF_PIN); #endif keyboard_config.raw = eeconfig_read_kb(); @@ -49,25 +50,28 @@ void keyboard_post_init_kb(void) { void ergodox_board_led_on(void) { #ifdef ERGODOX_LED_SHUTOFF_PIN - writePinHigh(ERGODOX_LED_SHUTOFF_PIN); + gpio_write_pin_high(ERGODOX_LED_SHUTOFF_PIN); #endif } __attribute__((weak)) void ergodox_right_led_1_on(void) { - writePinHigh(ERGODOX_LED_1_PIN); + gpio_set_pin_output(ERGODOX_LED_1_PIN); + gpio_write_pin_high(ERGODOX_LED_1_PIN); } __attribute__((weak)) void ergodox_right_led_2_on(void) { - writePinHigh(ERGODOX_LED_2_PIN); + gpio_set_pin_output(ERGODOX_LED_2_PIN); + gpio_write_pin_high(ERGODOX_LED_2_PIN); } __attribute__((weak)) void ergodox_right_led_3_on(void) { - writePinHigh(ERGODOX_LED_3_PIN); + gpio_set_pin_output(ERGODOX_LED_3_PIN); + gpio_write_pin_high(ERGODOX_LED_3_PIN); } void ergodox_board_led_off(void) { #ifdef ERGODOX_LED_SHUTOFF_PIN - writePinLow(ERGODOX_LED_SHUTOFF_PIN); + gpio_write_pin_low(ERGODOX_LED_SHUTOFF_PIN); #else ergodox_right_led_1_off(); ergodox_right_led_2_off(); @@ -76,15 +80,18 @@ void ergodox_board_led_off(void) { } __attribute__((weak)) void ergodox_right_led_1_off(void) { - setPinInput(ERGODOX_LED_1_PIN); + gpio_set_pin_input(ERGODOX_LED_1_PIN); + gpio_write_pin_low(ERGODOX_LED_1_PIN); } __attribute__((weak)) void ergodox_right_led_2_off(void) { - setPinInput(ERGODOX_LED_2_PIN); + gpio_set_pin_input(ERGODOX_LED_2_PIN); + gpio_write_pin_low(ERGODOX_LED_2_PIN); } __attribute__((weak)) void ergodox_right_led_3_off(void) { - setPinInput(ERGODOX_LED_3_PIN); + gpio_set_pin_input(ERGODOX_LED_3_PIN); + gpio_write_pin_low(ERGODOX_LED_3_PIN); } void ergodox_right_led_on(uint8_t led) { diff --git a/keyboards/zsa/ergodox_ez/keymaps/default/keymap.c b/keyboards/zsa/ergodox_ez/keymaps/default/keymap.c index 0a40cc91fddc..ac80c9985372 100644 --- a/keyboards/zsa/ergodox_ez/keymaps/default/keymap.c +++ b/keyboards/zsa/ergodox_ez/keymaps/default/keymap.c @@ -40,7 +40,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), GUI_T(KC_QUOT), KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), MEH_T(KC_NO), KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), KC_RSFT, - LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, TT(SYMB), + LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, LED_LEVEL, TT(SYMB), ALT_T(KC_APP), KC_LGUI, KC_LALT, CTL_T(KC_ESC), KC_HOME, KC_PGUP, KC_SPC, KC_BSPC, KC_END, KC_PGDN, KC_TAB, KC_ENT @@ -72,7 +72,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, QK_BOOT, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, - EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS, + EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_DOT, KC_0, KC_TRNS, KC_TRNS, RGB_MOD, KC_TRNS, RGB_TOG, RGB_M_P, KC_TRNS, KC_TRNS, RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, RGB_HUD, RGB_HUI diff --git a/keyboards/zsa/ergodox_ez/m32u4/m32u4.c b/keyboards/zsa/ergodox_ez/m32u4/m32u4.c index 699dc0beacb6..7f19250b4227 100644 --- a/keyboards/zsa/ergodox_ez/m32u4/m32u4.c +++ b/keyboards/zsa/ergodox_ez/m32u4/m32u4.c @@ -1,83 +1,55 @@ // Copyright 2023 Christopher Courtney, aka Drashna Jael're (@drashna) // SPDX-License-Identifier: GPL-3.0-or-later -#include #include "ergodox_ez.h" -static uint8_t ergodox_right_led_1_duty; -static uint8_t ergodox_right_led_2_duty; -static uint8_t ergodox_right_led_3_duty; - void ergodox_right_led_1_set(uint8_t n) { - ergodox_right_led_1_duty = n; - if (ergodox_right_led_1_duty == 0) { - ergodox_right_led_1_off(); - } else { - ergodox_right_led_1_on(); - } + OCR1A = n; } - -void ergodox_right_led_1_on(void) { - OCR1A = ergodox_right_led_1_duty; +void ergodox_right_led_2_set(uint8_t n) { + OCR1B = n; } - -void ergodox_right_led_1_off(void) { - OCR1A = 0; +void ergodox_right_led_3_set(uint8_t n) { + OCR1C = n; } -void ergodox_right_led_2_set(uint8_t n) { - ergodox_right_led_2_duty = n; - if (ergodox_right_led_2_duty == 0) { - ergodox_right_led_2_off(); - } else { - ergodox_right_led_2_on(); - } +__attribute__((weak)) void ergodox_right_led_1_on(void) { + gpio_write_pin_high(ERGODOX_LED_1_PIN); } -void ergodox_right_led_2_on(void) { - OCR1B = ergodox_right_led_2_duty; +__attribute__((weak)) void ergodox_right_led_2_on(void) { + gpio_write_pin_high(ERGODOX_LED_2_PIN); } -void ergodox_right_led_2_off(void) { - OCR1B = 0; +__attribute__((weak)) void ergodox_right_led_3_on(void) { + gpio_write_pin_high(ERGODOX_LED_3_PIN); } - -void ergodox_right_led_3_set(uint8_t n) { - ergodox_right_led_3_duty = n; - if (ergodox_right_led_3_duty == 0) { - ergodox_right_led_3_off(); - } else { - ergodox_right_led_3_on(); - } +__attribute__((weak)) void ergodox_right_led_1_off(void) { + gpio_write_pin_low(ERGODOX_LED_1_PIN); } -void ergodox_right_led_3_off(void) { - OCR1C = 0; +__attribute__((weak)) void ergodox_right_led_2_off(void) { + gpio_write_pin_low(ERGODOX_LED_2_PIN); } -void ergodox_right_led_3_on(void) { - OCR1C = ergodox_right_led_3_duty; +__attribute__((weak)) void ergodox_right_led_3_off(void) { + gpio_write_pin_low(ERGODOX_LED_3_PIN); } - void keyboard_post_init_sub(void) { // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md") TCCR1A = 0b10101001; // set and configure fast PWM TCCR1B = 0b00001001; // set and configure fast PWM // (tied to Vcc for hardware convenience) - setPinInput(B4); + gpio_set_pin_input(B4); // unused pins - C7, D4, D5, E6 // set as input with internal pull-up enabled - setPinInputHigh(C7); - setPinInputHigh(D4); - setPinInputHigh(D5); - setPinInputHigh(E6); - - setPinOutput(ERGODOX_LED_1_PIN); - setPinOutput(ERGODOX_LED_2_PIN); - setPinOutput(ERGODOX_LED_3_PIN); + gpio_set_pin_input_high(C7); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D5); + gpio_set_pin_input_high(E6); } #ifdef RGB_MATRIX_ENABLE