aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorskullydazed <skullydazed@users.noreply.github.com>2017-09-29 16:17:30 -0700
committerGitHub <noreply@github.com>2017-09-29 16:17:30 -0700
commit5fd68266f5d90b2c7045f44f678d71b782907752 (patch)
tree443e70a3f0dcebadd39a0c96857130546cc690a7 /tmk_core
parentb736f25e85171fceb06f01cf45a45f84dd0a4911 (diff)
downloadqmk_firmware-5fd68266f5d90b2c7045f44f678d71b782907752.tar.gz
qmk_firmware-5fd68266f5d90b2c7045f44f678d71b782907752.zip
Clueboard 60% support (#1746)
* initial clueboard_60 support * LED lighting support * fix the clueboard->clueboard_66 rename * Add layout support to clueboard_60 * Fix the 60_iso layout so it's actually iso * add a default keymap for AEK layout * fix clueboard_17 * Fixup the ISO layouts * Fix the `wait_ms()/wait_us()` definitions for chibios * Fix up the wait_ms/wait_us hack. Reduce stack size. * Add a missing #include "wait.h" * commit files that should have already been comitted
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/chibios.mk4
-rw-r--r--tmk_core/common/chibios/bootloader.c18
-rw-r--r--tmk_core/common/chibios/suspend.c5
-rw-r--r--tmk_core/common/wait.h11
-rw-r--r--tmk_core/protocol/chibios/main.c32
-rw-r--r--tmk_core/protocol/chibios/usb_main.c21
-rw-r--r--tmk_core/rules.mk2
7 files changed, 61 insertions, 32 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 61e0a847d..c938eaeb9 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -143,7 +143,7 @@ MCUFLAGS = -mcpu=$(MCU)
143 143
144DEBUG = gdb 144DEBUG = gdb
145 145
146DFU_ARGS = 146DFU_ARGS ?=
147ifneq ("$(SERIAL)","") 147ifneq ("$(SERIAL)","")
148 DFU_ARGS += -S $(SERIAL) 148 DFU_ARGS += -S $(SERIAL)
149endif 149endif
@@ -157,4 +157,4 @@ dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter
157 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin 157 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
158 158
159bin: $(BUILD_DIR)/$(TARGET).bin sizeafter 159bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
160 $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; \ No newline at end of file 160 $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 8a533ab6f..fc17fca1b 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -16,6 +16,19 @@ void bootloader_jump(void) {
16 NVIC_SystemReset(); 16 NVIC_SystemReset();
17} 17}
18 18
19#elif defined(STM32F3XX)
20/* This code should be checked whether it runs correctly on platforms.
21 * It was added for clueboard60 BUT HAS NOT BEEN TESTED.
22 * FIXME - Test this
23 */
24#define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
25extern uint32_t __ram0_end__;
26
27void bootloader_jump(void) {
28 *((unsigned long *)(SYMVAL(__ram0_end__) - 4)) = 0xDEADBEEF; // set magic flag => reset handler will jump into boot loader
29 NVIC_SystemReset();
30}
31
19#else /* defined(STM32F0XX) */ 32#else /* defined(STM32F0XX) */
20#error Check that the bootloader code works on your platform and add it to bootloader.c! 33#error Check that the bootloader code works on your platform and add it to bootloader.c!
21#endif /* defined(STM32F0XX) */ 34#endif /* defined(STM32F0XX) */
@@ -35,8 +48,9 @@ void bootloader_jump(void) {
35 48
36#else /* defined(KIIBOHD_BOOTLOADER) */ 49#else /* defined(KIIBOHD_BOOTLOADER) */
37/* Default for Kinetis - expecting an ARM Teensy */ 50/* Default for Kinetis - expecting an ARM Teensy */
51#include "wait.h"
38void bootloader_jump(void) { 52void bootloader_jump(void) {
39 chThdSleepMilliseconds(100); 53 wait_ms(100);
40 __BKPT(0); 54 __BKPT(0);
41} 55}
42#endif /* defined(KIIBOHD_BOOTLOADER) */ 56#endif /* defined(KIIBOHD_BOOTLOADER) */
@@ -44,4 +58,4 @@ void bootloader_jump(void) {
44#else /* neither STM32 nor KINETIS */ 58#else /* neither STM32 nor KINETIS */
45__attribute__((weak)) 59__attribute__((weak))
46void bootloader_jump(void) {} 60void bootloader_jump(void) {}
47#endif \ No newline at end of file 61#endif
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 6ca16034f..7c3c75387 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -10,10 +10,11 @@
10#include "host.h" 10#include "host.h"
11#include "backlight.h" 11#include "backlight.h"
12#include "suspend.h" 12#include "suspend.h"
13#include "wait.h"
13 14
14void suspend_idle(uint8_t time) { 15void suspend_idle(uint8_t time) {
15 // TODO: this is not used anywhere - what units is 'time' in? 16 // TODO: this is not used anywhere - what units is 'time' in?
16 chThdSleepMilliseconds(time); 17 wait_ms(time);
17} 18}
18 19
19void suspend_power_down(void) { 20void suspend_power_down(void) {
@@ -24,7 +25,7 @@ void suspend_power_down(void) {
24 // on AVR, this enables the watchdog for 15ms (max), and goes to 25 // on AVR, this enables the watchdog for 15ms (max), and goes to
25 // SLEEP_MODE_PWR_DOWN 26 // SLEEP_MODE_PWR_DOWN
26 27
27 chThdSleepMilliseconds(17); 28 wait_ms(17);
28} 29}
29 30
30__attribute__ ((weak)) void matrix_power_up(void) {} 31__attribute__ ((weak)) void matrix_power_up(void) {}
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h
index bdcb3f2a4..553f5243f 100644
--- a/tmk_core/common/wait.h
+++ b/tmk_core/common/wait.h
@@ -11,10 +11,15 @@ extern "C" {
11# include <util/delay.h> 11# include <util/delay.h>
12# define wait_ms(ms) _delay_ms(ms) 12# define wait_ms(ms) _delay_ms(ms)
13# define wait_us(us) _delay_us(us) 13# define wait_us(us) _delay_us(us)
14#elif defined(PROTOCOL_CHIBIOS) 14#elif defined PROTOCOL_CHIBIOS
15# include "ch.h" 15# include "ch.h"
16# define wait_ms(ms) chThdSleepMilliseconds(ms) 16# if defined(STM32F3xx_MCUCONF)
17# define wait_us(us) chThdSleepMicroseconds(us) 17# define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_HCLK, (ms)))
18# define wait_us(us) chSysPolledDelayX(US2RTC(STM32_HCLK, (us)))
19# else
20# define wait_ms(ms) chThdSleepMilliseconds(ms)
21# define wait_us(us) chThdSleepMicroseconds(us)
22# endif
18#elif defined(__arm__) 23#elif defined(__arm__)
19# include "wait_api.h" 24# include "wait_api.h"
20#else // Unit tests 25#else // Unit tests
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index b0eb9aef8..7138b5535 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -42,7 +42,7 @@
42#include "visualizer/visualizer.h" 42#include "visualizer/visualizer.h"
43#endif 43#endif
44#include "suspend.h" 44#include "suspend.h"
45 45#include "wait.h"
46 46
47/* ------------------------- 47/* -------------------------
48 * TMK host driver defs 48 * TMK host driver defs
@@ -70,19 +70,19 @@ host_driver_t chibios_driver = {
70 * Amber LED blinker thread, times are in milliseconds. 70 * Amber LED blinker thread, times are in milliseconds.
71 */ 71 */
72/* set this variable to non-zero anywhere to blink once */ 72/* set this variable to non-zero anywhere to blink once */
73// uint8_t blinkLed = 0; 73// static THD_WORKING_AREA(waThread1, 128);
74// static THD_WORKING_AREA(waBlinkerThread, 128); 74// static THD_FUNCTION(Thread1, arg) {
75// static THD_FUNCTION(blinkerThread, arg) { 75
76// (void)arg; 76// (void)arg;
77// chRegSetThreadName("blinkOrange"); 77// chRegSetThreadName("blinker");
78// while(true) { 78// while (true) {
79// if(blinkLed) { 79// systime_t time;
80// blinkLed = 0; 80
81// palSetPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13); 81// time = USB_DRIVER.state == USB_ACTIVE ? 250 : 500;
82// chThdSleepMilliseconds(100); 82// palClearLine(LINE_CAPS_LOCK);
83// palClearPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13); 83// chSysPolledDelayX(MS2RTC(STM32_HCLK, time));
84// } 84// palSetLine(LINE_CAPS_LOCK);
85// chThdSleepMilliseconds(100); 85// chSysPolledDelayX(MS2RTC(STM32_HCLK, time));
86// } 86// }
87// } 87// }
88 88
@@ -96,7 +96,7 @@ int main(void) {
96 chSysInit(); 96 chSysInit();
97 97
98 // TESTING 98 // TESTING
99 // chThdCreateStatic(waBlinkerThread, sizeof(waBlinkerThread), NORMALPRIO, blinkerThread, NULL); 99 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
100 100
101 /* Init USB */ 101 /* Init USB */
102 init_usb_driver(&USB_DRIVER); 102 init_usb_driver(&USB_DRIVER);
@@ -128,7 +128,7 @@ int main(void) {
128 } 128 }
129 serial_link_update(); 129 serial_link_update();
130#endif 130#endif
131 chThdSleepMilliseconds(50); 131 wait_ms(50);
132 } 132 }
133 133
134 /* Do need to wait here! 134 /* Do need to wait here!
@@ -136,7 +136,7 @@ int main(void) {
136 * before the USB is completely ready, which sometimes causes 136 * before the USB is completely ready, which sometimes causes
137 * HardFaults. 137 * HardFaults.
138 */ 138 */
139 chThdSleepMilliseconds(50); 139 wait_ms(50);
140 140
141 print("USB configured.\n"); 141 print("USB configured.\n");
142 142
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index d0c72c46c..59edab9bd 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -27,6 +27,7 @@
27#include "sleep_led.h" 27#include "sleep_led.h"
28#include "led.h" 28#include "led.h"
29#endif 29#endif
30#include "wait.h"
30 31
31#ifdef NKRO_ENABLE 32#ifdef NKRO_ENABLE
32 #include "keycode_config.h" 33 #include "keycode_config.h"
@@ -39,6 +40,14 @@
39 * --------------------------------------------------------- 40 * ---------------------------------------------------------
40 */ 41 */
41 42
43#ifndef usb_lld_connect_bus
44 #define usb_lld_connect_bus(usbp)
45#endif
46
47#ifndef usb_lld_disconnect_bus
48 #define usb_lld_disconnect_bus(usbp)
49#endif
50
42uint8_t keyboard_idle __attribute__((aligned(2))) = 0; 51uint8_t keyboard_idle __attribute__((aligned(2))) = 0;
43uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; 52uint8_t keyboard_protocol __attribute__((aligned(2))) = 1;
44uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; 53uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0;
@@ -1017,7 +1026,7 @@ void init_usb_driver(USBDriver *usbp) {
1017 * after a reset. 1026 * after a reset.
1018 */ 1027 */
1019 usbDisconnectBus(usbp); 1028 usbDisconnectBus(usbp);
1020 chThdSleepMilliseconds(1500); 1029 wait_ms(1500);
1021 usbStart(usbp, &usbcfg); 1030 usbStart(usbp, &usbcfg);
1022 usbConnectBus(usbp); 1031 usbConnectBus(usbp);
1023 1032
@@ -1037,16 +1046,16 @@ void send_remote_wakeup(USBDriver *usbp) {
1037#if defined(K20x) || defined(KL2x) 1046#if defined(K20x) || defined(KL2x)
1038#if KINETIS_USB_USE_USB0 1047#if KINETIS_USB_USE_USB0
1039 USB0->CTL |= USBx_CTL_RESUME; 1048 USB0->CTL |= USBx_CTL_RESUME;
1040 chThdSleepMilliseconds(15); 1049 wait_ms(15);
1041 USB0->CTL &= ~USBx_CTL_RESUME; 1050 USB0->CTL &= ~USBx_CTL_RESUME;
1042#endif /* KINETIS_USB_USE_USB0 */ 1051#endif /* KINETIS_USB_USE_USB0 */
1043#elif defined(STM32F0XX) || defined(STM32F1XX) /* K20x || KL2x */ 1052#elif defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) /* End K20x || KL2x */
1044 STM32_USB->CNTR |= CNTR_RESUME; 1053 STM32_USB->CNTR |= CNTR_RESUME;
1045 chThdSleepMilliseconds(15); 1054 wait_ms(15);
1046 STM32_USB->CNTR &= ~CNTR_RESUME; 1055 STM32_USB->CNTR &= ~CNTR_RESUME;
1047#else /* STM32F0XX || STM32F1XX */ 1056#else /* End STM32F0XX || STM32F1XX || STM32F3XX */
1048#warning Sending remote wakeup packet not implemented for your platform. 1057#warning Sending remote wakeup packet not implemented for your platform.
1049#endif /* K20x || KL2x */ 1058#endif
1050} 1059}
1051 1060
1052/* --------------------------------------------------------- 1061/* ---------------------------------------------------------
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index aef4d5e55..73ffeaac1 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -385,4 +385,4 @@ $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null)))
385.PHONY : all finish sizebefore sizeafter qmkversion \ 385.PHONY : all finish sizebefore sizeafter qmkversion \
386gccversion build elf hex eep lss sym coff extcoff \ 386gccversion build elf hex eep lss sym coff extcoff \
387clean clean_list debug gdb-config show_path \ 387clean clean_list debug gdb-config show_path \
388program teensy dfu flip dfu-ee flip-ee dfu-start \ No newline at end of file 388program teensy dfu flip dfu-ee flip-ee dfu-start