From: tmk Date: Mon, 10 Sep 2018 00:05:21 +0000 (+0900) Subject: core: lufa: Fix console output and init sequence X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=ffb52ab0c98540f6305a7c1d82b50c8d6611a727;p=max%2Ftmk_keyboard.git core: lufa: Fix console output and init sequence console_putc: Linux: works very well in general Windows: also works very well and connection seems to be faster than Linux Mac: to be: confirmed NOTE: long session of matrix_print still blocks keyboard_task in main loop and prevents it from sending keyboard report. XT protocol buffer overflow occurs when slamng on keys TODO: check when print functions are called in ISR --- diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 60849aea..4dce8adc 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -43,6 +43,7 @@ #include "action.h" #include "led.h" #include "sendchar.h" +#include "ringbuf.h" #include "debug.h" #ifdef SLEEP_LED_ENABLE #include "sleep_led.h" @@ -89,60 +90,97 @@ host_driver_t lufa_driver = { * Console ******************************************************************************/ #ifdef CONSOLE_ENABLE -static void Console_Task(void) +#define SENDBUF_SIZE 256 +static uint8_t sbuf[SENDBUF_SIZE]; +static ringbuf_t sendbuf = { + .buffer = sbuf, + .head = 0, + .tail = 0, + .size_mask = SENDBUF_SIZE - 1 +}; + +static bool console_putc(uint8_t c) { - /* Device must be connected and configured for the task to run */ + // return immediately if called while interrupt + if (!(SREG & (1<