Update GPIO macro usages in core (#23093)
This commit is contained in:
		
							parent
							
								
									6810aaf013
								
							
						
					
					
						commit
						2d1aed78a6
					
				
					 61 changed files with 334 additions and 334 deletions
				
			
		| 
						 | 
				
			
			@ -26,23 +26,23 @@ static const pin_t backlight_pin = BACKLIGHT_PIN;
 | 
			
		|||
 | 
			
		||||
static inline void backlight_on(pin_t backlight_pin) {
 | 
			
		||||
#if BACKLIGHT_ON_STATE == 0
 | 
			
		||||
    writePinLow(backlight_pin);
 | 
			
		||||
    gpio_write_pin_low(backlight_pin);
 | 
			
		||||
#else
 | 
			
		||||
    writePinHigh(backlight_pin);
 | 
			
		||||
    gpio_write_pin_high(backlight_pin);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void backlight_off(pin_t backlight_pin) {
 | 
			
		||||
#if BACKLIGHT_ON_STATE == 0
 | 
			
		||||
    writePinHigh(backlight_pin);
 | 
			
		||||
    gpio_write_pin_high(backlight_pin);
 | 
			
		||||
#else
 | 
			
		||||
    writePinLow(backlight_pin);
 | 
			
		||||
    gpio_write_pin_low(backlight_pin);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void backlight_pins_init(void) {
 | 
			
		||||
    // Setup backlight pin as output and output to off state.
 | 
			
		||||
    FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);)
 | 
			
		||||
    FOR_EACH_LED(gpio_set_pin_output(backlight_pin); backlight_off(backlight_pin);)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void backlight_pins_on(void) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,7 +94,7 @@ void dip_switch_init(void) {
 | 
			
		|||
    }
 | 
			
		||||
#    endif
 | 
			
		||||
    for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) {
 | 
			
		||||
        setPinInputHigh(dip_switch_pad[i]);
 | 
			
		||||
        gpio_set_pin_input_high(dip_switch_pad[i]);
 | 
			
		||||
    }
 | 
			
		||||
    dip_switch_read(true);
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ void dip_switch_read(bool forced) {
 | 
			
		|||
 | 
			
		||||
    for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) {
 | 
			
		||||
#ifdef DIP_SWITCH_PINS
 | 
			
		||||
        dip_switch_state[i] = !readPin(dip_switch_pad[i]);
 | 
			
		||||
        dip_switch_state[i] = !gpio_read_pin(dip_switch_pad[i]);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef DIP_SWITCH_MATRIX_GRID
 | 
			
		||||
        dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, read_raw);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -162,12 +162,12 @@ void encoder_init(void) {
 | 
			
		|||
#endif // defined(SPLIT_KEYBOARD) && defined(ENCODER_RESOLUTIONS)
 | 
			
		||||
 | 
			
		||||
    for (uint8_t i = 0; i < thisCount; i++) {
 | 
			
		||||
        setPinInputHigh(encoders_pad_a[i]);
 | 
			
		||||
        setPinInputHigh(encoders_pad_b[i]);
 | 
			
		||||
        gpio_set_pin_input_high(encoders_pad_a[i]);
 | 
			
		||||
        gpio_set_pin_input_high(encoders_pad_b[i]);
 | 
			
		||||
    }
 | 
			
		||||
    encoder_wait_pullup_charge();
 | 
			
		||||
    for (uint8_t i = 0; i < thisCount; i++) {
 | 
			
		||||
        encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
 | 
			
		||||
        encoder_state[i] = (gpio_read_pin(encoders_pad_a[i]) << 0) | (gpio_read_pin(encoders_pad_b[i]) << 1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -247,7 +247,7 @@ static bool encoder_update(uint8_t index, uint8_t state) {
 | 
			
		|||
bool encoder_read(void) {
 | 
			
		||||
    bool changed = false;
 | 
			
		||||
    for (uint8_t i = 0; i < thisCount; i++) {
 | 
			
		||||
        uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
 | 
			
		||||
        uint8_t new_status = (gpio_read_pin(encoders_pad_a[i]) << 0) | (gpio_read_pin(encoders_pad_b[i]) << 1);
 | 
			
		||||
        if ((encoder_state[i] & 0x3) != new_status) {
 | 
			
		||||
            encoder_state[i] <<= 2;
 | 
			
		||||
            encoder_state[i] |= new_status;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,10 +96,10 @@ void haptic_init(void) {
 | 
			
		|||
#endif
 | 
			
		||||
    eeconfig_debug_haptic();
 | 
			
		||||
#ifdef HAPTIC_ENABLE_PIN
 | 
			
		||||
    setPinOutput(HAPTIC_ENABLE_PIN);
 | 
			
		||||
    gpio_set_pin_output(HAPTIC_ENABLE_PIN);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef HAPTIC_ENABLE_STATUS_LED
 | 
			
		||||
    setPinOutput(HAPTIC_ENABLE_STATUS_LED);
 | 
			
		||||
    gpio_set_pin_output(HAPTIC_ENABLE_STATUS_LED);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -356,9 +356,9 @@ void haptic_shutdown(void) {
 | 
			
		|||
void haptic_notify_usb_device_state_change(void) {
 | 
			
		||||
    update_haptic_enable_gpios();
 | 
			
		||||
#if defined(HAPTIC_ENABLE_PIN)
 | 
			
		||||
    setPinOutput(HAPTIC_ENABLE_PIN);
 | 
			
		||||
    gpio_set_pin_output(HAPTIC_ENABLE_PIN);
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
    setPinOutput(HAPTIC_ENABLE_STATUS_LED);
 | 
			
		||||
    gpio_set_pin_output(HAPTIC_ENABLE_STATUS_LED);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,22 +84,22 @@ void haptic_notify_usb_device_state_change(void);
 | 
			
		|||
#    ifndef HAPTIC_ENABLE_PIN
 | 
			
		||||
#        error HAPTIC_ENABLE_PIN not defined
 | 
			
		||||
#    endif
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() writePinLow(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() writePinHigh(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#else
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() writePinHigh(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() writePinLow(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#    define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_PIN)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef HAPTIC_ENABLE_STATUS_LED_ACTIVE_LOW
 | 
			
		||||
#    ifndef HAPTIC_ENABLE_STATUS_LED
 | 
			
		||||
#        error HAPTIC_ENABLE_STATUS_LED not defined
 | 
			
		||||
#    endif
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() writePinLow(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() writePinHigh(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#else
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() writePinHigh(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() writePinLow(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#    define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_STATUS_LED)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef HAPTIC_OFF_IN_LOW_POWER
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ __attribute__((weak)) void joystick_axis_init(uint8_t axis) {
 | 
			
		|||
    if (axis >= JOYSTICK_AXIS_COUNT) return;
 | 
			
		||||
 | 
			
		||||
#if defined(JOYSTICK_ANALOG)
 | 
			
		||||
    setPinInput(joystick_axes[axis].input_pin);
 | 
			
		||||
    gpio_set_pin_input(joystick_axes[axis].input_pin);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -98,19 +98,19 @@ __attribute__((weak)) void led_update_ports(led_t led_state) {
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef LED_NUM_LOCK_PIN
 | 
			
		||||
    writePin(LED_NUM_LOCK_PIN, led_state.num_lock);
 | 
			
		||||
    gpio_write_pin(LED_NUM_LOCK_PIN, led_state.num_lock);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_CAPS_LOCK_PIN
 | 
			
		||||
    writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock);
 | 
			
		||||
    gpio_write_pin(LED_CAPS_LOCK_PIN, led_state.caps_lock);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_SCROLL_LOCK_PIN
 | 
			
		||||
    writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock);
 | 
			
		||||
    gpio_write_pin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_COMPOSE_PIN
 | 
			
		||||
    writePin(LED_COMPOSE_PIN, led_state.compose);
 | 
			
		||||
    gpio_write_pin(LED_COMPOSE_PIN, led_state.compose);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_KANA_PIN
 | 
			
		||||
    writePin(LED_KANA_PIN, led_state.kana);
 | 
			
		||||
    gpio_write_pin(LED_KANA_PIN, led_state.kana);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -118,24 +118,24 @@ __attribute__((weak)) void led_update_ports(led_t led_state) {
 | 
			
		|||
 */
 | 
			
		||||
__attribute__((weak)) void led_init_ports(void) {
 | 
			
		||||
#ifdef LED_NUM_LOCK_PIN
 | 
			
		||||
    setPinOutput(LED_NUM_LOCK_PIN);
 | 
			
		||||
    writePin(LED_NUM_LOCK_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
    gpio_set_pin_output(LED_NUM_LOCK_PIN);
 | 
			
		||||
    gpio_write_pin(LED_NUM_LOCK_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_CAPS_LOCK_PIN
 | 
			
		||||
    setPinOutput(LED_CAPS_LOCK_PIN);
 | 
			
		||||
    writePin(LED_CAPS_LOCK_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
    gpio_set_pin_output(LED_CAPS_LOCK_PIN);
 | 
			
		||||
    gpio_write_pin(LED_CAPS_LOCK_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_SCROLL_LOCK_PIN
 | 
			
		||||
    setPinOutput(LED_SCROLL_LOCK_PIN);
 | 
			
		||||
    writePin(LED_SCROLL_LOCK_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
    gpio_set_pin_output(LED_SCROLL_LOCK_PIN);
 | 
			
		||||
    gpio_write_pin(LED_SCROLL_LOCK_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_COMPOSE_PIN
 | 
			
		||||
    setPinOutput(LED_COMPOSE_PIN);
 | 
			
		||||
    writePin(LED_COMPOSE_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
    gpio_set_pin_output(LED_COMPOSE_PIN);
 | 
			
		||||
    gpio_write_pin(LED_COMPOSE_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LED_KANA_PIN
 | 
			
		||||
    setPinOutput(LED_KANA_PIN);
 | 
			
		||||
    writePin(LED_KANA_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
    gpio_set_pin_output(LED_KANA_PIN);
 | 
			
		||||
    gpio_write_pin(LED_KANA_PIN, !LED_PIN_ON_STATE);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,27 +78,27 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[]
 | 
			
		|||
 | 
			
		||||
static inline void setPinOutput_writeLow(pin_t pin) {
 | 
			
		||||
    ATOMIC_BLOCK_FORCEON {
 | 
			
		||||
        setPinOutput(pin);
 | 
			
		||||
        writePinLow(pin);
 | 
			
		||||
        gpio_set_pin_output(pin);
 | 
			
		||||
        gpio_write_pin_low(pin);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void setPinOutput_writeHigh(pin_t pin) {
 | 
			
		||||
    ATOMIC_BLOCK_FORCEON {
 | 
			
		||||
        setPinOutput(pin);
 | 
			
		||||
        writePinHigh(pin);
 | 
			
		||||
        gpio_set_pin_output(pin);
 | 
			
		||||
        gpio_write_pin_high(pin);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void setPinInputHigh_atomic(pin_t pin) {
 | 
			
		||||
    ATOMIC_BLOCK_FORCEON {
 | 
			
		||||
        setPinInputHigh(pin);
 | 
			
		||||
        gpio_set_pin_input_high(pin);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline uint8_t readMatrixPin(pin_t pin) {
 | 
			
		||||
    if (pin != NO_PIN) {
 | 
			
		||||
        return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
 | 
			
		||||
        return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ __attribute__((weak)) void matrix_init_pins(void) {
 | 
			
		|||
        for (int col = 0; col < MATRIX_COLS; col++) {
 | 
			
		||||
            pin_t pin = direct_pins[row][col];
 | 
			
		||||
            if (pin != NO_PIN) {
 | 
			
		||||
                setPinInputHigh(pin);
 | 
			
		||||
                gpio_set_pin_input_high(pin);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -149,9 +149,9 @@ __attribute__((weak)) void pointing_device_init(void) {
 | 
			
		|||
        pointing_device_driver.init();
 | 
			
		||||
#ifdef POINTING_DEVICE_MOTION_PIN
 | 
			
		||||
#    ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
 | 
			
		||||
        setPinInputHigh(POINTING_DEVICE_MOTION_PIN);
 | 
			
		||||
        gpio_set_pin_input_high(POINTING_DEVICE_MOTION_PIN);
 | 
			
		||||
#    else
 | 
			
		||||
        setPinInput(POINTING_DEVICE_MOTION_PIN);
 | 
			
		||||
        gpio_set_pin_input(POINTING_DEVICE_MOTION_PIN);
 | 
			
		||||
#    endif
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -247,9 +247,9 @@ __attribute__((weak)) bool pointing_device_task(void) {
 | 
			
		|||
#        error POINTING_DEVICE_MOTION_PIN not supported when sharing the pointing device report between sides.
 | 
			
		||||
#    endif
 | 
			
		||||
#    ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
 | 
			
		||||
    if (!readPin(POINTING_DEVICE_MOTION_PIN))
 | 
			
		||||
    if (!gpio_read_pin(POINTING_DEVICE_MOTION_PIN))
 | 
			
		||||
#    else
 | 
			
		||||
    if (readPin(POINTING_DEVICE_MOTION_PIN))
 | 
			
		||||
    if (gpio_read_pin(POINTING_DEVICE_MOTION_PIN))
 | 
			
		||||
#    endif
 | 
			
		||||
    {
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -123,14 +123,14 @@ void split_watchdog_task(void) {
 | 
			
		|||
void matrix_io_delay(void);
 | 
			
		||||
 | 
			
		||||
static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
 | 
			
		||||
    setPinInputHigh(in_pin);
 | 
			
		||||
    setPinOutput(out_pin);
 | 
			
		||||
    writePinLow(out_pin);
 | 
			
		||||
    gpio_set_pin_input_high(in_pin);
 | 
			
		||||
    gpio_set_pin_output(out_pin);
 | 
			
		||||
    gpio_write_pin_low(out_pin);
 | 
			
		||||
    // It's almost unnecessary, but wait until it's down to low, just in case.
 | 
			
		||||
    wait_us(1);
 | 
			
		||||
    uint8_t pin_state = readPin(in_pin);
 | 
			
		||||
    uint8_t pin_state = gpio_read_pin(in_pin);
 | 
			
		||||
    // Set out_pin to a setting that is less susceptible to noise.
 | 
			
		||||
    setPinInputHigh(out_pin);
 | 
			
		||||
    gpio_set_pin_input_high(out_pin);
 | 
			
		||||
    matrix_io_delay(); // Wait for the pull-up to go HIGH.
 | 
			
		||||
    return pin_state;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -138,13 +138,13 @@ static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
 | 
			
		|||
 | 
			
		||||
__attribute__((weak)) bool is_keyboard_left_impl(void) {
 | 
			
		||||
#if defined(SPLIT_HAND_PIN)
 | 
			
		||||
    setPinInput(SPLIT_HAND_PIN);
 | 
			
		||||
    gpio_set_pin_input(SPLIT_HAND_PIN);
 | 
			
		||||
    wait_us(100);
 | 
			
		||||
    // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
 | 
			
		||||
#    ifdef SPLIT_HAND_PIN_LOW_IS_LEFT
 | 
			
		||||
    return !readPin(SPLIT_HAND_PIN);
 | 
			
		||||
    return !gpio_read_pin(SPLIT_HAND_PIN);
 | 
			
		||||
#    else
 | 
			
		||||
    return readPin(SPLIT_HAND_PIN);
 | 
			
		||||
    return gpio_read_pin(SPLIT_HAND_PIN);
 | 
			
		||||
#    endif
 | 
			
		||||
#elif defined(SPLIT_HAND_MATRIX_GRID)
 | 
			
		||||
#    ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue