diff --git a/keyboards/40percentclub/ut47/led.c b/keyboards/40percentclub/ut47/led.c index 867a6e2e2a..fa431de760 100644 --- a/keyboards/40percentclub/ut47/led.c +++ b/keyboards/40percentclub/ut47/led.c @@ -25,16 +25,14 @@ bool led_update_kb(led_t led_state) if (res) { if (led_state.caps_lock) { // output low - DDRB |= (1<<0); - PORTB &= ~(1<<0); - DDRD |= (1<<5); - PORTD &= ~(1<<5); + gpio_set_pin_output(B0); + gpio_write_pin_low(B0); + gpio_set_pin_output(D5); + gpio_write_pin_low(D5); } else { // Hi-Z - DDRB &= ~(1<<0); - PORTB &= ~(1<<0); - DDRD &= ~(1<<5); - PORTD &= ~(1<<5); + gpio_set_pin_input(B0); + gpio_set_pin_input(D5); } } return false; diff --git a/keyboards/40percentclub/ut47/matrix.c b/keyboards/40percentclub/ut47/matrix.c index 02ed88b709..d803f11c5e 100644 --- a/keyboards/40percentclub/ut47/matrix.c +++ b/keyboards/40percentclub/ut47/matrix.c @@ -126,14 +126,18 @@ void matrix_print(void) static void init_cols(void) { // Input with pull-up(DDR:0, PORT:1) - DDRF &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7); - PORTF |= (1<<4 | 1<<5 | 1<<6 | 1<<7); - DDRE &= ~(1<<6); - PORTE |= (1<<6); - DDRD &= ~(1<<7); - PORTD |= (1<<7); - DDRB &= ~(1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6); - PORTB |= (1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6); + gpio_set_pin_input_high(F4); + gpio_set_pin_input_high(F5); + gpio_set_pin_input_high(F6); + gpio_set_pin_input_high(F7); + gpio_set_pin_input_high(E6); + gpio_set_pin_input_high(D7); + gpio_set_pin_input_high(B1); + gpio_set_pin_input_high(B2); + gpio_set_pin_input_high(B3); + gpio_set_pin_input_high(B4); + gpio_set_pin_input_high(B5); + gpio_set_pin_input_high(B6); } static matrix_row_t read_cols(void) @@ -160,10 +164,10 @@ static matrix_row_t read_cols(void) static void unselect_rows(void) { // Hi-Z(DDR:0, PORT:0) to unselect - DDRD &= ~0b00010011; - PORTD &= ~0b00010011; - DDRC &= ~0b01000000; - PORTC &= ~0b01000000; + gpio_set_pin_input(C6); + gpio_set_pin_input(D0); + gpio_set_pin_input(D1); + gpio_set_pin_input(D4); } static void select_row(uint8_t row) @@ -171,20 +175,20 @@ static void select_row(uint8_t row) // Output low(DDR:1, PORT:0) to select switch (row) { case 0: - DDRD |= (1<<1); - PORTD &= ~(1<<1); + gpio_set_pin_output(D1); + gpio_write_pin_low(D1); break; case 1: - DDRD |= (1<<0); - PORTD &= ~(1<<0); + gpio_set_pin_output(D0); + gpio_write_pin_low(D0); break; case 2: - DDRD |= (1<<4); - PORTD &= ~(1<<4); + gpio_set_pin_output(D4); + gpio_write_pin_low(D4); break; case 3: - DDRC |= (1<<6); - PORTC &= ~(1<<6); + gpio_set_pin_output(C6); + gpio_write_pin_low(C6); break; } } diff --git a/keyboards/amjkeyboard/amj96/matrix.c b/keyboards/amjkeyboard/amj96/matrix.c index 7faf40d4fe..448508971f 100644 --- a/keyboards/amjkeyboard/amj96/matrix.c +++ b/keyboards/amjkeyboard/amj96/matrix.c @@ -65,8 +65,8 @@ void matrix_init(void) #endif // 85 REST - DDRD |= _BV(PD7); - PORTD |= _BV(PD7); + gpio_set_pin_output(D7); + gpio_write_pin_high(D7); // initialize row and col init_rows(); @@ -143,36 +143,35 @@ static void init_cols(void) DDRD &= 0b00011100; PORTD |= 0b11100011; - DDRB &= ~(_BV(PB6) | _BV(PB7)| _BV(PB0)); - PORTB |= (_BV(PB6) | _BV(PB7)| _BV(PB0)); + gpio_set_pin_input_high(B0); + gpio_set_pin_input_high(B6); + gpio_set_pin_input_high(B7); - DDRE &= ~_BV(PE6); - PORTE |= _BV(PE6); + gpio_set_pin_input_high(E6); - DDRC &= ~_BV(PC7); - PORTC |= _BV(PC7); + gpio_set_pin_input_high(C7); } static matrix_row_t read_cols(void) { - return (PINF&_BV(PF7) ? 0 : (1<<0)) | - (PINF&_BV(PF6) ? 0 : (1<<1)) | - (PINF&_BV(PF5) ? 0 : (1<<2)) | - (PINF&_BV(PF4) ? 0 : (1<<3)) | - (PINF&_BV(PF1) ? 0 : (1<<4)) | - (PINF&_BV(PF0) ? 0 : (1<<5)) | - (PINE&_BV(PE6) ? 0 : (1<<6)) | - (PIND&_BV(PD7) ? 0 : (1<<7)) | - (PIND&_BV(PD6) ? 0 : (1<<8)) | - (PIND&_BV(PD5) ? 0 : (1<<9)) | - (PIND&_BV(PD1) ? 0 : (1<<10)) | - (PIND&_BV(PD0) ? 0 : (1<<11)) | - (PINB&_BV(PB7) ? 0 : (1<<12)) | - (PINB&_BV(PB6) ? 0 : (1<<13)) | - (PINB&_BV(PB0) ? 0 : (1<<14)) | - (PINC&_BV(PC7) ? 0 : (1<<15)); + return (gpio_read_pin(F7) ? 0 : (1<<0)) | + (gpio_read_pin(F6) ? 0 : (1<<1)) | + (gpio_read_pin(F5) ? 0 : (1<<2)) | + (gpio_read_pin(F4) ? 0 : (1<<3)) | + (gpio_read_pin(F1) ? 0 : (1<<4)) | + (gpio_read_pin(F0) ? 0 : (1<<5)) | + (gpio_read_pin(E6) ? 0 : (1<<6)) | + (gpio_read_pin(D7) ? 0 : (1<<7)) | + (gpio_read_pin(D6) ? 0 : (1<<8)) | + (gpio_read_pin(D5) ? 0 : (1<<9)) | + (gpio_read_pin(D1) ? 0 : (1<<10)) | + (gpio_read_pin(D0) ? 0 : (1<<11)) | + (gpio_read_pin(B7) ? 0 : (1<<12)) | + (gpio_read_pin(B6) ? 0 : (1<<13)) | + (gpio_read_pin(B0) ? 0 : (1<<14)) | + (gpio_read_pin(C7) ? 0 : (1<<15)); } /* Row pin configuration @@ -184,21 +183,23 @@ static matrix_row_t read_cols(void) static void init_rows(void) { - DDRB |= (1<> bit ; } @@ -138,18 +138,19 @@ void Matrix_ThrowByte(void) { void matrix_init (void) { // debug_matrix = 1; // PB0 (SS) and PB1 (SCLK) set to outputs - DDRB |= RESET | SCLK ; + gpio_set_pin_output(HP_46010A_RESET_PIN); + gpio_set_pin_output(HP_46010A_SCLK_PIN); // PB2, is unused, and PB3 is our serial input - DDRB &= ~SDATA ; + gpio_set_pin_input(HP_46010A_SDATA_PIN); // SS is reset for this board, and is active High // SCLK is the serial clock and is active High - PORTB &= ~RESET ; - PORTB |= SCLK ; + gpio_write_pin_low(HP_46010A_RESET_PIN); + gpio_write_pin_high(HP_46010A_SCLK_PIN); // led pin - DDRD |= LED ; - PORTD &= ~LED ; + gpio_set_pin_output(HP_46010A_LED_PIN); + gpio_write_pin_low(HP_46010A_LED_PIN); matrix_init_kb(); diff --git a/keyboards/converter/sun_usb/matrix.c b/keyboards/converter/sun_usb/matrix.c index 6d52d5cd6c..93354ee114 100644 --- a/keyboards/converter/sun_usb/matrix.c +++ b/keyboards/converter/sun_usb/matrix.c @@ -74,8 +74,8 @@ uint8_t matrix_cols(void) void matrix_init(void) { - /* DDRD |= (1<<6); */ - /* PORTD |= (1<<6); */ + /* gpio_set_pin_output(D6); */ + /* gpio_write_pin_high(D6); */ debug_enable = true; uart_init(1200); @@ -99,7 +99,7 @@ void matrix_init(void) /* } */ /* print(" Done\n"); */ - /* PORTD &= ~(1<<6); */ + /* gpio_write_pin_low(D6) */ matrix_init_kb(); return; diff --git a/keyboards/crawlpad/keymaps/default/keymap.c b/keyboards/crawlpad/keymaps/default/keymap.c index 547132bb7d..306ade6e5f 100755 --- a/keyboards/crawlpad/keymaps/default/keymap.c +++ b/keyboards/crawlpad/keymaps/default/keymap.c @@ -40,32 +40,16 @@ void set_led(int idx, bool enable) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case BL1: - if (record->event.pressed) { - PORTB |= (1 << 4); - } else { - PORTB &= ~(1 << 4); - } + gpio_write_pin(B4, record->event.pressed); return false; case BL2: - if (record->event.pressed) { - PORTB |= (1 << 5); - } else { - PORTB &= ~(1 << 5); - } + gpio_write_pin(B5, record->event.pressed); return false; case BL3: - if (record->event.pressed) { - PORTB |= (1 << 6); - } else { - PORTB &= ~(1 << 6); - } + gpio_write_pin(B6, record->event.pressed); return false; case BL4: - if (record->event.pressed) { - PORTB |= (1 << 7); - } else { - PORTB &= ~(1 << 7); - } + gpio_write_pin(B7, record->event.pressed); return false; } return true; @@ -73,6 +57,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { void matrix_init_user(void) { /* set LED row pins to output and low */ - DDRB |= (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7); - PORTB &= ~(1 << 4) & ~(1 << 5) & ~(1 << 6) & ~(1 << 7); + gpio_set_pin_output(B4); + gpio_set_pin_output(B5); + gpio_set_pin_output(B6); + gpio_set_pin_output(B7); + + gpio_write_pin_low(B4); + gpio_write_pin_low(B5); + gpio_write_pin_low(B6); + gpio_write_pin_low(B7); } diff --git a/keyboards/do60/do60.h b/keyboards/do60/do60.h index de64b8f134..5aa9c17f2e 100644 --- a/keyboards/do60/do60.h +++ b/keyboards/do60/do60.h @@ -2,6 +2,9 @@ #include "quantum.h" +#define DO60_CAPS_LOCK_LED_PIN B2 +#define DO60_BACKLIGHT_PIN F4 + /* DO60 LEDs * GPIO pads * 0 F7 not connected @@ -13,11 +16,21 @@ */ /* -inline void do60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); } -inline void do60_bl_led_on(void) { DDRF |= (1<<4); PORTF &= ~(1<<4); } +inline void do60_caps_led_on(void) { + gpio_set_pin_output(DO60_CAPS_LOCK_LED_PIN); + gpio_write_pin_low(DO60_CAPS_LOCK_LED_PIN); +} +inline void do60_bl_led_on(void) { + gpio_set_pin_output(DO60_BACKLIGHT_PIN); + gpio_write_pin_low(DO60_BACKLIGHT_PIN); +} -inline void do60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); } -inline void do60_bl_led_off(void) { DDRF &= ~(1<<4); PORTF &= ~(1<<4); } +inline void do60_caps_led_off(void) { + gpio_set_pin_input(DO60_CAPS_LOCK_LED_PIN); +} +inline void do60_bl_led_off(void) { + gpio_set_pin_input(DO60_BACKLIGHT_PIN); +} */ inline void setdefaultrgb(void){ rgblight_sethsv(100,100,100); } diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index 5270738f86..5fc173917f 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c @@ -24,13 +24,11 @@ extern inline void ergodox_board_led_on(void); extern inline void ergodox_right_led_1_on(void); extern inline void ergodox_right_led_2_on(void); extern inline void ergodox_right_led_3_on(void); -extern inline void ergodox_right_led_on(uint8_t led); extern inline void ergodox_board_led_off(void); extern inline void ergodox_right_led_1_off(void); extern inline void ergodox_right_led_2_off(void); extern inline void ergodox_right_led_3_off(void); -extern inline void ergodox_right_led_off(uint8_t led); extern inline void ergodox_led_all_on(void); extern inline void ergodox_led_all_off(void); @@ -53,17 +51,14 @@ void matrix_init_kb(void) { TCCR1B = 0b00001001; // set and configure fast PWM // (tied to Vcc for hardware convenience) - DDRB &= ~(1 << 4); // set B(4) as input - PORTB &= ~(1 << 4); // set B(4) internal pull-up disabled + gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled - // unused pins - C7, D4, D5, D7, E6 + // unused pins - C7, D4, D5, E6 // set as input with internal pull-up enabled - DDRC &= ~(1 << 7); - DDRD &= ~(1 << 5 | 1 << 4); - DDRE &= ~(1 << 6); - PORTC |= (1 << 7); - PORTD |= (1 << 5 | 1 << 4); - PORTE |= (1 << 6); + gpio_set_pin_input_high(C7); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D5); + gpio_set_pin_input_high(E6); keyboard_config.raw = eeconfig_read_kb(); ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4); diff --git a/keyboards/ergodox_ez/ergodox_ez.h b/keyboards/ergodox_ez/ergodox_ez.h index df2dbed715..3938ff49f1 100644 --- a/keyboards/ergodox_ez/ergodox_ez.h +++ b/keyboards/ergodox_ez/ergodox_ez.h @@ -51,18 +51,40 @@ uint8_t ergodox_left_leds_update(void); #define LED_BRIGHTNESS_HI 255 #endif +#define ERGODOX_EZ_BOARD_LED_PIN D6 +#define ERGODOX_EZ_RIGHT_LED_1_PIN B5 +#define ERGODOX_EZ_RIGHT_LED_2_PIN B6 +#define ERGODOX_EZ_RIGHT_LED_3_PIN B7 -inline void ergodox_board_led_on(void) { DDRD |= (1<<6); PORTD |= (1<<6); } -inline void ergodox_right_led_1_on(void) { DDRB |= (1<<5); PORTB |= (1<<5); } -inline void ergodox_right_led_2_on(void) { DDRB |= (1<<6); PORTB |= (1<<6); } -inline void ergodox_right_led_3_on(void) { DDRB |= (1<<7); PORTB |= (1<<7); } -inline void ergodox_right_led_on(uint8_t led) { DDRB |= (1<<(led+4)); PORTB |= (1<<(led+4)); } +inline void ergodox_board_led_on(void) { + gpio_set_pin_output(ERGODOX_EZ_BOARD_LED_PIN); + gpio_write_pin_high(ERGODOX_EZ_BOARD_LED_PIN); +} +inline void ergodox_right_led_1_on(void) { + gpio_set_pin_output(ERGODOX_EZ_RIGHT_LED_1_PIN); + gpio_write_pin_high(ERGODOX_EZ_RIGHT_LED_1_PIN); +} +inline void ergodox_right_led_2_on(void) { + gpio_set_pin_output(ERGODOX_EZ_RIGHT_LED_2_PIN); + gpio_write_pin_high(ERGODOX_EZ_RIGHT_LED_2_PIN); +} +inline void ergodox_right_led_3_on(void) { + gpio_set_pin_output(ERGODOX_EZ_RIGHT_LED_3_PIN); + gpio_write_pin_high(ERGODOX_EZ_RIGHT_LED_3_PIN); +} -inline void ergodox_board_led_off(void) { DDRD &= ~(1<<6); PORTD &= ~(1<<6); } -inline void ergodox_right_led_1_off(void) { DDRB &= ~(1<<5); PORTB &= ~(1<<5); } -inline void ergodox_right_led_2_off(void) { DDRB &= ~(1<<6); PORTB &= ~(1<<6); } -inline void ergodox_right_led_3_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); } -inline void ergodox_right_led_off(uint8_t led) { DDRB &= ~(1<<(led+4)); PORTB &= ~(1<<(led+4)); } +inline void ergodox_board_led_off(void) { + gpio_set_pin_input(ERGODOX_EZ_BOARD_LED_PIN); +} +inline void ergodox_right_led_1_off(void) { + gpio_set_pin_input(ERGODOX_EZ_RIGHT_LED_1_PIN); +} +inline void ergodox_right_led_2_off(void) { + gpio_set_pin_input(ERGODOX_EZ_RIGHT_LED_2_PIN); +} +inline void ergodox_right_led_3_off(void) { + gpio_set_pin_input(ERGODOX_EZ_RIGHT_LED_3_PIN); +} #ifdef LEFT_LEDS bool ergodox_left_led_1; diff --git a/keyboards/gboards/ergotaco/ergotaco.c b/keyboards/gboards/ergotaco/ergotaco.c index 6795dfde4f..1e526f15e2 100644 --- a/keyboards/gboards/ergotaco/ergotaco.c +++ b/keyboards/gboards/ergotaco/ergotaco.c @@ -5,25 +5,30 @@ i2c_status_t mcp23018_status = 0x20; void matrix_init_kb(void) { // (tied to Vcc for hardware convenience) - //DDRB &= ~(1<<4); // set B(4) as input - //PORTB &= ~(1<<4); // set B(4) internal pull-up disabled + //gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled // unused pins // set as input with internal pull-up enabled - DDRB &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7); - PORTB |= (1<<4 | 1<<5 | 1<<6 | 1<<7); + gpio_set_pin_input_high(B4); + gpio_set_pin_input_high(B5); + gpio_set_pin_input_high(B6); + gpio_set_pin_input_high(B7); - DDRC &= ~(1<<7 | 1<<6); - PORTC |= (1<<7 | 1<<6); + gpio_set_pin_input_high(C6); + gpio_set_pin_input_high(C7); - DDRD &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7); - PORTD |= (1<<4 | 1<<5 | 1<<6 | 1<<7); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D5); + gpio_set_pin_input_high(D6); + gpio_set_pin_input_high(D7); - DDRE &= ~(1<<6); - PORTE |= (1<<6); + gpio_set_pin_input_high(E6); - DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6 | 1<<7); - PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<6 | 1<<7); + gpio_set_pin_input_high(D0); + gpio_set_pin_input_high(D1); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D6); + gpio_set_pin_input_high(D7); matrix_init_user(); } diff --git a/keyboards/gboards/georgi/georgi.c b/keyboards/gboards/georgi/georgi.c index 44b7067b47..da88e6ed8b 100644 --- a/keyboards/gboards/georgi/georgi.c +++ b/keyboards/gboards/georgi/georgi.c @@ -7,17 +7,16 @@ void matrix_init_kb(void) { steno_set_mode(STENO_MODE_GEMINI); // or STENO_MODE_BOLT // (tied to Vcc for hardware convenience) - //DDRB &= ~(1<<4); // set B(4) as input - //PORTB &= ~(1<<4); // set B(4) internal pull-up disabled + //gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled - // unused pins - C7, D4, D5, D7, E6 + // unused pins - C7, D4, D5, D6, D7, E6 // set as input with internal pull-up enabled - DDRC &= ~(1<<7); - DDRD &= ~(1<<5 | 1<<4 | 1<<6 | 1<<7); - DDRE &= ~(1<<6); - PORTC |= (1<<7); - PORTD |= (1<<5 | 1<<4 | 1<<6 | 1<<7); - PORTE |= (1<<6); + gpio_set_pin_input_high(C7); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D5); + gpio_set_pin_input_high(D6); + gpio_set_pin_input_high(D7); + gpio_set_pin_input_high(E6); matrix_init_user(); } diff --git a/keyboards/gboards/gergo/gergo.c b/keyboards/gboards/gergo/gergo.c index fa73c4b42f..1ec6105eeb 100644 --- a/keyboards/gboards/gergo/gergo.c +++ b/keyboards/gboards/gergo/gergo.c @@ -5,17 +5,16 @@ i2c_status_t mcp23018_status = 0x20; void matrix_init_kb(void) { // (tied to Vcc for hardware convenience) - //DDRB &= ~(1<<4); // set B(4) as input - //PORTB &= ~(1<<4); // set B(4) internal pull-up disabled + //gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled - // unused pins - C7, D4, D5, D7, E6 + // unused pins - C7, D4, D5, D6, D7, E6 // set as input with internal pull-up enabled - DDRC &= ~(1<<7); - DDRD &= ~(1<<5 | 1<<4 | 1<<6 | 1<<7); - DDRE &= ~(1<<6); - PORTC |= (1<<7); - PORTD |= (1<<5 | 1<<4 | 1<<6 | 1<<7); - PORTE |= (1<<6); + gpio_set_pin_input_high(C7); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D5); + gpio_set_pin_input_high(D6); + gpio_set_pin_input_high(D7); + gpio_set_pin_input_high(E6); matrix_init_user(); } diff --git a/keyboards/gh80_3000/keymaps/ansi_wkl/keymap.c b/keyboards/gh80_3000/keymaps/ansi_wkl/keymap.c index a949b11941..54fdb3400d 100644 --- a/keyboards/gh80_3000/keymaps/ansi_wkl/keymap.c +++ b/keyboards/gh80_3000/keymaps/ansi_wkl/keymap.c @@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ) }; - diff --git a/keyboards/gh80_3000/keymaps/default/keymap.c b/keyboards/gh80_3000/keymaps/default/keymap.c index 08f43c1d68..4a54df83cc 100644 --- a/keyboards/gh80_3000/keymaps/default/keymap.c +++ b/keyboards/gh80_3000/keymaps/default/keymap.c @@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PCMM, KC_PDOT, KC_PENT ) }; - diff --git a/keyboards/gh80_3000/keymaps/iso_default/keymap.c b/keyboards/gh80_3000/keymaps/iso_default/keymap.c index ff2b373a54..b3433eb21a 100644 --- a/keyboards/gh80_3000/keymaps/iso_default/keymap.c +++ b/keyboards/gh80_3000/keymaps/iso_default/keymap.c @@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PCMM, KC_PDOT, KC_PENT ) }; - diff --git a/keyboards/gh80_3000/keymaps/iso_std/keymap.c b/keyboards/gh80_3000/keymaps/iso_std/keymap.c index 7783aae0a9..26fbb855e8 100644 --- a/keyboards/gh80_3000/keymaps/iso_std/keymap.c +++ b/keyboards/gh80_3000/keymaps/iso_std/keymap.c @@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ) }; - diff --git a/keyboards/gh80_3000/keymaps/iso_wkl/keymap.c b/keyboards/gh80_3000/keymaps/iso_wkl/keymap.c index 9108f6aba4..4d20f5a402 100644 --- a/keyboards/gh80_3000/keymaps/iso_wkl/keymap.c +++ b/keyboards/gh80_3000/keymaps/iso_wkl/keymap.c @@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ) }; - diff --git a/keyboards/glenpickle/chimera_ergo/chimera_ergo.c b/keyboards/glenpickle/chimera_ergo/chimera_ergo.c index 47653c2e4b..40748e0b3d 100644 --- a/keyboards/glenpickle/chimera_ergo/chimera_ergo.c +++ b/keyboards/glenpickle/chimera_ergo/chimera_ergo.c @@ -1,10 +1,12 @@ #include "chimera_ergo.h" void led_init(void) { - DDRD |= (1<<1); - PORTD |= (1<<1); - DDRF |= (1<<4) | (1<<5); - PORTF |= (1<<4) | (1<<5); + gpio_set_pin_output(CHIMERA_ERGO_GREEN_LED_PIN); + gpio_write_pin_high(CHIMERA_ERGO_GREEN_LED_PIN); + gpio_set_pin_output(CHIMERA_ERGO_BLUE_LED_PIN); + gpio_write_pin_high(CHIMERA_ERGO_BLUE_LED_PIN); + gpio_set_pin_output(CHIMERA_ERGO_RED_LED_PIN); + gpio_write_pin_high(CHIMERA_ERGO_RED_LED_PIN); } diff --git a/keyboards/glenpickle/chimera_ergo/chimera_ergo.h b/keyboards/glenpickle/chimera_ergo/chimera_ergo.h index 04ef56503f..46f0b931e8 100644 --- a/keyboards/glenpickle/chimera_ergo/chimera_ergo.h +++ b/keyboards/glenpickle/chimera_ergo/chimera_ergo.h @@ -2,12 +2,16 @@ #include "quantum.h" -#define red_led_off PORTF |= (1<<5) -#define red_led_on PORTF &= ~(1<<5) -#define blu_led_off PORTF |= (1<<4) -#define blu_led_on PORTF &= ~(1<<4) -#define grn_led_off PORTD |= (1<<1) -#define grn_led_on PORTD &= ~(1<<1) +#define CHIMERA_ERGO_RED_LED_PIN F5 +#define CHIMERA_ERGO_GREEN_LED_PIN D1 +#define CHIMERA_ERGO_BLUE_LED_PIN F4 + +#define red_led_off gpio_write_pin_high(CHIMERA_ERGO_RED_LED_PIN) +#define red_led_on gpio_write_pin_low(CHIMERA_ERGO_RED_LED_PIN) +#define blu_led_off gpio_write_pin_high(CHIMERA_ERGO_BLUE_LED_PIN) +#define blu_led_on gpio_write_pin_low(CHIMERA_ERGO_BLUE_LED_PIN) +#define grn_led_off gpio_write_pin_high(CHIMERA_ERGO_GREEN_LED_PIN) +#define grn_led_on gpio_write_pin_low(CHIMERA_ERGO_GREEN_LED_PIN) #define set_led_off red_led_off; grn_led_off; blu_led_off #define set_led_red red_led_on; grn_led_off; blu_led_off @@ -17,27 +21,3 @@ #define set_led_magenta red_led_on; grn_led_off; blu_led_on #define set_led_cyan red_led_off; grn_led_on; blu_led_on #define set_led_white red_led_on; grn_led_on; blu_led_on - -/* -#define LED_B 5 -#define LED_R 6 -#define LED_G 7 - -#define all_leds_off PORTF &= ~(1<event.pressed) { - PORTC |= (1 << 6); // PC6 goes high + gpio_write_pin_high(C6); } return true; case TO(OSY): if (record->event.pressed) { - PORTC &= ~(1 << 6); // PC6 goes high - PORTD |= (1<<4); + gpio_write_pin_low(C6); + gpio_write_pin_high(D4); } return true; case TO(DEF): if (record->event.pressed) { - PORTD &= ~(1 << 4); // PC6 goes high + gpio_write_pin_low(D4); } return true; diff --git a/keyboards/handwired/retro_refit/retro_refit.c b/keyboards/handwired/retro_refit/retro_refit.c index b7e1ec03fa..f23ef1fd40 100644 --- a/keyboards/handwired/retro_refit/retro_refit.c +++ b/keyboards/handwired/retro_refit/retro_refit.c @@ -6,8 +6,8 @@ void matrix_init_kb(void) { // runs once when the firmware starts up // Disable status LED on KB, enable status LED on Teensy (KB_STATUS = !TEENSY_STATUS) - DDRD |= (1<<6); - PORTD |= (1<<6); + gpio_set_pin_output(D6); + gpio_write_pin_high(D6); matrix_init_user(); }; diff --git a/keyboards/hotdox/hotdox.h b/keyboards/hotdox/hotdox.h index b933344439..d0b6c401f9 100644 --- a/keyboards/hotdox/hotdox.h +++ b/keyboards/hotdox/hotdox.h @@ -4,17 +4,46 @@ #include #include +#define HOTDOX_BOARD_LED_PIN B7 +#define HOTDOX_RIGHT_LED_1_PIN B5 +#define HOTDOX_RIGHT_LED_2_PIN B6 +#define HOTDOX_RIGHT_LED_3_PIN B4 + void init_ergodox(void); -inline void ergodox_board_led_on(void) { DDRB |= (1< #include #include -#include // LUFA #include "lufa.h" @@ -9,6 +7,8 @@ #include "sendchar.h" #include "debug.h" #include "keyboard.h" +#include "gpio.h" +#include "wait.h" #include "led.h" /* LED ping configuration */ @@ -16,16 +16,16 @@ //#define LEONARDO_LED #if defined(TMK_LED) // For TMK converter and Teensy -#define LED_TX_INIT (DDRD |= (1<<6)) -#define LED_TX_ON (PORTD |= (1<<6)) -#define LED_TX_OFF (PORTD &= ~(1<<6)) -#define LED_TX_TOGGLE (PORTD ^= (1<<6)) +#define LED_TX_INIT gpio_set_pin_output(D6) +#define LED_TX_ON gpio_write_pin_high(D6) +#define LED_TX_OFF gpio_write_pin_low(D6) +#define LED_TX_TOGGLE gpio_toggle_pin(D6) #elif defined(LEONARDO_LED) // For Leonardo(TX LED) -#define LED_TX_INIT (DDRD |= (1<<5)) -#define LED_TX_ON (PORTD &= ~(1<<5)) -#define LED_TX_OFF (PORTD |= (1<<5)) -#define LED_TX_TOGGLE (PORTD ^= (1<<5)) +#define LED_TX_INIT gpio_set_pin_output(D5) +#define LED_TX_ON gpio_write_pin_low(D5) +#define LED_TX_OFF gpio_write_pin_high(D5) +#define LED_TX_TOGGLE gpio_toggle_pin(D5) #else #define LED_TX_INIT #define LED_TX_ON diff --git a/keyboards/sixkeyboard/matrix.c b/keyboards/sixkeyboard/matrix.c index ddbd41ac55..24cb647297 100644 --- a/keyboards/sixkeyboard/matrix.c +++ b/keyboards/sixkeyboard/matrix.c @@ -71,13 +71,12 @@ uint8_t matrix_cols(void) void matrix_init(void) { - - DDRC &= ~(1<<7); - PORTC |= (1<<7); - DDRB &= ~(1<<7 | 1<<5); - PORTB |= (1<<7 | 1<<5); - DDRD &= ~(1<<6 | 1<<4 | 1<<1); - PORTD |= (1<<6 | 1<<4 | 1<<1); + gpio_set_pin_input_high(C7); + gpio_set_pin_input_high(B5); + gpio_set_pin_input_high(B7); + gpio_set_pin_input_high(D1); + gpio_set_pin_input_high(D4); + gpio_set_pin_input_high(D6); for (uint8_t i=0; i < MATRIX_ROWS; i++) { matrix[i] = 0; diff --git a/keyboards/sixkeyboard/sixkeyboard.c b/keyboards/sixkeyboard/sixkeyboard.c index 7667ee7f44..5a5c818d13 100644 --- a/keyboards/sixkeyboard/sixkeyboard.c +++ b/keyboards/sixkeyboard/sixkeyboard.c @@ -4,27 +4,26 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up - DDRC |= (1<<4); - PORTC &= ~(1<<4); + gpio_set_pin_output(C4); + gpio_write_pin_low(C4); + gpio_set_pin_output(C6); + gpio_write_pin_low(C6); - DDRC |= (1<<6); - PORTC &= ~(1<<6); + gpio_set_pin_output(B6); + gpio_write_pin_low(B6); - DDRB |= (1<<6); - PORTB &= ~(1<<6); + gpio_set_pin_output(B4); + gpio_write_pin_low(B4); - DDRB |= (1<<4); - PORTB &= ~(1<<4); + gpio_set_pin_output(D5); + gpio_write_pin_low(D5); - DDRD |= (1<<5); - PORTD &= ~(1<<5); + gpio_set_pin_output(D2); + gpio_write_pin_low(D2); - DDRD |= (1<<2); - PORTD &= ~(1<<2); - - DDRD |= (1<<3); - PORTD &= ~(1<<3); + gpio_set_pin_output(D3); + gpio_write_pin_low(D3); matrix_init_user(); }; \ No newline at end of file diff --git a/keyboards/tmo50/tmo50.c b/keyboards/tmo50/tmo50.c index 80eb286f45..635b9db003 100644 --- a/keyboards/tmo50/tmo50.c +++ b/keyboards/tmo50/tmo50.c @@ -19,14 +19,14 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up - DDRB |= (1 << PB0); //init B0 - PORTB &= ~(1 << PB0); //turn on B0 - DDRB |= (1 << PB1); - PORTB |= (1<. #define RGB_STEP 16 -#define RGB_RED_PIN PF6 -#define RGB_GREEN_PIN PF5 -#define RGB_BLUE_PIN PF4 +#define RGB_RED_PIN F6 +#define RGB_GREEN_PIN F5 +#define RGB_BLUE_PIN F4 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/v60_type_r/v60_type_r.c b/keyboards/v60_type_r/v60_type_r.c index 540c5ec6ec..6bace804e2 100644 --- a/keyboards/v60_type_r/v60_type_r.c +++ b/keyboards/v60_type_r/v60_type_r.c @@ -115,18 +115,22 @@ void rgb_timer_init(void) { } void rgb_init(void) { - DDRF |= (_BV(PF6) | _BV(PF5) | _BV(PF4)); - PORTF |= (_BV(PF6) | _BV(PF5) | _BV(PF4)); + gpio_set_pin_output(F4); + gpio_set_pin_output(F5); + gpio_set_pin_output(F6); + gpio_write_pin_high(F4); + gpio_write_pin_high(F5); + gpio_write_pin_high(F6); rgb_timer_init(); } -void set_rgb_pin_on(uint8_t pin) { - PORTF &= ~_BV(pin); +void set_rgb_pin_on(pin_t pin) { + gpio_write_pin_low(pin); } -void set_rgb_pin_off(uint8_t pin) { - PORTF |= _BV(pin); +void set_rgb_pin_off(pin_t pin) { + gpio_write_pin_high(pin); } ISR(TIMER3_COMPA_vect) diff --git a/keyboards/viktus/omnikey_bh/keymaps/default/keymap.c b/keyboards/viktus/omnikey_bh/keymaps/default/keymap.c index e5fb6bf902..ad63d05023 100644 --- a/keyboards/viktus/omnikey_bh/keymaps/default/keymap.c +++ b/keyboards/viktus/omnikey_bh/keymaps/default/keymap.c @@ -23,24 +23,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; bool led_update_user(led_t led_state) { - DDRB |= (1 << 4) | (1 << 5) | (1 << 6); + gpio_set_pin_output(B4); + gpio_set_pin_output(B5); + gpio_set_pin_output(B6); - if (led_state.num_lock) { - PORTB |= (1 << 4); - } else { - PORTB &= ~(1 << 4); - } + gpio_write_pin(B4, led_state.num_lock); + gpio_write_pin(B5, led_state.caps_lock); + gpio_write_pin(B6, led_state.scroll_lock); - if (led_state.caps_lock) { - PORTB |= (1 << 5); - } else { - PORTB &= ~(1 << 5); - } - - if (led_state.scroll_lock) { - PORTB |= (1 << 6); - } else { - PORTB &= ~(1 << 6); - } return false; } diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c index 02bcdd610b..936286c2ee 100644 --- a/keyboards/wilba_tech/wt_rgb_backlight.c +++ b/keyboards/wilba_tech/wt_rgb_backlight.c @@ -2629,15 +2629,12 @@ void backlight_debug_led( bool state ) { if (state) { - // Output high. - DDRE |= (1<<6); - PORTE |= (1<<6); + gpio_set_pin_output(E6); + gpio_write_pin_high(E6); } else { - // Output low. - DDRE &= ~(1<<6); - PORTE &= ~(1<<6); + gpio_set_pin_input(E6); } } #endif // defined(RGB_DEBUGGING_ONLY) diff --git a/keyboards/xiudi/xd60/xd60.h b/keyboards/xiudi/xd60/xd60.h index 3d3c1ae885..c399b2965d 100644 --- a/keyboards/xiudi/xd60/xd60.h +++ b/keyboards/xiudi/xd60/xd60.h @@ -2,6 +2,9 @@ #include "quantum.h" +#define XD60_CAPS_LOCK_LED_PIN B2 +#define XD60_BACKLIGHT_PIN F5 + /* XD60 LEDs * GPIO pads * 0 F7 not connected @@ -11,8 +14,18 @@ * B2 Capslock LED * B0 not connected */ -inline void xd60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); } -inline void xd60_bl_led_on(void) { DDRF |= (1<<5); PORTF &= ~(1<<5); } +inline void xd60_caps_led_on(void) { + gpio_set_pin_output(XD60_CAPS_LOCK_LED_PIN); + gpio_write_pin_low(XD60_CAPS_LOCK_LED_PIN); +} +inline void xd60_bl_led_on(void) { + gpio_set_pin_output(XD60_BACKLIGHT_PIN); + gpio_write_pin_low(XD60_BACKLIGHT_PIN); +} -inline void xd60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); } -inline void xd60_bl_led_off(void) { DDRF &= ~(1<<5); PORTF &= ~(1<<5); } +inline void xd60_caps_led_off(void) { + gpio_set_pin_input(XD60_CAPS_LOCK_LED_PIN); +} +inline void xd60_bl_led_off(void) { + gpio_set_pin_input(XD60_BACKLIGHT_PIN); +} diff --git a/keyboards/ydkb/yd68/keymaps/default/keymap.c b/keyboards/ydkb/yd68/keymaps/default/keymap.c index 45b3144b9c..44fe57da6a 100644 --- a/keyboards/ydkb/yd68/keymaps/default/keymap.c +++ b/keyboards/ydkb/yd68/keymaps/default/keymap.c @@ -43,7 +43,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case YD68_RGB_PWR: if (record->event.pressed) { // when keycode YD68_RGB_PWR is pressed - PORTE ^= (1<<2); + gpio_toggle_pin(E2); } else { // when keycode YD68_RGB_PWR is released }