Update i2c.c
This commit is contained in:
parent
29a25e0425
commit
a3bc6ac54b
1 changed files with 4 additions and 4 deletions
|
@ -110,9 +110,9 @@ uint8_t i2c_read(uint8_t ack) {
|
||||||
}
|
}
|
||||||
_SCL0;
|
_SCL0;
|
||||||
if (ack)
|
if (ack)
|
||||||
_SDA0; // ACK
|
|
||||||
else
|
|
||||||
_SDA1; // NACK
|
_SDA1; // NACK
|
||||||
|
else
|
||||||
|
_SDA0; // ACK
|
||||||
_DELAY;
|
_DELAY;
|
||||||
// Send clock
|
// Send clock
|
||||||
_SCL1;
|
_SCL1;
|
||||||
|
@ -134,9 +134,9 @@ bool i2c_slave_read(uint8_t slave_addr, uint8_t data, uint8_t *buf, uint16_t len
|
||||||
if(!i2c_write((slave_addr<<1) | 1)) goto fail_send; // adress + R
|
if(!i2c_write((slave_addr<<1) | 1)) goto fail_send; // adress + R
|
||||||
|
|
||||||
while(--len) {
|
while(--len) {
|
||||||
*(buf++) = i2c_read(1);
|
*(buf++) = i2c_read(0);
|
||||||
}
|
}
|
||||||
*buf = i2c_read(0);
|
*buf = i2c_read(1);
|
||||||
i2c_stop();
|
i2c_stop();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue