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
|
@ -48,35 +48,35 @@ _Static_assert(sizeof(mux_sel_pins) == 3, "invalid MUX_SEL_PINS");
|
|||
static ec_config_t config;
|
||||
static uint16_t ec_sw_value[MATRIX_COLS][MATRIX_ROWS];
|
||||
|
||||
static inline void discharge_capacitor(void) { setPinOutput(DISCHARGE_PIN); }
|
||||
static inline void discharge_capacitor(void) { gpio_set_pin_output(DISCHARGE_PIN); }
|
||||
static inline void charge_capacitor(uint8_t col) {
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
writePinHigh(col_pins[col]);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
gpio_write_pin_high(col_pins[col]);
|
||||
}
|
||||
|
||||
static inline void clear_all_col_pins(void) {
|
||||
for (int col = 0; col < sizeof(col_pins); col++) {
|
||||
writePinLow(col_pins[col]);
|
||||
gpio_write_pin_low(col_pins[col]);
|
||||
}
|
||||
}
|
||||
|
||||
void init_mux_sel(void) {
|
||||
for (int idx = 0; idx < sizeof(mux_sel_pins); idx++) {
|
||||
setPinOutput(mux_sel_pins[idx]);
|
||||
gpio_set_pin_output(mux_sel_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
void select_mux(uint8_t row) {
|
||||
uint8_t ch = row_channels[row];
|
||||
writePin(mux_sel_pins[0], ch & 1);
|
||||
writePin(mux_sel_pins[1], ch & 2);
|
||||
writePin(mux_sel_pins[2], ch & 4);
|
||||
gpio_write_pin(mux_sel_pins[0], ch & 1);
|
||||
gpio_write_pin(mux_sel_pins[1], ch & 2);
|
||||
gpio_write_pin(mux_sel_pins[2], ch & 4);
|
||||
}
|
||||
|
||||
void init_col(void) {
|
||||
for (int idx = 0; idx < sizeof(col_pins); idx++) {
|
||||
setPinOutput(col_pins[idx]);
|
||||
writePinLow(col_pins[idx]);
|
||||
gpio_set_pin_output(col_pins[idx]);
|
||||
gpio_write_pin_low(col_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
config = *ec_config;
|
||||
|
||||
// initialize discharge pin as discharge mode
|
||||
writePinLow(DISCHARGE_PIN);
|
||||
setPinOutput(DISCHARGE_PIN);
|
||||
gpio_write_pin_low(DISCHARGE_PIN);
|
||||
gpio_set_pin_output(DISCHARGE_PIN);
|
||||
|
||||
// set analog reference
|
||||
analogReference(ADC_REF_POWER);
|
||||
|
@ -98,7 +98,7 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
init_mux_sel();
|
||||
|
||||
// set discharge pin to charge mode
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
}
|
||||
|
||||
uint16_t ec_readkey_raw(uint8_t col, uint8_t row) {
|
||||
|
|
|
@ -48,35 +48,35 @@ _Static_assert(sizeof(mux_sel_pins) == 3, "invalid MUX_SEL_PINS");
|
|||
static ec_config_t config;
|
||||
static uint16_t ec_sw_value[MATRIX_COLS][MATRIX_ROWS];
|
||||
|
||||
static inline void discharge_capacitor(void) { setPinOutput(DISCHARGE_PIN); }
|
||||
static inline void discharge_capacitor(void) { gpio_set_pin_output(DISCHARGE_PIN); }
|
||||
static inline void charge_capacitor(uint8_t col) {
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
writePinHigh(col_pins[col]);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
gpio_write_pin_high(col_pins[col]);
|
||||
}
|
||||
|
||||
static inline void clear_all_col_pins(void) {
|
||||
for (int col = 0; col < sizeof(col_pins); col++) {
|
||||
writePinLow(col_pins[col]);
|
||||
gpio_write_pin_low(col_pins[col]);
|
||||
}
|
||||
}
|
||||
|
||||
void init_mux_sel(void) {
|
||||
for (int idx = 0; idx < sizeof(mux_sel_pins); idx++) {
|
||||
setPinOutput(mux_sel_pins[idx]);
|
||||
gpio_set_pin_output(mux_sel_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
void select_mux(uint8_t row) {
|
||||
uint8_t ch = row_channels[row];
|
||||
writePin(mux_sel_pins[0], ch & 1);
|
||||
writePin(mux_sel_pins[1], ch & 2);
|
||||
writePin(mux_sel_pins[2], ch & 4);
|
||||
gpio_write_pin(mux_sel_pins[0], ch & 1);
|
||||
gpio_write_pin(mux_sel_pins[1], ch & 2);
|
||||
gpio_write_pin(mux_sel_pins[2], ch & 4);
|
||||
}
|
||||
|
||||
void init_col(void) {
|
||||
for (int idx = 0; idx < sizeof(col_pins); idx++) {
|
||||
setPinOutput(col_pins[idx]);
|
||||
writePinLow(col_pins[idx]);
|
||||
gpio_set_pin_output(col_pins[idx]);
|
||||
gpio_write_pin_low(col_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
config = *ec_config;
|
||||
|
||||
// initialize discharge pin as discharge mode
|
||||
writePinLow(DISCHARGE_PIN);
|
||||
setPinOutput(DISCHARGE_PIN);
|
||||
gpio_write_pin_low(DISCHARGE_PIN);
|
||||
gpio_set_pin_output(DISCHARGE_PIN);
|
||||
|
||||
// set analog reference
|
||||
analogReference(ADC_REF_POWER);
|
||||
|
@ -98,7 +98,7 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
init_mux_sel();
|
||||
|
||||
// set discharge pin to charge mode
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
}
|
||||
|
||||
uint16_t ec_readkey_raw(uint8_t col, uint8_t row) {
|
||||
|
|
|
@ -48,35 +48,35 @@ _Static_assert(sizeof(mux_sel_pins) == 3, "invalid MUX_SEL_PINS");
|
|||
static ec_config_t config;
|
||||
static uint16_t ec_sw_value[MATRIX_COLS][MATRIX_ROWS];
|
||||
|
||||
static inline void discharge_capacitor(void) { setPinOutput(DISCHARGE_PIN); }
|
||||
static inline void discharge_capacitor(void) { gpio_set_pin_output(DISCHARGE_PIN); }
|
||||
static inline void charge_capacitor(uint8_t col) {
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
writePinHigh(col_pins[col]);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
gpio_write_pin_high(col_pins[col]);
|
||||
}
|
||||
|
||||
static inline void clear_all_col_pins(void) {
|
||||
for (int col = 0; col < sizeof(col_pins); col++) {
|
||||
writePinLow(col_pins[col]);
|
||||
gpio_write_pin_low(col_pins[col]);
|
||||
}
|
||||
}
|
||||
|
||||
void init_mux_sel(void) {
|
||||
for (int idx = 0; idx < sizeof(mux_sel_pins); idx++) {
|
||||
setPinOutput(mux_sel_pins[idx]);
|
||||
gpio_set_pin_output(mux_sel_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
void select_mux(uint8_t row) {
|
||||
uint8_t ch = row_channels[row];
|
||||
writePin(mux_sel_pins[0], ch & 1);
|
||||
writePin(mux_sel_pins[1], ch & 2);
|
||||
writePin(mux_sel_pins[2], ch & 4);
|
||||
gpio_write_pin(mux_sel_pins[0], ch & 1);
|
||||
gpio_write_pin(mux_sel_pins[1], ch & 2);
|
||||
gpio_write_pin(mux_sel_pins[2], ch & 4);
|
||||
}
|
||||
|
||||
void init_col(void) {
|
||||
for (int idx = 0; idx < sizeof(col_pins); idx++) {
|
||||
setPinOutput(col_pins[idx]);
|
||||
writePinLow(col_pins[idx]);
|
||||
gpio_set_pin_output(col_pins[idx]);
|
||||
gpio_write_pin_low(col_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
config = *ec_config;
|
||||
|
||||
// initialize discharge pin as discharge mode
|
||||
writePinLow(DISCHARGE_PIN);
|
||||
setPinOutput(DISCHARGE_PIN);
|
||||
gpio_write_pin_low(DISCHARGE_PIN);
|
||||
gpio_set_pin_output(DISCHARGE_PIN);
|
||||
|
||||
// set analog reference
|
||||
analogReference(ADC_REF_POWER);
|
||||
|
@ -98,7 +98,7 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
init_mux_sel();
|
||||
|
||||
// set discharge pin to charge mode
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
}
|
||||
|
||||
uint16_t ec_readkey_raw(uint8_t col, uint8_t row) {
|
||||
|
|
|
@ -33,22 +33,22 @@ static const pin_t col_pins[MATRIX_COLS] = {F5, F6, F7, C7, C6, B6, B5, D3,
|
|||
//_____REGULAR funcs____________________________________________________________
|
||||
|
||||
static 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]);
|
||||
}
|
||||
|
||||
static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); }
|
||||
static void unselect_row(uint8_t row) { gpio_set_pin_input_high(row_pins[row]); }
|
||||
|
||||
static void unselect_rows(void) {
|
||||
for (uint8_t x = 0; x < MATRIX_ROWS / 2; x++) {
|
||||
setPinInputHigh(row_pins[x]);
|
||||
gpio_set_pin_input_high(row_pins[x]);
|
||||
}
|
||||
}
|
||||
|
||||
static void init_pins(void) {
|
||||
unselect_rows();
|
||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
setPinInputHigh(col_pins[x]);
|
||||
gpio_set_pin_input_high(col_pins[x]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
// 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_row_value |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index);
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
// enable built in pullups to avoid timeouts when right hand not connected
|
||||
setPinInputHigh(D0);
|
||||
setPinInputHigh(D1);
|
||||
gpio_set_pin_input_high(D0);
|
||||
gpio_set_pin_input_high(D1);
|
||||
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
setPinOutput(F0);
|
||||
setPinOutput(F1);
|
||||
setPinOutput(F4);
|
||||
gpio_set_pin_output(F0);
|
||||
gpio_set_pin_output(F1);
|
||||
gpio_set_pin_output(F4);
|
||||
|
||||
matrix_init_user();
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ void matrix_init_kb(void) {
|
|||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if (res) {
|
||||
writePin(F0, led_state.num_lock);
|
||||
writePin(F1, led_state.caps_lock);
|
||||
writePin(F4, led_state.scroll_lock);
|
||||
gpio_write_pin(F0, led_state.num_lock);
|
||||
gpio_write_pin(F1, led_state.caps_lock);
|
||||
gpio_write_pin(F4, led_state.scroll_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
// enable built in pullups to avoid timeouts when right hand not connected
|
||||
setPinInputHigh(D0);
|
||||
setPinInputHigh(D1);
|
||||
gpio_set_pin_input_high(D0);
|
||||
gpio_set_pin_input_high(D1);
|
||||
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
// enable built in pullups to avoid timeouts when right hand not connected
|
||||
setPinInputHigh(D0);
|
||||
setPinInputHigh(D1);
|
||||
gpio_set_pin_input_high(D0);
|
||||
gpio_set_pin_input_high(D1);
|
||||
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
|
|
@ -49,35 +49,35 @@ _Static_assert(sizeof(mux_sel_pins) == 3, "invalid MUX_SEL_PINS");
|
|||
static ec_config_t config;
|
||||
static uint16_t ec_sw_value[MATRIX_COLS][MATRIX_ROWS];
|
||||
|
||||
static inline void discharge_capacitor(void) { setPinOutput(DISCHARGE_PIN); }
|
||||
static inline void discharge_capacitor(void) { gpio_set_pin_output(DISCHARGE_PIN); }
|
||||
static inline void charge_capacitor(uint8_t col) {
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
writePinHigh(col_pins[col]);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
gpio_write_pin_high(col_pins[col]);
|
||||
}
|
||||
|
||||
static inline void clear_all_col_pins(void) {
|
||||
for (int col = 0; col < sizeof(col_pins); col++) {
|
||||
writePinLow(col_pins[col]);
|
||||
gpio_write_pin_low(col_pins[col]);
|
||||
}
|
||||
}
|
||||
|
||||
void init_mux_sel(void) {
|
||||
for (int idx = 0; idx < sizeof(mux_sel_pins); idx++) {
|
||||
setPinOutput(mux_sel_pins[idx]);
|
||||
gpio_set_pin_output(mux_sel_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
void select_mux(uint8_t row) {
|
||||
uint8_t ch = row_channels[row];
|
||||
writePin(mux_sel_pins[0], ch & 1);
|
||||
writePin(mux_sel_pins[1], ch & 2);
|
||||
writePin(mux_sel_pins[2], ch & 4);
|
||||
gpio_write_pin(mux_sel_pins[0], ch & 1);
|
||||
gpio_write_pin(mux_sel_pins[1], ch & 2);
|
||||
gpio_write_pin(mux_sel_pins[2], ch & 4);
|
||||
}
|
||||
|
||||
void init_col(void) {
|
||||
for (int idx = 0; idx < sizeof(col_pins); idx++) {
|
||||
setPinOutput(col_pins[idx]);
|
||||
writePinLow(col_pins[idx]);
|
||||
gpio_set_pin_output(col_pins[idx]);
|
||||
gpio_write_pin_low(col_pins[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
config = *ec_config;
|
||||
|
||||
// initialize discharge pin as discharge mode
|
||||
writePinLow(DISCHARGE_PIN);
|
||||
setPinOutput(DISCHARGE_PIN);
|
||||
gpio_write_pin_low(DISCHARGE_PIN);
|
||||
gpio_set_pin_output(DISCHARGE_PIN);
|
||||
|
||||
// set analog reference
|
||||
analogReference(ADC_REF_POWER);
|
||||
|
@ -99,7 +99,7 @@ void ec_init(ec_config_t const* const ec_config) {
|
|||
init_mux_sel();
|
||||
|
||||
// set discharge pin to charge mode
|
||||
setPinInput(DISCHARGE_PIN);
|
||||
gpio_set_pin_input(DISCHARGE_PIN);
|
||||
}
|
||||
|
||||
uint16_t ec_readkey_raw(uint8_t col, uint8_t row) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue