X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fprotocol%2Flufa%2Flufa.c;h=48034dbeab18ef9af9a668db43d740406be9e6c2;hb=993a9b02f77eda8b06cf096f345ad3f35fafc7ba;hp=4dce8adc9993822cd3ccf7627bf5b44338218871;hpb=ffb52ab0c98540f6305a7c1d82b50c8d6611a727;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 4dce8adc..48034dbe 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<