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
|
|
@ -5,21 +5,21 @@ void matrix_init_kb(void)
|
|||
{
|
||||
matrix_init_user();
|
||||
|
||||
setPinOutput(RED_LED);
|
||||
setPinOutput(BLUE_LED);
|
||||
setPinOutput(GREEN_LED);
|
||||
gpio_set_pin_output(RED_LED);
|
||||
gpio_set_pin_output(BLUE_LED);
|
||||
gpio_set_pin_output(GREEN_LED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void turn_off_leds(void)
|
||||
{
|
||||
writePinLow(RED_LED);
|
||||
writePinLow(BLUE_LED);
|
||||
writePinLow(GREEN_LED);
|
||||
gpio_write_pin_low(RED_LED);
|
||||
gpio_write_pin_low(BLUE_LED);
|
||||
gpio_write_pin_low(GREEN_LED);
|
||||
}
|
||||
|
||||
void turn_on_led(pin_t pin)
|
||||
{
|
||||
writePinHigh(pin);
|
||||
gpio_write_pin_high(pin);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ void keyboard_pre_init_user(void) {
|
|||
// Call the keyboard pre init code.
|
||||
|
||||
// Set our LED pins as output
|
||||
setPinOutput(C3);
|
||||
gpio_set_pin_output(C3);
|
||||
}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
// Flash the led 1 sec on startup.
|
||||
writePinHigh(C3);
|
||||
gpio_write_pin_high(C3);
|
||||
wait_ms(1000);
|
||||
writePinLow(C3);
|
||||
gpio_write_pin_low(C3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
|
|||
|
||||
/* joystick button code (thumbstick pressed) */
|
||||
void keyboard_pre_init_kb(void) {
|
||||
setPinInputHigh(F6);
|
||||
gpio_set_pin_input_high(F6);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@ void suspend_wakeup_init_kb(void)
|
|||
bool led_update_kb(led_t led_state) {
|
||||
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(B2, !led_state.num_lock);
|
||||
writePin(C6, !led_state.caps_lock);
|
||||
writePin(B7, !led_state.scroll_lock);
|
||||
gpio_write_pin(B2, !led_state.num_lock);
|
||||
gpio_write_pin(C6, !led_state.caps_lock);
|
||||
gpio_write_pin(B7, !led_state.scroll_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ static void unselect_rows(void);
|
|||
void matrix_init_custom(void) {
|
||||
/* initialize row pins */
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
setPinOutput(row_pins[row]);
|
||||
gpio_set_pin_output(row_pins[row]);
|
||||
}
|
||||
unselect_rows();
|
||||
|
||||
|
|
@ -47,20 +47,20 @@ void matrix_init_custom(void) {
|
|||
spi_start(slavePin, lsbFirst, mode, divisor);
|
||||
|
||||
/* Initialize pin controlling the shift register's SH/~LD pin */
|
||||
setPinOutput(ROW_SHIFT_PIN);
|
||||
gpio_set_pin_output(ROW_SHIFT_PIN);
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row) {
|
||||
pin_t pin = row_pins[row];
|
||||
if (pin != NO_PIN) {
|
||||
writePinHigh(pin);
|
||||
gpio_write_pin_high(pin);
|
||||
}
|
||||
}
|
||||
|
||||
static void unselect_row(uint8_t row) {
|
||||
pin_t pin = row_pins[row];
|
||||
if (pin != NO_PIN) {
|
||||
writePinLow(pin);
|
||||
gpio_write_pin_low(pin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,12 +75,12 @@ bool matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
matrix_row_t current_row_value = 0;
|
||||
|
||||
/* Set shift register SH/~LD pin to "load" mode */
|
||||
writePinLow(ROW_SHIFT_PIN);
|
||||
gpio_write_pin_low(ROW_SHIFT_PIN);
|
||||
select_row(current_row);
|
||||
matrix_output_select_delay();
|
||||
|
||||
/* Set shift register SH/~LD pin to "shift" mode */
|
||||
writePinHigh(ROW_SHIFT_PIN);
|
||||
gpio_write_pin_high(ROW_SHIFT_PIN);
|
||||
|
||||
/* For each octet of columns... */
|
||||
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index += 8) {
|
||||
|
|
|
|||
|
|
@ -23,22 +23,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// runs once when the firmware starts up
|
||||
void matrix_init_kb(void) {
|
||||
// Set the LEDs pins
|
||||
setPinOutput(D5); // Layer 1 Status LED
|
||||
gpio_set_pin_output(D5); // Layer 1 Status LED
|
||||
|
||||
matrix_init_user();
|
||||
}
|
||||
|
||||
// Set LED based on layer
|
||||
__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
writePin(D5, layer_state_cmp(state, 1));
|
||||
gpio_write_pin(D5, layer_state_cmp(state, 1));
|
||||
return state;
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if (res) {
|
||||
// writePin sets the pin high for 1 and low for 0.
|
||||
writePin(D4, led_state.caps_lock);
|
||||
// gpio_write_pin sets the pin high for 1 and low for 0.
|
||||
gpio_write_pin(D4, led_state.caps_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "quantum.h"
|
||||
|
||||
void led_init_ports(void) {
|
||||
setPinOutput(F0);
|
||||
setPinOutput(F1);
|
||||
setPinOutput(F4);
|
||||
gpio_set_pin_output(F0);
|
||||
gpio_set_pin_output(F1);
|
||||
gpio_set_pin_output(F4);
|
||||
}
|
||||
|
|
@ -17,8 +17,8 @@
|
|||
#include "quantum.h"
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
setPinOutput(JOTANCK_LED1);
|
||||
setPinOutput(JOTANCK_LED2);
|
||||
gpio_set_pin_output(JOTANCK_LED1);
|
||||
gpio_set_pin_output(JOTANCK_LED2);
|
||||
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "quantum.h"
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
setPinOutput(JOTPAD16_LED1);
|
||||
setPinOutput(JOTPAD16_LED2);
|
||||
gpio_set_pin_output(JOTPAD16_LED1);
|
||||
gpio_set_pin_output(JOTPAD16_LED2);
|
||||
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ void matrix_init_kb(void) {
|
|||
// runs once when the firmware starts up
|
||||
|
||||
// Set our LED pins as output
|
||||
setPinOutput(B0);
|
||||
writePinLow(B0);
|
||||
gpio_set_pin_output(B0);
|
||||
gpio_write_pin_low(B0);
|
||||
|
||||
matrix_init_user();
|
||||
}
|
||||
|
|
@ -36,8 +36,8 @@ bool led_update_kb(led_t led_state) {
|
|||
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
// writePin sets the pin high for 1 and low for 0.
|
||||
writePin(B0, led_state.caps_lock);
|
||||
// gpio_write_pin sets the pin high for 1 and low for 0.
|
||||
gpio_write_pin(B0, led_state.caps_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ bool is_keyboard_master(void) {
|
|||
static int8_t is_master = -1;
|
||||
|
||||
if (is_master < 0) {
|
||||
while (readPin(SPI_SS_PIN)) {
|
||||
while (gpio_read_pin(SPI_SS_PIN)) {
|
||||
if (USB_Device_IsAddressSet()) {
|
||||
is_master = 1;
|
||||
return is_master;
|
||||
|
|
@ -53,7 +53,7 @@ bool is_keyboard_master(void) {
|
|||
}
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
setPinInputHigh(SPI_SS_PIN);
|
||||
gpio_set_pin_input_high(SPI_SS_PIN);
|
||||
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ bool shake_hands(bool master) {
|
|||
* alignment. */
|
||||
|
||||
if (master) {
|
||||
writePinLow(SPI_SS_PIN);
|
||||
gpio_write_pin_low(SPI_SS_PIN);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < 8 ; i += 1) {
|
||||
|
|
@ -64,7 +64,7 @@ bool shake_hands(bool master) {
|
|||
}
|
||||
|
||||
if (master) {
|
||||
writePinHigh(SPI_SS_PIN);
|
||||
gpio_write_pin_high(SPI_SS_PIN);
|
||||
}
|
||||
} while (i < 8);
|
||||
|
||||
|
|
@ -176,8 +176,8 @@ void transport_master_init(void) {
|
|||
* above depends on it and the SPI master driver won't do it
|
||||
* before we call spi_start(). */
|
||||
|
||||
writePinHigh(SPI_SS_PIN);
|
||||
setPinOutput(SPI_SS_PIN);
|
||||
gpio_write_pin_high(SPI_SS_PIN);
|
||||
gpio_set_pin_output(SPI_SS_PIN);
|
||||
|
||||
spi_init();
|
||||
|
||||
|
|
@ -195,10 +195,10 @@ void transport_slave_init(void) {
|
|||
* they're asserted making the MISO pin an output on both ends and
|
||||
* leading to potential shorts. */
|
||||
|
||||
setPinInputHigh(SPI_SS_PIN);
|
||||
setPinInput(SPI_SCK_PIN);
|
||||
setPinInput(SPI_MOSI_PIN);
|
||||
setPinOutput(SPI_MISO_PIN);
|
||||
gpio_set_pin_input_high(SPI_SS_PIN);
|
||||
gpio_set_pin_input(SPI_SCK_PIN);
|
||||
gpio_set_pin_input(SPI_MOSI_PIN);
|
||||
gpio_set_pin_output(SPI_MISO_PIN);
|
||||
|
||||
SPCR = _BV(SPE);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,19 +129,19 @@ void matrix_print(void)
|
|||
// uses standard row code
|
||||
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]);
|
||||
gpio_set_pin_input_high(row_pins[row]);
|
||||
}
|
||||
|
||||
static 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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,10 +149,10 @@ static void init_pins(void) { // still need some fixing, this might not work
|
|||
unselect_rows(); // with the loop
|
||||
/*
|
||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
setPinInputHigh(col_pins[x]);
|
||||
gpio_set_pin_input_high(col_pins[x]);
|
||||
}
|
||||
*/
|
||||
setPinInputHigh(dat_pin);
|
||||
gpio_set_pin_input_high(dat_pin);
|
||||
}
|
||||
|
||||
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
||||
|
|
@ -173,7 +173,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
// Select the col pin to read (active low)
|
||||
select_col_analog(col_index);
|
||||
wait_us(30);
|
||||
uint8_t pin_state = readPin(dat_pin);
|
||||
uint8_t pin_state = gpio_read_pin(dat_pin);
|
||||
|
||||
// Populate the matrix row with the state of the col pin
|
||||
current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
|
||||
|
|
@ -201,8 +201,8 @@ void matrix_init(void) {
|
|||
|
||||
matrix_init_kb();
|
||||
|
||||
setPinInput(D5);
|
||||
setPinInput(B0);
|
||||
gpio_set_pin_input(D5);
|
||||
gpio_set_pin_input(B0);
|
||||
}
|
||||
|
||||
// modified for per col read matrix scan
|
||||
|
|
@ -273,27 +273,27 @@ static void select_col_analog(uint8_t col) {
|
|||
|
||||
static void mux_pin_control(const uint8_t binary[]) {
|
||||
// set pin0
|
||||
setPinOutput(col_select_pins[0]);
|
||||
gpio_set_pin_output(col_select_pins[0]);
|
||||
if(binary[2] == 0) {
|
||||
writePinLow(col_select_pins[0]);
|
||||
gpio_write_pin_low(col_select_pins[0]);
|
||||
}
|
||||
else {
|
||||
writePinHigh(col_select_pins[0]);
|
||||
gpio_write_pin_high(col_select_pins[0]);
|
||||
}
|
||||
// set pin1
|
||||
setPinOutput(col_select_pins[1]);
|
||||
gpio_set_pin_output(col_select_pins[1]);
|
||||
if(binary[1] == 0) {
|
||||
writePinLow(col_select_pins[1]);
|
||||
gpio_write_pin_low(col_select_pins[1]);
|
||||
}
|
||||
else {
|
||||
writePinHigh(col_select_pins[1]);
|
||||
gpio_write_pin_high(col_select_pins[1]);
|
||||
}
|
||||
// set pin2
|
||||
setPinOutput(col_select_pins[2]);
|
||||
gpio_set_pin_output(col_select_pins[2]);
|
||||
if(binary[0] == 0) {
|
||||
writePinLow(col_select_pins[2]);
|
||||
gpio_write_pin_low(col_select_pins[2]);
|
||||
}
|
||||
else {
|
||||
writePinHigh(col_select_pins[2]);
|
||||
gpio_write_pin_high(col_select_pins[2]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,22 +17,22 @@
|
|||
|
||||
void matrix_init_kb(void) {
|
||||
// set CapsLock LED to output and low
|
||||
setPinOutput(B0);
|
||||
writePinLow(B0);
|
||||
gpio_set_pin_output(B0);
|
||||
gpio_write_pin_low(B0);
|
||||
// set NumLock LED to output and low
|
||||
setPinOutput(B1);
|
||||
writePinLow(B1);
|
||||
gpio_set_pin_output(B1);
|
||||
gpio_write_pin_low(B1);
|
||||
// set ScrollLock LED to output and low
|
||||
setPinOutput(B2);
|
||||
writePinLow(B2);
|
||||
gpio_set_pin_output(B2);
|
||||
gpio_write_pin_low(B2);
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
writePin(B1, led_state.num_lock);
|
||||
writePin(B0, led_state.caps_lock);
|
||||
//writePin(B2, led_state.scroll_lock);
|
||||
gpio_write_pin(B1, led_state.num_lock);
|
||||
gpio_write_pin(B0, led_state.caps_lock);
|
||||
//gpio_write_pin(B2, led_state.scroll_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -41,9 +41,9 @@ bool led_update_kb(led_t led_state) {
|
|||
layer_state_t layer_state_set_kb(layer_state_t state)
|
||||
{
|
||||
if (get_highest_layer(state) == 1) {
|
||||
writePinHigh(B2);
|
||||
gpio_write_pin_high(B2);
|
||||
} else {
|
||||
writePinLow(B2);
|
||||
gpio_write_pin_low(B2);
|
||||
}
|
||||
return layer_state_set_user(state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ void matrix_init_kb(void) {
|
|||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
writePin(D0, !led_state.caps_lock);
|
||||
writePin(D1, !led_state.num_lock);
|
||||
writePin(C6, !led_state.scroll_lock);
|
||||
gpio_write_pin(D0, !led_state.caps_lock);
|
||||
gpio_write_pin(D1, !led_state.num_lock);
|
||||
gpio_write_pin(C6, !led_state.scroll_lock);
|
||||
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
#include "selene.h"
|
||||
|
||||
void matrix_init_kb(void){
|
||||
setPinOutput(NUM_LOCK_PIN);
|
||||
setPinOutput(CAPS_LOCK_PIN);
|
||||
setPinOutput(SCROLL_LOCK_PIN);
|
||||
gpio_set_pin_output(NUM_LOCK_PIN);
|
||||
gpio_set_pin_output(CAPS_LOCK_PIN);
|
||||
gpio_set_pin_output(SCROLL_LOCK_PIN);
|
||||
}
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
|
|
@ -30,9 +30,9 @@ void keyboard_post_init_user(void) {
|
|||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
writePin(NUM_LOCK_PIN, led_state.num_lock);
|
||||
writePin(CAPS_LOCK_PIN, led_state.caps_lock);
|
||||
writePin(SCROLL_LOCK_PIN, led_state.scroll_lock);
|
||||
gpio_write_pin(NUM_LOCK_PIN, led_state.num_lock);
|
||||
gpio_write_pin(CAPS_LOCK_PIN, led_state.caps_lock);
|
||||
gpio_write_pin(SCROLL_LOCK_PIN, led_state.scroll_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@
|
|||
|
||||
void matrix_init_kb(void) {
|
||||
/* LED pins setup */
|
||||
setPinOutput(LED_KANA_PIN);
|
||||
setPinOutput(LED_CAPS_LOCK_PIN);
|
||||
setPinOutput(LED_CTRL_XFER_PIN);
|
||||
setPinOutput(LED_NUM_LOCK_PIN);
|
||||
setPinOutput(LED_KB_LOCK_PIN);
|
||||
gpio_set_pin_output(LED_KANA_PIN);
|
||||
gpio_set_pin_output(LED_CAPS_LOCK_PIN);
|
||||
gpio_set_pin_output(LED_CTRL_XFER_PIN);
|
||||
gpio_set_pin_output(LED_NUM_LOCK_PIN);
|
||||
gpio_set_pin_output(LED_KB_LOCK_PIN);
|
||||
|
||||
writePinHigh(LED_KANA_PIN);
|
||||
writePinHigh(LED_CAPS_LOCK_PIN);
|
||||
writePinHigh(LED_CTRL_XFER_PIN);
|
||||
writePinHigh(LED_NUM_LOCK_PIN);
|
||||
writePinHigh(LED_KB_LOCK_PIN);
|
||||
gpio_write_pin_high(LED_KANA_PIN);
|
||||
gpio_write_pin_high(LED_CAPS_LOCK_PIN);
|
||||
gpio_write_pin_high(LED_CTRL_XFER_PIN);
|
||||
gpio_write_pin_high(LED_NUM_LOCK_PIN);
|
||||
gpio_write_pin_high(LED_KB_LOCK_PIN);
|
||||
|
||||
matrix_init_user();
|
||||
}
|
||||
|
|
@ -36,9 +36,9 @@ void matrix_init_kb(void) {
|
|||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
writePin(LED_NUM_LOCK_PIN, !led_state.num_lock);
|
||||
writePin(LED_CAPS_LOCK_PIN, !led_state.caps_lock);
|
||||
writePin(LED_CTRL_XFER_PIN, !led_state.scroll_lock);
|
||||
gpio_write_pin(LED_NUM_LOCK_PIN, !led_state.num_lock);
|
||||
gpio_write_pin(LED_CAPS_LOCK_PIN, !led_state.caps_lock);
|
||||
gpio_write_pin(LED_CTRL_XFER_PIN, !led_state.scroll_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,23 +8,23 @@
|
|||
#include <gpio.h>
|
||||
|
||||
static inline void setDebugPinOutput_Low(void) {
|
||||
setPinOutput(MATRIX_DEBUG_PIN);
|
||||
writePinLow(MATRIX_DEBUG_PIN);
|
||||
gpio_set_pin_output(MATRIX_DEBUG_PIN);
|
||||
gpio_write_pin_low(MATRIX_DEBUG_PIN);
|
||||
}
|
||||
|
||||
#define MATRIX_DEBUG_PIN_INIT() setDebugPinOutput_Low()
|
||||
|
||||
#ifdef MATRIX_DEBUG_SCAN
|
||||
# define MATRIX_DEBUG_SCAN_START() writePinHigh(MATRIX_DEBUG_PIN)
|
||||
# define MATRIX_DEBUG_SCAN_END() writePinLow(MATRIX_DEBUG_PIN)
|
||||
# define MATRIX_DEBUG_SCAN_START() gpio_write_pin_high(MATRIX_DEBUG_PIN)
|
||||
# define MATRIX_DEBUG_SCAN_END() gpio_write_pin_low(MATRIX_DEBUG_PIN)
|
||||
#else
|
||||
# define MATRIX_DEBUG_SCAN_START()
|
||||
# define MATRIX_DEBUG_SCAN_END()
|
||||
#endif
|
||||
|
||||
#ifdef MATRIX_DEBUG_DELAY
|
||||
# define MATRIX_DEBUG_DELAY_START() writePinHigh(MATRIX_DEBUG_PIN)
|
||||
# define MATRIX_DEBUG_DELAY_END() writePinLow(MATRIX_DEBUG_PIN)
|
||||
# define MATRIX_DEBUG_DELAY_START() gpio_write_pin_high(MATRIX_DEBUG_PIN)
|
||||
# define MATRIX_DEBUG_DELAY_END() gpio_write_pin_low(MATRIX_DEBUG_PIN)
|
||||
#else
|
||||
# define MATRIX_DEBUG_DELAY_START()
|
||||
# define MATRIX_DEBUG_DELAY_END()
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
|
|||
|
||||
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 setPinInputHigh_atomic(pin_t pin) {
|
||||
ATOMIC_BLOCK_FORCEON { setPinInputHigh(pin); }
|
||||
ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
|
||||
}
|
||||
|
||||
// matrix code
|
||||
|
|
@ -80,7 +80,7 @@ static void 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
||||
pin_t pin = direct_pins[current_row][col_index];
|
||||
if (pin != NO_PIN) {
|
||||
current_row_value |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index);
|
||||
current_row_value |= gpio_read_pin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,8 +120,8 @@ static void unselect_rows(void) {
|
|||
|
||||
static void init_pins(void) {
|
||||
# ifdef MATRIX_MUL_SELECT
|
||||
setPinOutput(MATRIX_MUL_SELECT);
|
||||
writePinLow(MATRIX_MUL_SELECT);
|
||||
gpio_set_pin_output(MATRIX_MUL_SELECT);
|
||||
gpio_write_pin_low(MATRIX_MUL_SELECT);
|
||||
# endif
|
||||
unselect_rows();
|
||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
|
|
@ -141,10 +141,10 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
||||
// Select the col pin to read (active low)
|
||||
# ifdef MATRIX_MUL_SELECT
|
||||
writePin(MATRIX_MUL_SELECT, col_sel[col_index]);
|
||||
gpio_write_pin(MATRIX_MUL_SELECT, col_sel[col_index]);
|
||||
waitInputPinDelay();
|
||||
# endif
|
||||
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);
|
||||
|
|
@ -160,7 +160,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
is_pressed = false;
|
||||
for (uint8_t i = 0; i < ARRAY_SIZE(delay_ports); i++) {
|
||||
# ifdef MATRIX_IO_DELAY_MULSEL
|
||||
writePin(MATRIX_MUL_SELECT, delay_sel[i]);
|
||||
gpio_write_pin(MATRIX_MUL_SELECT, delay_sel[i]);
|
||||
waitInputPinDelay();
|
||||
# endif
|
||||
is_pressed |= ((readPort(delay_ports[i]) & delay_masks[i]) != delay_masks[i]);
|
||||
|
|
@ -174,10 +174,10 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
||||
MATRIX_DEBUG_DELAY_START();
|
||||
# ifdef MATRIX_MUL_SELECT
|
||||
writePin(MATRIX_MUL_SELECT, col_sel[col_index]);
|
||||
gpio_write_pin(MATRIX_MUL_SELECT, col_sel[col_index]);
|
||||
waitInputPinDelay();
|
||||
# endif
|
||||
while (readPin(col_pins[col_index]) == 0) {
|
||||
while (gpio_read_pin(col_pins[col_index]) == 0) {
|
||||
}
|
||||
MATRIX_DEBUG_DELAY_END();
|
||||
}
|
||||
|
|
@ -193,10 +193,10 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||
MATRIX_DEBUG_DELAY_END();
|
||||
MATRIX_DEBUG_DELAY_START();
|
||||
# ifdef MATRIX_MUL_SELECT
|
||||
writePin(MATRIX_MUL_SELECT, col_sel[col_index]);
|
||||
gpio_write_pin(MATRIX_MUL_SELECT, col_sel[col_index]);
|
||||
waitInputPinDelay();
|
||||
# endif
|
||||
state |= (readPin(col_pins[col_index]) == 0);
|
||||
state |= (gpio_read_pin(col_pins[col_index]) == 0);
|
||||
}
|
||||
MATRIX_DEBUG_DELAY_END();
|
||||
} while (state);
|
||||
|
|
@ -250,7 +250,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
|
|||
matrix_row_t current_row_value = last_row_value;
|
||||
|
||||
// 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_row_value |= (MATRIX_ROW_SHIFTER << current_col);
|
||||
key_pressed = true;
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ static const pin_t sel_pins[] = { MATRIX_EXT_74HC15x };
|
|||
LOCAL_FUNC ALWAYS_INLINE void select74HC15x(uint8_t devid);
|
||||
LOCAL_FUNC
|
||||
void select74HC15x(uint8_t devid) {
|
||||
writePin(sel_pins[0], devid&1);
|
||||
gpio_write_pin(sel_pins[0], devid&1);
|
||||
#if defined(MATRIX_EXTENSION_74HC153)
|
||||
writePin(sel_pins[1], devid&2);
|
||||
gpio_write_pin(sel_pins[1], devid&2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ LOCAL_FUNC port_width_t readPortMultiplexer(uint8_t devid, pin_t port) {
|
|||
#define readMatrixPort(dev, port) \
|
||||
((dev) == MCU_GPIO)? readPort(port): (IS_74HC15x(dev))? readPortMultiplexer((dev)-MCU_GPIOa, port):0
|
||||
|
||||
#define INIT_74HC15X(x) setPinOutput(x); writePinLow(x);
|
||||
#define INIT_74HC15X(x) gpio_set_pin_output(x); gpio_write_pin_low(x);
|
||||
LOCAL_FUNC
|
||||
void init_74hc15x(void) {
|
||||
MAP(INIT_74HC15X, MATRIX_EXT_74HC15x)
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
#include "tractyl_manuform.h"
|
||||
|
||||
void keyboard_pre_init_sub(void) { setPinInputHigh(A0); }
|
||||
void keyboard_pre_init_sub(void) { gpio_set_pin_input_high(A0); }
|
||||
|
||||
void matrix_scan_sub_kb(void) {
|
||||
if (!readPin(A0)) {
|
||||
if (!gpio_read_pin(A0)) {
|
||||
reset_keyboard();
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ __attribute__((weak)) void bootmagic_scan(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (matrix_get_row(row) & (1 << col) || !readPin(A0)) {
|
||||
if (matrix_get_row(row) & (1 << col) || !gpio_read_pin(A0)) {
|
||||
eeconfig_disable();
|
||||
bootloader_jump();
|
||||
}
|
||||
|
|
@ -53,9 +53,9 @@ __attribute__((weak)) void bootmagic_scan(void) {
|
|||
|
||||
#ifdef USB_VBUS_PIN
|
||||
bool usb_vbus_state(void) {
|
||||
setPinInputLow(USB_VBUS_PIN);
|
||||
gpio_set_pin_input_low(USB_VBUS_PIN);
|
||||
wait_us(5);
|
||||
return readPin(USB_VBUS_PIN);
|
||||
return gpio_read_pin(USB_VBUS_PIN);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ void matrix_init_kb(void) {
|
|||
#endif
|
||||
|
||||
// Turn status LED on
|
||||
setPinOutput(C7);
|
||||
writePinHigh(C7);
|
||||
gpio_set_pin_output(C7);
|
||||
gpio_write_pin_high(C7);
|
||||
|
||||
matrix_init_user();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
#include "woodpad.h"
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
setPinOutput(F7);
|
||||
gpio_set_pin_output(F7);
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
||||
inline void numlock_led_on(void) {
|
||||
writePinHigh(F7);
|
||||
gpio_write_pin_high(F7);
|
||||
}
|
||||
|
||||
inline void numlock_led_off(void) {
|
||||
writePinLow(F7);
|
||||
gpio_write_pin_low(F7);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
#include "quantum.h"
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
setPinOutput(NUM_LOCK_LED_PIN);
|
||||
setPinOutput(CAPS_LOCK_LED_PIN);
|
||||
setPinOutput(SCROLL_LOCK_LED_PIN);
|
||||
gpio_set_pin_output(NUM_LOCK_LED_PIN);
|
||||
gpio_set_pin_output(CAPS_LOCK_LED_PIN);
|
||||
gpio_set_pin_output(SCROLL_LOCK_LED_PIN);
|
||||
|
||||
writePinLow(NUM_LOCK_LED_PIN);
|
||||
writePinLow(CAPS_LOCK_LED_PIN);
|
||||
writePinLow(SCROLL_LOCK_LED_PIN);
|
||||
gpio_write_pin_low(NUM_LOCK_LED_PIN);
|
||||
gpio_write_pin_low(CAPS_LOCK_LED_PIN);
|
||||
gpio_write_pin_low(SCROLL_LOCK_LED_PIN);
|
||||
|
||||
matrix_init_user();
|
||||
}
|
||||
|
|
@ -31,9 +31,9 @@ void matrix_init_kb(void) {
|
|||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
writePin(NUM_LOCK_LED_PIN, !led_state.num_lock);
|
||||
writePin(CAPS_LOCK_LED_PIN, !led_state.caps_lock);
|
||||
writePin(SCROLL_LOCK_LED_PIN, !led_state.scroll_lock);
|
||||
gpio_write_pin(NUM_LOCK_LED_PIN, !led_state.num_lock);
|
||||
gpio_write_pin(CAPS_LOCK_LED_PIN, !led_state.caps_lock);
|
||||
gpio_write_pin(SCROLL_LOCK_LED_PIN, !led_state.scroll_lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue