summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kbc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/kbc.c b/kbc.c
index a1f70b8..95665c9 100644
--- a/kbc.c
+++ b/kbc.c
@@ -357,12 +357,13 @@ static uint8_t wait_byte(void)
#define CNTR_KEYMATIC 30
/* CNTR_BEEP_ACC == CNTR_KEYMATIC */
static uint8_t cntr = 0;
static uint8_t close_try = 0;
+static uint8_t idle_looped = 0;
#ifdef KILLSWITCH
static uint8_t error;
#endif
static EEMEM uint8_t passwd[sizeof(PIN) - 1] = PIN;
static EEMEM uint8_t mpasswd[sizeof(MASTER_PIN) - 1] = MASTER_PIN;
@@ -423,13 +424,19 @@ static void state_enter(void)
statecntr = WAIT_IDLE;
nextstate = STATE_FAILURE;
if (send_byte(0xed) != 0xfa)
break;
if (send_byte(0x00) != 0xfa)
break;
- nextstate = STATE_NONE;
+
+ /* We have some issues with the keyboard failing every
+ * now and then. Until we know more about the issue,
+ * reset it every 256th time we enter STATE_IDLE :/ */
+ idle_looped += 1;
+ if (idle_looped != 0xff)
+ nextstate = STATE_NONE;
break;
case STATE_IDLEBLINK:
toutstate = STATE_IDLE;
statecntr = WAIT_IDLEBLINK;
nextstate = STATE_FAILURE;
if (send_byte(0xed) != 0xfa)
@@ -438,12 +445,13 @@ static void state_enter(void)
break;
nextstate = STATE_NONE;
cntr = CNTR_BLINK;
break;
case STATE_INPUT:
toutstate = STATE_IDLE;
+ idle_looped = 0; /* input still works, reset idle counter */
statecntr = WAIT_INPUT;
if (send_byte(0xed) != 0xfa)
break;
if (send_byte(KBLED_STATE) != 0xfa)
break;
break;