From b5a8788d5576ec53174b42314554e0f142a0d1ee Mon Sep 17 00:00:00 2001 From: ficeto Date: Fri, 22 May 2015 15:13:11 +0300 Subject: [PATCH] fix I2C --- .../esp8266/cores/esp8266/core_esp8266_si2c.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_si2c.c b/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_si2c.c index 29149aa09..cff2809d3 100644 --- a/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_si2c.c +++ b/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_si2c.c @@ -150,6 +150,13 @@ unsigned char twi_writeTo(unsigned char address, unsigned char * buf, unsigned i if(!twi_write_byte(buf[i])) return 3;//received NACK on transmit of data } if(sendStop) twi_write_stop(); + i = 0; + while(SDA_READ() == 0 && (i++) < 10){ + SCL_LOW(); + twi_delay(twi_dcount); + SCL_HIGH(); + twi_delay(twi_dcount); + } return 0; } @@ -158,15 +165,13 @@ unsigned char twi_readFrom(unsigned char address, unsigned char* buf, unsigned i if(!twi_write_start()) return 4;//line busy if(!twi_write_byte(((address << 1) | 1) & 0xFF)) return 2;//received NACK on transmit of address for(i=0; i