diff options
Diffstat (limited to 'keyboards/keychron/c2_pro/matrix.c')
-rw-r--r-- | keyboards/keychron/c2_pro/matrix.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/keyboards/keychron/c2_pro/matrix.c b/keyboards/keychron/c2_pro/matrix.c index 5065f97aa7..7d5b3e4e79 100644 --- a/keyboards/keychron/c2_pro/matrix.c +++ b/keyboards/keychron/c2_pro/matrix.c @@ -14,7 +14,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "quantum.h" +#include "matrix.h" +#include "atomic_util.h" +#include <string.h> #ifndef SHIFT_COL_START # define SHIFT_COL_START 8 @@ -41,27 +43,27 @@ pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; static inline void setPinOutput_writeLow(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinOutput(pin); - writePinLow(pin); + gpio_set_pin_output(pin); + gpio_write_pin_low(pin); } } static inline void setPinOutput_writeHigh(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinOutput(pin); - writePinHigh(pin); + gpio_set_pin_output(pin); + gpio_write_pin_high(pin); } } static inline void setPinInput_high(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinInputHigh(pin); + gpio_set_pin_input_high(pin); } } static inline uint8_t readMatrixPin(pin_t pin) { if (pin != NO_PIN) { - return readPin(pin); + return gpio_read_pin(pin); } else { return 1; } @@ -79,13 +81,13 @@ static void HC595_output(SIZE_T data, uint8_t bit) { ATOMIC_BLOCK_FORCEON { for (uint8_t i = 0; i < (SHIFT_COL_END - SHIFT_COL_START + 1); i++) { if (data & 0x1) { - writePinHigh(HC595_DS); + gpio_write_pin_high(HC595_DS); } else { - writePinLow(HC595_DS); + gpio_write_pin_low(HC595_DS); } - writePinHigh(HC595_SHCP); + gpio_write_pin_high(HC595_SHCP); HC595_delay(n); - writePinLow(HC595_SHCP); + gpio_write_pin_low(HC595_SHCP); HC595_delay(n); if (bit) { break; @@ -93,9 +95,9 @@ static void HC595_output(SIZE_T data, uint8_t bit) { data = data >> 1; } } - writePinHigh(HC595_STCP); + gpio_write_pin_high(HC595_STCP); HC595_delay(n); - writePinLow(HC595_STCP); + gpio_write_pin_low(HC595_STCP); HC595_delay(n); } } @@ -173,9 +175,9 @@ static void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t curre } void matrix_init_custom(void) { - setPinOutput(HC595_DS); - setPinOutput(HC595_STCP); - setPinOutput(HC595_SHCP); + gpio_set_pin_output(HC595_DS); + gpio_set_pin_output(HC595_STCP); + gpio_set_pin_output(HC595_SHCP); for (uint8_t x = 0; x < MATRIX_ROWS; x++) { if (row_pins[x] != NO_PIN) { |