From b6cc5394b86ddc8ada190778032604257bedbf1b Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 11 Sep 2018 01:11:06 +0900 Subject: [PATCH] xt_usb: Change ring buffer and control Data line --- tmk_core/protocol/xt_interrupt.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tmk_core/protocol/xt_interrupt.c b/tmk_core/protocol/xt_interrupt.c index a0c55e9c..ebaa436b 100644 --- a/tmk_core/protocol/xt_interrupt.c +++ b/tmk_core/protocol/xt_interrupt.c @@ -39,10 +39,20 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "pbuff.h" #include "xt.h" #include "wait.h" #include "print.h" +#include "ringbuf.h" + + +#define BUF_SIZE 16 +static uint8_t buf[BUF_SIZE]; +static ringbuf_t rb = { + .buffer = buf, + .head = 0, + .tail = 0, + .size_mask = BUF_SIZE - 1 +}; void xt_host_init(void) { @@ -69,10 +79,12 @@ void xt_host_init(void) /* get data received by interrupt */ uint8_t xt_host_recv(void) { - if (pbuf_has_data()) { - return pbuf_dequeue(); - } else { + if (ringbuf_is_empty(&rb)) { return 0; + } else { + int16_t d = ringbuf_get(&rb); + XT_DATA_IN(); // ready to receive from keyboard + return d; } } @@ -111,7 +123,11 @@ ISR(XT_INT_VECT) break; } if (state++ == BIT7) { - pbuf_enqueue(data); + ringbuf_put(&rb, data); + if (ringbuf_is_full(&rb)) { + XT_DATA_LO(); // inhibit keyboard sending + print("Full"); + } state = START; data = 0; } -- 2.44.0