mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-05-31 13:33:23 +00:00
code review suggestions: use alternate functions in matrix.c
Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
parent
61960ab4d1
commit
742049b8bc
@ -39,37 +39,37 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
|||||||
|
|
||||||
static void select_row(uint8_t row)
|
static void select_row(uint8_t row)
|
||||||
{
|
{
|
||||||
setPinOutput(row_pins[row]);
|
gpio_set_pin_output(row_pins[row]);
|
||||||
writePinLow(row_pins[row]);
|
gpio_write_pin_low(row_pins[row]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unselect_row(uint8_t row)
|
static void unselect_row(uint8_t row)
|
||||||
{
|
{
|
||||||
setPinInputHigh(row_pins[row]);
|
gpio_set_pin_input_high(row_pins[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++) {
|
||||||
setPinInputHigh(row_pins[x]);
|
gpio_set_pin_input_high(row_pins[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void select_col(uint8_t col)
|
static void select_col(uint8_t col)
|
||||||
{
|
{
|
||||||
setPinOutput(col_pins[col]);
|
gpio_set_pin_output(col_pins[col]);
|
||||||
writePinLow(col_pins[col]);
|
gpio_write_pin_low(col_pins[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unselect_col(uint8_t col)
|
static void unselect_col(uint8_t col)
|
||||||
{
|
{
|
||||||
setPinInputHigh(col_pins[col]);
|
gpio_set_pin_input_high(col_pins[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unselect_cols(void)
|
static void unselect_cols(void)
|
||||||
{
|
{
|
||||||
for(uint8_t x = 0; x < MATRIX_COLS; x++) {
|
for(uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||||
setPinInputHigh(col_pins[x]);
|
gpio_set_pin_input_high(col_pins[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,10 +77,10 @@ static void init_pins(void) {
|
|||||||
unselect_rows();
|
unselect_rows();
|
||||||
unselect_cols();
|
unselect_cols();
|
||||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||||
setPinInputHigh(col_pins[x]);
|
gpio_set_pin_input_high(col_pins[x]);
|
||||||
}
|
}
|
||||||
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
setPinInputHigh(row_pins[x]);
|
gpio_set_pin_input_high(row_pins[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||||||
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
||||||
|
|
||||||
// Select the col pin to read (active low)
|
// Select the col pin to read (active low)
|
||||||
uint8_t pin_state = readPin(col_pins[col_index]);
|
uint8_t pin_state = gpio_read_pin(col_pins[col_index]);
|
||||||
|
|
||||||
// Populate the matrix row with the state of the col pin
|
// Populate the matrix row with the state of the col pin
|
||||||
current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
|
current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
|
||||||
@ -128,7 +128,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
|
|||||||
matrix_row_t last_row_value = current_matrix[tmp];
|
matrix_row_t last_row_value = current_matrix[tmp];
|
||||||
|
|
||||||
// Check row pin state
|
// Check row pin state
|
||||||
if (readPin(row_pins[row_index]) == 0)
|
if (gpio_read_pin(row_pins[row_index]) == 0)
|
||||||
{
|
{
|
||||||
// Pin LO, set col bit
|
// Pin LO, set col bit
|
||||||
current_matrix[tmp] |= (ROW_SHIFTER << current_col);
|
current_matrix[tmp] |= (ROW_SHIFTER << current_col);
|
||||||
|
Loading…
Reference in New Issue
Block a user