From: tmk Date: Mon, 15 Oct 2018 15:40:14 +0000 (+0900) Subject: core: Update console startup for hid_listen X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=00f5ed3210e1241da04b7c6970bb53ce912cf3f4;p=max%2Ftmk_keyboard.git core: Update console startup for hid_listen --- diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index b1567fa9..a709d1f1 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -50,6 +50,7 @@ #endif #include "suspend.h" #include "hook.h" +#include "timer.h" #ifdef LUFA_DEBUG_SUART #include "avr/suart.h" @@ -99,14 +100,31 @@ static ringbuf_t sendbuf = { .size_mask = SENDBUF_SIZE - 1 }; +// TODO: Around 2500ms delay often works anyhoo but proper startup would be better +// 1000ms delay of hid_listen affects this probably +/* wait for Console startup */ +static bool console_is_ready(void) +{ + static bool hid_listen_ready = false; + if (!hid_listen_ready) { + if (timer_read32() < 2500) + return false; + hid_listen_ready = true; + } + return true; +} + static bool console_putc(uint8_t c) { + if (!console_is_ready()) + goto EXIT; + // return immediately if called while interrupt if (!(SREG & (1<