Update atomic GPIO macros in keyboard custom matrix (#23796)
This commit is contained in:
		
							parent
							
								
									5c43a9bed1
								
							
						
					
					
						commit
						1552cf2ddc
					
				
					 20 changed files with 270 additions and 270 deletions
				
			
		| 
						 | 
				
			
			@ -34,21 +34,21 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
 | 
			
		|||
 | 
			
		||||
#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 {
 | 
			
		||||
        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);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -65,37 +65,37 @@ static inline uint8_t readMatrixPin(pin_t pin) {
 | 
			
		|||
static void shiftOut(uint8_t dataOut) {
 | 
			
		||||
    for (uint8_t i = 0; i < 8; i++) {
 | 
			
		||||
        if (dataOut & 0x1) {
 | 
			
		||||
            setPinOutput_writeHigh(DATA_PIN);
 | 
			
		||||
            gpio_atomic_set_pin_output_high(DATA_PIN);
 | 
			
		||||
        } else {
 | 
			
		||||
            setPinOutput_writeLow(DATA_PIN);
 | 
			
		||||
            gpio_atomic_set_pin_output_low(DATA_PIN);
 | 
			
		||||
        }
 | 
			
		||||
        dataOut = dataOut >> 1;
 | 
			
		||||
        setPinOutput_writeHigh(CLOCK_PIN);
 | 
			
		||||
        setPinOutput_writeLow(CLOCK_PIN);
 | 
			
		||||
        gpio_atomic_set_pin_output_high(CLOCK_PIN);
 | 
			
		||||
        gpio_atomic_set_pin_output_low(CLOCK_PIN);
 | 
			
		||||
    }
 | 
			
		||||
    setPinOutput_writeHigh(LATCH_PIN);
 | 
			
		||||
    setPinOutput_writeLow(LATCH_PIN);
 | 
			
		||||
    gpio_atomic_set_pin_output_high(LATCH_PIN);
 | 
			
		||||
    gpio_atomic_set_pin_output_low(LATCH_PIN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void shiftout_single(uint8_t data) {
 | 
			
		||||
    if (data & 0x1) {
 | 
			
		||||
        setPinOutput_writeHigh(DATA_PIN);
 | 
			
		||||
        gpio_atomic_set_pin_output_high(DATA_PIN);
 | 
			
		||||
    } else {
 | 
			
		||||
        setPinOutput_writeLow(DATA_PIN);
 | 
			
		||||
        gpio_atomic_set_pin_output_low(DATA_PIN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setPinOutput_writeHigh(CLOCK_PIN);
 | 
			
		||||
    setPinOutput_writeLow(CLOCK_PIN);
 | 
			
		||||
    gpio_atomic_set_pin_output_high(CLOCK_PIN);
 | 
			
		||||
    gpio_atomic_set_pin_output_low(CLOCK_PIN);
 | 
			
		||||
 | 
			
		||||
    setPinOutput_writeHigh(LATCH_PIN);
 | 
			
		||||
    setPinOutput_writeLow(LATCH_PIN);
 | 
			
		||||
    gpio_atomic_set_pin_output_high(LATCH_PIN);
 | 
			
		||||
    gpio_atomic_set_pin_output_low(LATCH_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;
 | 
			
		||||
    } else {
 | 
			
		||||
        if (col == 8) {
 | 
			
		||||
| 
						 | 
				
			
			@ -113,9 +113,9 @@ static void unselect_col(uint8_t 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
 | 
			
		||||
    } else {
 | 
			
		||||
        if (col == (MATRIX_COLS - 1)) shiftout_single(0x01);
 | 
			
		||||
| 
						 | 
				
			
			@ -129,9 +129,9 @@ static void unselect_cols(void) {
 | 
			
		|||
 | 
			
		||||
        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
 | 
			
		||||
        }
 | 
			
		||||
        if (x == (MATRIX_COLS - 1))
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ static void matrix_init_pins(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]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue