From 46468d4af7ace336c31029372368154ce3000b59 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 9 Nov 2015 00:18:08 +0300 Subject: [PATCH] I2C: generate STOP in case of NACK (fix #698, #254) thanks @petrd and @Yazzcat --- cores/esp8266/core_esp8266_si2c.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cores/esp8266/core_esp8266_si2c.c b/cores/esp8266/core_esp8266_si2c.c index 1db11bb87..4008c5c8f 100644 --- a/cores/esp8266/core_esp8266_si2c.c +++ b/cores/esp8266/core_esp8266_si2c.c @@ -150,9 +150,15 @@ static unsigned char twi_read_byte(bool nack) { unsigned char twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop){ unsigned int i; if(!twi_write_start()) return 4;//line busy - if(!twi_write_byte(((address << 1) | 0) & 0xFF)) return 2;//received NACK on transmit of address - for(i=0; i