diff options
author | Nick Brassel <nick@tzarc.org> | 2021-08-29 08:20:25 +1000 |
---|---|---|
committer | Nick Brassel <nick@tzarc.org> | 2021-08-29 08:20:25 +1000 |
commit | f061ca497464fe85284906fb163a33eaee7a91ef (patch) | |
tree | 33ef1bfb529aed382e8526c607c4e18717f92571 /keyboards/xd96/matrix.c | |
parent | ff65185dec6f97be1eb49f17cea526a0d0bbf3d6 (diff) | |
parent | 4bad375d7c09d949a9dcdd4feba147c9c7a67ec6 (diff) | |
download | qmk_firmware-f061ca497464fe85284906fb163a33eaee7a91ef.tar.gz qmk_firmware-f061ca497464fe85284906fb163a33eaee7a91ef.zip |
Breaking changes develop merge to master, 2021Q3 edition. (#14196)
Diffstat (limited to 'keyboards/xd96/matrix.c')
-rw-r--r-- | keyboards/xd96/matrix.c | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/keyboards/xd96/matrix.c b/keyboards/xd96/matrix.c deleted file mode 100644 index 8cecc79c26..0000000000 --- a/keyboards/xd96/matrix.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright 2019 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -#include <stdint.h> -#include <stdbool.h> -#include <avr/io.h> -#include <string.h> -#include "matrix.h" -#include "pca9555.h" -#include "quantum.h" - -#include "debug.h" - -// PCA9555 slave addresses -#define IC1 0x20 -#define IC2 0x21 - -//_____Utility funcs___________________________________________________________ - -static void init_pins(void) { - // init all cols high - IC2 all input - pca9555_set_config(IC2, PCA9555_PORT0, ALL_INPUT);//same as initial state - pca9555_set_config(IC2, PCA9555_PORT1, ALL_INPUT);//same as initial state - pca9555_set_config(IC1, PCA9555_PORT1, ALL_INPUT);//same as initial state - - // init all rows - IC1 port0 input - pca9555_set_config(IC1, PCA9555_PORT0, ALL_INPUT);//same as initial state -} - -static void select_row(uint8_t row) { - // For the XD96 all rows are on the same IC and port - // so its safe enough to assume here row == pin - uint8_t pin = row; - uint8_t mask = 1 << pin; - - pca9555_set_output(IC1, PCA9555_PORT0, ALL_HIGH & (~mask)); - pca9555_set_config(IC1, PCA9555_PORT0, ALL_INPUT & (~mask)); -} - -static uint32_t read_cols(void) { - uint32_t state_1 = pca9555_readPins(IC2, PCA9555_PORT0); - uint32_t state_2 = pca9555_readPins(IC2, PCA9555_PORT1); - uint32_t state_3 = pca9555_readPins(IC1, PCA9555_PORT1); - - // For the XD96 the pins are mapped to port expanders as follows: - // all 8 pins port 0 IC2, first 6 pins port 1 IC2, first 4 pins port 1 IC1 - uint32_t state = (((state_3 & 0b00001111) << 14) | ((state_2 & 0b00111111) << 8) | state_1); - return (~state) & 0b111111111111111111; -} - -static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { - // Store last value of row prior to reading - matrix_row_t last_row_value = current_matrix[current_row]; - - // Clear data in matrix row - current_matrix[current_row] = 0; - - // Select row and wait for row selection to stabilize - select_row(current_row); - wait_us(30); - - current_matrix[current_row] = read_cols(); - - // No need to Unselect row as the next `select_row` will blank everything - - return (last_row_value != current_matrix[current_row]); -} - -//_____CUSTOM MATRIX IMPLEMENTATION____________________________________________________ - -void matrix_init_custom(void) { - pca9555_init(IC1); - pca9555_init(IC2); - - init_pins(); -} - -bool matrix_scan_custom(matrix_row_t current_matrix[]) { - bool changed = false; - for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { - changed |= read_cols_on_row(current_matrix, current_row); - } - return changed; -}
\ No newline at end of file |