mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-22 00:14:38 +00:00
Ensure setPinInput actually sets input high-Z (#6237)
* Ensure setPinInput actually sets input high-z * Fixed _PIN_ADDRESS Macro arguments as recommended by vomindoraan * Fixed instances of setInput to use new behavour * Changed kmac matrix to use input with pullups * Update keyboards/gh60/revc/revc.h Co-Authored-By: fauxpark <fauxpark@gmail.com> * Fixed input state for unselect_rows * fixed merge conflict * Updated all instances of older uses of setPinInput() * Fixed naming mistake Co-authored-by: fauxpark <fauxpark@gmail.com>
This commit is contained in:
parent
645c5fabf2
commit
05d6e6ca78
19 changed files with 21 additions and 39 deletions
|
@ -48,8 +48,6 @@ void led_set_user(uint8_t usb_led){
|
||||||
} else {
|
} else {
|
||||||
//set to Hi-Z
|
//set to Hi-Z
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ CHANGELOG:
|
||||||
0.6 - Swapped ESC and GRV in all layers.
|
0.6 - Swapped ESC and GRV in all layers.
|
||||||
0.7 - Brought code up to current standards.
|
0.7 - Brought code up to current standards.
|
||||||
0.8 - Added MACLOCK macro.
|
0.8 - Added MACLOCK macro.
|
||||||
|
0.9 - Updated code to correspond to new setPinInput behaviour
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
|
||||||
|
@ -124,9 +125,7 @@ void matrix_init_user(void) {
|
||||||
#ifdef BOOTLOADER_CATERINA
|
#ifdef BOOTLOADER_CATERINA
|
||||||
// This will disable the red LEDs on the ProMicros
|
// This will disable the red LEDs on the ProMicros
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ The bottom row is fairly Kinesis-ish since the Contour and Advantage keyboards h
|
||||||
### 0.7
|
### 0.7
|
||||||
* Brought code up to new standards (as of 27 June 2019).
|
* Brought code up to new standards (as of 27 June 2019).
|
||||||
* Updated this readme file.
|
* Updated this readme file.
|
||||||
|
### 0.8
|
||||||
|
* Added MACLOCK macro.
|
||||||
|
### 0.9
|
||||||
|
* Updated code to correspond to new setPinInput behaviour.
|
||||||
|
|
||||||
### TODO:
|
### TODO:
|
||||||
|
|
||||||
|
|
|
@ -132,9 +132,7 @@ void matrix_init_user(void) {
|
||||||
#ifdef BOOTLOADER_CATERINA
|
#ifdef BOOTLOADER_CATERINA
|
||||||
// This will disable the red LEDs on the ProMicros
|
// This will disable the red LEDs on the ProMicros
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -155,4 +153,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ inline void gh60_fn_led_on(void) { setPinOutput(F5); writePinLow(F5); }
|
||||||
inline void gh60_esc_led_on(void) { setPinOutput(F6); writePinLow(F6); }
|
inline void gh60_esc_led_on(void) { setPinOutput(F6); writePinLow(F6); }
|
||||||
inline void gh60_wasd_leds_on(void) { setPinOutput(F7); writePinLow(F7); }
|
inline void gh60_wasd_leds_on(void) { setPinOutput(F7); writePinLow(F7); }
|
||||||
|
|
||||||
inline void gh60_caps_led_off(void) { setPinInput(B2); writePinLow(B2); }
|
inline void gh60_caps_led_off(void) { setPinInput(B2); }
|
||||||
inline void gh60_poker_leds_off(void) { setPinInput(F4); writePinLow(F4); }
|
inline void gh60_poker_leds_off(void) { setPinInput(F4); }
|
||||||
inline void gh60_fn_led_off(void) { setPinInput(F5); writePinLow(F5); }
|
inline void gh60_fn_led_off(void) { setPinInput(F5); }
|
||||||
inline void gh60_esc_led_off(void) { setPinInput(F6); writePinLow(F6); }
|
inline void gh60_esc_led_off(void) { setPinInput(F6); }
|
||||||
inline void gh60_wasd_leds_off(void) { setPinInput(F7); writePinLow(F7); }
|
inline void gh60_wasd_leds_off(void) { setPinInput(F7); }
|
||||||
|
|
||||||
/* GH60 keymap definition macro
|
/* GH60 keymap definition macro
|
||||||
* K2C, K31 and K3C are extra keys for ISO
|
* K2C, K31 and K3C are extra keys for ISO
|
||||||
|
|
|
@ -150,7 +150,7 @@ static void unselect_row(uint8_t row)
|
||||||
static void unselect_rows(void)
|
static void unselect_rows(void)
|
||||||
{
|
{
|
||||||
for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
setPinInput(row_pins[x]);
|
setPinInputHigh(row_pins[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,10 +215,7 @@ void matrix_init(void) {
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
|
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
setPinInput(B0);
|
||||||
|
|
||||||
setPinInput(B0);
|
|
||||||
writePinLow(B0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// modified for per col read matrix scan
|
// modified for per col read matrix scan
|
||||||
|
|
|
@ -59,7 +59,6 @@ void led_set_user(uint8_t usb_led) {
|
||||||
writePinLow(D5);
|
writePinLow(D5);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
|
if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
|
||||||
|
@ -67,7 +66,6 @@ void led_set_user(uint8_t usb_led) {
|
||||||
writePinLow(E6);
|
writePinLow(E6);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(E6);
|
setPinInput(E6);
|
||||||
writePinLow(E6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ void led_set_user(uint8_t usb_led) {
|
||||||
writePinLow(D5);
|
writePinLow(D5);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
|
if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
|
||||||
|
@ -62,7 +61,6 @@ void led_set_user(uint8_t usb_led) {
|
||||||
writePinLow(E6);
|
writePinLow(E6);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(E6);
|
setPinInput(E6);
|
||||||
writePinLow(E6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,5 @@ void led_set_user(uint8_t usb_led) {
|
||||||
writePinLow(B2);
|
writePinLow(B2);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(B2);
|
setPinInput(B2);
|
||||||
writePinLow(B2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ static void select_col(uint8_t col) {
|
||||||
static void init_pins(void) {
|
static void init_pins(void) {
|
||||||
unselect_cols();
|
unselect_cols();
|
||||||
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
setPinInput(row_pins[x]);
|
setPinInputHigh(row_pins[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPinInputHigh(E2);
|
setPinInputHigh(E2);
|
||||||
|
|
|
@ -169,9 +169,7 @@ void matrix_init_user(void) {
|
||||||
#ifdef BOOTLOADER_CATERINA
|
#ifdef BOOTLOADER_CATERINA
|
||||||
// This will disable the red LEDs on the ProMicros
|
// This will disable the red LEDs on the ProMicros
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -192,4 +190,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ void led_set_kb(uint8_t usb_led) {
|
||||||
writePinHigh(B0);
|
writePinHigh(B0);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
led_set_user(usb_led);
|
led_set_user(usb_led);
|
||||||
|
|
|
@ -63,9 +63,7 @@ void matrix_init_user(void) {
|
||||||
#ifdef BOOTLOADER_CATERINA
|
#ifdef BOOTLOADER_CATERINA
|
||||||
// This will disable the red LEDs on the ProMicros
|
// This will disable the red LEDs on the ProMicros
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,4 +84,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ void led_set_kb(uint8_t usb_led) {
|
||||||
writePinLow(F4);
|
writePinLow(F4);
|
||||||
} else {
|
} else {
|
||||||
setPinInput(F4);
|
setPinInput(F4);
|
||||||
writePinLow(F4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
led_set_user(usb_led);
|
led_set_user(usb_led);
|
||||||
|
|
|
@ -132,9 +132,7 @@ void matrix_init_user(void) {
|
||||||
#ifdef BOOTLOADER_CATERINA
|
#ifdef BOOTLOADER_CATERINA
|
||||||
// This will disable the red LEDs on the ProMicros
|
// This will disable the red LEDs on the ProMicros
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -155,4 +153,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,9 +151,7 @@ void matrix_init_user(void) {
|
||||||
#ifdef BOOTLOADER_CATERINA
|
#ifdef BOOTLOADER_CATERINA
|
||||||
// This will disable the red LEDs on the ProMicros
|
// This will disable the red LEDs on the ProMicros
|
||||||
setPinInput(D5);
|
setPinInput(D5);
|
||||||
writePinLow(D5);
|
|
||||||
setPinInput(B0);
|
setPinInput(B0);
|
||||||
writePinLow(B0);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,4 +172,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef __ASSEMBLER__
|
# ifndef __ASSEMBLER__
|
||||||
# define _PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + (p >> PORT_SHIFTER) + offset)
|
# define _PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + ((p) >> PORT_SHIFTER) + (offset))
|
||||||
// Port X Input Pins Address
|
// Port X Input Pins Address
|
||||||
# define PINx_ADDRESS(p) _PIN_ADDRESS(p, 0)
|
# define PINx_ADDRESS(p) _PIN_ADDRESS(p, 0)
|
||||||
// Port X Data Direction Register, 0:input 1:output
|
// Port X Data Direction Register, 0:input 1:output
|
||||||
|
|
|
@ -174,7 +174,7 @@ extern layer_state_t layer_state;
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
typedef uint8_t pin_t;
|
typedef uint8_t pin_t;
|
||||||
|
|
||||||
# define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF))
|
# define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
|
||||||
# define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
|
# define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||||
# define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
|
# define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
|
||||||
# define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
|
# define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||||
|
@ -184,6 +184,7 @@ typedef uint8_t pin_t;
|
||||||
# define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
|
# define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
|
||||||
|
|
||||||
# define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
|
# define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
|
||||||
|
|
||||||
#elif defined(PROTOCOL_CHIBIOS)
|
#elif defined(PROTOCOL_CHIBIOS)
|
||||||
typedef ioline_t pin_t;
|
typedef ioline_t pin_t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue