From ea004061a55033aa5e940c31e34bcdcf4dc0fed3 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 2 Mar 2018 02:31:44 +0900 Subject: [PATCH] xt_usb: Read data earlier as possible in ISR --- tmk_core/protocol/xt_interrupt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tmk_core/protocol/xt_interrupt.c b/tmk_core/protocol/xt_interrupt.c index 8c8408ba..5531464d 100644 --- a/tmk_core/protocol/xt_interrupt.c +++ b/tmk_core/protocol/xt_interrupt.c @@ -93,17 +93,18 @@ ISR(XT_INT_VECT) } state = START; static uint8_t data = 0; + uint8_t dbit = data_in(); // This is needed if using PCINT which can be called on both falling and rising edge if (clock_in()) return; switch (state) { case START: // ignore start(0) bit - if (!data_in()) return; + if (!dbit) return; break; case BIT0 ... BIT7: data >>= 1; - if (data_in()) + if (dbit) data |= 0x80; break; } -- 2.46.2