Update GPIO API usage in keyboard code (#23361)

This commit is contained in:
Ryan
2024-05-03 15:21:29 +10:00
committed by GitHub
parent 5426a7a129
commit d09a06a1b3
390 changed files with 3912 additions and 3913 deletions

View File

@@ -23,12 +23,12 @@
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(F7);
gpio_set_pin_output(F7);
}
bool led_update_kb(led_t led_state) {
if(led_update_user(led_state)) {
writePin(F7, !led_state.num_lock);
gpio_write_pin(F7, !led_state.num_lock);
}
return true;
}

View File

@@ -19,12 +19,12 @@
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(C6);
gpio_set_pin_output(C6);
}
bool led_update_kb(led_t led_state) {
if(led_update_user(led_state)) {
writePin(C6, !led_state.caps_lock);
gpio_write_pin(C6, !led_state.caps_lock);
}
return true;
}

View File

@@ -18,15 +18,15 @@
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(D5);
setPinOutput(E6);
gpio_set_pin_output(D5);
gpio_set_pin_output(E6);
matrix_init_user();
}
bool led_update_kb(led_t led_state) {
if(led_update_user(led_state)) {
writePin(D5, !led_state.caps_lock);
writePin(E6, !led_state.scroll_lock);
gpio_write_pin(D5, !led_state.caps_lock);
gpio_write_pin(E6, !led_state.scroll_lock);
}
return true;
}

View File

@@ -18,15 +18,15 @@
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(D5);
setPinOutput(E6);
gpio_set_pin_output(D5);
gpio_set_pin_output(E6);
matrix_init_user();
}
bool led_update_kb(led_t led_state) {
if(led_update_user(led_state)) {
writePin(D5, !led_state.caps_lock);
writePin(E6, !led_state.scroll_lock);
gpio_write_pin(D5, !led_state.caps_lock);
gpio_write_pin(E6, !led_state.scroll_lock);
}
return true;
}

View File

@@ -27,11 +27,11 @@ static matrix_row_t last_matrix[MATRIX_ROWS]; // raw values of last scan
// matrix code
void select_row(uint8_t row) {
setPinOutput(row_pins[row]);
writePinLow(row_pins[row]);
gpio_set_pin_output(row_pins[row]);
gpio_write_pin_low(row_pins[row]);
}
void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); }
void unselect_row(uint8_t row) { gpio_set_pin_input_high(row_pins[row]); }
bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
// Store last value of row prior to reading
@@ -47,7 +47,7 @@ static matrix_row_t last_matrix[MATRIX_ROWS]; // raw values of last scan
// For each col...
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
// Select the col pin to read (active low)
uint8_t pin_state = readPin(col_pins[col_index]);
uint8_t pin_state = gpio_read_pin(col_pins[col_index]);
// Populate the matrix row with the state of the col pin
current_matrix[current_row] |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index);
@@ -60,11 +60,11 @@ static matrix_row_t last_matrix[MATRIX_ROWS]; // raw values of last scan
}
void select_col(uint8_t col) {
setPinOutput(col_pins[col]);
writePinLow(col_pins[col]);
gpio_set_pin_output(col_pins[col]);
gpio_write_pin_low(col_pins[col]);
}
void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
void unselect_col(uint8_t col) { gpio_set_pin_input_high(col_pins[col]); }
bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
bool matrix_changed = false;
@@ -79,7 +79,7 @@ static matrix_row_t last_matrix[MATRIX_ROWS]; // raw values of last scan
matrix_row_t last_row_value = current_matrix[row_index];
// Check row pin state
if (readPin(row_pins[row_index]) == 0) {
if (gpio_read_pin(row_pins[row_index]) == 0) {
// Pin LO, set col bit
current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col);
}
@@ -98,13 +98,13 @@ static matrix_row_t last_matrix[MATRIX_ROWS]; // raw values of last scan
void unselect_rows(void) {
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh(row_pins[x]);
gpio_set_pin_input_high(row_pins[x]);
}
}
void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh(col_pins[x]);
gpio_set_pin_input_high(col_pins[x]);
}
}

View File

@@ -24,8 +24,8 @@
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(D3);
setPinOutput(D5);
gpio_set_pin_output(D3);
gpio_set_pin_output(D5);
matrix_init_user();
}
@@ -33,13 +33,13 @@ bool led_update_kb(led_t led_state) {
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
bool res = led_update_user(led_state);
if(res) {
// writePin sets the pin high for 1 and low for 0.
// gpio_write_pin sets the pin high for 1 and low for 0.
// In this example the pins are inverted, setting
// it low/0 turns it on, and high/1 turns the LED off.
// This behavior depends on whether the LED is between the pin
// and VCC or the pin and GND.
writePin(D3, led_state.caps_lock);
writePin(D5, led_state.scroll_lock);
gpio_write_pin(D3, led_state.caps_lock);
gpio_write_pin(D5, led_state.scroll_lock);
}
return res;
return led_update_user(led_state);