modify sda pin direction for read.

This commit is contained in:
Thomas Klaehn 2019-07-25 14:22:15 +02:00
parent 29d76c9d2f
commit 98c04194fe

View File

@ -168,9 +168,11 @@ static uint8_t read_bit(const struct i2c_bb *i2c)
gpio_write(i2c->sda, 1); gpio_write(i2c->sda, 1);
usleep(5); usleep(5);
gpio_write(i2c->scl, 1); gpio_write(i2c->scl, 1);
gpio_direction(i2c->sda, IN);
usleep(5); usleep(5);
res = gpio_read(i2c->sda); res = gpio_read(i2c->sda);
gpio_write(i2c->scl, 0); gpio_write(i2c->scl, 0);
gpio_direction(i2c->sda, OUT);
if(res < 0) { if(res < 0) {
res = 0; res = 0;