mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
update skyloong/gk104/q1 about gpio command
This commit is contained in:
parent
fa8e8ddd5d
commit
2c01d31446
@ -35,17 +35,17 @@
|
|||||||
|
|
||||||
#define CLOCK_TIME 15
|
#define CLOCK_TIME 15
|
||||||
|
|
||||||
static inline void setPinOutput_writeLow(pin_t pin) {
|
static inline void gpio_set_pin_output_write_low(pin_t pin) {
|
||||||
ATOMIC_BLOCK_FORCEON {
|
ATOMIC_BLOCK_FORCEON {
|
||||||
setPinOutput(pin);
|
gpio_set_pin_output(pin);
|
||||||
writePinLow(pin);
|
gpio_write_pin_low(pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setPinOutput_writeHigh(pin_t pin) {
|
static inline void gpio_set_pin_output_write_high(pin_t pin) {
|
||||||
ATOMIC_BLOCK_FORCEON {
|
ATOMIC_BLOCK_FORCEON {
|
||||||
setPinOutput(pin);
|
gpio_set_pin_output(pin);
|
||||||
writePinHigh(pin);
|
gpio_write_pin_high(pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,22 +56,22 @@ static inline void select_delay(uint16_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void clockPulse(uint16_t n) {
|
static inline void clockPulse(uint16_t n) {
|
||||||
writePinHigh(HC595_SH_PIN);
|
gpio_write_pin_high(HC595_SH_PIN);
|
||||||
writePinHigh(HC595_ST_PIN);
|
gpio_write_pin_high(HC595_ST_PIN);
|
||||||
select_delay(n);
|
select_delay(n);
|
||||||
writePinLow(HC595_SH_PIN);
|
gpio_write_pin_low(HC595_SH_PIN);
|
||||||
writePinLow(HC595_ST_PIN);
|
gpio_write_pin_low(HC595_ST_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_serial_to_parallel(uint8_t data) { // Serial port to parallel port function
|
static void s_serial_to_parallel(uint8_t data) { // Serial port to parallel port function
|
||||||
setPinOutput_writeLow(HC595_DS);
|
gpio_set_pin_output_write_low(HC595_DS);
|
||||||
setPinOutput_writeLow(HC595_SH_PIN);
|
gpio_set_pin_output_write_low(HC595_SH_PIN);
|
||||||
setPinOutput_writeLow(HC595_ST_PIN);
|
gpio_set_pin_output_write_low(HC595_ST_PIN);
|
||||||
for(uint8_t i = 0; i < 8; i++) {
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
if(data & 0x01){
|
if(data & 0x01){
|
||||||
writePinHigh(HC595_DS);
|
gpio_write_pin_high(HC595_DS);
|
||||||
}else{
|
}else{
|
||||||
writePinLow(HC595_DS);
|
gpio_write_pin_low(HC595_DS);
|
||||||
}
|
}
|
||||||
clockPulse(CLOCK_TIME);
|
clockPulse(CLOCK_TIME);
|
||||||
data >>= 1; // Move the data one digit to the right
|
data >>= 1; // Move the data one digit to the right
|
||||||
|
@ -29,27 +29,27 @@ static inline void select_delay(uint16_t n) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setPinOutput_writeLow(pin_t pin) {
|
static inline void gpio_set_pin_output_write_low(pin_t pin) {
|
||||||
ATOMIC_BLOCK_FORCEON {
|
ATOMIC_BLOCK_FORCEON {
|
||||||
gpio_set_pin_output(pin);
|
gpio_set_pin_output(pin);
|
||||||
gpio_write_pin_low(pin);
|
gpio_write_pin_low(pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setPinOutput_writeHigh(pin_t pin) {
|
static inline void gpio_set_pin_output_write_high(pin_t pin) {
|
||||||
ATOMIC_BLOCK_FORCEON {
|
ATOMIC_BLOCK_FORCEON {
|
||||||
gpio_set_pin_output(pin);
|
gpio_set_pin_output(pin);
|
||||||
gpio_write_pin_high(pin);
|
gpio_write_pin_high(pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setPinInputHigh_atomic(pin_t pin) {
|
static inline void gpio_set_pin_input_high_atomic(pin_t pin) {
|
||||||
ATOMIC_BLOCK_FORCEON {
|
ATOMIC_BLOCK_FORCEON {
|
||||||
gpio_set_pin_input_high(pin);
|
gpio_set_pin_input_high(pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t readMatrixPin(pin_t pin) {
|
static inline uint8_t read_matrix_pin(pin_t pin) {
|
||||||
if (pin != NO_PIN) {
|
if (pin != NO_PIN) {
|
||||||
return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
|
return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
|
||||||
} else {
|
} else {
|
||||||
@ -57,7 +57,7 @@ static inline uint8_t readMatrixPin(pin_t pin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void clockPulse(uint16_t n) {
|
static inline void clock_pulse(uint16_t n) {
|
||||||
gpio_write_pin_high(HC595_SH_PIN);
|
gpio_write_pin_high(HC595_SH_PIN);
|
||||||
gpio_write_pin_high(HC595_ST_PIN);
|
gpio_write_pin_high(HC595_ST_PIN);
|
||||||
select_delay(n);
|
select_delay(n);
|
||||||
@ -68,14 +68,14 @@ static inline void clockPulse(uint16_t n) {
|
|||||||
// matrix code
|
// matrix code
|
||||||
|
|
||||||
static bool select_col(uint8_t col) {
|
static bool select_col(uint8_t col) {
|
||||||
setPinOutput_writeHigh(HC595_DS_PIN);
|
gpio_set_pin_output_write_high(HC595_DS_PIN);
|
||||||
for (uint8_t m = 0; m <= col; m++) {
|
for (uint8_t m = 0; m <= col; m++) {
|
||||||
if(m == 0){
|
if(m == 0){
|
||||||
gpio_write_pin_low(HC595_DS_PIN);
|
gpio_write_pin_low(HC595_DS_PIN);
|
||||||
}else{
|
}else{
|
||||||
gpio_write_pin_high(HC595_DS_PIN);
|
gpio_write_pin_high(HC595_DS_PIN);
|
||||||
}
|
}
|
||||||
clockPulse(ClOCK_TIME);
|
clock_pulse(ClOCK_TIME);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -83,18 +83,18 @@ static bool select_col(uint8_t col) {
|
|||||||
|
|
||||||
static void unselect_col(uint8_t col) {
|
static void unselect_col(uint8_t col) {
|
||||||
uint8_t x = (MATRIX_COLS - col);
|
uint8_t x = (MATRIX_COLS - col);
|
||||||
setPinOutput_writeHigh(HC595_DS_PIN);
|
gpio_set_pin_output_write_high(HC595_DS_PIN);
|
||||||
for (uint8_t y = 0; y < x ; y++) {
|
for (uint8_t y = 0; y < x ; y++) {
|
||||||
clockPulse(ClOCK_TIME);
|
clock_pulse(ClOCK_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unselect_cols(void) {
|
static void unselect_cols(void) {
|
||||||
setPinOutput_writeLow(HC595_SH_PIN);
|
gpio_set_pin_output_write_low(HC595_SH_PIN);
|
||||||
setPinOutput_writeLow(HC595_ST_PIN);
|
gpio_set_pin_output_write_low(HC595_ST_PIN);
|
||||||
setPinOutput_writeHigh(HC595_DS_PIN);
|
gpio_set_pin_output_write_high(HC595_DS_PIN);
|
||||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||||
clockPulse(ClOCK_TIME);
|
clock_pulse(ClOCK_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ __attribute__((weak)) void matrix_init_pins(void) {
|
|||||||
unselect_cols();
|
unselect_cols();
|
||||||
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
if (row_pins[x] != NO_PIN) {
|
if (row_pins[x] != NO_PIN) {
|
||||||
setPinInputHigh_atomic(row_pins[x]);
|
gpio_set_pin_input_high_atomic(row_pins[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[]
|
|||||||
// For each row...
|
// For each row...
|
||||||
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
|
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
|
||||||
// Check row pin state
|
// Check row pin state
|
||||||
if (readMatrixPin(row_pins[row_index]) == 0) {
|
if (read_matrix_pin(row_pins[row_index]) == 0) {
|
||||||
// Pin LO, set col bit
|
// Pin LO, set col bit
|
||||||
current_matrix[row_index] |= row_shifter;
|
current_matrix[row_index] |= row_shifter;
|
||||||
key_pressed = true;
|
key_pressed = true;
|
||||||
|
@ -222,7 +222,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void suspend_power_down_kb() {
|
void suspend_power_down_kb() {
|
||||||
writePinLow(MAC_PIN);
|
gpio_write_pin_low(MAC_PIN);
|
||||||
s_serial_to_parallel(0);
|
s_serial_to_parallel(0);
|
||||||
suspend_power_down_user();
|
suspend_power_down_user();
|
||||||
}
|
}
|
||||||
@ -240,13 +240,13 @@ bool shutdown_kb(bool jump_to_bootloader) {
|
|||||||
layer_state_t default_layer_state_set_kb(layer_state_t state) {
|
layer_state_t default_layer_state_set_kb(layer_state_t state) {
|
||||||
switch (get_highest_layer(state)) {
|
switch (get_highest_layer(state)) {
|
||||||
case 0:
|
case 0:
|
||||||
writePinLow(MAC_PIN);
|
gpio_write_pin_low(MAC_PIN);
|
||||||
//switch to win layer display
|
//switch to win layer display
|
||||||
IND = IND & (~MAC_ON);
|
IND = IND & (~MAC_ON);
|
||||||
IND = IND | WIN_ON;
|
IND = IND | WIN_ON;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
writePinHigh(MAC_PIN);
|
gpio_write_pin_high(MAC_PIN);
|
||||||
//switch to mac layer display
|
//switch to mac layer display
|
||||||
IND = IND & (~WIN_ON);
|
IND = IND & (~WIN_ON);
|
||||||
IND = IND | MAC_ON;
|
IND = IND | MAC_ON;
|
||||||
@ -307,8 +307,8 @@ bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
|
|||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
// JTAG-DP Disabled and SW-DP Disabled
|
// JTAG-DP Disabled and SW-DP Disabled
|
||||||
AFIO->MAPR = (AFIO->MAPR & ~AFIO_MAPR_SWJ_CFG_Msk) | AFIO_MAPR_SWJ_CFG_DISABLE;
|
AFIO->MAPR = (AFIO->MAPR & ~AFIO_MAPR_SWJ_CFG_Msk) | AFIO_MAPR_SWJ_CFG_DISABLE;
|
||||||
setPinOutput(MAC_PIN);
|
gpio_set_pin_output(MAC_PIN);
|
||||||
writePinHigh(MAC_PIN);
|
gpio_write_pin_high(MAC_PIN);
|
||||||
s_serial_to_parallel(0xFF);
|
s_serial_to_parallel(0xFF);
|
||||||
IND = SKYLOONG;
|
IND = SKYLOONG;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user