Update GPIO API usage in keyboard code (#23361)
This commit is contained in:
parent
5426a7a129
commit
d09a06a1b3
390 changed files with 3912 additions and 3913 deletions
|
|
@ -46,23 +46,23 @@ void keyboard_post_init_kb(void) {
|
|||
memset(&kb_state, 0, sizeof(kb_state));
|
||||
|
||||
// Turn off increased current limits
|
||||
setPinOutput(RGB_CURR_1500mA_OK_PIN);
|
||||
writePinLow(RGB_CURR_1500mA_OK_PIN);
|
||||
setPinOutput(RGB_CURR_3000mA_OK_PIN);
|
||||
writePinLow(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_set_pin_output(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_set_pin_output(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_3000mA_OK_PIN);
|
||||
|
||||
// Turn on the RGB
|
||||
setPinOutput(RGB_POWER_ENABLE_PIN);
|
||||
writePinHigh(RGB_POWER_ENABLE_PIN);
|
||||
gpio_set_pin_output(RGB_POWER_ENABLE_PIN);
|
||||
gpio_write_pin_high(RGB_POWER_ENABLE_PIN);
|
||||
|
||||
#ifdef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
|
||||
setPinOutput(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
|
||||
writePinHigh(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
|
||||
gpio_set_pin_output(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
|
||||
gpio_write_pin_high(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
|
||||
#endif // EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
|
||||
|
||||
// Turn on the LCD
|
||||
setPinOutput(LCD_POWER_ENABLE_PIN);
|
||||
writePinHigh(LCD_POWER_ENABLE_PIN);
|
||||
gpio_set_pin_output(LCD_POWER_ENABLE_PIN);
|
||||
gpio_write_pin_high(LCD_POWER_ENABLE_PIN);
|
||||
|
||||
// Let the LCD get some power...
|
||||
wait_ms(150);
|
||||
|
|
@ -148,16 +148,16 @@ void housekeeping_task_kb(void) {
|
|||
switch (current_setting) {
|
||||
default:
|
||||
case USBPD_500MA:
|
||||
writePinLow(RGB_CURR_1500mA_OK_PIN);
|
||||
writePinLow(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_3000mA_OK_PIN);
|
||||
break;
|
||||
case USBPD_1500MA:
|
||||
writePinHigh(RGB_CURR_1500mA_OK_PIN);
|
||||
writePinLow(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_write_pin_high(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_3000mA_OK_PIN);
|
||||
break;
|
||||
case USBPD_3000MA:
|
||||
writePinHigh(RGB_CURR_1500mA_OK_PIN);
|
||||
writePinHigh(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_write_pin_high(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_write_pin_high(RGB_CURR_3000mA_OK_PIN);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
|
@ -166,12 +166,12 @@ void housekeeping_task_kb(void) {
|
|||
default:
|
||||
case USBPD_500MA:
|
||||
case USBPD_1500MA:
|
||||
writePinLow(RGB_CURR_1500mA_OK_PIN);
|
||||
writePinLow(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_3000mA_OK_PIN);
|
||||
break;
|
||||
case USBPD_3000MA:
|
||||
writePinHigh(RGB_CURR_1500mA_OK_PIN);
|
||||
writePinLow(RGB_CURR_3000mA_OK_PIN);
|
||||
gpio_write_pin_high(RGB_CURR_1500mA_OK_PIN);
|
||||
gpio_write_pin_low(RGB_CURR_3000mA_OK_PIN);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -189,7 +189,7 @@ void housekeeping_task_kb(void) {
|
|||
// Enable/disable RGB
|
||||
if (peripherals_on) {
|
||||
// Turn on RGB
|
||||
writePinHigh(RGB_POWER_ENABLE_PIN);
|
||||
gpio_write_pin_high(RGB_POWER_ENABLE_PIN);
|
||||
// Modify the RGB state if different to the LCD state
|
||||
if (rgb_matrix_is_enabled() != peripherals_on) {
|
||||
// Wait for a small amount of time to allow the RGB capacitors to charge, before enabling RGB output
|
||||
|
|
@ -199,7 +199,7 @@ void housekeeping_task_kb(void) {
|
|||
}
|
||||
} else {
|
||||
// Turn off RGB
|
||||
writePinLow(RGB_POWER_ENABLE_PIN);
|
||||
gpio_write_pin_low(RGB_POWER_ENABLE_PIN);
|
||||
// Disable the PWM output for the RGB
|
||||
if (rgb_matrix_is_enabled() != peripherals_on) {
|
||||
rgb_matrix_disable_noeeprom();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ void matrix_wait_for_pin(pin_t pin, uint8_t target_state) {
|
|||
rtcnt_t start = chSysGetRealtimeCounterX();
|
||||
rtcnt_t end = start + 5000;
|
||||
while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
|
||||
if (readPin(pin) == target_state) {
|
||||
if (gpio_read_pin(pin) == target_state) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,10 +36,10 @@ static void dummy_vt_callback(virtual_timer_t *vtp, void *p) {}
|
|||
|
||||
void matrix_init_custom(void) {
|
||||
for (int i = 0; i < MATRIX_ROWS; ++i) {
|
||||
setPinInputHigh(row_pins[i]);
|
||||
gpio_set_pin_input_high(row_pins[i]);
|
||||
}
|
||||
for (int i = 0; i < MATRIX_COLS; ++i) {
|
||||
setPinInputHigh(col_pins[i]);
|
||||
gpio_set_pin_input_high(col_pins[i]);
|
||||
}
|
||||
|
||||
// Start a virtual timer so we'll still get periodic wakeups, now that USB SOF doesn't wake up the main loop
|
||||
|
|
@ -56,8 +56,8 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
|||
pin_t curr_col_pin = col_pins[current_col];
|
||||
|
||||
// Setup the output column pin
|
||||
setPinOutput(curr_col_pin);
|
||||
writePinLow(curr_col_pin);
|
||||
gpio_set_pin_output(curr_col_pin);
|
||||
gpio_write_pin_low(curr_col_pin);
|
||||
matrix_wait_for_pin(curr_col_pin, 0);
|
||||
|
||||
// Read the row ports
|
||||
|
|
@ -65,7 +65,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
|||
uint32_t gpio_c = palReadPort(GPIOC);
|
||||
|
||||
// Unselect the row pin
|
||||
setPinInputHigh(curr_col_pin);
|
||||
gpio_set_pin_input_high(curr_col_pin);
|
||||
|
||||
// Construct the packed bitmask for the pins
|
||||
uint32_t readback = ~(((gpio_b & GPIOB_BITMASK) >> GPIOB_OFFSET) | (((gpio_c & GPIOC_BITMASK) >> GPIOC_OFFSET) << GPIOB_COUNT));
|
||||
|
|
@ -98,11 +98,11 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
|||
void matrix_wait_for_interrupt(void) {
|
||||
// Set up row/col pins and attach callback
|
||||
for (int i = 0; i < ARRAY_SIZE(col_pins); ++i) {
|
||||
setPinOutput(col_pins[i]);
|
||||
writePinLow(col_pins[i]);
|
||||
gpio_set_pin_output(col_pins[i]);
|
||||
gpio_write_pin_low(col_pins[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRAY_SIZE(row_pins); ++i) {
|
||||
setPinInputHigh(row_pins[i]);
|
||||
gpio_set_pin_input_high(row_pins[i]);
|
||||
palEnableLineEvent(row_pins[i], PAL_EVENT_MODE_BOTH_EDGES);
|
||||
}
|
||||
|
||||
|
|
@ -112,11 +112,11 @@ void matrix_wait_for_interrupt(void) {
|
|||
// Now that the interrupt has woken us up, reset all the row/col pins back to defaults
|
||||
for (int i = 0; i < ARRAY_SIZE(row_pins); ++i) {
|
||||
palDisableLineEvent(row_pins[i]);
|
||||
writePinHigh(row_pins[i]);
|
||||
setPinInputHigh(row_pins[i]);
|
||||
gpio_write_pin_high(row_pins[i]);
|
||||
gpio_set_pin_input_high(row_pins[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRAY_SIZE(col_pins); ++i) {
|
||||
writePinHigh(col_pins[i]);
|
||||
setPinInputHigh(col_pins[i]);
|
||||
gpio_write_pin_high(col_pins[i]);
|
||||
gpio_set_pin_input_high(col_pins[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
void keyboard_post_init_kb(void) {
|
||||
// Enable RGB current limiter and wait for a bit before allowing RGB to continue
|
||||
setPinOutput(RGB_ENABLE_PIN);
|
||||
writePinHigh(RGB_ENABLE_PIN);
|
||||
gpio_set_pin_output(RGB_ENABLE_PIN);
|
||||
gpio_write_pin_high(RGB_ENABLE_PIN);
|
||||
wait_ms(20);
|
||||
|
||||
// Offload to the user func
|
||||
|
|
@ -16,12 +16,12 @@ void keyboard_post_init_kb(void) {
|
|||
|
||||
void matrix_init_custom(void) {
|
||||
// SPI Matrix
|
||||
setPinOutput(SPI_MATRIX_CHIP_SELECT_PIN);
|
||||
writePinHigh(SPI_MATRIX_CHIP_SELECT_PIN);
|
||||
gpio_set_pin_output(SPI_MATRIX_CHIP_SELECT_PIN);
|
||||
gpio_write_pin_high(SPI_MATRIX_CHIP_SELECT_PIN);
|
||||
spi_init();
|
||||
|
||||
// Encoder pushbutton
|
||||
setPinInputLow(ENCODER_PUSHBUTTON_PIN);
|
||||
gpio_set_pin_input_low(ENCODER_PUSHBUTTON_PIN);
|
||||
}
|
||||
|
||||
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
||||
|
|
@ -33,7 +33,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
|||
spi_stop();
|
||||
|
||||
// Read from the encoder pushbutton
|
||||
temp_matrix[5] = readPin(ENCODER_PUSHBUTTON_PIN) ? 1 : 0;
|
||||
temp_matrix[5] = gpio_read_pin(ENCODER_PUSHBUTTON_PIN) ? 1 : 0;
|
||||
|
||||
// Check if we've changed, return the last-read data
|
||||
bool changed = memcmp(current_matrix, temp_matrix, sizeof(temp_matrix)) != 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue