X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fprotocol%2Flufa%2Flufa.c;h=32bc698109b577537ca14f1c144b99232ee2ccef;hb=45e45691e0c03f1b5ea4341c6d90f9a09016a37d;hp=b1567fa9bdac242dfbe9a12395c7db8212177748;hpb=e3d7b50f63dfc71b5488928093f2d641589518b0;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index b1567fa9..32bc6981 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -50,11 +50,16 @@ #endif #include "suspend.h" #include "hook.h" +#include "timer.h" #ifdef LUFA_DEBUG_SUART #include "avr/suart.h" #endif +#ifdef LUFA_DEBUG_UART +#include "uart.h" +#endif + #include "matrix.h" #include "descriptor.h" #include "lufa.h" @@ -99,14 +104,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<