Skip to content

Commit

Permalink
Update core_esp8266_si2c.c
Browse files Browse the repository at this point in the history
Repair I2C communication
issue 698
esp8266#698
  • Loading branch information
petrd committed Aug 17, 2015
1 parent aafacdc commit 9fbb834
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ 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
if(!twi_write_byte(((address << 1) | 0) & 0xFF)) {twi_write_stop();return 2;}//received NACK on transmit of address

This comment has been minimized.

Copy link
@igrr

igrr Aug 18, 2015

My guess is that this should be if (sendStop) twi_write_stop();, but please verify if that works with your sensor.

This comment has been minimized.

Copy link
@petrd

petrd Aug 18, 2015

Author Owner

if(!twi_write_byte(((address << 1) | 0) & 0xFF)) {if(sendStop) twi_write_stop(); return 2;}

It works without any problems, thank you.

for(i=0; i<len; i++){
if(!twi_write_byte(buf[i])) return 3;//received NACK on transmit of data

This comment has been minimized.

Copy link
@igrr

igrr Aug 18, 2015

Perhaps should send a stop here as well?

This comment has been minimized.

Copy link
@petrd

petrd Aug 18, 2015

Author Owner

  for(i=0; i<len; i++){
      if(!twi_write_byte(buf[i])) {if(sendStop) twi_write_stop(); return 3;}//received NACK on transmit of data
  }

Probably not affect the outcome ...

}
Expand Down

0 comments on commit 9fbb834

Please sign in to comment.