diff options
-rw-r--r-- | drivers/arm/i2c_master.c | 15 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.c | 51 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.h | 142 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.mk | 5 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/chconf.h | 524 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/config.h | 35 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/ergodox_stm32.c | 65 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/ergodox_stm32.h | 114 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/halconf.h | 353 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/info.json | 104 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/keymaps/default/keymap.c | 56 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/ld/stm32f103_bootloader.ld | 85 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/matrix.c | 196 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/mcuconf.h | 209 | ||||
-rw-r--r-- | keyboards/ergodox_stm32/rules.mk | 32 |
15 files changed, 1983 insertions, 3 deletions
diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c index 18068d3a6..fcfe85b56 100644 --- a/drivers/arm/i2c_master.c +++ b/drivers/arm/i2c_master.c | |||
@@ -32,6 +32,17 @@ | |||
32 | 32 | ||
33 | static uint8_t i2c_address; | 33 | static uint8_t i2c_address; |
34 | 34 | ||
35 | // ChibiOS uses two initialization structure for v1 and v2/v3 i2c APIs. | ||
36 | // The F1 series uses the v1 api, which have to initialized this way. | ||
37 | #ifdef STM32F103xB | ||
38 | static const I2CConfig i2cconfig = { | ||
39 | OPMODE_I2C, | ||
40 | 400000, | ||
41 | FAST_DUTY_CYCLE_2, | ||
42 | }; | ||
43 | #else | ||
44 | // This configures the I2C clock to 400khz assuming a 72Mhz clock | ||
45 | // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html | ||
35 | static const I2CConfig i2cconfig = { | 46 | static const I2CConfig i2cconfig = { |
36 | #ifdef USE_I2CV1 | 47 | #ifdef USE_I2CV1 |
37 | I2C1_OPMODE, | 48 | I2C1_OPMODE, |
@@ -41,6 +52,7 @@ static const I2CConfig i2cconfig = { | |||
41 | STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), 0, 0 | 52 | STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), 0, 0 |
42 | #endif | 53 | #endif |
43 | }; | 54 | }; |
55 | #endif | ||
44 | 56 | ||
45 | static i2c_status_t chibios_to_qmk(const msg_t* status) { | 57 | static i2c_status_t chibios_to_qmk(const msg_t* status) { |
46 | switch (*status) { | 58 | switch (*status) { |
@@ -60,7 +72,6 @@ __attribute__((weak)) void i2c_init(void) { | |||
60 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT); | 72 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT); |
61 | 73 | ||
62 | chThdSleepMilliseconds(10); | 74 | chThdSleepMilliseconds(10); |
63 | |||
64 | #ifdef USE_I2CV1 | 75 | #ifdef USE_I2CV1 |
65 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); | 76 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); |
66 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); | 77 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); |
@@ -68,8 +79,6 @@ __attribute__((weak)) void i2c_init(void) { | |||
68 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); | 79 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); |
69 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); | 80 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); |
70 | #endif | 81 | #endif |
71 | |||
72 | // i2cInit(); //This is invoked by halInit() so no need to redo it. | ||
73 | } | 82 | } |
74 | 83 | ||
75 | i2c_status_t i2c_start(uint8_t address) { | 84 | i2c_status_t i2c_start(uint8_t address) { |
diff --git a/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.c b/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.c new file mode 100644 index 000000000..d953d6a13 --- /dev/null +++ b/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include "hal.h" | ||
18 | |||
19 | /** | ||
20 | * @brief PAL setup. | ||
21 | * @details Digital I/O ports static configuration as defined in @p board.h. | ||
22 | * This variable is used by the HAL when initializing the PAL driver. | ||
23 | */ | ||
24 | #if HAL_USE_PAL || defined(__DOXYGEN__) | ||
25 | const PALConfig pal_default_config = | ||
26 | { | ||
27 | {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH}, | ||
28 | {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH}, | ||
29 | {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH}, | ||
30 | {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH}, | ||
31 | {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH}, | ||
32 | }; | ||
33 | #endif | ||
34 | |||
35 | /* | ||
36 | * Early initialization code. | ||
37 | * This initialization must be performed just after stack setup and before | ||
38 | * any other initialization. | ||
39 | */ | ||
40 | void __early_init(void) { | ||
41 | |||
42 | stm32_clock_init(); | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | * Board-specific initialization code. | ||
47 | */ | ||
48 | void boardInit(void) { | ||
49 | AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE; | ||
50 | |||
51 | } | ||
diff --git a/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.h b/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.h new file mode 100644 index 000000000..307a17e38 --- /dev/null +++ b/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _BOARD_H_ | ||
18 | #define _BOARD_H_ | ||
19 | |||
20 | /* | ||
21 | * Board identifier. | ||
22 | */ | ||
23 | #define BOARD_JM60 | ||
24 | #define BOARD_NAME "ErgoDox STM32 Keyboard" | ||
25 | |||
26 | /* | ||
27 | * Board frequencies. | ||
28 | */ | ||
29 | #define STM32_LSECLK 0 | ||
30 | #define STM32_HSECLK 8000000 | ||
31 | |||
32 | /* | ||
33 | * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h. | ||
34 | * | ||
35 | * Only xB (128KB Flash) is defined, but it's identical to the | ||
36 | * x8 version (64KB Flash) except for the Flash region size in the | ||
37 | * linker script. For x8 parts use xB here and change to the x8 linker | ||
38 | * script in the project Makefile. | ||
39 | */ | ||
40 | #define STM32F103xB | ||
41 | |||
42 | /* | ||
43 | * IO pins assignments | ||
44 | * | ||
45 | * numbering is sorted by onboard/connectors, as from the schematics in | ||
46 | * http://www.vcc-gnd.com/read.php?tid=369 | ||
47 | */ | ||
48 | |||
49 | /* on-board */ | ||
50 | #define GPIOA_USBDM 11 // pin 8 | ||
51 | #define GPIOA_USBDP 12 // pin 9 | ||
52 | |||
53 | #define GPIOC_OSC32_IN 14 | ||
54 | #define GPIOC_OSC32_OUT 15 | ||
55 | |||
56 | /* | ||
57 | * I/O ports initial setup, this configuration is established soon after reset | ||
58 | * in the initialization code. | ||
59 | * | ||
60 | * The digits have the following meaning: | ||
61 | * 0 - Analog input. | ||
62 | * 1 - Push Pull output 10MHz. | ||
63 | * 2 - Push Pull output 2MHz. | ||
64 | * 3 - Push Pull output 50MHz. | ||
65 | * 4 - Digital input. | ||
66 | * 5 - Open Drain output 10MHz. | ||
67 | * 6 - Open Drain output 2MHz. | ||
68 | * 7 - Open Drain output 50MHz. | ||
69 | * 8 - Digital input with PullUp or PullDown resistor depending on ODR. | ||
70 | * 9 - Alternate Push Pull output 10MHz. | ||
71 | * A - Alternate Push Pull output 2MHz. | ||
72 | * B - Alternate Push Pull output 50MHz. | ||
73 | * C - Reserved. | ||
74 | * D - Alternate Open Drain output 10MHz. | ||
75 | * E - Alternate Open Drain output 2MHz. | ||
76 | * F - Alternate Open Drain output 50MHz. | ||
77 | * Please refer to the STM32 Reference Manual for details. | ||
78 | */ | ||
79 | |||
80 | /* | ||
81 | * Port A setup. | ||
82 | * Everything input with pull-up except: | ||
83 | */ | ||
84 | #define VAL_GPIOACRL 0x88888888 /* PA7...PA0 */ | ||
85 | #define VAL_GPIOACRH 0x88888888 /* PA15...PA8 */ | ||
86 | #define VAL_GPIOAODR 0xFFFFFFFF | ||
87 | |||
88 | /* | ||
89 | * Port B setup. | ||
90 | * Everything input with pull-up except: | ||
91 | */ | ||
92 | #define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */ | ||
93 | #define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */ | ||
94 | #define VAL_GPIOBODR 0xFFFFFFFF | ||
95 | |||
96 | /* | ||
97 | * Port C setup. | ||
98 | * Everything input with pull-up except: | ||
99 | */ | ||
100 | #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */ | ||
101 | #define VAL_GPIOCCRH 0x88888888 /* PC15...PC8 */ | ||
102 | #define VAL_GPIOCODR 0xFFFFFFFF | ||
103 | |||
104 | /* | ||
105 | * Port D setup. | ||
106 | * Everything input with pull-up except: | ||
107 | * PD0 - Normal input (XTAL). | ||
108 | * PD1 - Normal input (XTAL). | ||
109 | */ | ||
110 | #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */ | ||
111 | #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */ | ||
112 | #define VAL_GPIODODR 0xFFFFFFFF | ||
113 | |||
114 | /* | ||
115 | * Port E setup. | ||
116 | * Everything input with pull-up except: | ||
117 | */ | ||
118 | #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */ | ||
119 | #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */ | ||
120 | #define VAL_GPIOEODR 0xFFFFFFFF | ||
121 | |||
122 | /* | ||
123 | * USB bus activation macro, required by the USB driver. | ||
124 | */ | ||
125 | #define usb_lld_connect_bus(usbp) /* always connected */ | ||
126 | |||
127 | /* | ||
128 | * USB bus de-activation macro, required by the USB driver. | ||
129 | */ | ||
130 | #define usb_lld_disconnect_bus(usbp) /* always connected */ | ||
131 | |||
132 | #if !defined(_FROM_ASM_) | ||
133 | #ifdef __cplusplus | ||
134 | extern "C" { | ||
135 | #endif | ||
136 | void boardInit(void); | ||
137 | #ifdef __cplusplus | ||
138 | } | ||
139 | #endif | ||
140 | #endif /* _FROM_ASM_ */ | ||
141 | |||
142 | #endif /* _BOARD_H_ */ | ||
diff --git a/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.mk b/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.mk new file mode 100644 index 000000000..85ff835ef --- /dev/null +++ b/keyboards/ergodox_stm32/boards/ERGODOX_STM32_BOARD/board.mk | |||
@@ -0,0 +1,5 @@ | |||
1 | # List of all the board related files. | ||
2 | BOARDSRC = $(BOARD_PATH)/boards/ERGODOX_STM32_BOARD/board.c | ||
3 | |||
4 | # Required include directories | ||
5 | BOARDINC = $(BOARD_PATH)/boards/ERGODOX_STM32_BOARD | ||
diff --git a/keyboards/ergodox_stm32/chconf.h b/keyboards/ergodox_stm32/chconf.h new file mode 100644 index 000000000..d9114ec85 --- /dev/null +++ b/keyboards/ergodox_stm32/chconf.h | |||
@@ -0,0 +1,524 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file templates/chconf.h | ||
19 | * @brief Configuration file template. | ||
20 | * @details A copy of this file must be placed in each project directory, it | ||
21 | * contains the application specific kernel settings. | ||
22 | * | ||
23 | * @addtogroup config | ||
24 | * @details Kernel related settings and hooks. | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | #ifndef CHCONF_H | ||
29 | #define CHCONF_H | ||
30 | |||
31 | #define _CHIBIOS_RT_CONF_ | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /** | ||
35 | * @name System timers settings | ||
36 | * @{ | ||
37 | */ | ||
38 | /*===========================================================================*/ | ||
39 | |||
40 | /** | ||
41 | * @brief System time counter resolution. | ||
42 | * @note Allowed values are 16 or 32 bits. | ||
43 | */ | ||
44 | #define CH_CFG_ST_RESOLUTION 32 | ||
45 | |||
46 | /** | ||
47 | * @brief System tick frequency. | ||
48 | * @details Frequency of the system timer that drives the system ticks. This | ||
49 | * setting also defines the system tick time unit. | ||
50 | */ | ||
51 | #define CH_CFG_ST_FREQUENCY 100000 | ||
52 | |||
53 | /** | ||
54 | * @brief Time delta constant for the tick-less mode. | ||
55 | * @note If this value is zero then the system uses the classic | ||
56 | * periodic tick. This value represents the minimum number | ||
57 | * of ticks that is safe to specify in a timeout directive. | ||
58 | * The value one is not valid, timeouts are rounded up to | ||
59 | * this value. | ||
60 | */ | ||
61 | #define CH_CFG_ST_TIMEDELTA 0 | ||
62 | |||
63 | /** @} */ | ||
64 | |||
65 | /*===========================================================================*/ | ||
66 | /** | ||
67 | * @name Kernel parameters and options | ||
68 | * @{ | ||
69 | */ | ||
70 | /*===========================================================================*/ | ||
71 | |||
72 | /** | ||
73 | * @brief Round robin interval. | ||
74 | * @details This constant is the number of system ticks allowed for the | ||
75 | * threads before preemption occurs. Setting this value to zero | ||
76 | * disables the preemption for threads with equal priority and the | ||
77 | * round robin becomes cooperative. Note that higher priority | ||
78 | * threads can still preempt, the kernel is always preemptive. | ||
79 | * @note Disabling the round robin preemption makes the kernel more compact | ||
80 | * and generally faster. | ||
81 | * @note The round robin preemption is not supported in tickless mode and | ||
82 | * must be set to zero in that case. | ||
83 | */ | ||
84 | #define CH_CFG_TIME_QUANTUM 20 | ||
85 | |||
86 | /** | ||
87 | * @brief Managed RAM size. | ||
88 | * @details Size of the RAM area to be managed by the OS. If set to zero | ||
89 | * then the whole available RAM is used. The core memory is made | ||
90 | * available to the heap allocator and/or can be used directly through | ||
91 | * the simplified core memory allocator. | ||
92 | * | ||
93 | * @note In order to let the OS manage the whole RAM the linker script must | ||
94 | * provide the @p __heap_base__ and @p __heap_end__ symbols. | ||
95 | * @note Requires @p CH_CFG_USE_MEMCORE. | ||
96 | */ | ||
97 | #define CH_CFG_MEMCORE_SIZE 0 | ||
98 | |||
99 | /** | ||
100 | * @brief Idle thread automatic spawn suppression. | ||
101 | * @details When this option is activated the function @p chSysInit() | ||
102 | * does not spawn the idle thread. The application @p main() | ||
103 | * function becomes the idle thread and must implement an | ||
104 | * infinite loop. | ||
105 | */ | ||
106 | #define CH_CFG_NO_IDLE_THREAD FALSE | ||
107 | |||
108 | /* Use __WFI in the idle thread for waiting. Does lower the power | ||
109 | * consumption. */ | ||
110 | #define CORTEX_ENABLE_WFI_IDLE TRUE | ||
111 | |||
112 | /** @} */ | ||
113 | |||
114 | /*===========================================================================*/ | ||
115 | /** | ||
116 | * @name Performance options | ||
117 | * @{ | ||
118 | */ | ||
119 | /*===========================================================================*/ | ||
120 | |||
121 | /** | ||
122 | * @brief OS optimization. | ||
123 | * @details If enabled then time efficient rather than space efficient code | ||
124 | * is used when two possible implementations exist. | ||
125 | * | ||
126 | * @note This is not related to the compiler optimization options. | ||
127 | * @note The default is @p TRUE. | ||
128 | */ | ||
129 | #define CH_CFG_OPTIMIZE_SPEED TRUE | ||
130 | |||
131 | /** @} */ | ||
132 | |||
133 | /*===========================================================================*/ | ||
134 | /** | ||
135 | * @name Subsystem options | ||
136 | * @{ | ||
137 | */ | ||
138 | /*===========================================================================*/ | ||
139 | |||
140 | /** | ||
141 | * @brief Time Measurement APIs. | ||
142 | * @details If enabled then the time measurement APIs are included in | ||
143 | * the kernel. | ||
144 | * | ||
145 | * @note The default is @p TRUE. | ||
146 | */ | ||
147 | #define CH_CFG_USE_TM FALSE | ||
148 | |||
149 | /** | ||
150 | * @brief Threads registry APIs. | ||
151 | * @details If enabled then the registry APIs are included in the kernel. | ||
152 | * | ||
153 | * @note The default is @p TRUE. | ||
154 | */ | ||
155 | #define CH_CFG_USE_REGISTRY TRUE | ||
156 | |||
157 | /** | ||
158 | * @brief Threads synchronization APIs. | ||
159 | * @details If enabled then the @p chThdWait() function is included in | ||
160 | * the kernel. | ||
161 | * | ||
162 | * @note The default is @p TRUE. | ||
163 | */ | ||
164 | #define CH_CFG_USE_WAITEXIT TRUE | ||
165 | |||
166 | /** | ||
167 | * @brief Semaphores APIs. | ||
168 | * @details If enabled then the Semaphores APIs are included in the kernel. | ||
169 | * | ||
170 | * @note The default is @p TRUE. | ||
171 | */ | ||
172 | #define CH_CFG_USE_SEMAPHORES TRUE | ||
173 | |||
174 | /** | ||
175 | * @brief Semaphores queuing mode. | ||
176 | * @details If enabled then the threads are enqueued on semaphores by | ||
177 | * priority rather than in FIFO order. | ||
178 | * | ||
179 | * @note The default is @p FALSE. Enable this if you have special | ||
180 | * requirements. | ||
181 | * @note Requires @p CH_CFG_USE_SEMAPHORES. | ||
182 | */ | ||
183 | #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE | ||
184 | |||
185 | /** | ||
186 | * @brief Mutexes APIs. | ||
187 | * @details If enabled then the mutexes APIs are included in the kernel. | ||
188 | * | ||
189 | * @note The default is @p TRUE. | ||
190 | */ | ||
191 | #define CH_CFG_USE_MUTEXES TRUE | ||
192 | |||
193 | /** | ||
194 | * @brief Enables recursive behavior on mutexes. | ||
195 | * @note Recursive mutexes are heavier and have an increased | ||
196 | * memory footprint. | ||
197 | * | ||
198 | * @note The default is @p FALSE. | ||
199 | * @note Requires @p CH_CFG_USE_MUTEXES. | ||
200 | */ | ||
201 | #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE | ||
202 | |||
203 | /** | ||
204 | * @brief Conditional Variables APIs. | ||
205 | * @details If enabled then the conditional variables APIs are included | ||
206 | * in the kernel. | ||
207 | * | ||
208 | * @note The default is @p TRUE. | ||
209 | * @note Requires @p CH_CFG_USE_MUTEXES. | ||
210 | */ | ||
211 | #define CH_CFG_USE_CONDVARS TRUE | ||
212 | |||
213 | /** | ||
214 | * @brief Conditional Variables APIs with timeout. | ||
215 | * @details If enabled then the conditional variables APIs with timeout | ||
216 | * specification are included in the kernel. | ||
217 | * | ||
218 | * @note The default is @p TRUE. | ||
219 | * @note Requires @p CH_CFG_USE_CONDVARS. | ||
220 | */ | ||
221 | #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE | ||
222 | |||
223 | /** | ||
224 | * @brief Events Flags APIs. | ||
225 | * @details If enabled then the event flags APIs are included in the kernel. | ||
226 | * | ||
227 | * @note The default is @p TRUE. | ||
228 | */ | ||
229 | #define CH_CFG_USE_EVENTS TRUE | ||
230 | |||
231 | /** | ||
232 | * @brief Events Flags APIs with timeout. | ||
233 | * @details If enabled then the events APIs with timeout specification | ||
234 | * are included in the kernel. | ||
235 | * | ||
236 | * @note The default is @p TRUE. | ||
237 | * @note Requires @p CH_CFG_USE_EVENTS. | ||
238 | */ | ||
239 | #define CH_CFG_USE_EVENTS_TIMEOUT TRUE | ||
240 | |||
241 | /** | ||
242 | * @brief Synchronous Messages APIs. | ||
243 | * @details If enabled then the synchronous messages APIs are included | ||
244 | * in the kernel. | ||
245 | * | ||
246 | * @note The default is @p TRUE. | ||
247 | */ | ||
248 | #define CH_CFG_USE_MESSAGES TRUE | ||
249 | |||
250 | /** | ||
251 | * @brief Synchronous Messages queuing mode. | ||
252 | * @details If enabled then messages are served by priority rather than in | ||
253 | * FIFO order. | ||
254 | * | ||
255 | * @note The default is @p FALSE. Enable this if you have special | ||
256 | * requirements. | ||
257 | * @note Requires @p CH_CFG_USE_MESSAGES. | ||
258 | */ | ||
259 | #define CH_CFG_USE_MESSAGES_PRIORITY FALSE | ||
260 | |||
261 | /** | ||
262 | * @brief Mailboxes APIs. | ||
263 | * @details If enabled then the asynchronous messages (mailboxes) APIs are | ||
264 | * included in the kernel. | ||
265 | * | ||
266 | * @note The default is @p TRUE. | ||
267 | * @note Requires @p CH_CFG_USE_SEMAPHORES. | ||
268 | */ | ||
269 | #define CH_CFG_USE_MAILBOXES TRUE | ||
270 | |||
271 | /** | ||
272 | * @brief Core Memory Manager APIs. | ||
273 | * @details If enabled then the core memory manager APIs are included | ||
274 | * in the kernel. | ||
275 | * | ||
276 | * @note The default is @p TRUE. | ||
277 | */ | ||
278 | #define CH_CFG_USE_MEMCORE TRUE | ||
279 | |||
280 | /** | ||
281 | * @brief Heap Allocator APIs. | ||
282 | * @details If enabled then the memory heap allocator APIs are included | ||
283 | * in the kernel. | ||
284 | * | ||
285 | * @note The default is @p TRUE. | ||
286 | * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or | ||
287 | * @p CH_CFG_USE_SEMAPHORES. | ||
288 | * @note Mutexes are recommended. | ||
289 | */ | ||
290 | #define CH_CFG_USE_HEAP TRUE | ||
291 | |||
292 | /** | ||
293 | * @brief Memory Pools Allocator APIs. | ||
294 | * @details If enabled then the memory pools allocator APIs are included | ||
295 | * in the kernel. | ||
296 | * | ||
297 | * @note The default is @p TRUE. | ||
298 | */ | ||
299 | #define CH_CFG_USE_MEMPOOLS TRUE | ||
300 | |||
301 | /** | ||
302 | * @brief Dynamic Threads APIs. | ||
303 | * @details If enabled then the dynamic threads creation APIs are included | ||
304 | * in the kernel. | ||
305 | * | ||
306 | * @note The default is @p TRUE. | ||
307 | * @note Requires @p CH_CFG_USE_WAITEXIT. | ||
308 | * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. | ||
309 | */ | ||
310 | #define CH_CFG_USE_DYNAMIC TRUE | ||
311 | |||
312 | /** @} */ | ||
313 | |||
314 | /*===========================================================================*/ | ||
315 | /** | ||
316 | * @name Debug options | ||
317 | * @{ | ||
318 | */ | ||
319 | /*===========================================================================*/ | ||
320 | |||
321 | /** | ||
322 | * @brief Debug option, kernel statistics. | ||
323 | * | ||
324 | * @note The default is @p FALSE. | ||
325 | */ | ||
326 | #define CH_DBG_STATISTICS FALSE | ||
327 | |||
328 | /** | ||
329 | * @brief Debug option, system state check. | ||
330 | * @details If enabled the correct call protocol for system APIs is checked | ||
331 | * at runtime. | ||
332 | * | ||
333 | * @note The default is @p FALSE. | ||
334 | */ | ||
335 | #define CH_DBG_SYSTEM_STATE_CHECK FALSE | ||
336 | |||
337 | /** | ||
338 | * @brief Debug option, parameters checks. | ||
339 | * @details If enabled then the checks on the API functions input | ||
340 | * parameters are activated. | ||
341 | * | ||
342 | * @note The default is @p FALSE. | ||
343 | */ | ||
344 | #define CH_DBG_ENABLE_CHECKS FALSE | ||
345 | |||
346 | /** | ||
347 | * @brief Debug option, consistency checks. | ||
348 | * @details If enabled then all the assertions in the kernel code are | ||
349 | * activated. This includes consistency checks inside the kernel, | ||
350 | * runtime anomalies and port-defined checks. | ||
351 | * | ||
352 | * @note The default is @p FALSE. | ||
353 | */ | ||
354 | #define CH_DBG_ENABLE_ASSERTS FALSE | ||
355 | |||
356 | /** | ||
357 | * @brief Debug option, trace buffer. | ||
358 | * @details If enabled then the trace buffer is activated. | ||
359 | * | ||
360 | * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. | ||
361 | */ | ||
362 | #define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED | ||
363 | |||
364 | /** | ||
365 | * @brief Trace buffer entries. | ||
366 | * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is | ||
367 | * different from @p CH_DBG_TRACE_MASK_DISABLED. | ||
368 | */ | ||
369 | #define CH_DBG_TRACE_BUFFER_SIZE 128 | ||
370 | |||
371 | /** | ||
372 | * @brief Debug option, stack checks. | ||
373 | * @details If enabled then a runtime stack check is performed. | ||
374 | * | ||
375 | * @note The default is @p FALSE. | ||
376 | * @note The stack check is performed in a architecture/port dependent way. | ||
377 | * It may not be implemented or some ports. | ||
378 | * @note The default failure mode is to halt the system with the global | ||
379 | * @p panic_msg variable set to @p NULL. | ||
380 | */ | ||
381 | #define CH_DBG_ENABLE_STACK_CHECK FALSE | ||
382 | |||
383 | /** | ||
384 | * @brief Debug option, stacks initialization. | ||
385 | * @details If enabled then the threads working area is filled with a byte | ||
386 | * value when a thread is created. This can be useful for the | ||
387 | * runtime measurement of the used stack. | ||
388 | * | ||
389 | * @note The default is @p FALSE. | ||
390 | */ | ||
391 | #define CH_DBG_FILL_THREADS FALSE | ||
392 | |||
393 | /** | ||
394 | * @brief Debug option, threads profiling. | ||
395 | * @details If enabled then a field is added to the @p thread_t structure that | ||
396 | * counts the system ticks occurred while executing the thread. | ||
397 | * | ||
398 | * @note The default is @p FALSE. | ||
399 | * @note This debug option is not currently compatible with the | ||
400 | * tickless mode. | ||
401 | */ | ||
402 | #define CH_DBG_THREADS_PROFILING FALSE | ||
403 | |||
404 | /** @} */ | ||
405 | |||
406 | /*===========================================================================*/ | ||
407 | /** | ||
408 | * @name Kernel hooks | ||
409 | * @{ | ||
410 | */ | ||
411 | /*===========================================================================*/ | ||
412 | |||
413 | /** | ||
414 | * @brief Threads descriptor structure extension. | ||
415 | * @details User fields added to the end of the @p thread_t structure. | ||
416 | */ | ||
417 | #define CH_CFG_THREAD_EXTRA_FIELDS \ | ||
418 | /* Add threads custom fields here.*/ | ||
419 | |||
420 | /** | ||
421 | * @brief Threads initialization hook. | ||
422 | * @details User initialization code added to the @p chThdInit() API. | ||
423 | * | ||
424 | * @note It is invoked from within @p chThdInit() and implicitly from all | ||
425 | * the threads creation APIs. | ||
426 | */ | ||
427 | #define CH_CFG_THREAD_INIT_HOOK(tp) { \ | ||
428 | /* Add threads initialization code here.*/ \ | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * @brief Threads finalization hook. | ||
433 | * @details User finalization code added to the @p chThdExit() API. | ||
434 | */ | ||
435 | #define CH_CFG_THREAD_EXIT_HOOK(tp) { \ | ||
436 | /* Add threads finalization code here.*/ \ | ||
437 | } | ||
438 | |||
439 | /** | ||
440 | * @brief Context switch hook. | ||
441 | * @details This hook is invoked just before switching between threads. | ||
442 | */ | ||
443 | #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ | ||
444 | /* Context switch code here.*/ \ | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @brief ISR enter hook. | ||
449 | */ | ||
450 | #define CH_CFG_IRQ_PROLOGUE_HOOK() { \ | ||
451 | /* IRQ prologue code here.*/ \ | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * @brief ISR exit hook. | ||
456 | */ | ||
457 | #define CH_CFG_IRQ_EPILOGUE_HOOK() { \ | ||
458 | /* IRQ epilogue code here.*/ \ | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * @brief Idle thread enter hook. | ||
463 | * @note This hook is invoked within a critical zone, no OS functions | ||
464 | * should be invoked from here. | ||
465 | * @note This macro can be used to activate a power saving mode. | ||
466 | */ | ||
467 | #define CH_CFG_IDLE_ENTER_HOOK() { \ | ||
468 | /* Idle-enter code here.*/ \ | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * @brief Idle thread leave hook. | ||
473 | * @note This hook is invoked within a critical zone, no OS functions | ||
474 | * should be invoked from here. | ||
475 | * @note This macro can be used to deactivate a power saving mode. | ||
476 | */ | ||
477 | #define CH_CFG_IDLE_LEAVE_HOOK() { \ | ||
478 | /* Idle-leave code here.*/ \ | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * @brief Idle Loop hook. | ||
483 | * @details This hook is continuously invoked by the idle thread loop. | ||
484 | */ | ||
485 | #define CH_CFG_IDLE_LOOP_HOOK() { \ | ||
486 | /* Idle loop code here.*/ \ | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * @brief System tick event hook. | ||
491 | * @details This hook is invoked in the system tick handler immediately | ||
492 | * after processing the virtual timers queue. | ||
493 | */ | ||
494 | #define CH_CFG_SYSTEM_TICK_HOOK() { \ | ||
495 | /* System tick event code here.*/ \ | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * @brief System halt hook. | ||
500 | * @details This hook is invoked in case to a system halting error before | ||
501 | * the system is halted. | ||
502 | */ | ||
503 | #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ | ||
504 | /* System halt code here.*/ \ | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * @brief Trace hook. | ||
509 | * @details This hook is invoked each time a new record is written in the | ||
510 | * trace buffer. | ||
511 | */ | ||
512 | #define CH_CFG_TRACE_HOOK(tep) { \ | ||
513 | /* Trace code here.*/ \ | ||
514 | } | ||
515 | |||
516 | /** @} */ | ||
517 | |||
518 | /*===========================================================================*/ | ||
519 | /* Port-specific settings (override port settings defaulted in chcore.h). */ | ||
520 | /*===========================================================================*/ | ||
521 | |||
522 | #endif /* CHCONF_H */ | ||
523 | |||
524 | /** @} */ | ||
diff --git a/keyboards/ergodox_stm32/config.h b/keyboards/ergodox_stm32/config.h new file mode 100644 index 000000000..530565521 --- /dev/null +++ b/keyboards/ergodox_stm32/config.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | Copyright 2019 Yaotian Feng(Codetector) <codetector@codetector.cn> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | #pragma once | ||
18 | |||
19 | #include "config_common.h" | ||
20 | |||
21 | #define VENDOR_ID 0xFEED | ||
22 | #define PRODUCT_ID 0x1308 | ||
23 | #define DEVICE_VER 0x101 | ||
24 | #define MANUFACTURER ErgoDox | ||
25 | #define PRODUCT ErgoDox STM | ||
26 | #define DESCRIPTION ErgoDox STM32 Keyboard | ||
27 | |||
28 | #define MATRIX_ROWS 14 | ||
29 | #define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2) | ||
30 | #define MATRIX_COLS 6 | ||
31 | /* key combination for command */ | ||
32 | #define IS_COMMAND() ( \ | ||
33 | keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \ | ||
34 | keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \ | ||
35 | ) | ||
diff --git a/keyboards/ergodox_stm32/ergodox_stm32.c b/keyboards/ergodox_stm32/ergodox_stm32.c new file mode 100644 index 000000000..176fb3f43 --- /dev/null +++ b/keyboards/ergodox_stm32/ergodox_stm32.c | |||
@@ -0,0 +1,65 @@ | |||
1 | #include "i2c_master.h" | ||
2 | #include QMK_KEYBOARD_H | ||
3 | |||
4 | extern inline void ergodox_board_led_1_on(void); | ||
5 | extern inline void ergodox_board_led_2_on(void); | ||
6 | extern inline void ergodox_board_led_3_on(void); | ||
7 | extern inline void ergodox_board_led_1_off(void); | ||
8 | extern inline void ergodox_board_led_2_off(void); | ||
9 | extern inline void ergodox_board_led_3_off(void); | ||
10 | extern inline void ergodox_led_all_off(void); | ||
11 | |||
12 | volatile int mcp23017_status = 0x20; | ||
13 | uint8_t i2c_initializied = 0; | ||
14 | |||
15 | void matrix_init_kb(void) | ||
16 | { | ||
17 | // Init LED Ports | ||
18 | palSetPadMode(GPIOA, 10, PAL_MODE_OUTPUT_PUSHPULL); // LED 1 | ||
19 | palSetPadMode(GPIOA, 9, PAL_MODE_OUTPUT_PUSHPULL); // LED 2 | ||
20 | palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); // LED 3 | ||
21 | |||
22 | ergodox_blink_all_leds(); | ||
23 | |||
24 | matrix_init_user(); | ||
25 | } | ||
26 | |||
27 | void ergodox_blink_all_leds(void) | ||
28 | { | ||
29 | ergodox_led_all_off(); | ||
30 | // ergodox_led_all_set(LED_BRIGHTNESS_DEFAULT); | ||
31 | ergodox_board_led_1_on(); | ||
32 | wait_ms(50); | ||
33 | ergodox_board_led_2_on(); | ||
34 | wait_ms(50); | ||
35 | ergodox_board_led_3_on(); | ||
36 | wait_ms(50); | ||
37 | ergodox_board_led_1_off(); | ||
38 | wait_ms(50); | ||
39 | ergodox_board_led_2_off(); | ||
40 | wait_ms(50); | ||
41 | ergodox_board_led_3_off(); | ||
42 | } | ||
43 | |||
44 | uint8_t init_mcp23017(void) { | ||
45 | if (!i2c_initializied) { | ||
46 | i2c_init(); | ||
47 | i2c_initializied = 1; | ||
48 | } | ||
49 | |||
50 | uint8_t data[2]; | ||
51 | data[0] = 0x0; | ||
52 | data[1] = 0b00111111; | ||
53 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_IODIRA, data, 2, 50000); | ||
54 | if (mcp23017_status) goto out; | ||
55 | data[0] = 0xFFU; | ||
56 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPIOA, data, 1, 5000); | ||
57 | if (mcp23017_status) goto out; | ||
58 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPPUB, data+1, 1, 2); | ||
59 | if (mcp23017_status) goto out; | ||
60 | |||
61 | out: | ||
62 | return mcp23017_status; | ||
63 | // i2c_readReg(I2C_ADDR, ); | ||
64 | } | ||
65 | |||
diff --git a/keyboards/ergodox_stm32/ergodox_stm32.h b/keyboards/ergodox_stm32/ergodox_stm32.h new file mode 100644 index 000000000..be1c2e9c3 --- /dev/null +++ b/keyboards/ergodox_stm32/ergodox_stm32.h | |||
@@ -0,0 +1,114 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "quantum.h" | ||
4 | #include "action_layer.h" | ||
5 | #include <stdint.h> | ||
6 | #include <stdbool.h> | ||
7 | #include "hal.h" | ||
8 | |||
9 | // #define I2C_ADDR 0b01000000 | ||
10 | #define I2C_ADDR 0b01000000 | ||
11 | #define I2C_IODIRA 0x0 | ||
12 | #define I2C_IODIRB 0x1 | ||
13 | #define I2C_GPIOA 0x12 | ||
14 | #define I2C_GPIOB 0x13 | ||
15 | #define I2C_OLATA 0x14 | ||
16 | #define I2C_OLATB 0x15 | ||
17 | #define I2C_GPPUA 0x0C | ||
18 | #define I2C_GPPUB 0x0D | ||
19 | |||
20 | inline void ergodox_board_led_1_on(void) { palSetPad(GPIOA, 10); } | ||
21 | inline void ergodox_board_led_2_on(void) { palSetPad(GPIOA, 9); } | ||
22 | inline void ergodox_board_led_3_on(void) { palSetPad(GPIOA, 8); } | ||
23 | inline void ergodox_board_led_1_off(void) { palClearPad(GPIOA, 10); } | ||
24 | inline void ergodox_board_led_2_off(void) { palClearPad(GPIOA, 9); } | ||
25 | inline void ergodox_board_led_3_off(void) { palClearPad(GPIOA, 8); } | ||
26 | inline void ergodox_led_all_off(void) | ||
27 | { | ||
28 | palClearPad(GPIOA, 10); | ||
29 | palClearPad(GPIOA, 9); | ||
30 | palClearPad(GPIOA, 8); | ||
31 | } | ||
32 | |||
33 | extern volatile int mcp23017_status; | ||
34 | |||
35 | uint8_t init_mcp23017(void); | ||
36 | |||
37 | void ergodox_blink_all_leds(void); | ||
38 | |||
39 | /* | ||
40 | * LEFT HAND: LINES 115-122 | ||
41 | * RIGHT HAND: LINES 124-131 | ||
42 | */ | ||
43 | #define LAYOUT_ergodox( \ | ||
44 | \ | ||
45 | k00, k01, k02, k03, k04, k05, k06, \ | ||
46 | k10, k11, k12, k13, k14, k15, k16, \ | ||
47 | k20, k21, k22, k23, k24, k25, \ | ||
48 | k30, k31, k32, k33, k34, k35, k36, \ | ||
49 | k40, k41, k42, k43, k44, \ | ||
50 | k55, k56, \ | ||
51 | k54, \ | ||
52 | k53, k52, k51, \ | ||
53 | \ | ||
54 | k07, k08, k09, k0A, k0B, k0C, k0D, \ | ||
55 | k17, k18, k19, k1A, k1B, k1C, k1D, \ | ||
56 | k28, k29, k2A, k2B, k2C, k2D, \ | ||
57 | k37, k38, k39, k3A, k3B, k3C, k3D, \ | ||
58 | k49, k4A, k4B, k4C, k4D, \ | ||
59 | k57, k58, \ | ||
60 | k59, \ | ||
61 | k5C, k5B, k5A) \ | ||
62 | \ | ||
63 | /* matrix positions */ \ | ||
64 | { \ | ||
65 | {k00, k10, k20, k30, k40, KC_NO}, \ | ||
66 | {k01, k11, k21, k31, k41, k51}, \ | ||
67 | {k02, k12, k22, k32, k42, k52}, \ | ||
68 | {k03, k13, k23, k33, k43, k53}, \ | ||
69 | {k04, k14, k24, k34, k44, k54}, \ | ||
70 | {k05, k15, k25, k35, KC_NO, k55}, \ | ||
71 | {k06, k16, KC_NO, k36, KC_NO, k56}, \ | ||
72 | \ | ||
73 | {k07, k17, KC_NO, k37, KC_NO, k57}, \ | ||
74 | {k08, k18, k28, k38, KC_NO, k58}, \ | ||
75 | {k09, k19, k29, k39, k49, k59}, \ | ||
76 | {k0A, k1A, k2A, k3A, k4A, k5A}, \ | ||
77 | {k0B, k1B, k2B, k3B, k4B, k5B}, \ | ||
78 | {k0C, k1C, k2C, k3C, k4C, k5C}, \ | ||
79 | { \ | ||
80 | k0D, k1D, k2D, k3D, k4D, KC_NO \ | ||
81 | } \ | ||
82 | } | ||
83 | |||
84 | /* ---------- LEFT HAND ----------- ---------- RIGHT HAND ---------- */ | ||
85 | #define LAYOUT_ergodox_pretty( \ | ||
86 | L00, L01, L02, L03, L04, L05, L06, R00, R01, R02, R03, R04, R05, R06, \ | ||
87 | L10, L11, L12, L13, L14, L15, L16, R10, R11, R12, R13, R14, R15, R16, \ | ||
88 | L20, L21, L22, L23, L24, L25, R21, R22, R23, R24, R25, R26, \ | ||
89 | L30, L31, L32, L33, L34, L35, L36, R30, R31, R32, R33, R34, R35, R36, \ | ||
90 | L40, L41, L42, L43, L44, R42, R43, R44, R45, R46, \ | ||
91 | L55, L56, R50, R51, \ | ||
92 | L54, R52, \ | ||
93 | L53, L52, L51, R55, R54, R53) \ | ||
94 | \ | ||
95 | /* matrix positions */ \ | ||
96 | { \ | ||
97 | {L00, L10, L20, L30, L40, KC_NO}, \ | ||
98 | {L01, L11, L21, L31, L41, L51}, \ | ||
99 | {L02, L12, L22, L32, L42, L52}, \ | ||
100 | {L03, L13, L23, L33, L43, L53}, \ | ||
101 | {L04, L14, L24, L34, L44, L54}, \ | ||
102 | {L05, L15, L25, L35, KC_NO, L55}, \ | ||
103 | {L06, L16, KC_NO, L36, KC_NO, L56}, \ | ||
104 | \ | ||
105 | {R00, R10, KC_NO, R30, KC_NO, R50}, \ | ||
106 | {R01, R11, R21, R31, KC_NO, R51}, \ | ||
107 | {R02, R12, R22, R32, R42, R52}, \ | ||
108 | {R03, R13, R23, R33, R43, R53}, \ | ||
109 | {R04, R14, R24, R34, R44, R54}, \ | ||
110 | {R05, R15, R25, R35, R45, R55}, \ | ||
111 | { \ | ||
112 | R06, R16, R26, R36, R46, KC_NO \ | ||
113 | } \ | ||
114 | } | ||
diff --git a/keyboards/ergodox_stm32/halconf.h b/keyboards/ergodox_stm32/halconf.h new file mode 100644 index 000000000..b87b0635c --- /dev/null +++ b/keyboards/ergodox_stm32/halconf.h | |||
@@ -0,0 +1,353 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file templates/halconf.h | ||
19 | * @brief HAL configuration header. | ||
20 | * @details HAL configuration file, this file allows to enable or disable the | ||
21 | * various device drivers from your application. You may also use | ||
22 | * this file in order to override the device drivers default settings. | ||
23 | * | ||
24 | * @addtogroup HAL_CONF | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | #ifndef _HALCONF_H_ | ||
29 | #define _HALCONF_H_ | ||
30 | |||
31 | #include "mcuconf.h" | ||
32 | |||
33 | /** | ||
34 | * @brief Enables the PAL subsystem. | ||
35 | */ | ||
36 | #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) | ||
37 | #define HAL_USE_PAL TRUE | ||
38 | #endif | ||
39 | |||
40 | /** | ||
41 | * @brief Enables the ADC subsystem. | ||
42 | */ | ||
43 | #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) | ||
44 | #define HAL_USE_ADC FALSE | ||
45 | #endif | ||
46 | |||
47 | /** | ||
48 | * @brief Enables the CAN subsystem. | ||
49 | */ | ||
50 | #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) | ||
51 | #define HAL_USE_CAN FALSE | ||
52 | #endif | ||
53 | |||
54 | /** | ||
55 | * @brief Enables the DAC subsystem. | ||
56 | */ | ||
57 | #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) | ||
58 | #define HAL_USE_DAC FALSE | ||
59 | #endif | ||
60 | |||
61 | /** | ||
62 | * @brief Enables the EXT subsystem. | ||
63 | */ | ||
64 | #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) | ||
65 | #define HAL_USE_EXT FALSE | ||
66 | #endif | ||
67 | |||
68 | /** | ||
69 | * @brief Enables the GPT subsystem. | ||
70 | */ | ||
71 | #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) | ||
72 | #define HAL_USE_GPT FALSE | ||
73 | #endif | ||
74 | |||
75 | /** | ||
76 | * @brief Enables the I2C subsystem. | ||
77 | */ | ||
78 | #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) | ||
79 | #define HAL_USE_I2C TRUE | ||
80 | #endif | ||
81 | |||
82 | /** | ||
83 | * @brief Enables the I2S subsystem. | ||
84 | */ | ||
85 | #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) | ||
86 | #define HAL_USE_I2S FALSE | ||
87 | #endif | ||
88 | |||
89 | /** | ||
90 | * @brief Enables the ICU subsystem. | ||
91 | */ | ||
92 | #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) | ||
93 | #define HAL_USE_ICU FALSE | ||
94 | #endif | ||
95 | |||
96 | /** | ||
97 | * @brief Enables the MAC subsystem. | ||
98 | */ | ||
99 | #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) | ||
100 | #define HAL_USE_MAC FALSE | ||
101 | #endif | ||
102 | |||
103 | /** | ||
104 | * @brief Enables the MMC_SPI subsystem. | ||
105 | */ | ||
106 | #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) | ||
107 | #define HAL_USE_MMC_SPI FALSE | ||
108 | #endif | ||
109 | |||
110 | /** | ||
111 | * @brief Enables the PWM subsystem. | ||
112 | */ | ||
113 | #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) | ||
114 | #define HAL_USE_PWM FALSE | ||
115 | #endif | ||
116 | |||
117 | /** | ||
118 | * @brief Enables the RTC subsystem. | ||
119 | */ | ||
120 | #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) | ||
121 | #define HAL_USE_RTC FALSE | ||
122 | #endif | ||
123 | |||
124 | /** | ||
125 | * @brief Enables the SDC subsystem. | ||
126 | */ | ||
127 | #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) | ||
128 | #define HAL_USE_SDC FALSE | ||
129 | #endif | ||
130 | |||
131 | /** | ||
132 | * @brief Enables the SERIAL subsystem. | ||
133 | */ | ||
134 | #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) | ||
135 | #define HAL_USE_SERIAL FALSE | ||
136 | #endif | ||
137 | |||
138 | /** | ||
139 | * @brief Enables the SERIAL over USB subsystem. | ||
140 | */ | ||
141 | #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) | ||
142 | #define HAL_USE_SERIAL_USB FALSE | ||
143 | #endif | ||
144 | |||
145 | /** | ||
146 | * @brief Enables the SPI subsystem. | ||
147 | */ | ||
148 | #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) | ||
149 | #define HAL_USE_SPI FALSE | ||
150 | #endif | ||
151 | |||
152 | /** | ||
153 | * @brief Enables the UART subsystem. | ||
154 | */ | ||
155 | #if !defined(HAL_USE_UART) || defined(__DOXYGEN__) | ||
156 | #define HAL_USE_UART FALSE | ||
157 | #endif | ||
158 | |||
159 | /** | ||
160 | * @brief Enables the USB subsystem. | ||
161 | */ | ||
162 | #if !defined(HAL_USE_USB) || defined(__DOXYGEN__) | ||
163 | #define HAL_USE_USB TRUE | ||
164 | #endif | ||
165 | |||
166 | /** | ||
167 | * @brief Enables the WDG subsystem. | ||
168 | */ | ||
169 | #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) | ||
170 | #define HAL_USE_WDG FALSE | ||
171 | #endif | ||
172 | |||
173 | /*===========================================================================*/ | ||
174 | /* ADC driver related settings. */ | ||
175 | /*===========================================================================*/ | ||
176 | |||
177 | /** | ||
178 | * @brief Enables synchronous APIs. | ||
179 | * @note Disabling this option saves both code and data space. | ||
180 | */ | ||
181 | #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) | ||
182 | #define ADC_USE_WAIT TRUE | ||
183 | #endif | ||
184 | |||
185 | /** | ||
186 | * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. | ||
187 | * @note Disabling this option saves both code and data space. | ||
188 | */ | ||
189 | #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
190 | #define ADC_USE_MUTUAL_EXCLUSION TRUE | ||
191 | #endif | ||
192 | |||
193 | /*===========================================================================*/ | ||
194 | /* CAN driver related settings. */ | ||
195 | /*===========================================================================*/ | ||
196 | |||
197 | /** | ||
198 | * @brief Sleep mode related APIs inclusion switch. | ||
199 | */ | ||
200 | #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) | ||
201 | #define CAN_USE_SLEEP_MODE TRUE | ||
202 | #endif | ||
203 | |||
204 | /*===========================================================================*/ | ||
205 | /* I2C driver related settings. */ | ||
206 | /*===========================================================================*/ | ||
207 | |||
208 | /** | ||
209 | * @brief Enables the mutual exclusion APIs on the I2C bus. | ||
210 | */ | ||
211 | #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
212 | #define I2C_USE_MUTUAL_EXCLUSION TRUE | ||
213 | #endif | ||
214 | |||
215 | /*===========================================================================*/ | ||
216 | /* MAC driver related settings. */ | ||
217 | /*===========================================================================*/ | ||
218 | |||
219 | /** | ||
220 | * @brief Enables an event sources for incoming packets. | ||
221 | */ | ||
222 | #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) | ||
223 | #define MAC_USE_ZERO_COPY FALSE | ||
224 | #endif | ||
225 | |||
226 | /** | ||
227 | * @brief Enables an event sources for incoming packets. | ||
228 | */ | ||
229 | #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) | ||
230 | #define MAC_USE_EVENTS TRUE | ||
231 | #endif | ||
232 | |||
233 | /*===========================================================================*/ | ||
234 | /* MMC_SPI driver related settings. */ | ||
235 | /*===========================================================================*/ | ||
236 | |||
237 | /** | ||
238 | * @brief Delays insertions. | ||
239 | * @details If enabled this options inserts delays into the MMC waiting | ||
240 | * routines releasing some extra CPU time for the threads with | ||
241 | * lower priority, this may slow down the driver a bit however. | ||
242 | * This option is recommended also if the SPI driver does not | ||
243 | * use a DMA channel and heavily loads the CPU. | ||
244 | */ | ||
245 | #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) | ||
246 | #define MMC_NICE_WAITING TRUE | ||
247 | #endif | ||
248 | |||
249 | /*===========================================================================*/ | ||
250 | /* SDC driver related settings. */ | ||
251 | /*===========================================================================*/ | ||
252 | |||
253 | /** | ||
254 | * @brief Number of initialization attempts before rejecting the card. | ||
255 | * @note Attempts are performed at 10mS intervals. | ||
256 | */ | ||
257 | #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) | ||
258 | #define SDC_INIT_RETRY 100 | ||
259 | #endif | ||
260 | |||
261 | /** | ||
262 | * @brief Include support for MMC cards. | ||
263 | * @note MMC support is not yet implemented so this option must be kept | ||
264 | * at @p FALSE. | ||
265 | */ | ||
266 | #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) | ||
267 | #define SDC_MMC_SUPPORT FALSE | ||
268 | #endif | ||
269 | |||
270 | /** | ||
271 | * @brief Delays insertions. | ||
272 | * @details If enabled this options inserts delays into the MMC waiting | ||
273 | * routines releasing some extra CPU time for the threads with | ||
274 | * lower priority, this may slow down the driver a bit however. | ||
275 | */ | ||
276 | #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) | ||
277 | #define SDC_NICE_WAITING TRUE | ||
278 | #endif | ||
279 | |||
280 | /*===========================================================================*/ | ||
281 | /* SERIAL driver related settings. */ | ||
282 | /*===========================================================================*/ | ||
283 | |||
284 | /** | ||
285 | * @brief Default bit rate. | ||
286 | * @details Configuration parameter, this is the baud rate selected for the | ||
287 | * default configuration. | ||
288 | */ | ||
289 | #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) | ||
290 | #define SERIAL_DEFAULT_BITRATE 38400 | ||
291 | #endif | ||
292 | |||
293 | /** | ||
294 | * @brief Serial buffers size. | ||
295 | * @details Configuration parameter, you can change the depth of the queue | ||
296 | * buffers depending on the requirements of your application. | ||
297 | * @note The default is 64 bytes for both the transmission and receive | ||
298 | * buffers. | ||
299 | */ | ||
300 | #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) | ||
301 | #define SERIAL_BUFFERS_SIZE 16 | ||
302 | #endif | ||
303 | |||
304 | /*===========================================================================*/ | ||
305 | /* SERIAL_USB driver related setting. */ | ||
306 | /*===========================================================================*/ | ||
307 | |||
308 | /** | ||
309 | * @brief Serial over USB buffers size. | ||
310 | * @details Configuration parameter, the buffer size must be a multiple of | ||
311 | * the USB data endpoint maximum packet size. | ||
312 | * @note The default is 64 bytes for both the transmission and receive | ||
313 | * buffers. | ||
314 | */ | ||
315 | #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) | ||
316 | #define SERIAL_USB_BUFFERS_SIZE 1 | ||
317 | #endif | ||
318 | |||
319 | /*===========================================================================*/ | ||
320 | /* SPI driver related settings. */ | ||
321 | /*===========================================================================*/ | ||
322 | |||
323 | /** | ||
324 | * @brief Enables synchronous APIs. | ||
325 | * @note Disabling this option saves both code and data space. | ||
326 | */ | ||
327 | #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) | ||
328 | #define SPI_USE_WAIT TRUE | ||
329 | #endif | ||
330 | |||
331 | /** | ||
332 | * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. | ||
333 | * @note Disabling this option saves both code and data space. | ||
334 | */ | ||
335 | #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
336 | #define SPI_USE_MUTUAL_EXCLUSION TRUE | ||
337 | #endif | ||
338 | |||
339 | /*===========================================================================*/ | ||
340 | /* USB driver related settings. */ | ||
341 | /*===========================================================================*/ | ||
342 | |||
343 | /** | ||
344 | * @brief Enables synchronous APIs. | ||
345 | * @note Disabling this option saves both code and data space. | ||
346 | */ | ||
347 | #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) | ||
348 | #define USB_USE_WAIT TRUE | ||
349 | #endif | ||
350 | |||
351 | #endif /* _HALCONF_H_ */ | ||
352 | |||
353 | /** @} */ | ||
diff --git a/keyboards/ergodox_stm32/info.json b/keyboards/ergodox_stm32/info.json new file mode 100644 index 000000000..627b300fe --- /dev/null +++ b/keyboards/ergodox_stm32/info.json | |||
@@ -0,0 +1,104 @@ | |||
1 | { | ||
2 | "keyboard_name": "ErgoDox STM32", | ||
3 | "url": "github.com/codetector1374", | ||
4 | "maintainer": "codetector1374", | ||
5 | "width": 19.5, | ||
6 | "height": 9.375, | ||
7 | |||
8 | "layouts": { | ||
9 | "LAYOUT_ergodox": { | ||
10 | "layout": [ | ||
11 | {"x":0, "y":0.375, "w":1.5}, {"x":1.5, "y":0.375}, {"x":2.5, "y":0.125}, {"x":3.5, "y":0}, {"x":4.5, "y":0.125}, {"x":5.5, "y":0.25}, {"x":6.5, "y":0.25}, | ||
12 | {"x":0, "y":1.375, "w":1.5}, {"x":1.5, "y":1.375}, {"x":2.5, "y":1.125}, {"x":3.5, "y":1}, {"x":4.5, "y":1.125}, {"x":5.5, "y":1.25}, {"x":6.5, "y":1.25, "h":1.5}, | ||
13 | {"x":0, "y":2.375, "w":1.5}, {"x":1.5, "y":2.375}, {"x":2.5, "y":2.125}, {"x":3.5, "y":2}, {"x":4.5, "y":2.125}, {"x":5.5, "y":2.25}, | ||
14 | {"x":0, "y":3.375, "w":1.5}, {"x":1.5, "y":3.375}, {"x":2.5, "y":3.125}, {"x":3.5, "y":3}, {"x":4.5, "y":3.125}, {"x":5.5, "y":3.25}, {"x":6.5, "y":2.75, "h":1.5}, | ||
15 | {"x":0.5, "y":4.375}, {"x":1.5, "y":4.375}, {"x":2.5, "y":4.125}, {"x":3.5, "y":4}, {"x":4.5, "y":4.125}, | ||
16 | |||
17 | {"x":6, "y":5}, {"x":7, "y":5}, | ||
18 | {"x":7, "y":6}, | ||
19 | {"x":5, "y":6, "h":2}, {"x":6, "y":6, "h":2}, {"x":7, "y":7}, | ||
20 | |||
21 | |||
22 | {"x":9.5, "y":0.25}, {"x":10.5, "y":0.25}, {"x":11.5, "y":0.125}, {"x":12.5, "y":0}, {"x":13.5, "y":0.125}, {"x":14.5, "y":0.375}, {"x":15.5, "y":0.375, "w":1.5}, | ||
23 | {"x":9.5, "y":1.25, "h":1.5}, {"x":10.5, "y":1.25}, {"x":11.5, "y":1.125}, {"x":12.5, "y":1}, {"x":13.5, "y":1.125}, {"x":14.5, "y":1.375}, {"x":15.5, "y":1.375, "w":1.5}, | ||
24 | {"x":10.5, "y":2.25}, {"x":11.5, "y":2.125}, {"x":12.5, "y":2}, {"x":13.5, "y":2.125}, {"x":14.5, "y":2.375}, {"x":15.5, "y":2.375, "w":1.5}, | ||
25 | {"x":9.5, "y":2.75, "h":1.5}, {"x":10.5, "y":3.25}, {"x":11.5, "y":3.125}, {"x":12.5, "y":3}, {"x":13.5, "y":3.125}, {"x":14.5, "y":3.375}, {"x":15.5, "y":3.375, "w":1.5}, | ||
26 | {"x":11.5, "y":4.125}, {"x":12.5, "y":4}, {"x":13.5, "y":4.125}, {"x":14.5, "y":4.375}, {"x":15.5, "y":4.375}, | ||
27 | |||
28 | |||
29 | {"x":9, "y":5}, {"x":10, "y":5}, | ||
30 | {"x":9, "y":6}, | ||
31 | {"x":9, "y":7}, {"x":10, "y":6, "h":2}, {"x":11, "y":6, "h":2} | ||
32 | ] | ||
33 | }, | ||
34 | "LAYOUT_ergodox_pretty": { | ||
35 | "layout": [ | ||
36 | {"x":0, "y":0.375, "w":1.5}, {"x":1.5, "y":0.375}, {"x":2.5, "y":0.125}, {"x":3.5, "y":0}, {"x":4.5, "y":0.125}, {"x":5.5, "y":0.25}, {"x":6.5, "y":0.25}, | ||
37 | {"x":9.5, "y":0.25}, {"x":10.5, "y":0.25}, {"x":11.5, "y":0.125}, {"x":12.5, "y":0}, {"x":13.5, "y":0.125}, {"x":14.5, "y":0.375}, {"x":15.5, "y":0.375, "w":1.5}, | ||
38 | |||
39 | {"x":0, "y":1.375, "w":1.5}, {"x":1.5, "y":1.375}, {"x":2.5, "y":1.125}, {"x":3.5, "y":1}, {"x":4.5, "y":1.125}, {"x":5.5, "y":1.25}, {"x":6.5, "y":1.25, "h":1.5}, | ||
40 | {"x":9.5, "y":1.25, "h":1.5}, {"x":10.5, "y":1.25}, {"x":11.5, "y":1.125}, {"x":12.5, "y":1}, {"x":13.5, "y":1.125}, {"x":14.5, "y":1.375}, {"x":15.5, "y":1.375, "w":1.5}, | ||
41 | |||
42 | {"x":0, "y":2.375, "w":1.5}, {"x":1.5, "y":2.375}, {"x":2.5, "y":2.125}, {"x":3.5, "y":2}, {"x":4.5, "y":2.125}, {"x":5.5, "y":2.25}, | ||
43 | {"x":10.5, "y":2.25}, {"x":11.5, "y":2.125}, {"x":12.5, "y":2}, {"x":13.5, "y":2.125}, {"x":14.5, "y":2.375}, {"x":15.5, "y":2.375, "w":1.5}, | ||
44 | |||
45 | {"x":0, "y":3.375, "w":1.5}, {"x":1.5, "y":3.375}, {"x":2.5, "y":3.125}, {"x":3.5, "y":3}, {"x":4.5, "y":3.125}, {"x":5.5, "y":3.25}, {"x":6.5, "y":2.75, "h":1.5}, | ||
46 | {"x":9.5, "y":2.75, "h":1.5}, {"x":10.5, "y":3.25}, {"x":11.5, "y":3.125}, {"x":12.5, "y":3}, {"x":13.5, "y":3.125}, {"x":14.5, "y":3.375}, {"x":15.5, "y":3.375, "w":1.5}, | ||
47 | |||
48 | {"x":0.5, "y":4.375}, {"x":1.5, "y":4.375}, {"x":2.5, "y":4.125}, {"x":3.5, "y":4}, {"x":4.5, "y":4.125}, | ||
49 | {"x":11.5, "y":4.125}, {"x":12.5, "y":4}, {"x":13.5, "y":4.125}, {"x":14.5, "y":4.375}, {"x":15.5, "y":4.375}, | ||
50 | |||
51 | {"x":6, "y":5}, {"x":7, "y":5}, {"x":9, "y":5}, {"x":10, "y":5}, | ||
52 | {"x":7, "y":6}, {"x":9, "y":6}, | ||
53 | {"x":5, "y":6, "h":2}, {"x":6, "y":6, "h":2}, {"x":7, "y":7}, {"x":9, "y":7}, {"x":10, "y":6, "h":2}, {"x":11, "y":6, "h":2} | ||
54 | ] | ||
55 | }, | ||
56 | "LAYOUT_ergodox_80": { | ||
57 | "layout": [ | ||
58 | {"x":0, "y":0.375, "w":1.5}, {"x":1.5, "y":0.375}, {"x":2.5, "y":0.125}, {"x":3.5, "y":0}, {"x":4.5, "y":0.125}, {"x":5.5, "y":0.25}, {"x":6.5, "y":0.25}, | ||
59 | {"x":0, "y":1.375, "w":1.5}, {"x":1.5, "y":1.375}, {"x":2.5, "y":1.125}, {"x":3.5, "y":1}, {"x":4.5, "y":1.125}, {"x":5.5, "y":1.25}, {"x":6.5, "y":1.25, "h":1.5}, | ||
60 | {"x":0, "y":2.375, "w":1.5}, {"x":1.5, "y":2.375}, {"x":2.5, "y":2.125}, {"x":3.5, "y":2}, {"x":4.5, "y":2.125}, {"x":5.5, "y":2.25}, | ||
61 | {"x":0, "y":3.375, "w":1.5}, {"x":1.5, "y":3.375}, {"x":2.5, "y":3.125}, {"x":3.5, "y":3}, {"x":4.5, "y":3.125}, {"x":5.5, "y":3.25}, {"x":6.5, "y":2.75, "h":1.5}, | ||
62 | {"x":0.5, "y":4.375}, {"x":1.5, "y":4.375}, {"x":2.5, "y":4.125}, {"x":3.5, "y":4}, {"x":4.5, "y":4.125}, | ||
63 | |||
64 | {"x":6, "y":5}, {"x":7, "y":5}, | ||
65 | {"x":5, "y":6}, {"x":6, "y":6}, {"x":7, "y":6}, | ||
66 | {"x":5, "y":7}, {"x":6, "y":7}, {"x":7, "y":7}, | ||
67 | |||
68 | |||
69 | {"x":9.5, "y":0.25}, {"x":10.5, "y":0.25}, {"x":11.5, "y":0.125}, {"x":12.5, "y":0}, {"x":13.5, "y":0.125}, {"x":14.5, "y":0.375}, {"x":15.5, "y":0.375, "w":1.5}, | ||
70 | {"x":9.5, "y":1.25, "h":1.5}, {"x":10.5, "y":1.25}, {"x":11.5, "y":1.125}, {"x":12.5, "y":1}, {"x":13.5, "y":1.125}, {"x":14.5, "y":1.375}, {"x":15.5, "y":1.375, "w":1.5}, | ||
71 | {"x":10.5, "y":2.25}, {"x":11.5, "y":2.125}, {"x":12.5, "y":2}, {"x":13.5, "y":2.125}, {"x":14.5, "y":2.375}, {"x":15.5, "y":2.375, "w":1.5}, | ||
72 | {"x":9.5, "y":2.75, "h":1.5}, {"x":10.5, "y":3.25}, {"x":11.5, "y":3.125}, {"x":12.5, "y":3}, {"x":13.5, "y":3.125}, {"x":14.5, "y":3.375}, {"x":15.5, "y":3.375, "w":1.5}, | ||
73 | {"x":11.5, "y":4.125}, {"x":12.5, "y":4}, {"x":13.5, "y":4.125}, {"x":14.5, "y":4.375}, {"x":15.5, "y":4.375}, | ||
74 | |||
75 | |||
76 | {"x":9, "y":5}, {"x":10, "y":5}, | ||
77 | {"x":9, "y":6}, {"x":10, "y":6}, {"x":11, "y":6}, | ||
78 | {"x":9, "y":7}, {"x":10, "y":7}, {"x":11, "y":7} | ||
79 | ] | ||
80 | }, | ||
81 | "LAYOUT_ergodox_pretty_80": { | ||
82 | "layout": [ | ||
83 | {"x":0, "y":0.375, "w":1.5}, {"x":1.5, "y":0.375}, {"x":2.5, "y":0.125}, {"x":3.5, "y":0}, {"x":4.5, "y":0.125}, {"x":5.5, "y":0.25}, {"x":6.5, "y":0.25}, | ||
84 | {"x":9.5, "y":0.25}, {"x":10.5, "y":0.25}, {"x":11.5, "y":0.125}, {"x":12.5, "y":0}, {"x":13.5, "y":0.125}, {"x":14.5, "y":0.375}, {"x":15.5, "y":0.375, "w":1.5}, | ||
85 | |||
86 | {"x":0, "y":1.375, "w":1.5}, {"x":1.5, "y":1.375}, {"x":2.5, "y":1.125}, {"x":3.5, "y":1}, {"x":4.5, "y":1.125}, {"x":5.5, "y":1.25}, {"x":6.5, "y":1.25, "h":1.5}, | ||
87 | {"x":9.5, "y":1.25, "h":1.5}, {"x":10.5, "y":1.25}, {"x":11.5, "y":1.125}, {"x":12.5, "y":1}, {"x":13.5, "y":1.125}, {"x":14.5, "y":1.375}, {"x":15.5, "y":1.375, "w":1.5}, | ||
88 | |||
89 | {"x":0, "y":2.375, "w":1.5}, {"x":1.5, "y":2.375}, {"x":2.5, "y":2.125}, {"x":3.5, "y":2}, {"x":4.5, "y":2.125}, {"x":5.5, "y":2.25}, | ||
90 | {"x":10.5, "y":2.25}, {"x":11.5, "y":2.125}, {"x":12.5, "y":2}, {"x":13.5, "y":2.125}, {"x":14.5, "y":2.375}, {"x":15.5, "y":2.375, "w":1.5}, | ||
91 | |||
92 | {"x":0, "y":3.375, "w":1.5}, {"x":1.5, "y":3.375}, {"x":2.5, "y":3.125}, {"x":3.5, "y":3}, {"x":4.5, "y":3.125}, {"x":5.5, "y":3.25}, {"x":6.5, "y":2.75, "h":1.5}, | ||
93 | {"x":9.5, "y":2.75, "h":1.5}, {"x":10.5, "y":3.25}, {"x":11.5, "y":3.125}, {"x":12.5, "y":3}, {"x":13.5, "y":3.125}, {"x":14.5, "y":3.375}, {"x":15.5, "y":3.375, "w":1.5}, | ||
94 | |||
95 | {"x":0.5, "y":4.375}, {"x":1.5, "y":4.375}, {"x":2.5, "y":4.125}, {"x":3.5, "y":4}, {"x":4.5, "y":4.125}, | ||
96 | {"x":11.5, "y":4.125}, {"x":12.5, "y":4}, {"x":13.5, "y":4.125}, {"x":14.5, "y":4.375}, {"x":15.5, "y":4.375}, | ||
97 | |||
98 | {"x":6, "y":5}, {"x":7, "y":5}, {"x":9, "y":5}, {"x":10, "y":5}, | ||
99 | {"x":5, "y":6}, {"x":6, "y":6}, {"x":7, "y":6}, {"x":9, "y":6}, {"x":10, "y":6}, {"x":11, "y":6}, | ||
100 | {"x":5, "y":7}, {"x":6, "y":7}, {"x":7, "y":7}, {"x":9, "y":7}, {"x":10, "y":7}, {"x":11, "y":7} | ||
101 | ] | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/keyboards/ergodox_stm32/keymaps/default/keymap.c b/keyboards/ergodox_stm32/keymaps/default/keymap.c new file mode 100644 index 000000000..d3d4b5722 --- /dev/null +++ b/keyboards/ergodox_stm32/keymaps/default/keymap.c | |||
@@ -0,0 +1,56 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | |||
3 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
4 | [0] = LAYOUT_ergodox(KC_GRAVE,KC_1,KC_2,KC_3,KC_4,KC_5,KC_MINUS,KC_TAB,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_LPRN,KC_ESCAPE,KC_A,KC_S,KC_D,KC_F,KC_G,KC_LSHIFT,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_RPRN,KC_LCTRL,KC_LGUI,KC_LALT,KC_LGUI,KC_LALT,KC_INSERT,MO(1),KC_HOME,KC_SPACE,KC_DELETE,KC_END,KC_EQUAL,KC_6,KC_7,KC_8,KC_9,KC_0,KC_BSPACE,KC_LBRACKET,KC_Y,KC_U,KC_I,KC_O,KC_P,KC_BSLASH,KC_H,KC_J,KC_K,KC_L,KC_SCOLON,KC_QUOTE,KC_RBRACKET,KC_N,KC_M,KC_COMMA,KC_DOT,KC_SLASH,KC_RSHIFT,KC_LEFT,KC_DOWN,KC_UP,KC_RIGHT,KC_RCTRL,MO(1),TG(2),KC_PGUP,KC_PGDOWN,KC_BSPACE,KC_ENTER), | ||
5 | |||
6 | [1] = LAYOUT_ergodox(KC_TILD,KC_F1,KC_F2,KC_F3,KC_F4,KC_F5,KC_F6,KC_GRAVE,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_CAPSLOCK,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_MEDIA_PLAY_PAUSE,KC_TRANSPARENT,KC_TRANSPARENT,KC_F7,KC_F8,KC_F9,KC_F10,KC_F11,KC_F12,KC_BSPACE,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,LCTL(LGUI(KC_Q)),KC_MEDIA_PREV_TRACK,KC_MEDIA_NEXT_TRACK,KC_AUDIO_VOL_DOWN,KC_AUDIO_VOL_UP), | ||
7 | |||
8 | [2] = LAYOUT_ergodox(KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_NUMLOCK,KC_KP_SLASH,KC_KP_ASTERISK,KC_KP_MINUS,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_KP_7,KC_KP_8,KC_KP_9,KC_KP_PLUS,KC_TRANSPARENT,KC_TRANSPARENT,KC_KP_4,KC_KP_5,KC_KP_6,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_KP_1,KC_KP_2,KC_KP_3,KC_ENTER,KC_TRANSPARENT,KC_KP_DOT,KC_KP_0,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT), | ||
9 | |||
10 | }; | ||
11 | |||
12 | const uint16_t PROGMEM fn_actions[] = { | ||
13 | [1] = TT(1) | ||
14 | }; | ||
15 | |||
16 | uint32_t layer_state_set_user(uint32_t state) { | ||
17 | |||
18 | uint8_t layer = biton32(state); | ||
19 | |||
20 | ergodox_led_all_off(); | ||
21 | ergodox_board_led_1_off(); | ||
22 | ergodox_board_led_2_off(); | ||
23 | ergodox_board_led_3_off(); | ||
24 | switch (layer) { | ||
25 | case 1: | ||
26 | ergodox_board_led_1_on(); | ||
27 | break; | ||
28 | case 2: | ||
29 | ergodox_board_led_2_on(); | ||
30 | break; | ||
31 | case 3: | ||
32 | ergodox_board_led_2_on(); | ||
33 | break; | ||
34 | case 4: | ||
35 | ergodox_board_led_1_on(); | ||
36 | ergodox_board_led_2_on(); | ||
37 | break; | ||
38 | case 5: | ||
39 | ergodox_board_led_1_on(); | ||
40 | ergodox_board_led_3_on(); | ||
41 | break; | ||
42 | case 6: | ||
43 | ergodox_board_led_2_on(); | ||
44 | ergodox_board_led_3_on(); | ||
45 | break; | ||
46 | case 7: | ||
47 | ergodox_board_led_1_on(); | ||
48 | ergodox_board_led_2_on(); | ||
49 | ergodox_board_led_3_on(); | ||
50 | break; | ||
51 | default: | ||
52 | break; | ||
53 | } | ||
54 | return state; | ||
55 | |||
56 | }; | ||
diff --git a/keyboards/ergodox_stm32/ld/stm32f103_bootloader.ld b/keyboards/ergodox_stm32/ld/stm32f103_bootloader.ld new file mode 100644 index 000000000..77100fce3 --- /dev/null +++ b/keyboards/ergodox_stm32/ld/stm32f103_bootloader.ld | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /* | ||
18 | * ST32F103xB memory setup for use with the originaljm60 bootloader. | ||
19 | */ | ||
20 | MEMORY | ||
21 | { | ||
22 | flash0 : org = 0x08000000, len = 64k /* TODO */ | ||
23 | flash1 : org = 0x00000000, len = 0 | ||
24 | flash2 : org = 0x00000000, len = 0 | ||
25 | flash3 : org = 0x00000000, len = 0 | ||
26 | flash4 : org = 0x00000000, len = 0 | ||
27 | flash5 : org = 0x00000000, len = 0 | ||
28 | flash6 : org = 0x00000000, len = 0 | ||
29 | flash7 : org = 0x00000000, len = 0 | ||
30 | ram0 : org = 0x20000000, len = 20k | ||
31 | ram1 : org = 0x00000000, len = 0 | ||
32 | ram2 : org = 0x00000000, len = 0 | ||
33 | ram3 : org = 0x00000000, len = 0 | ||
34 | ram4 : org = 0x00000000, len = 0 | ||
35 | ram5 : org = 0x00000000, len = 0 | ||
36 | ram6 : org = 0x00000000, len = 0 | ||
37 | ram7 : org = 0x00000000, len = 0 | ||
38 | } | ||
39 | |||
40 | /* For each data/text section two region are defined, a virtual region | ||
41 | and a load region (_LMA suffix).*/ | ||
42 | |||
43 | /* Flash region to be used for exception vectors.*/ | ||
44 | REGION_ALIAS("VECTORS_FLASH", flash0); | ||
45 | REGION_ALIAS("VECTORS_FLASH_LMA", flash0); | ||
46 | |||
47 | /* Flash region to be used for constructors and destructors.*/ | ||
48 | REGION_ALIAS("XTORS_FLASH", flash0); | ||
49 | REGION_ALIAS("XTORS_FLASH_LMA", flash0); | ||
50 | |||
51 | /* Flash region to be used for code text.*/ | ||
52 | REGION_ALIAS("TEXT_FLASH", flash0); | ||
53 | REGION_ALIAS("TEXT_FLASH_LMA", flash0); | ||
54 | |||
55 | /* Flash region to be used for read only data.*/ | ||
56 | REGION_ALIAS("RODATA_FLASH", flash0); | ||
57 | REGION_ALIAS("RODATA_FLASH_LMA", flash0); | ||
58 | |||
59 | /* Flash region to be used for various.*/ | ||
60 | REGION_ALIAS("VARIOUS_FLASH", flash0); | ||
61 | REGION_ALIAS("VARIOUS_FLASH_LMA", flash0); | ||
62 | |||
63 | /* Flash region to be used for RAM(n) initialization data.*/ | ||
64 | REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0); | ||
65 | |||
66 | /* RAM region to be used for Main stack. This stack accommodates the processing | ||
67 | of all exceptions and interrupts.*/ | ||
68 | REGION_ALIAS("MAIN_STACK_RAM", ram0); | ||
69 | |||
70 | /* RAM region to be used for the process stack. This is the stack used by | ||
71 | the main() function.*/ | ||
72 | REGION_ALIAS("PROCESS_STACK_RAM", ram0); | ||
73 | |||
74 | /* RAM region to be used for data segment.*/ | ||
75 | REGION_ALIAS("DATA_RAM", ram0); | ||
76 | REGION_ALIAS("DATA_RAM_LMA", flash0); | ||
77 | |||
78 | /* RAM region to be used for BSS segment.*/ | ||
79 | REGION_ALIAS("BSS_RAM", ram0); | ||
80 | |||
81 | /* RAM region to be used for the default heap.*/ | ||
82 | REGION_ALIAS("HEAP_RAM", ram0); | ||
83 | |||
84 | /* Generic rules inclusion.*/ | ||
85 | INCLUDE rules.ld | ||
diff --git a/keyboards/ergodox_stm32/matrix.c b/keyboards/ergodox_stm32/matrix.c new file mode 100644 index 000000000..5a280ee17 --- /dev/null +++ b/keyboards/ergodox_stm32/matrix.c | |||
@@ -0,0 +1,196 @@ | |||
1 | #include <stdint.h> | ||
2 | #include <stdbool.h> | ||
3 | #include <string.h> | ||
4 | #include <hal.h> | ||
5 | #include "timer.h" | ||
6 | #include "wait.h" | ||
7 | #include "print.h" | ||
8 | #include "matrix.h" | ||
9 | #include "i2c_master.h" | ||
10 | #include QMK_KEYBOARD_H | ||
11 | |||
12 | #ifndef DEBOUNCE | ||
13 | #define DEBOUNCE 10 | ||
14 | #endif | ||
15 | |||
16 | //#define DEBUG_MATRIX_SCAN_RATE | ||
17 | |||
18 | //#ifdef DEBUG_MATRIX_SCAN_RATE | ||
19 | //uint32_t matrix_timer; | ||
20 | //uint32_t matrix_scan_count; | ||
21 | //#endif | ||
22 | |||
23 | static uint8_t mcp23017_reset_loop = 0; | ||
24 | |||
25 | volatile matrix_row_t matrix[MATRIX_ROWS]; | ||
26 | volatile matrix_row_t raw_matrix[MATRIX_ROWS]; | ||
27 | volatile uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS]; | ||
28 | |||
29 | static matrix_row_t read_cols(uint8_t row); | ||
30 | |||
31 | static void init_cols(void); | ||
32 | |||
33 | static void unselect_rows(void); | ||
34 | |||
35 | static void select_row(uint8_t row); | ||
36 | |||
37 | static void init_rows(void); | ||
38 | |||
39 | __attribute__((weak)) void matrix_init_user(void) {} | ||
40 | |||
41 | __attribute__((weak)) void matrix_scan_user(void) {} | ||
42 | |||
43 | __attribute__((weak)) void matrix_init_kb(void) { | ||
44 | matrix_init_user(); | ||
45 | } | ||
46 | |||
47 | __attribute__((weak)) void matrix_scan_kb(void) { | ||
48 | matrix_scan_user(); | ||
49 | } | ||
50 | |||
51 | void matrix_init(void) { | ||
52 | mcp23017_status = init_mcp23017(); | ||
53 | (void) mcp23017_reset_loop; | ||
54 | init_rows(); | ||
55 | unselect_rows(); | ||
56 | init_cols(); | ||
57 | |||
58 | |||
59 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
60 | matrix[i] = 0; | ||
61 | raw_matrix[i] = 0; | ||
62 | for (uint8_t j = 0; j < MATRIX_COLS; ++j) { | ||
63 | debounce_matrix[i * MATRIX_COLS + j] = 0; | ||
64 | } | ||
65 | } | ||
66 | matrix_init_quantum(); | ||
67 | } | ||
68 | |||
69 | void matrix_power_up(void) { | ||
70 | mcp23017_status = init_mcp23017(); | ||
71 | |||
72 | init_rows(); | ||
73 | unselect_rows(); | ||
74 | init_cols(); | ||
75 | |||
76 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
77 | matrix[i] = 0; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | matrix_row_t debounce_mask(matrix_row_t rawcols, uint8_t row) { | ||
82 | matrix_row_t result = 0; | ||
83 | matrix_row_t change = rawcols ^raw_matrix[row]; | ||
84 | raw_matrix[row] = rawcols; | ||
85 | for (uint8_t i = 0; i < MATRIX_COLS; ++i) { | ||
86 | if (debounce_matrix[row * MATRIX_COLS + i]) { | ||
87 | --debounce_matrix[row * MATRIX_COLS + i]; | ||
88 | } else { | ||
89 | result |= (1 << i); | ||
90 | } | ||
91 | if (change & (1 << i)) { | ||
92 | debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE; | ||
93 | } | ||
94 | } | ||
95 | return result; | ||
96 | } | ||
97 | |||
98 | matrix_row_t debounce_read_cols(uint8_t row) { | ||
99 | // Read the row without debouncing filtering and store it for later usage. | ||
100 | matrix_row_t cols = read_cols(row); | ||
101 | // Get the Debounce mask. | ||
102 | matrix_row_t mask = debounce_mask(cols, row); | ||
103 | // debounce the row and return the result. | ||
104 | return (cols & mask) | (matrix[row] & ~mask);; | ||
105 | } | ||
106 | |||
107 | uint8_t matrix_scan(void) { | ||
108 | if (mcp23017_status) { | ||
109 | if (++mcp23017_reset_loop == 0) { | ||
110 | mcp23017_status = init_mcp23017(); | ||
111 | if (!mcp23017_status) { | ||
112 | ergodox_blink_all_leds(); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { | ||
117 | select_row(i); | ||
118 | select_row(i + MATRIX_ROWS_PER_SIDE); | ||
119 | |||
120 | matrix[i] = debounce_read_cols(i); | ||
121 | matrix[i + MATRIX_ROWS_PER_SIDE] = debounce_read_cols(i + MATRIX_ROWS_PER_SIDE); | ||
122 | |||
123 | unselect_rows(); | ||
124 | } | ||
125 | matrix_scan_quantum(); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | bool matrix_is_modified(void) { | ||
130 | return true; | ||
131 | } | ||
132 | |||
133 | inline | ||
134 | bool matrix_is_on(uint8_t row, uint8_t col) { | ||
135 | return (matrix[row] & (1 << col)); | ||
136 | } | ||
137 | |||
138 | inline | ||
139 | matrix_row_t matrix_get_row(uint8_t row) { | ||
140 | return matrix[row]; | ||
141 | } | ||
142 | |||
143 | void matrix_print(void) { | ||
144 | } | ||
145 | |||
146 | static matrix_row_t read_cols(uint8_t row) { | ||
147 | if (row < MATRIX_ROWS_PER_SIDE) { | ||
148 | uint8_t data = 0xFF; | ||
149 | if (!mcp23017_status) { | ||
150 | uint8_t regAddr = I2C_GPIOB; | ||
151 | mcp23017_status = i2c_readReg(I2C_ADDR, regAddr, &data, 1, 10); | ||
152 | } | ||
153 | if (mcp23017_status) { | ||
154 | return 0; | ||
155 | } | ||
156 | return (~data) & 0x3F; | ||
157 | } else { | ||
158 | uint8_t data_p = (GPIOB -> IDR); | ||
159 | uint8_t data = data_p; | ||
160 | return ((~data) & 0x3f); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | static void init_cols(void) { | ||
165 | palSetPadMode(GPIOB, 0, PAL_MODE_INPUT_PULLUP); | ||
166 | palSetPadMode(GPIOB, 1, PAL_MODE_INPUT_PULLUP); | ||
167 | palSetPadMode(GPIOB, 2, PAL_MODE_INPUT_PULLUP); | ||
168 | palSetPadMode(GPIOB, 3, PAL_MODE_INPUT_PULLUP); | ||
169 | palSetPadMode(GPIOB, 4, PAL_MODE_INPUT_PULLUP); | ||
170 | palSetPadMode(GPIOB, 5, PAL_MODE_INPUT_PULLUP); | ||
171 | } | ||
172 | |||
173 | static void init_rows(void) { | ||
174 | palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL); | ||
175 | palSetPadMode(GPIOB, 9, PAL_MODE_OUTPUT_PUSHPULL); | ||
176 | palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL); | ||
177 | palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL); | ||
178 | palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL); | ||
179 | palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL); | ||
180 | palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL); | ||
181 | } | ||
182 | |||
183 | static void unselect_rows(void) { | ||
184 | GPIOB->BSRR = 0b1111111 << 8; | ||
185 | } | ||
186 | |||
187 | static void select_row(uint8_t row) { | ||
188 | if (row < MATRIX_ROWS_PER_SIDE) { | ||
189 | if (!mcp23017_status) { | ||
190 | uint8_t data = (0xFF & ~(1 << row)); | ||
191 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPIOA, &data, 1, 10); | ||
192 | } | ||
193 | } else { | ||
194 | GPIOB->BRR = 0x1 << (row+1); | ||
195 | } | ||
196 | } | ||
diff --git a/keyboards/ergodox_stm32/mcuconf.h b/keyboards/ergodox_stm32/mcuconf.h new file mode 100644 index 000000000..0494526e5 --- /dev/null +++ b/keyboards/ergodox_stm32/mcuconf.h | |||
@@ -0,0 +1,209 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _MCUCONF_H_ | ||
18 | #define _MCUCONF_H_ | ||
19 | |||
20 | #define STM32F103_MCUCONF | ||
21 | |||
22 | /* | ||
23 | * STM32F103 drivers configuration. | ||
24 | * The following settings override the default settings present in | ||
25 | * the various device driver implementation headers. | ||
26 | * Note that the settings for each driver only have effect if the whole | ||
27 | * driver is enabled in halconf.h. | ||
28 | * | ||
29 | * IRQ priorities: | ||
30 | * 15...0 Lowest...Highest. | ||
31 | * | ||
32 | * DMA priorities: | ||
33 | * 0...3 Lowest...Highest. | ||
34 | */ | ||
35 | |||
36 | /* | ||
37 | * HAL driver system settings. | ||
38 | */ | ||
39 | #define STM32_NO_INIT FALSE | ||
40 | #define STM32_HSI_ENABLED TRUE | ||
41 | #define STM32_LSI_ENABLED FALSE | ||
42 | #define STM32_HSE_ENABLED TRUE | ||
43 | #define STM32_LSE_ENABLED FALSE | ||
44 | #define STM32_SW STM32_SW_PLL | ||
45 | #define STM32_PLLSRC STM32_PLLSRC_HSE | ||
46 | #define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1 | ||
47 | #define STM32_PLLMUL_VALUE 9 | ||
48 | #define STM32_HPRE STM32_HPRE_DIV1 | ||
49 | #define STM32_PPRE1 STM32_PPRE1_DIV2 | ||
50 | #define STM32_PPRE2 STM32_PPRE2_DIV2 | ||
51 | #define STM32_ADCPRE STM32_ADCPRE_DIV4 | ||
52 | #define STM32_USB_CLOCK_REQUIRED TRUE | ||
53 | #define STM32_USBPRE STM32_USBPRE_DIV1P5 | ||
54 | #define STM32_MCOSEL STM32_MCOSEL_NOCLOCK | ||
55 | #define STM32_RTCSEL STM32_RTCSEL_HSEDIV | ||
56 | #define STM32_PVD_ENABLE FALSE | ||
57 | #define STM32_PLS STM32_PLS_LEV0 | ||
58 | |||
59 | /* | ||
60 | * ADC driver system settings. | ||
61 | */ | ||
62 | #define STM32_ADC_USE_ADC1 FALSE | ||
63 | #define STM32_ADC_ADC1_DMA_PRIORITY 2 | ||
64 | #define STM32_ADC_ADC1_IRQ_PRIORITY 6 | ||
65 | |||
66 | /* | ||
67 | * CAN driver system settings. | ||
68 | */ | ||
69 | #define STM32_CAN_USE_CAN1 FALSE | ||
70 | #define STM32_CAN_CAN1_IRQ_PRIORITY 11 | ||
71 | |||
72 | /* | ||
73 | * EXT driver system settings. | ||
74 | */ | ||
75 | #define STM32_EXT_EXTI0_IRQ_PRIORITY 6 | ||
76 | #define STM32_EXT_EXTI1_IRQ_PRIORITY 6 | ||
77 | #define STM32_EXT_EXTI2_IRQ_PRIORITY 6 | ||
78 | #define STM32_EXT_EXTI3_IRQ_PRIORITY 6 | ||
79 | #define STM32_EXT_EXTI4_IRQ_PRIORITY 6 | ||
80 | #define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6 | ||
81 | #define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6 | ||
82 | #define STM32_EXT_EXTI16_IRQ_PRIORITY 6 | ||
83 | #define STM32_EXT_EXTI17_IRQ_PRIORITY 6 | ||
84 | #define STM32_EXT_EXTI18_IRQ_PRIORITY 6 | ||
85 | #define STM32_EXT_EXTI19_IRQ_PRIORITY 6 | ||
86 | |||
87 | /* | ||
88 | * GPT driver system settings. | ||
89 | */ | ||
90 | #define STM32_GPT_USE_TIM1 FALSE | ||
91 | #define STM32_GPT_USE_TIM2 FALSE | ||
92 | #define STM32_GPT_USE_TIM3 FALSE | ||
93 | #define STM32_GPT_USE_TIM4 FALSE | ||
94 | #define STM32_GPT_USE_TIM5 FALSE | ||
95 | #define STM32_GPT_USE_TIM8 FALSE | ||
96 | #define STM32_GPT_TIM1_IRQ_PRIORITY 7 | ||
97 | #define STM32_GPT_TIM2_IRQ_PRIORITY 7 | ||
98 | #define STM32_GPT_TIM3_IRQ_PRIORITY 7 | ||
99 | #define STM32_GPT_TIM4_IRQ_PRIORITY 7 | ||
100 | #define STM32_GPT_TIM5_IRQ_PRIORITY 7 | ||
101 | #define STM32_GPT_TIM8_IRQ_PRIORITY 7 | ||
102 | |||
103 | /* | ||
104 | * I2C driver system settings. | ||
105 | */ | ||
106 | #define STM32_I2C_USE_I2C1 TRUE | ||
107 | #define STM32_I2C_USE_I2C2 FALSE | ||
108 | #define STM32_I2C_BUSY_TIMEOUT 50 | ||
109 | #define STM32_I2C_I2C1_IRQ_PRIORITY 5 | ||
110 | #define STM32_I2C_I2C2_IRQ_PRIORITY 5 | ||
111 | #define STM32_I2C_I2C1_DMA_PRIORITY 3 | ||
112 | #define STM32_I2C_I2C2_DMA_PRIORITY 3 | ||
113 | #define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") | ||
114 | |||
115 | /* | ||
116 | * ICU driver system settings. | ||
117 | */ | ||
118 | #define STM32_ICU_USE_TIM1 FALSE | ||
119 | #define STM32_ICU_USE_TIM2 FALSE | ||
120 | #define STM32_ICU_USE_TIM3 FALSE | ||
121 | #define STM32_ICU_USE_TIM4 FALSE | ||
122 | #define STM32_ICU_USE_TIM5 FALSE | ||
123 | #define STM32_ICU_USE_TIM8 FALSE | ||
124 | #define STM32_ICU_TIM1_IRQ_PRIORITY 7 | ||
125 | #define STM32_ICU_TIM2_IRQ_PRIORITY 7 | ||
126 | #define STM32_ICU_TIM3_IRQ_PRIORITY 7 | ||
127 | #define STM32_ICU_TIM4_IRQ_PRIORITY 7 | ||
128 | #define STM32_ICU_TIM5_IRQ_PRIORITY 7 | ||
129 | #define STM32_ICU_TIM8_IRQ_PRIORITY 7 | ||
130 | |||
131 | /* | ||
132 | * PWM driver system settings. | ||
133 | */ | ||
134 | #define STM32_PWM_USE_ADVANCED FALSE | ||
135 | #define STM32_PWM_USE_TIM1 FALSE | ||
136 | #define STM32_PWM_USE_TIM2 FALSE | ||
137 | #define STM32_PWM_USE_TIM3 FALSE | ||
138 | #define STM32_PWM_USE_TIM4 FALSE | ||
139 | #define STM32_PWM_USE_TIM5 FALSE | ||
140 | #define STM32_PWM_USE_TIM8 FALSE | ||
141 | #define STM32_PWM_TIM1_IRQ_PRIORITY 7 | ||
142 | #define STM32_PWM_TIM2_IRQ_PRIORITY 7 | ||
143 | #define STM32_PWM_TIM3_IRQ_PRIORITY 7 | ||
144 | #define STM32_PWM_TIM4_IRQ_PRIORITY 7 | ||
145 | #define STM32_PWM_TIM5_IRQ_PRIORITY 7 | ||
146 | #define STM32_PWM_TIM8_IRQ_PRIORITY 7 | ||
147 | |||
148 | /* | ||
149 | * RTC driver system settings. | ||
150 | */ | ||
151 | #define STM32_RTC_IRQ_PRIORITY 15 | ||
152 | |||
153 | /* | ||
154 | * SERIAL driver system settings. | ||
155 | */ | ||
156 | #define STM32_SERIAL_USE_USART1 FALSE | ||
157 | #define STM32_SERIAL_USE_USART2 FALSE | ||
158 | #define STM32_SERIAL_USE_USART3 FALSE | ||
159 | #define STM32_SERIAL_USE_UART4 FALSE | ||
160 | #define STM32_SERIAL_USE_UART5 FALSE | ||
161 | #define STM32_SERIAL_USART1_PRIORITY 12 | ||
162 | #define STM32_SERIAL_USART2_PRIORITY 12 | ||
163 | #define STM32_SERIAL_USART3_PRIORITY 12 | ||
164 | #define STM32_SERIAL_UART4_PRIORITY 12 | ||
165 | #define STM32_SERIAL_UART5_PRIORITY 12 | ||
166 | |||
167 | /* | ||
168 | * SPI driver system settings. | ||
169 | */ | ||
170 | #define STM32_SPI_USE_SPI1 FALSE | ||
171 | #define STM32_SPI_USE_SPI2 FALSE | ||
172 | #define STM32_SPI_USE_SPI3 FALSE | ||
173 | #define STM32_SPI_SPI1_DMA_PRIORITY 1 | ||
174 | #define STM32_SPI_SPI2_DMA_PRIORITY 1 | ||
175 | #define STM32_SPI_SPI3_DMA_PRIORITY 1 | ||
176 | #define STM32_SPI_SPI1_IRQ_PRIORITY 10 | ||
177 | #define STM32_SPI_SPI2_IRQ_PRIORITY 10 | ||
178 | #define STM32_SPI_SPI3_IRQ_PRIORITY 10 | ||
179 | #define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") | ||
180 | |||
181 | /* | ||
182 | * ST driver system settings. | ||
183 | */ | ||
184 | #define STM32_ST_IRQ_PRIORITY 8 | ||
185 | #define STM32_ST_USE_TIMER 2 | ||
186 | |||
187 | /* | ||
188 | * UART driver system settings. | ||
189 | */ | ||
190 | #define STM32_UART_USE_USART1 FALSE | ||
191 | #define STM32_UART_USE_USART2 FALSE | ||
192 | #define STM32_UART_USE_USART3 FALSE | ||
193 | #define STM32_UART_USART1_IRQ_PRIORITY 12 | ||
194 | #define STM32_UART_USART2_IRQ_PRIORITY 12 | ||
195 | #define STM32_UART_USART3_IRQ_PRIORITY 12 | ||
196 | #define STM32_UART_USART1_DMA_PRIORITY 0 | ||
197 | #define STM32_UART_USART2_DMA_PRIORITY 0 | ||
198 | #define STM32_UART_USART3_DMA_PRIORITY 0 | ||
199 | #define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") | ||
200 | |||
201 | /* | ||
202 | * USB driver system settings. | ||
203 | */ | ||
204 | #define STM32_USB_USE_USB1 TRUE | ||
205 | #define STM32_USB_LOW_POWER_ON_SUSPEND FALSE | ||
206 | #define STM32_USB_USB1_HP_IRQ_PRIORITY 13 | ||
207 | #define STM32_USB_USB1_LP_IRQ_PRIORITY 14 | ||
208 | |||
209 | #endif /* _MCUCONF_H_ */ | ||
diff --git a/keyboards/ergodox_stm32/rules.mk b/keyboards/ergodox_stm32/rules.mk new file mode 100644 index 000000000..1bf1a742a --- /dev/null +++ b/keyboards/ergodox_stm32/rules.mk | |||
@@ -0,0 +1,32 @@ | |||
1 | SRC += matrix.c | ||
2 | QUANTUM_LIB_SRC += i2c_master.c | ||
3 | |||
4 | CFLAGS += "-Wno-error=deprecated" | ||
5 | |||
6 | MCU_FAMILY = STM32 | ||
7 | MCU_SERIES = STM32F1xx | ||
8 | |||
9 | MCU_LDSCRIPT = stm32f103_bootloader | ||
10 | |||
11 | MCU_STARTUP = stm32f1xx | ||
12 | |||
13 | BOARD = ERGODOX_STM32_BOARD | ||
14 | |||
15 | MCU = cortex-m3 | ||
16 | |||
17 | ARMV = 7 | ||
18 | |||
19 | OPT_DEFS = | ||
20 | |||
21 | EXTRAFLAGS=-O0 -g | ||
22 | |||
23 | BOOTMAGIC_ENABLE = no | ||
24 | MOUSEKEY_ENABLE = no # Mouse keys | ||
25 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
26 | CONSOLE_ENABLE = no # Console for debug | ||
27 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
28 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
29 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
30 | CUSTOM_MATRIX = yes # Custom matrix file | ||
31 | NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
32 | UNICODE_ENABLE = yes # Unicode | ||