summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-10-09 19:56:40 +0200
committerDaniel Friesel <derf@finalrewind.org>2013-10-09 19:56:40 +0200
commitdc0f1b195bb5a76c37cd7bc8942fd0070d6954e1 (patch)
tree1407f5ac48dfe3944e21508a3a6a9795345dc65c
parentaf7f315f7f64720804086bfb6f14a217e9b97d39 (diff)
directly store bit mask in POS
-rw-r--r--main.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/main.c b/main.c
index 15726e8..15f4cee 100644
--- a/main.c
+++ b/main.c
@@ -149,7 +149,7 @@ ISR(INT1_vect)
DDRD = 0;
LASTCMD = 0;
BUF = 0;
- POS = 0;
+ POS = 1;
APOS = 0;
asm volatile ("wdr");
EIFR |= _BV(INTF1);
@@ -159,21 +159,23 @@ ISR(INT1_vect)
* Line was high for > 15us - got a "write 0"
*/
if (LCNTL > 15) {
- POS++;
+ // nothing to do
}
/*
* Line was high for <= 15us - got a "write 1". Might also be a
* "read", so only do stuff if we don't have a command set
*/
else {
- BUF |= _BV(POS);
- POS++;
+ BUF |= POS;
}
/*
* We received 8 command bits. Store the command and switch to
* write mode (also, store the first byte to be sent)
*/
- if (POS == 7) {
+ if (POS != 0x80) {
+ POS <<= 1;
+ }
+ else {
LASTCMD = BUF;
POS = 1;
APOS = 0;
@@ -291,11 +293,6 @@ ISR(INT1_vect)
BYTE = ~ADDR2;
else if (APOS == 7)
BYTE = ~ADDR1;
-
- else if (APOS == 8) {
- LASTCMD = 0;
- POS = 0;
- }
}
}