1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Merge remote-tracking branch 'remotes/ficeto/esp8266' into esp8266

This commit is contained in:
Markus Sattler 2015-05-22 14:17:31 +02:00
commit c9a5975aa8

View File

@ -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<len; i++) buf[i] = twi_read_byte(false);
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);
}
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;
}