diff options
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r-- | tmk_core/protocol/chibios/main.c | 32 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 21 |
2 files changed, 31 insertions, 22 deletions
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 | |||
42 | uint8_t keyboard_idle __attribute__((aligned(2))) = 0; | 51 | uint8_t keyboard_idle __attribute__((aligned(2))) = 0; |
43 | uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; | 52 | uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; |
44 | uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; | 53 | uint16_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 | /* --------------------------------------------------------- |