1
0
Fork 0
forked from forks/qmk_firmware

Update atomic GPIO macros in keyboard custom matrix (#23796)

This commit is contained in:
Ryan 2024-07-13 18:41:05 +10:00 committed by GitHub
parent 5c43a9bed1
commit 1552cf2ddc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 270 additions and 270 deletions

View file

@ -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 row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -55,7 +55,7 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static bool select_row(uint8_t row) { static bool select_row(uint8_t row) {
pin_t pin = row_pins[row]; pin_t pin = row_pins[row];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} }
return false; return false;
@ -64,7 +64,7 @@ static bool select_row(uint8_t row) {
static void unselect_row(uint8_t row) { static void unselect_row(uint8_t row) {
pin_t pin = row_pins[row]; pin_t pin = row_pins[row];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
} }
} }
@ -84,7 +84,7 @@ static void init_pins(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) { for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if (col_pins[x] != NO_PIN) { if (col_pins[x] != NO_PIN) {
setPinInputHigh_atomic(col_pins[x]); gpio_atomic_set_pin_input_high(col_pins[x]);
} }
} }
} }

View file

@ -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; static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define MATRIX_ROW_SHIFTER ((matrix_row_t)1) #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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -50,7 +50,7 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} }
return false; return false;
@ -60,9 +60,9 @@ static void unselect_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
# ifdef MATRIX_UNSELECT_DRIVE_HIGH # ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
# else # else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
# endif # endif
} }
} }
@ -78,10 +78,10 @@ __attribute__((weak)) void matrix_init_custom(void) {
unselect_cols(); unselect_cols();
for (uint8_t x = 0; x < MATRIX_ROWS; x++) { for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
if (row_pins[x] != NO_PIN) { 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 __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

View file

@ -50,25 +50,25 @@ matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }
void matrix_print(void) {} 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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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); } ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
} }
// matrix code // 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) { static void unselect_rows(void) {
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
@ -103,24 +103,24 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
return false; 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) { static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) { 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) { static void init_pins(void) {
unselect_rows(); unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) { 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(); unselect_cols();
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }

View file

@ -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 raw_matrix[MATRIX_ROWS]; // raw values
extern matrix_row_t matrix[MATRIX_ROWS]; // debounced 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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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); } ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
} }
@ -108,13 +108,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
#elif defined(DIODE_DIRECTION) #elif defined(DIODE_DIRECTION)
# if (DIODE_DIRECTION == COL2ROW) # 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) { static void unselect_rows(void) {
for (uint8_t x = 0; x < MATRIX_ROWS; x++) { for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
@ -125,7 +125,7 @@ static void init_pins(void) {
# endif # endif
unselect_rows(); unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) { for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh_atomic(col_pins[x]); gpio_atomic_set_pin_input_high(col_pins[x]);
} }
} }
@ -218,20 +218,20 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
# elif (DIODE_DIRECTION == ROW2COL) # 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) { static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) { 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) { 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++) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }

View file

@ -41,21 +41,21 @@
pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
pin_t col_pins[MATRIX_COLS] = MATRIX_COL_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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -106,7 +106,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (col < SHIFT_COL_START || col > SHIFT_COL_END) { if (col < SHIFT_COL_START || col > SHIFT_COL_END) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == SHIFT_COL_START) { if (col == SHIFT_COL_START) {
@ -122,9 +122,9 @@ static void unselect_col(uint8_t col) {
if (col < SHIFT_COL_START || col > SHIFT_COL_END) { if (col < SHIFT_COL_START || col > SHIFT_COL_END) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInput_high(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
HC595_output(0x01, 1); HC595_output(0x01, 1);
@ -136,9 +136,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (x < SHIFT_COL_START || x > SHIFT_COL_END) { if (x < SHIFT_COL_START || x > SHIFT_COL_END) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInput_high(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (x == SHIFT_COL_START) HC595_output(UNSELECT_ALL_COL, 0); if (x == SHIFT_COL_START) HC595_output(UNSELECT_ALL_COL, 0);
@ -181,7 +181,7 @@ void matrix_init_custom(void) {
for (uint8_t x = 0; x < MATRIX_ROWS; x++) { for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInput_high(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -65,35 +65,35 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static void shiftOutMultiple(uint16_t dataOut) { static void shiftOutMultiple(uint16_t dataOut) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
dataOut = dataOut >> 1; dataOut = dataOut >> 1;
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
} }
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static void shiftOut_single(uint8_t dataOut) { static void shiftOut_single(uint8_t dataOut) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == (MATRIX_COLS - 8)) { if (col == (MATRIX_COLS - 8)) {
@ -111,16 +111,16 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (col == (MATRIX_COLS - 1)) { if (col == (MATRIX_COLS - 1)) {
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
} }
} }
@ -131,9 +131,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (x == (MATRIX_COLS - 1)) { if (x == (MATRIX_COLS - 1)) {
@ -148,7 +148,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -65,36 +65,36 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static void shiftOut(uint8_t dataOut) { static void shiftOut(uint8_t dataOut) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
dataOut = dataOut >> 1; dataOut = dataOut >> 1;
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
} }
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static void shiftout_single(uint8_t data) { static void shiftout_single(uint8_t data) {
if (data & 0x1) { if (data & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 10) { if (col == 10) {
@ -112,16 +112,16 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (col == (MATRIX_COLS - 1)) if (col == (MATRIX_COLS - 1))
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
} }
@ -131,9 +131,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == 10) if (x == 10)
@ -146,7 +146,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -65,37 +65,37 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static void shiftOut(uint8_t dataOut) { static void shiftOut(uint8_t dataOut) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
dataOut = dataOut >> 1; dataOut = dataOut >> 1;
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
} }
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static void shiftout_single(uint8_t data) { static void shiftout_single(uint8_t data) {
if (data & 0x1) { if (data & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 8) { if (col == 8) {
@ -113,9 +113,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (col == (MATRIX_COLS - 1)) shiftout_single(0x01); if (col == (MATRIX_COLS - 1)) shiftout_single(0x01);
@ -129,9 +129,9 @@ static void unselect_cols(void) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == (MATRIX_COLS - 1)) if (x == (MATRIX_COLS - 1))
@ -144,7 +144,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -65,37 +65,37 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static void shiftOut(uint8_t dataOut) { static void shiftOut(uint8_t dataOut) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
dataOut = dataOut >> 1; dataOut = dataOut >> 1;
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
} }
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static void shiftout_single(uint8_t data) { static void shiftout_single(uint8_t data) {
if (data & 0x1) { if (data & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 8) { if (col == 8) {
@ -113,9 +113,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (col == (MATRIX_COLS - 1)) if (col == (MATRIX_COLS - 1))
@ -130,9 +130,9 @@ static void unselect_cols(void) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == (MATRIX_COLS - 1)) if (x == (MATRIX_COLS - 1))
@ -145,7 +145,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -65,36 +65,36 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static void shiftOut(uint8_t dataOut) { static void shiftOut(uint8_t dataOut) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
dataOut = dataOut >> 1; dataOut = dataOut >> 1;
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
} }
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static void shiftout_single(uint8_t data) { static void shiftout_single(uint8_t data) {
if (data & 0x1) { if (data & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 10) { if (col == 10) {
@ -112,16 +112,16 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (col == (MATRIX_COLS - 1)) if (col == (MATRIX_COLS - 1))
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
} }
@ -131,9 +131,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == (MATRIX_COLS - 1)) if (x == (MATRIX_COLS - 1))
@ -146,7 +146,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -46,21 +46,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
# define CLR_REG_VAL 0xFF # define CLR_REG_VAL 0xFF
#endif #endif
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -77,36 +77,36 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static void shiftOut(uint16_t dataOut) { static void shiftOut(uint16_t dataOut) {
for (uint8_t i = 0; i < NO_PIN_NUM; i++) { for (uint8_t i = 0; i < NO_PIN_NUM; i++) {
if (dataOut & 0x1) { if (dataOut & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
dataOut = dataOut >> 1; dataOut = dataOut >> 1;
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
} }
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static void shiftout_single(uint8_t data) { static void shiftout_single(uint8_t data) {
if (data & 0x1) { if (data & 0x1) {
setPinOutput_writeHigh(DATA_PIN); gpio_atomic_set_pin_output_high(DATA_PIN);
} else { } else {
setPinOutput_writeLow(DATA_PIN); gpio_atomic_set_pin_output_low(DATA_PIN);
} }
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == NO_PIN_START) { if (col == NO_PIN_START) {
@ -124,16 +124,16 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (col == (MATRIX_COLS - NO_PIN_OFFSET - 1)) if (col == (MATRIX_COLS - NO_PIN_OFFSET - 1))
setPinOutput_writeHigh(CLOCK_PIN); gpio_atomic_set_pin_output_high(CLOCK_PIN);
setPinOutput_writeLow(CLOCK_PIN); gpio_atomic_set_pin_output_low(CLOCK_PIN);
setPinOutput_writeHigh(LATCH_PIN); gpio_atomic_set_pin_output_high(LATCH_PIN);
setPinOutput_writeLow(LATCH_PIN); gpio_atomic_set_pin_output_low(LATCH_PIN);
} }
} }
@ -142,9 +142,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == (MATRIX_COLS - NO_PIN_OFFSET - 1)) if (x == (MATRIX_COLS - NO_PIN_OFFSET - 1))
@ -157,7 +157,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,26 +34,26 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void writePinLow_atomic(pin_t pin) { static inline void gpio_atomic_write_pin_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_write_pin_low(pin); gpio_write_pin_low(pin);
} }
} }
static inline void writePinHigh_atomic(pin_t pin) { static inline void gpio_atomic_write_pin_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_write_pin_high(pin); gpio_write_pin_high(pin);
} }
} }
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -119,9 +119,9 @@ static bool select_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
writePinLow_atomic(pin); gpio_atomic_write_pin_low(pin);
#else #else
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
#endif #endif
return true; return true;
} else { } else {
@ -138,9 +138,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
writePinHigh_atomic(pin); gpio_atomic_write_pin_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
shiftout_single(0x01); shiftout_single(0x01);
@ -152,9 +152,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (x == 0) if (x == 0)
@ -178,7 +178,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND MATRIX_ROWS #define ROWS_PER_HAND MATRIX_ROWS
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -113,7 +113,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 8) { if (col == 8) {
@ -129,9 +129,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
shiftOut_single(0x01); shiftOut_single(0x01);
@ -143,9 +143,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (x == 8) if (x == 8)
@ -169,7 +169,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -105,7 +105,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == PIN_START_74HC595) { if (col == PIN_START_74HC595) {
@ -121,9 +121,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
shiftOut_single(0x01); shiftOut_single(0x01);
@ -137,9 +137,9 @@ static void unselect_cols(void) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == PIN_START_74HC595) if (x == PIN_START_74HC595)
@ -162,7 +162,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -113,7 +113,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 8) { if (col == 8) {
@ -129,9 +129,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
shiftOut_single(0x01); shiftOut_single(0x01);
@ -143,9 +143,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (x == 8) if (x == 8)
@ -169,7 +169,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -113,7 +113,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == 10) { if (col == 10) {
@ -129,9 +129,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
shiftOut_single(0x01); shiftOut_single(0x01);
@ -143,9 +143,9 @@ static void unselect_cols(void) {
pin_t pin = col_pins[x]; pin_t pin = col_pins[x];
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
if (x == 10) if (x == 10)
@ -169,7 +169,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define ROWS_PER_HAND (MATRIX_ROWS) #define ROWS_PER_HAND (MATRIX_ROWS)
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -105,7 +105,7 @@ static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} else { } else {
if (col == PIN_START_74HC595) { if (col == PIN_START_74HC595) {
@ -121,9 +121,9 @@ static void unselect_col(uint8_t col) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} else { } else {
shiftOut_single(0x01); shiftOut_single(0x01);
@ -137,9 +137,9 @@ static void unselect_cols(void) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
#ifdef MATRIX_UNSELECT_DRIVE_HIGH #ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
#else #else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
#endif #endif
} }
if (x == PIN_START_74HC595) if (x == PIN_START_74HC595)
@ -162,7 +162,7 @@ static void matrix_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++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }

View file

@ -20,53 +20,53 @@ 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 row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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); } ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
} }
static void select_row(uint8_t row) { static void select_row(uint8_t row) {
setPinOutput_writeLow(row_pins[row]); gpio_atomic_set_pin_output_low(row_pins[row]);
} }
static void unselect_row(uint8_t row) { static void unselect_row(uint8_t row) {
setPinInputHigh_atomic(row_pins[row]); gpio_atomic_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_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
static void select_col(uint8_t col) { static void select_col(uint8_t col) {
setPinOutput_writeLow(col_pins[col]); gpio_atomic_set_pin_output_low(col_pins[col]);
} }
static void unselect_col(uint8_t col) { static void unselect_col(uint8_t col) {
setPinInputHigh_atomic(col_pins[col]); gpio_atomic_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_atomic(col_pins[x]); gpio_atomic_set_pin_input_high(col_pins[x]);
} }
} }
static void init_pins(void) { static void init_pins(void) {
unselect_rows(); unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) { 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(); unselect_cols();
for (uint8_t x = 0; x < MATRIX_ROWS; x++) { for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }

View file

@ -20,21 +20,21 @@ static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#define MATRIX_ROW_SHIFTER ((matrix_row_t)1) #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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -51,7 +51,7 @@ static inline uint8_t readMatrixPin(pin_t pin) {
static bool select_row(uint8_t row) { static bool select_row(uint8_t row) {
pin_t pin = row_pins[row]; pin_t pin = row_pins[row];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} }
return false; return false;
@ -60,7 +60,7 @@ static bool select_row(uint8_t row) {
static void unselect_row(uint8_t row) { static void unselect_row(uint8_t row) {
pin_t pin = row_pins[row]; pin_t pin = row_pins[row];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
} }
} }
@ -74,11 +74,11 @@ __attribute__((weak)) void matrix_init_custom(void) {
unselect_rows(); unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) { for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if (col_pins[x] != NO_PIN) { if (col_pins[x] != NO_PIN) {
setPinInputHigh_atomic(col_pins[x]); gpio_atomic_set_pin_input_high(col_pins[x]);
} }
} }
setPinInputHigh_atomic(F7); gpio_atomic_set_pin_input_high(F7);
setPinInputHigh_atomic(F0); gpio_atomic_set_pin_input_high(F0);
} }
void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {

View file

@ -76,21 +76,21 @@ __attribute__((weak)) void matrix_init_pins(void);
__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row);
__attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter); __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter);
static inline void setPinOutput_writeLow(pin_t pin) { static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_low(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_output(pin); gpio_set_pin_output(pin);
gpio_write_pin_high(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 { ATOMIC_BLOCK_FORCEON {
gpio_set_pin_input_high(pin); gpio_set_pin_input_high(pin);
} }
@ -140,7 +140,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[]
static bool select_row(uint8_t row) { static bool select_row(uint8_t row) {
pin_t pin = row_pins[row]; pin_t pin = row_pins[row];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} }
return false; return false;
@ -150,9 +150,9 @@ static void unselect_row(uint8_t row) {
pin_t pin = row_pins[row]; pin_t pin = row_pins[row];
if (pin != NO_PIN) { if (pin != NO_PIN) {
# ifdef MATRIX_UNSELECT_DRIVE_HIGH # ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
# else # else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
# endif # endif
} }
} }
@ -167,7 +167,7 @@ __attribute__((weak)) void matrix_init_pins(void) {
unselect_rows(); unselect_rows();
for (uint8_t x = 0; x < MATRIX_COLS; x++) { for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if (col_pins[x] != NO_PIN) { if (col_pins[x] != NO_PIN) {
setPinInputHigh_atomic(col_pins[x]); gpio_atomic_set_pin_input_high(col_pins[x]);
} }
} }
} }
@ -203,7 +203,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[]
static bool select_col(uint8_t col) { static bool select_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinOutput_writeLow(pin); gpio_atomic_set_pin_output_low(pin);
return true; return true;
} }
return false; return false;
@ -213,9 +213,9 @@ static void unselect_col(uint8_t col) {
pin_t pin = col_pins[col]; pin_t pin = col_pins[col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
# ifdef MATRIX_UNSELECT_DRIVE_HIGH # ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin); gpio_atomic_set_pin_output_high(pin);
# else # else
setPinInputHigh_atomic(pin); gpio_atomic_set_pin_input_high(pin);
# endif # endif
} }
} }
@ -230,7 +230,7 @@ __attribute__((weak)) void matrix_init_pins(void) {
unselect_cols(); unselect_cols();
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
if (row_pins[x] != NO_PIN) { if (row_pins[x] != NO_PIN) {
setPinInputHigh_atomic(row_pins[x]); gpio_atomic_set_pin_input_high(row_pins[x]);
} }
} }
} }