mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
I2C bus reset with info to user
I2C slave might stil have something to send when ESP826 starts I2C, thus keeping the bus stuck. Happens e.g. when power failure/reset during transmission. Thanks to work of drmpf there is a solution. Implemented as separate method so as not to interfere with existing. Usage: Wire.begin(); if (Wire.status() != I2C_OK) Serial.writeln("Something wrong with I2C bus that cannot be recovered. Perform power cycle or search for other masters on bus.";
This commit is contained in:
@ -26,12 +26,19 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define I2C_OK 0
|
||||
#define I2C_SCL_HELD_LOW 1
|
||||
#define I2C_SCL_HELD_LOW_AFTER_READ 2
|
||||
#define I2C_SDA_HELD_LOW 3
|
||||
#define I2C_SDA_HELD_LOW_AFTER_INIT 4
|
||||
|
||||
void twi_init(unsigned char sda, unsigned char scl);
|
||||
void twi_stop(void);
|
||||
void twi_setClock(unsigned int freq);
|
||||
void twi_setClockStretchLimit(uint32_t limit);
|
||||
uint8_t twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop);
|
||||
uint8_t twi_readFrom(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop);
|
||||
uint8_t twi_status();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user