Update i2c.c

This commit is contained in:
Zaltora 2016-09-01 10:24:28 +02:00 committed by GitHub
parent 29a25e0425
commit a3bc6ac54b

View file

@ -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;