diff options
| author | Joel Challis <git@zvecr.com> | 2021-02-14 00:51:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-14 11:51:06 +1100 |
| commit | de8caf708c1a9a80527a04be620ed3969262e50b (patch) | |
| tree | 2b0839ed1f1c77c3bab8c1c28fff6f4ba62696eb /tmk_core | |
| parent | 101990139f3efc0d61491d58f41474f5bc039c66 (diff) | |
| download | qmk_firmware-de8caf708c1a9a80527a04be620ed3969262e50b.tar.gz qmk_firmware-de8caf708c1a9a80527a04be620ed3969262e50b.zip | |
Split gpio and atomic to platform (#11792)
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/atomic_util.h | 32 | ||||
| -rw-r--r-- | tmk_core/common/avr/atomic_util.h | 22 | ||||
| -rw-r--r-- | tmk_core/common/avr/gpio.h | 34 | ||||
| -rw-r--r-- | tmk_core/common/avr/pin_defs.h | 128 | ||||
| -rw-r--r-- | tmk_core/common/chibios/atomic_util.h | 37 | ||||
| -rw-r--r-- | tmk_core/common/chibios/gpio.h | 34 | ||||
| -rw-r--r-- | tmk_core/common/chibios/pin_defs.h | 242 | ||||
| -rw-r--r-- | tmk_core/common/gpio.h | 22 | ||||
| -rw-r--r-- | tmk_core/common/pin_defs.h | 23 |
9 files changed, 574 insertions, 0 deletions
diff --git a/tmk_core/common/atomic_util.h b/tmk_core/common/atomic_util.h new file mode 100644 index 000000000..2c95302a1 --- /dev/null +++ b/tmk_core/common/atomic_util.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | // Macro to help make GPIO and other controls atomic. | ||
| 19 | |||
| 20 | #ifndef IGNORE_ATOMIC_BLOCK | ||
| 21 | # if __has_include_next("atomic_util.h") | ||
| 22 | # include_next "atomic_util.h" /* Include the platforms atomic.h */ | ||
| 23 | # else | ||
| 24 | # define ATOMIC_BLOCK _Static_assert(0, "ATOMIC_BLOCK not implemented") | ||
| 25 | # define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented") | ||
| 26 | # define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON not implemented") | ||
| 27 | # endif | ||
| 28 | #else /* do nothing atomic macro */ | ||
| 29 | # define ATOMIC_BLOCK for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0) | ||
| 30 | # define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK | ||
| 31 | # define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK | ||
| 32 | #endif | ||
diff --git a/tmk_core/common/avr/atomic_util.h b/tmk_core/common/avr/atomic_util.h new file mode 100644 index 000000000..7c5d2e7dc --- /dev/null +++ b/tmk_core/common/avr/atomic_util.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | /* atomic macro for AVR */ | ||
| 19 | #include <util/atomic.h> | ||
| 20 | |||
| 21 | #define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK(ATOMIC_RESTORESTATE) | ||
| 22 | #define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON) | ||
diff --git a/tmk_core/common/avr/gpio.h b/tmk_core/common/avr/gpio.h new file mode 100644 index 000000000..231556c29 --- /dev/null +++ b/tmk_core/common/avr/gpio.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include "pin_defs.h" | ||
| 20 | |||
| 21 | typedef uint8_t pin_t; | ||
| 22 | |||
| 23 | #define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) | ||
| 24 | #define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) | ||
| 25 | #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") | ||
| 26 | #define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF)) | ||
| 27 | |||
| 28 | #define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) | ||
| 29 | #define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) | ||
| 30 | #define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin)) | ||
| 31 | |||
| 32 | #define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF))) | ||
| 33 | |||
| 34 | #define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF)) | ||
diff --git a/tmk_core/common/avr/pin_defs.h b/tmk_core/common/avr/pin_defs.h new file mode 100644 index 000000000..dbfed21f4 --- /dev/null +++ b/tmk_core/common/avr/pin_defs.h | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | |||
| 20 | #define PORT_SHIFTER 4 // this may be 4 for all AVR chips | ||
| 21 | |||
| 22 | // If you want to add more to this list, reference the PINx definitions in these header | ||
| 23 | // files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr | ||
| 24 | |||
| 25 | #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__) | ||
| 26 | # define ADDRESS_BASE 0x00 | ||
| 27 | # define PINB_ADDRESS 0x3 | ||
| 28 | # define PINC_ADDRESS 0x6 | ||
| 29 | # define PIND_ADDRESS 0x9 | ||
| 30 | # define PINE_ADDRESS 0xC | ||
| 31 | # define PINF_ADDRESS 0xF | ||
| 32 | #elif defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) | ||
| 33 | # define ADDRESS_BASE 0x00 | ||
| 34 | # define PINB_ADDRESS 0x3 | ||
| 35 | # define PINC_ADDRESS 0x6 | ||
| 36 | # define PIND_ADDRESS 0x9 | ||
| 37 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) | ||
| 38 | # define ADDRESS_BASE 0x00 | ||
| 39 | # define PINA_ADDRESS 0x0 | ||
| 40 | # define PINB_ADDRESS 0x3 | ||
| 41 | # define PINC_ADDRESS 0x6 | ||
| 42 | # define PIND_ADDRESS 0x9 | ||
| 43 | # define PINE_ADDRESS 0xC | ||
| 44 | # define PINF_ADDRESS 0xF | ||
| 45 | #elif defined(__AVR_ATmega32A__) | ||
| 46 | # define ADDRESS_BASE 0x10 | ||
| 47 | # define PIND_ADDRESS 0x0 | ||
| 48 | # define PINC_ADDRESS 0x3 | ||
| 49 | # define PINB_ADDRESS 0x6 | ||
| 50 | # define PINA_ADDRESS 0x9 | ||
| 51 | #elif defined(__AVR_ATtiny85__) | ||
| 52 | # define ADDRESS_BASE 0x10 | ||
| 53 | # define PINB_ADDRESS 0x6 | ||
| 54 | #else | ||
| 55 | # error "Pins are not defined" | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin) | ||
| 59 | |||
| 60 | #define _PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + ((p) >> PORT_SHIFTER) + (offset)) | ||
| 61 | // Port X Input Pins Address | ||
| 62 | #define PINx_ADDRESS(p) _PIN_ADDRESS(p, 0) | ||
| 63 | // Port X Data Direction Register, 0:input 1:output | ||
| 64 | #define DDRx_ADDRESS(p) _PIN_ADDRESS(p, 1) | ||
| 65 | // Port X Data Register | ||
| 66 | #define PORTx_ADDRESS(p) _PIN_ADDRESS(p, 2) | ||
| 67 | |||
| 68 | /* I/O pins */ | ||
| 69 | #ifdef PORTA | ||
| 70 | # define A0 PINDEF(A, 0) | ||
| 71 | # define A1 PINDEF(A, 1) | ||
| 72 | # define A2 PINDEF(A, 2) | ||
| 73 | # define A3 PINDEF(A, 3) | ||
| 74 | # define A4 PINDEF(A, 4) | ||
| 75 | # define A5 PINDEF(A, 5) | ||
| 76 | # define A6 PINDEF(A, 6) | ||
| 77 | # define A7 PINDEF(A, 7) | ||
| 78 | #endif | ||
| 79 | #ifdef PORTB | ||
| 80 | # define B0 PINDEF(B, 0) | ||
| 81 | # define B1 PINDEF(B, 1) | ||
| 82 | # define B2 PINDEF(B, 2) | ||
| 83 | # define B3 PINDEF(B, 3) | ||
| 84 | # define B4 PINDEF(B, 4) | ||
| 85 | # define B5 PINDEF(B, 5) | ||
| 86 | # define B6 PINDEF(B, 6) | ||
| 87 | # define B7 PINDEF(B, 7) | ||
| 88 | #endif | ||
| 89 | #ifdef PORTC | ||
| 90 | # define C0 PINDEF(C, 0) | ||
| 91 | # define C1 PINDEF(C, 1) | ||
| 92 | # define C2 PINDEF(C, 2) | ||
| 93 | # define C3 PINDEF(C, 3) | ||
| 94 | # define C4 PINDEF(C, 4) | ||
| 95 | # define C5 PINDEF(C, 5) | ||
| 96 | # define C6 PINDEF(C, 6) | ||
| 97 | # define C7 PINDEF(C, 7) | ||
| 98 | #endif | ||
| 99 | #ifdef PORTD | ||
| 100 | # define D0 PINDEF(D, 0) | ||
| 101 | # define D1 PINDEF(D, 1) | ||
| 102 | # define D2 PINDEF(D, 2) | ||
| 103 | # define D3 PINDEF(D, 3) | ||
| 104 | # define D4 PINDEF(D, 4) | ||
| 105 | # define D5 PINDEF(D, 5) | ||
| 106 | # define D6 PINDEF(D, 6) | ||
| 107 | # define D7 PINDEF(D, 7) | ||
| 108 | #endif | ||
| 109 | #ifdef PORTE | ||
| 110 | # define E0 PINDEF(E, 0) | ||
| 111 | # define E1 PINDEF(E, 1) | ||
| 112 | # define E2 PINDEF(E, 2) | ||
| 113 | # define E3 PINDEF(E, 3) | ||
| 114 | # define E4 PINDEF(E, 4) | ||
| 115 | # define E5 PINDEF(E, 5) | ||
| 116 | # define E6 PINDEF(E, 6) | ||
| 117 | # define E7 PINDEF(E, 7) | ||
| 118 | #endif | ||
| 119 | #ifdef PORTF | ||
| 120 | # define F0 PINDEF(F, 0) | ||
| 121 | # define F1 PINDEF(F, 1) | ||
| 122 | # define F2 PINDEF(F, 2) | ||
| 123 | # define F3 PINDEF(F, 3) | ||
| 124 | # define F4 PINDEF(F, 4) | ||
| 125 | # define F5 PINDEF(F, 5) | ||
| 126 | # define F6 PINDEF(F, 6) | ||
| 127 | # define F7 PINDEF(F, 7) | ||
| 128 | #endif \ No newline at end of file | ||
diff --git a/tmk_core/common/chibios/atomic_util.h b/tmk_core/common/chibios/atomic_util.h new file mode 100644 index 000000000..897504515 --- /dev/null +++ b/tmk_core/common/chibios/atomic_util.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include <ch.h> | ||
| 19 | |||
| 20 | static __inline__ uint8_t __interrupt_disable__(void) { | ||
| 21 | chSysLock(); | ||
| 22 | |||
| 23 | return 1; | ||
| 24 | } | ||
| 25 | |||
| 26 | static __inline__ void __interrupt_enable__(const uint8_t *__s) { | ||
| 27 | chSysUnlock(); | ||
| 28 | |||
| 29 | __asm__ volatile("" ::: "memory"); | ||
| 30 | (void)__s; | ||
| 31 | } | ||
| 32 | |||
| 33 | #define ATOMIC_BLOCK(type) for (type, __ToDo = __interrupt_disable__(); __ToDo; __ToDo = 0) | ||
| 34 | #define ATOMIC_FORCEON uint8_t sreg_save __attribute__((__cleanup__(__interrupt_enable__))) = 0 | ||
| 35 | |||
| 36 | #define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented") | ||
| 37 | #define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON) | ||
diff --git a/tmk_core/common/chibios/gpio.h b/tmk_core/common/chibios/gpio.h new file mode 100644 index 000000000..5d0e142ab --- /dev/null +++ b/tmk_core/common/chibios/gpio.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include <hal.h> | ||
| 19 | #include "pin_defs.h" | ||
| 20 | |||
| 21 | typedef ioline_t pin_t; | ||
| 22 | |||
| 23 | #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT) | ||
| 24 | #define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP) | ||
| 25 | #define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN) | ||
| 26 | #define setPinOutput(pin) palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL) | ||
| 27 | |||
| 28 | #define writePinHigh(pin) palSetLine(pin) | ||
| 29 | #define writePinLow(pin) palClearLine(pin) | ||
| 30 | #define writePin(pin, level) ((level) ? (writePinHigh(pin)) : (writePinLow(pin))) | ||
| 31 | |||
| 32 | #define readPin(pin) palReadLine(pin) | ||
| 33 | |||
| 34 | #define togglePin(pin) palToggleLine(pin) | ||
diff --git a/tmk_core/common/chibios/pin_defs.h b/tmk_core/common/chibios/pin_defs.h new file mode 100644 index 000000000..86bc1076e --- /dev/null +++ b/tmk_core/common/chibios/pin_defs.h | |||
| @@ -0,0 +1,242 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | // Defines mapping for Proton C replacement | ||
| 19 | #ifdef CONVERT_TO_PROTON_C | ||
| 20 | // Left side (front) | ||
| 21 | # define D3 PAL_LINE(GPIOA, 9) | ||
| 22 | # define D2 PAL_LINE(GPIOA, 10) | ||
| 23 | // GND | ||
| 24 | // GND | ||
| 25 | # define D1 PAL_LINE(GPIOB, 7) | ||
| 26 | # define D0 PAL_LINE(GPIOB, 6) | ||
| 27 | # define D4 PAL_LINE(GPIOB, 5) | ||
| 28 | # define C6 PAL_LINE(GPIOB, 4) | ||
| 29 | # define D7 PAL_LINE(GPIOB, 3) | ||
| 30 | # define E6 PAL_LINE(GPIOB, 2) | ||
| 31 | # define B4 PAL_LINE(GPIOB, 1) | ||
| 32 | # define B5 PAL_LINE(GPIOB, 0) | ||
| 33 | |||
| 34 | // Right side (front) | ||
| 35 | // RAW | ||
| 36 | // GND | ||
| 37 | // RESET | ||
| 38 | // VCC | ||
| 39 | # define F4 PAL_LINE(GPIOA, 2) | ||
| 40 | # define F5 PAL_LINE(GPIOA, 1) | ||
| 41 | # define F6 PAL_LINE(GPIOA, 0) | ||
| 42 | # define F7 PAL_LINE(GPIOB, 8) | ||
| 43 | # define B1 PAL_LINE(GPIOB, 13) | ||
| 44 | # define B3 PAL_LINE(GPIOB, 14) | ||
| 45 | # define B2 PAL_LINE(GPIOB, 15) | ||
| 46 | # define B6 PAL_LINE(GPIOB, 9) | ||
| 47 | |||
| 48 | // LEDs (only D5/C13 uses an actual LED) | ||
| 49 | # ifdef CONVERT_TO_PROTON_C_RXLED | ||
| 50 | # define D5 PAL_LINE(GPIOC, 14) | ||
| 51 | # define B0 PAL_LINE(GPIOC, 13) | ||
| 52 | # else | ||
| 53 | # define D5 PAL_LINE(GPIOC, 13) | ||
| 54 | # define B0 PAL_LINE(GPIOC, 14) | ||
| 55 | # endif | ||
| 56 | #else | ||
| 57 | # define A0 PAL_LINE(GPIOA, 0) | ||
| 58 | # define A1 PAL_LINE(GPIOA, 1) | ||
| 59 | # define A2 PAL_LINE(GPIOA, 2) | ||
| 60 | # define A3 PAL_LINE(GPIOA, 3) | ||
| 61 | # define A4 PAL_LINE(GPIOA, 4) | ||
| 62 | # define A5 PAL_LINE(GPIOA, 5) | ||
| 63 | # define A6 PAL_LINE(GPIOA, 6) | ||
| 64 | # define A7 PAL_LINE(GPIOA, 7) | ||
| 65 | # define A8 PAL_LINE(GPIOA, 8) | ||
| 66 | # define A9 PAL_LINE(GPIOA, 9) | ||
| 67 | # define A10 PAL_LINE(GPIOA, 10) | ||
| 68 | # define A11 PAL_LINE(GPIOA, 11) | ||
| 69 | # define A12 PAL_LINE(GPIOA, 12) | ||
| 70 | # define A13 PAL_LINE(GPIOA, 13) | ||
| 71 | # define A14 PAL_LINE(GPIOA, 14) | ||
| 72 | # define A15 PAL_LINE(GPIOA, 15) | ||
| 73 | # define B0 PAL_LINE(GPIOB, 0) | ||
| 74 | # define B1 PAL_LINE(GPIOB, 1) | ||
| 75 | # define B2 PAL_LINE(GPIOB, 2) | ||
| 76 | # define B3 PAL_LINE(GPIOB, 3) | ||
| 77 | # define B4 PAL_LINE(GPIOB, 4) | ||
| 78 | # define B5 PAL_LINE(GPIOB, 5) | ||
| 79 | # define B6 PAL_LINE(GPIOB, 6) | ||
| 80 | # define B7 PAL_LINE(GPIOB, 7) | ||
| 81 | # define B8 PAL_LINE(GPIOB, 8) | ||
| 82 | # define B9 PAL_LINE(GPIOB, 9) | ||
| 83 | # define B10 PAL_LINE(GPIOB, 10) | ||
| 84 | # define B11 PAL_LINE(GPIOB, 11) | ||
| 85 | # define B12 PAL_LINE(GPIOB, 12) | ||
| 86 | # define B13 PAL_LINE(GPIOB, 13) | ||
| 87 | # define B14 PAL_LINE(GPIOB, 14) | ||
| 88 | # define B15 PAL_LINE(GPIOB, 15) | ||
| 89 | # define B16 PAL_LINE(GPIOB, 16) | ||
| 90 | # define B17 PAL_LINE(GPIOB, 17) | ||
| 91 | # define B18 PAL_LINE(GPIOB, 18) | ||
| 92 | # define B19 PAL_LINE(GPIOB, 19) | ||
| 93 | # define C0 PAL_LINE(GPIOC, 0) | ||
| 94 | # define C1 PAL_LINE(GPIOC, 1) | ||
| 95 | # define C2 PAL_LINE(GPIOC, 2) | ||
| 96 | # define C3 PAL_LINE(GPIOC, 3) | ||
| 97 | # define C4 PAL_LINE(GPIOC, 4) | ||
| 98 | # define C5 PAL_LINE(GPIOC, 5) | ||
| 99 | # define C6 PAL_LINE(GPIOC, 6) | ||
| 100 | # define C7 PAL_LINE(GPIOC, 7) | ||
| 101 | # define C8 PAL_LINE(GPIOC, 8) | ||
| 102 | # define C9 PAL_LINE(GPIOC, 9) | ||
| 103 | # define C10 PAL_LINE(GPIOC, 10) | ||
| 104 | # define C11 PAL_LINE(GPIOC, 11) | ||
| 105 | # define C12 PAL_LINE(GPIOC, 12) | ||
| 106 | # define C13 PAL_LINE(GPIOC, 13) | ||
| 107 | # define C14 PAL_LINE(GPIOC, 14) | ||
| 108 | # define C15 PAL_LINE(GPIOC, 15) | ||
| 109 | # define D0 PAL_LINE(GPIOD, 0) | ||
| 110 | # define D1 PAL_LINE(GPIOD, 1) | ||
| 111 | # define D2 PAL_LINE(GPIOD, 2) | ||
| 112 | # define D3 PAL_LINE(GPIOD, 3) | ||
| 113 | # define D4 PAL_LINE(GPIOD, 4) | ||
| 114 | # define D5 PAL_LINE(GPIOD, 5) | ||
| 115 | # define D6 PAL_LINE(GPIOD, 6) | ||
| 116 | # define D7 PAL_LINE(GPIOD, 7) | ||
| 117 | # define D8 PAL_LINE(GPIOD, 8) | ||
| 118 | # define D9 PAL_LINE(GPIOD, 9) | ||
| 119 | # define D10 PAL_LINE(GPIOD, 10) | ||
| 120 | # define D11 PAL_LINE(GPIOD, 11) | ||
| 121 | # define D12 PAL_LINE(GPIOD, 12) | ||
| 122 | # define D13 PAL_LINE(GPIOD, 13) | ||
| 123 | # define D14 PAL_LINE(GPIOD, 14) | ||
| 124 | # define D15 PAL_LINE(GPIOD, 15) | ||
| 125 | # define E0 PAL_LINE(GPIOE, 0) | ||
| 126 | # define E1 PAL_LINE(GPIOE, 1) | ||
| 127 | # define E2 PAL_LINE(GPIOE, 2) | ||
| 128 | # define E3 PAL_LINE(GPIOE, 3) | ||
| 129 | # define E4 PAL_LINE(GPIOE, 4) | ||
| 130 | # define E5 PAL_LINE(GPIOE, 5) | ||
| 131 | # define E6 PAL_LINE(GPIOE, 6) | ||
| 132 | # define E7 PAL_LINE(GPIOE, 7) | ||
| 133 | # define E8 PAL_LINE(GPIOE, 8) | ||
| 134 | # define E9 PAL_LINE(GPIOE, 9) | ||
| 135 | # define E10 PAL_LINE(GPIOE, 10) | ||
| 136 | # define E11 PAL_LINE(GPIOE, 11) | ||
| 137 | # define E12 PAL_LINE(GPIOE, 12) | ||
| 138 | # define E13 PAL_LINE(GPIOE, 13) | ||
| 139 | # define E14 PAL_LINE(GPIOE, 14) | ||
| 140 | # define E15 PAL_LINE(GPIOE, 15) | ||
| 141 | # define F0 PAL_LINE(GPIOF, 0) | ||
| 142 | # define F1 PAL_LINE(GPIOF, 1) | ||
| 143 | # define F2 PAL_LINE(GPIOF, 2) | ||
| 144 | # define F3 PAL_LINE(GPIOF, 3) | ||
| 145 | # define F4 PAL_LINE(GPIOF, 4) | ||
| 146 | # define F5 PAL_LINE(GPIOF, 5) | ||
| 147 | # define F6 PAL_LINE(GPIOF, 6) | ||
| 148 | # define F7 PAL_LINE(GPIOF, 7) | ||
| 149 | # define F8 PAL_LINE(GPIOF, 8) | ||
| 150 | # define F9 PAL_LINE(GPIOF, 9) | ||
| 151 | # define F10 PAL_LINE(GPIOF, 10) | ||
| 152 | # define F11 PAL_LINE(GPIOF, 11) | ||
| 153 | # define F12 PAL_LINE(GPIOF, 12) | ||
| 154 | # define F13 PAL_LINE(GPIOF, 13) | ||
| 155 | # define F14 PAL_LINE(GPIOF, 14) | ||
| 156 | # define F15 PAL_LINE(GPIOF, 15) | ||
| 157 | # define G0 PAL_LINE(GPIOG, 0) | ||
| 158 | # define G1 PAL_LINE(GPIOG, 1) | ||
| 159 | # define G2 PAL_LINE(GPIOG, 2) | ||
| 160 | # define G3 PAL_LINE(GPIOG, 3) | ||
| 161 | # define G4 PAL_LINE(GPIOG, 4) | ||
| 162 | # define G5 PAL_LINE(GPIOG, 5) | ||
| 163 | # define G6 PAL_LINE(GPIOG, 6) | ||
| 164 | # define G7 PAL_LINE(GPIOG, 7) | ||
| 165 | # define G8 PAL_LINE(GPIOG, 8) | ||
| 166 | # define G9 PAL_LINE(GPIOG, 9) | ||
| 167 | # define G10 PAL_LINE(GPIOG, 10) | ||
| 168 | # define G11 PAL_LINE(GPIOG, 11) | ||
| 169 | # define G12 PAL_LINE(GPIOG, 12) | ||
| 170 | # define G13 PAL_LINE(GPIOG, 13) | ||
| 171 | # define G14 PAL_LINE(GPIOG, 14) | ||
| 172 | # define G15 PAL_LINE(GPIOG, 15) | ||
| 173 | # define H0 PAL_LINE(GPIOH, 0) | ||
| 174 | # define H1 PAL_LINE(GPIOH, 1) | ||
| 175 | # define H2 PAL_LINE(GPIOH, 2) | ||
| 176 | # define H3 PAL_LINE(GPIOH, 3) | ||
| 177 | # define H4 PAL_LINE(GPIOH, 4) | ||
| 178 | # define H5 PAL_LINE(GPIOH, 5) | ||
| 179 | # define H6 PAL_LINE(GPIOH, 6) | ||
| 180 | # define H7 PAL_LINE(GPIOH, 7) | ||
| 181 | # define H8 PAL_LINE(GPIOH, 8) | ||
| 182 | # define H9 PAL_LINE(GPIOH, 9) | ||
| 183 | # define H10 PAL_LINE(GPIOH, 10) | ||
| 184 | # define H11 PAL_LINE(GPIOH, 11) | ||
| 185 | # define H12 PAL_LINE(GPIOH, 12) | ||
| 186 | # define H13 PAL_LINE(GPIOH, 13) | ||
| 187 | # define H14 PAL_LINE(GPIOH, 14) | ||
| 188 | # define H15 PAL_LINE(GPIOH, 15) | ||
| 189 | # define I0 PAL_LINE(GPIOI, 0) | ||
| 190 | # define I1 PAL_LINE(GPIOI, 1) | ||
| 191 | # define I2 PAL_LINE(GPIOI, 2) | ||
| 192 | # define I3 PAL_LINE(GPIOI, 3) | ||
| 193 | # define I4 PAL_LINE(GPIOI, 4) | ||
| 194 | # define I5 PAL_LINE(GPIOI, 5) | ||
| 195 | # define I6 PAL_LINE(GPIOI, 6) | ||
| 196 | # define I7 PAL_LINE(GPIOI, 7) | ||
| 197 | # define I8 PAL_LINE(GPIOI, 8) | ||
| 198 | # define I9 PAL_LINE(GPIOI, 9) | ||
| 199 | # define I10 PAL_LINE(GPIOI, 10) | ||
| 200 | # define I11 PAL_LINE(GPIOI, 11) | ||
| 201 | # define I12 PAL_LINE(GPIOI, 12) | ||
| 202 | # define I13 PAL_LINE(GPIOI, 13) | ||
| 203 | # define I14 PAL_LINE(GPIOI, 14) | ||
| 204 | # define I15 PAL_LINE(GPIOI, 15) | ||
| 205 | # define J0 PAL_LINE(GPIOJ, 0) | ||
| 206 | # define J1 PAL_LINE(GPIOJ, 1) | ||
| 207 | # define J2 PAL_LINE(GPIOJ, 2) | ||
| 208 | # define J3 PAL_LINE(GPIOJ, 3) | ||
| 209 | # define J4 PAL_LINE(GPIOJ, 4) | ||
| 210 | # define J5 PAL_LINE(GPIOJ, 5) | ||
| 211 | # define J6 PAL_LINE(GPIOJ, 6) | ||
| 212 | # define J7 PAL_LINE(GPIOJ, 7) | ||
| 213 | # define J8 PAL_LINE(GPIOJ, 8) | ||
| 214 | # define J9 PAL_LINE(GPIOJ, 9) | ||
| 215 | # define J10 PAL_LINE(GPIOJ, 10) | ||
| 216 | # define J11 PAL_LINE(GPIOJ, 11) | ||
| 217 | # define J12 PAL_LINE(GPIOJ, 12) | ||
| 218 | # define J13 PAL_LINE(GPIOJ, 13) | ||
| 219 | # define J14 PAL_LINE(GPIOJ, 14) | ||
| 220 | # define J15 PAL_LINE(GPIOJ, 15) | ||
| 221 | // Keyboards can `#define KEYBOARD_REQUIRES_GPIOK` if they need to access GPIO-K pins. These conflict with a whole | ||
| 222 | // bunch of layout definitions, so it's intentionally left out unless absolutely required -- in that case, the | ||
| 223 | // keyboard designer should use a different symbol when defining their layout macros. | ||
| 224 | # ifdef KEYBOARD_REQUIRES_GPIOK | ||
| 225 | # define K0 PAL_LINE(GPIOK, 0) | ||
| 226 | # define K1 PAL_LINE(GPIOK, 1) | ||
| 227 | # define K2 PAL_LINE(GPIOK, 2) | ||
| 228 | # define K3 PAL_LINE(GPIOK, 3) | ||
| 229 | # define K4 PAL_LINE(GPIOK, 4) | ||
| 230 | # define K5 PAL_LINE(GPIOK, 5) | ||
| 231 | # define K6 PAL_LINE(GPIOK, 6) | ||
| 232 | # define K7 PAL_LINE(GPIOK, 7) | ||
| 233 | # define K8 PAL_LINE(GPIOK, 8) | ||
| 234 | # define K9 PAL_LINE(GPIOK, 9) | ||
| 235 | # define K10 PAL_LINE(GPIOK, 10) | ||
| 236 | # define K11 PAL_LINE(GPIOK, 11) | ||
| 237 | # define K12 PAL_LINE(GPIOK, 12) | ||
| 238 | # define K13 PAL_LINE(GPIOK, 13) | ||
| 239 | # define K14 PAL_LINE(GPIOK, 14) | ||
| 240 | # define K15 PAL_LINE(GPIOK, 15) | ||
| 241 | # endif | ||
| 242 | #endif | ||
diff --git a/tmk_core/common/gpio.h b/tmk_core/common/gpio.h new file mode 100644 index 000000000..b47f6f8e4 --- /dev/null +++ b/tmk_core/common/gpio.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include "pin_defs.h" | ||
| 19 | |||
| 20 | #if __has_include_next("gpio.h") | ||
| 21 | # include_next "gpio.h" /* Include the platforms gpio.h */ | ||
| 22 | #endif \ No newline at end of file | ||
diff --git a/tmk_core/common/pin_defs.h b/tmk_core/common/pin_defs.h new file mode 100644 index 000000000..ea730138f --- /dev/null +++ b/tmk_core/common/pin_defs.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | // useful for direct pin mapping | ||
| 19 | #define NO_PIN (pin_t)(~0) | ||
| 20 | |||
| 21 | #if __has_include_next("pin_defs.h") | ||
| 22 | # include_next "pin_defs.h" /* Include the platforms pin_defs.h */ | ||
| 23 | #endif | ||
