1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +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(!twi_write_byte(buf[i])) return 3;//received NACK on transmit of data
} }
if(sendStop) twi_write_stop(); 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; return 0;
} }
@ -158,8 +165,7 @@ unsigned char twi_readFrom(unsigned char address, unsigned char* buf, unsigned i
if(!twi_write_start()) return 4;//line busy if(!twi_write_start()) return 4;//line busy
if(!twi_write_byte(((address << 1) | 1) & 0xFF)) return 2;//received NACK on transmit of address 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); for(i=0; i<len; i++) buf[i] = twi_read_byte(false);
if(sendStop){ if(sendStop) twi_write_stop();
twi_write_stop();
i = 0; i = 0;
while(SDA_READ() == 0 && (i++) < 10){ while(SDA_READ() == 0 && (i++) < 10){
SCL_LOW(); SCL_LOW();
@ -167,6 +173,5 @@ unsigned char twi_readFrom(unsigned char address, unsigned char* buf, unsigned i
SCL_HIGH(); SCL_HIGH();
twi_delay(twi_dcount); twi_delay(twi_dcount);
} }
}
return 0; return 0;
} }