Skip to content

Commit

Permalink
Update atomic GPIO macros in keyboard custom matrix (qmk#23796)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and acidMyke committed Nov 3, 2024
1 parent 00961f0 commit 3e406f0
Show file tree
Hide file tree
Showing 20 changed files with 270 additions and 270 deletions.
12 changes: 6 additions & 6 deletions keyboards/argyle/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;

static inline void setPinOutput_writeLow(pin_t pin) {
static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_low(pin);
}
}

static inline void setPinOutput_writeHigh(pin_t pin) {
static inline void gpio_atomic_set_pin_output_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_high(pin);
}
}

static inline void setPinInputHigh_atomic(pin_t pin) {
static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin);
}
Expand All @@ -55,7 +55,7 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static bool select_row(uint8_t row) {
pin_t pin = row_pins[row];
if (pin != NO_PIN) {
setPinOutput_writeLow(pin);
gpio_atomic_set_pin_output_low(pin);
return true;
}
return false;
Expand All @@ -64,7 +64,7 @@ static bool select_row(uint8_t row) {
static void unselect_row(uint8_t row) {
pin_t pin = row_pins[row];
if (pin != NO_PIN) {
setPinInputHigh_atomic(pin);
gpio_atomic_set_pin_input_high(pin);
}
}

Expand All @@ -84,7 +84,7 @@ static void init_pins(void) {

for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if (col_pins[x] != NO_PIN) {
setPinInputHigh_atomic(col_pins[x]);
gpio_atomic_set_pin_input_high(col_pins[x]);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions keyboards/gmmk/numpad/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define MATRIX_ROW_SHIFTER ((matrix_row_t)1)

static inline void setPinOutput_writeLow(pin_t pin) {
static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_low(pin);
}
}

static inline void setPinOutput_writeHigh(pin_t pin) {
static inline void gpio_atomic_set_pin_output_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_high(pin);
}
}

static inline void setPinInputHigh_atomic(pin_t pin) {
static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin);
}
Expand All @@ -50,7 +50,7 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static bool select_col(uint8_t col) {
pin_t pin = col_pins[col];
if (pin != NO_PIN) {
setPinOutput_writeLow(pin);
gpio_atomic_set_pin_output_low(pin);
return true;
}
return false;
Expand All @@ -60,9 +60,9 @@ static void unselect_col(uint8_t col) {
pin_t pin = col_pins[col];
if (pin != NO_PIN) {
# ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin);
gpio_atomic_set_pin_output_high(pin);
# else
setPinInputHigh_atomic(pin);
gpio_atomic_set_pin_input_high(pin);
# endif
}
}
Expand All @@ -78,10 +78,10 @@ __attribute__((weak)) void matrix_init_custom(void) {
unselect_cols();
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]);
gpio_atomic_set_pin_input_high(row_pins[x]);
}
}
setPinInputHigh_atomic(B8);
gpio_atomic_set_pin_input_high(B8);
}

__attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter) { // Start with a clear matrix row
Expand Down
20 changes: 10 additions & 10 deletions keyboards/halfcliff/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }

void matrix_print(void) {}

static inline void setPinOutput_writeLow(pin_t pin) {
static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_low(pin);
}
}

static inline void setPinInputHigh_atomic(pin_t pin) {
static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
}

// matrix code
static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); }
static void select_row(uint8_t row) { gpio_atomic_set_pin_output_low(row_pins[row]); }

static void unselect_row(uint8_t row) { setPinInputHigh_atomic(row_pins[row]); }
static void unselect_row(uint8_t row) { gpio_atomic_set_pin_input_high(row_pins[row]); }

static void unselect_rows(void) {
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
setPinInputHigh_atomic(row_pins[x]);
gpio_atomic_set_pin_input_high(row_pins[x]);
}
}

Expand Down Expand Up @@ -103,24 +103,24 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
return false;
}

static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); }
static void select_col(uint8_t col) { gpio_atomic_set_pin_output_low(col_pins[col]); }

static void unselect_col(uint8_t col) { setPinInputHigh_atomic(col_pins[col]); }
static void unselect_col(uint8_t col) { gpio_atomic_set_pin_input_high(col_pins[col]); }

static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh_atomic(col_pins[x]);
gpio_atomic_set_pin_input_high(col_pins[x]);
}
}

static void init_pins(void) {
unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh_atomic(col_pins[x]);
gpio_atomic_set_pin_input_high(col_pins[x]);
}
unselect_cols();
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
setPinInputHigh_atomic(row_pins[x]);
gpio_atomic_set_pin_input_high(row_pins[x]);
}
}

Expand Down
20 changes: 10 additions & 10 deletions keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ static const uint8_t delay_sel[] = {MATRIX_IO_DELAY_MULSEL};
extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values

static inline void setPinOutput_writeLow(pin_t pin) {
static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_low(pin);
}
}

static inline void setPinInputHigh_atomic(pin_t pin) {
static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
}

Expand Down Expand Up @@ -108,13 +108,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
#elif defined(DIODE_DIRECTION)
# if (DIODE_DIRECTION == COL2ROW)

static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); }
static void select_row(uint8_t row) { gpio_atomic_set_pin_output_low(row_pins[row]); }

static void unselect_row(uint8_t row) { setPinInputHigh_atomic(row_pins[row]); }
static void unselect_row(uint8_t row) { gpio_atomic_set_pin_input_high(row_pins[row]); }

static void unselect_rows(void) {
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh_atomic(row_pins[x]);
gpio_atomic_set_pin_input_high(row_pins[x]);
}
}

Expand All @@ -125,7 +125,7 @@ static void init_pins(void) {
# endif
unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh_atomic(col_pins[x]);
gpio_atomic_set_pin_input_high(col_pins[x]);
}
}

Expand Down Expand Up @@ -218,20 +218,20 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)

# elif (DIODE_DIRECTION == ROW2COL)

static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); }
static void select_col(uint8_t col) { gpio_atomic_set_pin_output_low(col_pins[col]); }

static void unselect_col(uint8_t col) { setPinInputHigh_atomic(col_pins[col]); }
static void unselect_col(uint8_t col) { gpio_atomic_set_pin_input_high(col_pins[col]); }

static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh_atomic(col_pins[x]);
gpio_atomic_set_pin_input_high(col_pins[x]);
}
}

static void init_pins(void) {
unselect_cols();
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh_atomic(row_pins[x]);
gpio_atomic_set_pin_input_high(row_pins[x]);
}
}

Expand Down
18 changes: 9 additions & 9 deletions keyboards/keychron/c2_pro/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;

static inline void setPinOutput_writeLow(pin_t pin) {
static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_low(pin);
}
}

static inline void setPinOutput_writeHigh(pin_t pin) {
static inline void gpio_atomic_set_pin_output_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin);
gpio_write_pin_high(pin);
}
}

static inline void setPinInput_high(pin_t pin) {
static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col];

if (col < SHIFT_COL_START || col > SHIFT_COL_END) {
setPinOutput_writeLow(pin);
gpio_atomic_set_pin_output_low(pin);
return true;
} else {
if (col == SHIFT_COL_START) {
Expand All @@ -122,9 +122,9 @@ static void unselect_col(uint8_t col) {

if (col < SHIFT_COL_START || col > SHIFT_COL_END) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin);
gpio_atomic_set_pin_output_high(pin);
#else
setPinInput_high(pin);
gpio_atomic_set_pin_input_high(pin);
#endif
} else {
HC595_output(0x01, 1);
Expand All @@ -136,9 +136,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x];
if (x < SHIFT_COL_START || x > SHIFT_COL_END) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin);
gpio_atomic_set_pin_output_high(pin);
#else
setPinInput_high(pin);
gpio_atomic_set_pin_input_high(pin);
#endif
} else {
if (x == SHIFT_COL_START) HC595_output(UNSELECT_ALL_COL, 0);
Expand Down Expand Up @@ -181,7 +181,7 @@ void matrix_init_custom(void) {

for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
if (row_pins[x] != NO_PIN) {
setPinInput_high(row_pins[x]);
gpio_atomic_set_pin_input_high(row_pins[x]);
}
}

Expand Down
Loading

0 comments on commit 3e406f0

Please sign in to comment.