summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/chibios/main.c
diff options
context:
space:
mode:
authorChristopher Browne <cbbrowne@ca.afilias.info>2016-07-07 17:13:22 +0200
committerChristopher Browne <cbbrowne@ca.afilias.info>2016-07-07 17:13:22 +0200
commit97dfbd1afce005392aa8f067e89bdf95334bdea5 (patch)
tree1b198dd239bcb49564c31f124978abde0b467a81 /tmk_core/protocol/chibios/main.c
parent2e1cfaf73fccdfaba2d7542f00bd7c3d49998d5d (diff)
parentad43d450ca1b988d196da80e2a745f45f24068f6 (diff)
downloadqmk_firmware-97dfbd1afce005392aa8f067e89bdf95334bdea5.tar.gz
qmk_firmware-97dfbd1afce005392aa8f067e89bdf95334bdea5.tar.xz
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'tmk_core/protocol/chibios/main.c')
-rw-r--r--tmk_core/protocol/chibios/main.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index 54bb6a8f5..b0eb9aef8 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -35,6 +35,12 @@
#ifdef SLEEP_LED_ENABLE
#include "sleep_led.h"
#endif
+#ifdef SERIAL_LINK_ENABLE
+#include "serial_link/system/serial_link.h"
+#endif
+#ifdef VISUALIZER_ENABLE
+#include "visualizer/visualizer.h"
+#endif
#include "suspend.h"
@@ -98,9 +104,32 @@ int main(void) {
/* init printf */
init_printf(NULL,sendchar_pf);
- /* Wait until the USB is active */
- while(USB_DRIVER.state != USB_ACTIVE)
+#ifdef SERIAL_LINK_ENABLE
+ init_serial_link();
+#endif
+
+#ifdef VISUALIZER_ENABLE
+ visualizer_init();
+#endif
+
+
+ host_driver_t* driver = NULL;
+
+ /* Wait until the USB or serial link is active */
+ while (true) {
+ if(USB_DRIVER.state == USB_ACTIVE) {
+ driver = &chibios_driver;
+ break;
+ }
+#ifdef SERIAL_LINK_ENABLE
+ if(is_serial_link_connected()) {
+ driver = get_serial_link_driver();
+ break;
+ }
+ serial_link_update();
+#endif
chThdSleepMilliseconds(50);
+ }
/* Do need to wait here!
* Otherwise the next print might start a transfer on console EP
@@ -113,7 +142,7 @@ int main(void) {
/* init TMK modules */
keyboard_init();
- host_set_driver(&chibios_driver);
+ host_set_driver(driver);
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
@@ -126,8 +155,14 @@ int main(void) {
if(USB_DRIVER.state == USB_SUSPENDED) {
print("[s]");
+#ifdef VISUALIZER_ENABLE
+ visualizer_suspend();
+#endif
while(USB_DRIVER.state == USB_SUSPENDED) {
/* Do this in the suspended state */
+#ifdef SERIAL_LINK_ENABLE
+ serial_link_update();
+#endif
suspend_power_down(); // on AVR this deep sleeps for 15ms
/* Remote wakeup */
if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
@@ -140,6 +175,10 @@ int main(void) {
#ifdef MOUSEKEY_ENABLE
mousekey_send();
#endif /* MOUSEKEY_ENABLE */
+
+#ifdef VISUALIZER_ENABLE
+ visualizer_resume();
+#endif
}
keyboard_task();