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
|
@ -34,7 +34,7 @@ static pin_t dip_switch_pad[] = DIP_SWITCH_PINS;
|
|||
|
||||
void matrix_init_custom(void) {
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
setPinInputLow(row_pins[row]);
|
||||
gpio_set_pin_input_low(row_pins[row]);
|
||||
}
|
||||
|
||||
shift_init();
|
||||
|
@ -65,12 +65,12 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
|||
void matrix_power_up(void) {
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
palDisableLineEvent(row_pins[row]);
|
||||
setPinInputLow(row_pins[row]);
|
||||
gpio_set_pin_input_low(row_pins[row]);
|
||||
}
|
||||
init_cols();
|
||||
#ifdef DIP_SWITCH_PINS
|
||||
for (uint8_t i = 1; i < NUMBER_OF_DIP_SWITCHES; i++) {
|
||||
setPinInputHigh(dip_switch_pad[i]);
|
||||
gpio_set_pin_input_high(dip_switch_pad[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -78,12 +78,12 @@ void matrix_power_up(void) {
|
|||
void matrix_power_down(void) {
|
||||
unselect_cols();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
setPinInputLow(row_pins[row]);
|
||||
gpio_set_pin_input_low(row_pins[row]);
|
||||
palEnableLineEvent(row_pins[row], PAL_EVENT_MODE_RISING_EDGE);
|
||||
}
|
||||
#ifdef DIP_SWITCH_PINS
|
||||
for (uint8_t i = 1; i < NUMBER_OF_DIP_SWITCHES; i++) {
|
||||
setPinInputLow(dip_switch_pad[i]);
|
||||
gpio_set_pin_input_low(dip_switch_pad[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ void matrix_power_down(void) {
|
|||
static uint8_t read_rows(void) {
|
||||
uint8_t row_value = 0;
|
||||
for(uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
row_value |= (readPin(row_pins[row]) << row);
|
||||
row_value |= (gpio_read_pin(row_pins[row]) << row);
|
||||
}
|
||||
return row_value;
|
||||
}
|
||||
|
@ -100,15 +100,15 @@ static void init_cols(void) {
|
|||
shift_writeAll(0);
|
||||
for(uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
if(col_pins[col] < H0) {
|
||||
setPinOutput(col_pins[col]);
|
||||
writePinLow(col_pins[col]);
|
||||
gpio_set_pin_output(col_pins[col]);
|
||||
gpio_write_pin_low(col_pins[col]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col) {
|
||||
if(col_pins[col] < H0){
|
||||
writePinHigh(col_pins[col]);
|
||||
gpio_write_pin_high(col_pins[col]);
|
||||
waitInputPinDelay();
|
||||
waitInputPinDelay();
|
||||
waitInputPinDelay();
|
||||
|
@ -122,7 +122,7 @@ static void select_col(uint8_t col) {
|
|||
|
||||
static void unselect_col(uint8_t col) {
|
||||
if(col_pins[col] < H0){
|
||||
writePinLow(col_pins[col]);
|
||||
gpio_write_pin_low(col_pins[col]);
|
||||
}else{
|
||||
shift_writePin(col_pins[col], 0);
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ static void unselect_cols(void) {
|
|||
shift_writeAll(1);
|
||||
for(uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
if(col_pins[col] < H0) {
|
||||
setPinOutput(col_pins[col]);
|
||||
writePinHigh(col_pins[col]);
|
||||
gpio_set_pin_output(col_pins[col]);
|
||||
gpio_write_pin_high(col_pins[col]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,25 +49,25 @@ void ws2812_poweron(void) {
|
|||
if(p_setup) return;
|
||||
p_setup = true;
|
||||
s_init = false;
|
||||
setPinOutput(RGB_EN_PIN);
|
||||
writePinHigh(RGB_EN_PIN);
|
||||
gpio_set_pin_output(RGB_EN_PIN);
|
||||
gpio_write_pin_high(RGB_EN_PIN);
|
||||
}
|
||||
|
||||
void ws2812_poweroff(void) {
|
||||
if(!p_setup) return;
|
||||
p_setup = false;
|
||||
setPinInputLow(WS2812_DI_PIN);
|
||||
writePinLow(RGB_EN_PIN);
|
||||
gpio_set_pin_input_low(WS2812_DI_PIN);
|
||||
gpio_write_pin_low(RGB_EN_PIN);
|
||||
}
|
||||
|
||||
void keyboard_pre_init_kb() {
|
||||
keyboard_pre_init_user();
|
||||
|
||||
setPinInputLow(MWPROTO_STATUS_PIN);
|
||||
setPinOutput(MWPROTO_WAKEUP_PIN);
|
||||
writePinLow(MWPROTO_WAKEUP_PIN);
|
||||
gpio_set_pin_input_low(MWPROTO_STATUS_PIN);
|
||||
gpio_set_pin_output(MWPROTO_WAKEUP_PIN);
|
||||
gpio_write_pin_low(MWPROTO_WAKEUP_PIN);
|
||||
wait_ms(2);
|
||||
writePinHigh(MWPROTO_WAKEUP_PIN);
|
||||
gpio_write_pin_high(MWPROTO_WAKEUP_PIN);
|
||||
|
||||
palSetLineMode(MWPROTO_TX_PIN, PAL_MODE_ALTERNATE(MWPROTO_TX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
|
||||
sdStart(&MWPROTO_DRIVER, &mwproto_uart_config);
|
||||
|
@ -84,14 +84,14 @@ void keyboard_post_init_kb(void) {
|
|||
"BUILD: " __DATE__ "\n"
|
||||
); /* clang-format on */
|
||||
|
||||
writePinLow(MWPROTO_WAKEUP_PIN);
|
||||
gpio_write_pin_low(MWPROTO_WAKEUP_PIN);
|
||||
wait_ms(50);
|
||||
sdPutI(&MWPROTO_DRIVER, 0xA5);
|
||||
sdPutI(&MWPROTO_DRIVER, 0x12);
|
||||
sdPutI(&MWPROTO_DRIVER, 0x01);
|
||||
sdPutI(&MWPROTO_DRIVER, 0x02);
|
||||
sdPutI(&MWPROTO_DRIVER, 0xB4);
|
||||
writePinHigh(MWPROTO_WAKEUP_PIN);
|
||||
gpio_write_pin_high(MWPROTO_WAKEUP_PIN);
|
||||
|
||||
ws2812_poweron();
|
||||
loop10hz_token = defer_exec(LOOP_10HZ_PERIOD, loop_10Hz, NULL);
|
||||
|
@ -117,7 +117,7 @@ bool dip_switch_update_mask_kb(uint32_t state) {
|
|||
usbDisconnectBus(&USB_DRIVER);
|
||||
usbStop(&USB_DRIVER);
|
||||
shutdown_user(true);
|
||||
setPinInputHigh(POWER_SWITCH_PIN);
|
||||
gpio_set_pin_input_high(POWER_SWITCH_PIN);
|
||||
palEnableLineEvent(POWER_SWITCH_PIN, PAL_EVENT_MODE_RISING_EDGE);
|
||||
POWER_EnterSleep();
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ uint32_t loop_10Hz(uint32_t trigger_time, void *cb_arg) {
|
|||
static uint32_t pmu_timer = 0;
|
||||
if(timer_elapsed32(pmu_timer) > 3000) {
|
||||
pmu_timer = timer_read32();
|
||||
writePinLow(MWPROTO_WAKEUP_PIN);
|
||||
if(readPin(MWPROTO_STATUS_PIN))
|
||||
gpio_write_pin_low(MWPROTO_WAKEUP_PIN);
|
||||
if(gpio_read_pin(MWPROTO_STATUS_PIN))
|
||||
wait_us(500);
|
||||
else
|
||||
wait_us(1500);
|
||||
|
@ -141,7 +141,7 @@ uint32_t loop_10Hz(uint32_t trigger_time, void *cb_arg) {
|
|||
sdPutI(&MWPROTO_DRIVER, 0x28);
|
||||
sdPutI(&MWPROTO_DRIVER, 0x00);
|
||||
sdPutI(&MWPROTO_DRIVER, 0x8D);
|
||||
writePinHigh(MWPROTO_WAKEUP_PIN);
|
||||
gpio_write_pin_high(MWPROTO_WAKEUP_PIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,8 +151,8 @@ uint32_t loop_10Hz(uint32_t trigger_time, void *cb_arg) {
|
|||
matrix[2] == 0 && matrix[3] == 0 && matrix[4] == 0 && matrix[5] == 0x201) {
|
||||
if(restore_tick++ > 50) {
|
||||
restore_tick = 0;
|
||||
writePinLow(MWPROTO_WAKEUP_PIN);
|
||||
if(readPin(MWPROTO_STATUS_PIN))
|
||||
gpio_write_pin_low(MWPROTO_WAKEUP_PIN);
|
||||
if(gpio_read_pin(MWPROTO_STATUS_PIN))
|
||||
wait_us(500);
|
||||
else
|
||||
wait_us(1500);
|
||||
|
@ -161,7 +161,7 @@ uint32_t loop_10Hz(uint32_t trigger_time, void *cb_arg) {
|
|||
sdPutI(&MWPROTO_DRIVER, 0x01);
|
||||
sdPutI(&MWPROTO_DRIVER, 0x0F);
|
||||
sdPutI(&MWPROTO_DRIVER, 0xB4);
|
||||
writePinHigh(MWPROTO_WAKEUP_PIN);
|
||||
gpio_write_pin_high(MWPROTO_WAKEUP_PIN);
|
||||
wait_ms(50);
|
||||
eeconfig_init();
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
|
|
|
@ -23,30 +23,30 @@ static uint8_t shift_values[SHR_SERIES_NUM] = {0};
|
|||
|
||||
void shift_init(void) {
|
||||
#ifdef SHR_OE_PIN
|
||||
setPinOutput(SHR_OE_PIN);
|
||||
writePinHigh(SHR_OE_PIN);
|
||||
gpio_set_pin_output(SHR_OE_PIN);
|
||||
gpio_write_pin_high(SHR_OE_PIN);
|
||||
#endif
|
||||
setPinOutput(SHR_DATA_PIN);
|
||||
setPinOutput(SHR_LATCH_PIN);
|
||||
setPinOutput(SHR_CLOCK_PIN);
|
||||
gpio_set_pin_output(SHR_DATA_PIN);
|
||||
gpio_set_pin_output(SHR_LATCH_PIN);
|
||||
gpio_set_pin_output(SHR_CLOCK_PIN);
|
||||
}
|
||||
|
||||
void shift_enable(void) {
|
||||
#ifdef SHR_OE_PIN
|
||||
writePinLow(SHR_OE_PIN);
|
||||
gpio_write_pin_low(SHR_OE_PIN);
|
||||
#endif
|
||||
writePinLow(SHR_DATA_PIN);
|
||||
writePinLow(SHR_LATCH_PIN);
|
||||
writePinLow(SHR_CLOCK_PIN);
|
||||
gpio_write_pin_low(SHR_DATA_PIN);
|
||||
gpio_write_pin_low(SHR_LATCH_PIN);
|
||||
gpio_write_pin_low(SHR_CLOCK_PIN);
|
||||
}
|
||||
|
||||
void shift_disable(void) {
|
||||
#ifdef SHR_OE_PIN
|
||||
writePinHigh(SHR_OE_PIN);
|
||||
gpio_write_pin_high(SHR_OE_PIN);
|
||||
#endif
|
||||
writePinLow(SHR_DATA_PIN);
|
||||
writePinLow(SHR_LATCH_PIN);
|
||||
writePinLow(SHR_CLOCK_PIN);
|
||||
gpio_write_pin_low(SHR_DATA_PIN);
|
||||
gpio_write_pin_low(SHR_LATCH_PIN);
|
||||
gpio_write_pin_low(SHR_CLOCK_PIN);
|
||||
}
|
||||
|
||||
void shift_writePin(pin_t pin, int level) {
|
||||
|
@ -78,13 +78,13 @@ void shift_writeAll(int level) {
|
|||
|
||||
static void shift_out(void) {
|
||||
uint8_t n = SHR_SERIES_NUM;
|
||||
writePinLow(SHR_LATCH_PIN);
|
||||
gpio_write_pin_low(SHR_LATCH_PIN);
|
||||
while(n--){
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
writePinLow(SHR_CLOCK_PIN);
|
||||
writePin(SHR_DATA_PIN, shift_values[n] & (0x80 >> i));
|
||||
writePinHigh(SHR_CLOCK_PIN);
|
||||
gpio_write_pin_low(SHR_CLOCK_PIN);
|
||||
gpio_write_pin(SHR_DATA_PIN, shift_values[n] & (0x80 >> i));
|
||||
gpio_write_pin_high(SHR_CLOCK_PIN);
|
||||
}
|
||||
}
|
||||
writePinHigh(SHR_LATCH_PIN);
|
||||
gpio_write_pin_high(SHR_LATCH_PIN);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue