summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2012-09-03 00:02:48 +0200
committerChristian Franke <nobody@nowhere.ws>2012-09-03 00:02:48 +0200
commit97140abf540f41e97ae59beff8a3c106010641aa (patch)
tree408b0291c30a498331814e3c9d5bbb31c9f5229a
parentb4491d3116e0f9c45972262d5d5d9c2e1e2da561 (diff)
some comments and bugfixes
-rw-r--r--kbc.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/kbc.c b/kbc.c
index 5d13e55..f343012 100644
--- a/kbc.c
+++ b/kbc.c
@@ -63,7 +63,15 @@ enum state {
STATE_ERROR,
#endif
};
-static volatile enum state state, nextstate, toutstate;
+
+/* state is the current system state */
+static volatile enum state state;
+
+/* system will advance to nextstate on return to main, if nextstate is != STATE_NONE */
+static volatile enum state nextstate;
+
+/* system will advance to toutstate on timeout. */
+static volatile enum state toutstate;
static void power_up()
{
@@ -109,7 +117,7 @@ static void dbg_wr(uint8_t what)
sei();
}
-ISR(SIG_SPI)
+ISR(SPI_STC_vect)
{
if (dbgpos) {
SPDR = dbgtx[0];
@@ -401,7 +409,7 @@ static void state_enter(void)
nextstate = STATE_IDLE;
break;
case STATE_IDLE:
- memset(&code, 0, sizeof(code));
+ memset(code, 0, sizeof(code));
toutstate = STATE_IDLEBLINK;
statecntr = WAIT_IDLE;
nextstate = STATE_FAILURE;
@@ -487,7 +495,7 @@ static void state_enter(void)
}
}
-ISR(SIG_OVERFLOW0)
+ISR(TIMER0_OVF_vect)
{
if (!--cntr) {
cntr = CNTRTOP;
@@ -536,6 +544,7 @@ static void handle_keypress(uint8_t data)
if (release) {
pressed = 0;
release = 0;
+ e0 = 0;
return;
}
if (data == pressed)
@@ -603,7 +612,7 @@ static void handle_keypress(uint8_t data)
cntr = CNTR_KEYMATIC;
nextstate = STATE_ACCEPT;
}
- memset(&code, 0, sizeof(code));
+ memset(code, 0, sizeof(code));
return;
}
@@ -616,7 +625,7 @@ static void handle_keypress(uint8_t data)
nextstate = STATE_INPUT;
}
-ISR(SIG_USART_RECV)
+ISR(USART_RX_vect)
{
uint8_t data = UDR0;