diff options
author | Christopher Browne <cbbrowne@ca.afilias.info> | 2016-07-07 11:13:22 -0400 |
---|---|---|
committer | Christopher Browne <cbbrowne@ca.afilias.info> | 2016-07-07 11:13:22 -0400 |
commit | 97dfbd1afce005392aa8f067e89bdf95334bdea5 (patch) | |
tree | 1b198dd239bcb49564c31f124978abde0b467a81 /tmk_core/protocol/chibios | |
parent | 2e1cfaf73fccdfaba2d7542f00bd7c3d49998d5d (diff) | |
parent | ad43d450ca1b988d196da80e2a745f45f24068f6 (diff) |
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r-- | tmk_core/protocol/chibios/main.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 54bb6a8f55..b0eb9aef81 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(); |