aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2014-08-02 14:09:17 -0700
committerKing Kévin <kingkevin@cuvoodoo.info>2014-08-02 14:09:17 -0700
commit42d4dbdc2d15886c837f747e7a1e3c02a4802dff (patch)
tree9be9564a618c8e1354dc4d0da1ac8bbee5087c90
parent53663ade65a4938384dc1b583d3dbcd211540725 (diff)
fix bit save in byte read
-rw-r--r--pic/MDR/I2C.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pic/MDR/I2C.c b/pic/MDR/I2C.c
index 3da593e..54b2056 100644
--- a/pic/MDR/I2C.c
+++ b/pic/MDR/I2C.c
@@ -120,12 +120,12 @@ uint8_t read_byte(uint8_t ack)
for (bit=0; bit<8; bit++) {
delay(); /* wait for SDA to change */
release_SCL(); /* SDA should be valid when clock is high */
+ byte <<= 1; /* make place to save the next bit */
if (PORTB&SDA) { /* read bit */
byte += 1;
} else {
byte += 0;
}
- byte <<= 1;
hold_SCL(); /* set clock to low for SDA to change */
}
if (ack) {