diff options
author | Jack Humbert <jack.humb@gmail.com> | 2016-07-06 09:48:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 09:48:58 -0400 |
commit | 19f480992c015aec0a15dca43e740bad8b7834e6 (patch) | |
tree | 2d1470d076017af6d089a00f4bb317abdb331346 | |
parent | c6d671e54c249497b5c01ad9badaa50425f394f9 (diff) | |
parent | e5726b017a9de2922ea923818c6e215600f68a85 (diff) | |
download | qmk_firmware-19f480992c015aec0a15dca43e740bad8b7834e6.tar.gz qmk_firmware-19f480992c015aec0a15dca43e740bad8b7834e6.zip |
Merge pull request #487 from fredizzimo/serial_link_ergodox
Integrate serial link support for ChibiOS and Infinity Ergodox
-rw-r--r-- | Makefile | 26 | ||||
-rw-r--r-- | keyboards/infinity_ergodox/Makefile | 1 | ||||
-rw-r--r-- | keyboards/infinity_ergodox/infinity_ergodox.c | 10 | ||||
-rw-r--r-- | tmk_core/common.mk | 9 | ||||
-rw-r--r-- | tmk_core/common/keyboard.c | 11 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/main.c | 30 |
6 files changed, 81 insertions, 6 deletions
@@ -59,6 +59,12 @@ ifndef KEYBOARD | |||
59 | KEYBOARD=planck | 59 | KEYBOARD=planck |
60 | endif | 60 | endif |
61 | 61 | ||
62 | MASTER ?= left | ||
63 | ifdef master | ||
64 | MASTER = $(master) | ||
65 | endif | ||
66 | |||
67 | |||
62 | # converts things to keyboards/subproject | 68 | # converts things to keyboards/subproject |
63 | ifneq (,$(findstring /,$(KEYBOARD))) | 69 | ifneq (,$(findstring /,$(KEYBOARD))) |
64 | TEMP:=$(KEYBOARD) | 70 | TEMP:=$(KEYBOARD) |
@@ -198,10 +204,28 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | |||
198 | endif | 204 | endif |
199 | 205 | ||
200 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | 206 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) |
201 | OPT_DEFS += -DTAP_DANCE_ENABLE | 207 | OPT_DEFS += -DTAP_DANCE_ENABLE |
202 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c | 208 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c |
203 | endif | 209 | endif |
204 | 210 | ||
211 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) | ||
212 | SERIAL_DIR = $(QUANTUM_DIR)/serial_link | ||
213 | SERIAL_PATH = $(QUANTUM_PATH)/serial_link | ||
214 | SERIAL_SRC = $(wildcard $(SERIAL_PATH)/protocol/*.c) | ||
215 | SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) | ||
216 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) | ||
217 | OPT_DEFS += -DSERIAL_LINK_ENABLE | ||
218 | VAPTH += $(SERIAL_PATH) | ||
219 | endif | ||
220 | |||
221 | ifeq ($(MASTER),right) | ||
222 | OPT_DEFS += -DMASTER_IS_ON_RIGHT | ||
223 | else | ||
224 | ifneq ($(MASTER),left) | ||
225 | $(error MASTER does not have a valid value(left/right)) | ||
226 | endif | ||
227 | endif | ||
228 | |||
205 | # Optimize size but this may cause error "relocation truncated to fit" | 229 | # Optimize size but this may cause error "relocation truncated to fit" |
206 | #EXTRALDFLAGS = -Wl,--relax | 230 | #EXTRALDFLAGS = -Wl,--relax |
207 | 231 | ||
diff --git a/keyboards/infinity_ergodox/Makefile b/keyboards/infinity_ergodox/Makefile index fb21aae5e..efa32e037 100644 --- a/keyboards/infinity_ergodox/Makefile +++ b/keyboards/infinity_ergodox/Makefile | |||
@@ -66,6 +66,7 @@ COMMAND_ENABLE ?= yes # Commands for debug and configuration | |||
66 | SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend | 66 | SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend |
67 | NKRO_ENABLE ?= yes # USB Nkey Rollover | 67 | NKRO_ENABLE ?= yes # USB Nkey Rollover |
68 | CUSTOM_MATRIX ?= yes # Custom matrix file | 68 | CUSTOM_MATRIX ?= yes # Custom matrix file |
69 | SERIAL_LINK_ENABLE = yes | ||
69 | 70 | ||
70 | ifndef QUANTUM_DIR | 71 | ifndef QUANTUM_DIR |
71 | include ../../Makefile | 72 | include ../../Makefile |
diff --git a/keyboards/infinity_ergodox/infinity_ergodox.c b/keyboards/infinity_ergodox/infinity_ergodox.c index 34aded1a7..85054775e 100644 --- a/keyboards/infinity_ergodox/infinity_ergodox.c +++ b/keyboards/infinity_ergodox/infinity_ergodox.c | |||
@@ -1 +1,11 @@ | |||
1 | #include "infinity_ergodox.h" | 1 | #include "infinity_ergodox.h" |
2 | #include "ch.h" | ||
3 | #include "hal.h" | ||
4 | #include "serial_link/system/serial_link.h" | ||
5 | |||
6 | void init_serial_link_hal(void) { | ||
7 | PORTA->PCR[1] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(2); | ||
8 | PORTA->PCR[2] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(2); | ||
9 | PORTE->PCR[0] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(3); | ||
10 | PORTE->PCR[1] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(3); | ||
11 | } | ||
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index d71fba9bc..5bae0d762 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
@@ -97,6 +97,15 @@ ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes) | |||
97 | endif | 97 | endif |
98 | endif | 98 | endif |
99 | 99 | ||
100 | ifeq ($(MASTER),right) | ||
101 | OPT_DEFS += -DMASTER_IS_ON_RIGHT | ||
102 | else | ||
103 | ifneq ($(MASTER),left) | ||
104 | $(error MASTER does not have a valid value(left/right)) | ||
105 | endif | ||
106 | endif | ||
107 | |||
108 | |||
100 | # Version string | 109 | # Version string |
101 | OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) | 110 | OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) |
102 | 111 | ||
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 81df8eb73..3a1262a9f 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
@@ -49,6 +49,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
49 | #ifdef RGBLIGHT_ENABLE | 49 | #ifdef RGBLIGHT_ENABLE |
50 | # include "rgblight.h" | 50 | # include "rgblight.h" |
51 | #endif | 51 | #endif |
52 | #ifdef SERIAL_LINK_ENABLE | ||
53 | # include "serial_link/system/serial_link.h" | ||
54 | #endif | ||
52 | 55 | ||
53 | #ifdef MATRIX_HAS_GHOST | 56 | #ifdef MATRIX_HAS_GHOST |
54 | static bool has_ghost_in_row(uint8_t row) | 57 | static bool has_ghost_in_row(uint8_t row) |
@@ -167,11 +170,15 @@ MATRIX_LOOP_END: | |||
167 | #endif | 170 | #endif |
168 | 171 | ||
169 | #ifdef SERIAL_MOUSE_ENABLE | 172 | #ifdef SERIAL_MOUSE_ENABLE |
170 | serial_mouse_task(); | 173 | serial_mouse_task(); |
171 | #endif | 174 | #endif |
172 | 175 | ||
173 | #ifdef ADB_MOUSE_ENABLE | 176 | #ifdef ADB_MOUSE_ENABLE |
174 | adb_mouse_task(); | 177 | adb_mouse_task(); |
178 | #endif | ||
179 | |||
180 | #ifdef SERIAL_LINK_ENABLE | ||
181 | serial_link_update(); | ||
175 | #endif | 182 | #endif |
176 | 183 | ||
177 | // update LED | 184 | // update LED |
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 54bb6a8f5..aeb11752f 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #ifdef SLEEP_LED_ENABLE | 35 | #ifdef SLEEP_LED_ENABLE |
36 | #include "sleep_led.h" | 36 | #include "sleep_led.h" |
37 | #endif | 37 | #endif |
38 | #ifdef SERIAL_LINK_ENABLE | ||
39 | #include "serial_link/system/serial_link.h" | ||
40 | #endif | ||
38 | #include "suspend.h" | 41 | #include "suspend.h" |
39 | 42 | ||
40 | 43 | ||
@@ -98,9 +101,27 @@ int main(void) { | |||
98 | /* init printf */ | 101 | /* init printf */ |
99 | init_printf(NULL,sendchar_pf); | 102 | init_printf(NULL,sendchar_pf); |
100 | 103 | ||
101 | /* Wait until the USB is active */ | 104 | #ifdef SERIAL_LINK_ENABLE |
102 | while(USB_DRIVER.state != USB_ACTIVE) | 105 | init_serial_link(); |
106 | #endif | ||
107 | |||
108 | host_driver_t* driver = NULL; | ||
109 | |||
110 | /* Wait until the USB or serial link is active */ | ||
111 | while (true) { | ||
112 | if(USB_DRIVER.state == USB_ACTIVE) { | ||
113 | driver = &chibios_driver; | ||
114 | break; | ||
115 | } | ||
116 | #ifdef SERIAL_LINK_ENABLE | ||
117 | if(is_serial_link_connected()) { | ||
118 | driver = get_serial_link_driver(); | ||
119 | break; | ||
120 | } | ||
121 | serial_link_update(); | ||
122 | #endif | ||
103 | chThdSleepMilliseconds(50); | 123 | chThdSleepMilliseconds(50); |
124 | } | ||
104 | 125 | ||
105 | /* Do need to wait here! | 126 | /* Do need to wait here! |
106 | * Otherwise the next print might start a transfer on console EP | 127 | * Otherwise the next print might start a transfer on console EP |
@@ -113,7 +134,7 @@ int main(void) { | |||
113 | 134 | ||
114 | /* init TMK modules */ | 135 | /* init TMK modules */ |
115 | keyboard_init(); | 136 | keyboard_init(); |
116 | host_set_driver(&chibios_driver); | 137 | host_set_driver(driver); |
117 | 138 | ||
118 | #ifdef SLEEP_LED_ENABLE | 139 | #ifdef SLEEP_LED_ENABLE |
119 | sleep_led_init(); | 140 | sleep_led_init(); |
@@ -128,6 +149,9 @@ int main(void) { | |||
128 | print("[s]"); | 149 | print("[s]"); |
129 | while(USB_DRIVER.state == USB_SUSPENDED) { | 150 | while(USB_DRIVER.state == USB_SUSPENDED) { |
130 | /* Do this in the suspended state */ | 151 | /* Do this in the suspended state */ |
152 | #ifdef SERIAL_LINK_ENABLE | ||
153 | serial_link_update(); | ||
154 | #endif | ||
131 | suspend_power_down(); // on AVR this deep sleeps for 15ms | 155 | suspend_power_down(); // on AVR this deep sleeps for 15ms |
132 | /* Remote wakeup */ | 156 | /* Remote wakeup */ |
133 | if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) { | 157 | if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) { |