missed update logging change for WireUtils
This commit is contained in:
parent
ac5eaf36fa
commit
3b6472f41e
|
|
@ -23,7 +23,8 @@
|
||||||
#include "WireUtils.h"
|
#include "WireUtils.h"
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
#include "Logger.h"
|
#include "Log.h"
|
||||||
|
const char* TAG = "wire_utils";
|
||||||
|
|
||||||
WireUtilsC::WireUtilsC()
|
WireUtilsC::WireUtilsC()
|
||||||
{
|
{
|
||||||
|
|
@ -42,7 +43,7 @@ WireUtilsC::WireUtilsC()
|
||||||
*/
|
*/
|
||||||
int WireUtilsC::clearBus()
|
int WireUtilsC::clearBus()
|
||||||
{
|
{
|
||||||
dbprintln("WireUtils::ClearBus: attempting to clean i2c bus");
|
logger.warning(TAG, "WireUtils::ClearBus: attempting to clean i2c bus");
|
||||||
#if defined(TWCR) && defined(TWEN)
|
#if defined(TWCR) && defined(TWEN)
|
||||||
TWCR &= ~(_BV(TWEN)); //Disable the Atmel 2-Wire interface so we can control the SDA and SCL pins directly
|
TWCR &= ~(_BV(TWEN)); //Disable the Atmel 2-Wire interface so we can control the SDA and SCL pins directly
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -52,7 +53,7 @@ int WireUtilsC::clearBus()
|
||||||
boolean SCL_LOW = (digitalRead(SCL) == LOW); // Check is SCL is Low.
|
boolean SCL_LOW = (digitalRead(SCL) == LOW); // Check is SCL is Low.
|
||||||
if (SCL_LOW)
|
if (SCL_LOW)
|
||||||
{ //If it is held low Arduno cannot become the I2C master.
|
{ //If it is held low Arduno cannot become the I2C master.
|
||||||
dbprintln("WireUtils::ClearBus: Failed! SCL held low!");
|
logger.error(TAG, "WireUtils::ClearBus: Failed! SCL held low!");
|
||||||
return 1; //I2C bus error. Could not clear SCL clock line held low
|
return 1; //I2C bus error. Could not clear SCL clock line held low
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,14 +82,14 @@ int WireUtilsC::clearBus()
|
||||||
}
|
}
|
||||||
if (SCL_LOW)
|
if (SCL_LOW)
|
||||||
{ // still low after 2 sec error
|
{ // still low after 2 sec error
|
||||||
dbprintln("WireUtils::ClearBus: Failed! SCL clock line held low by slave clock stretch for >2sec");
|
logger.error(TAG, "WireUtils::ClearBus: Failed! SCL clock line held low by slave clock stretch for >2sec");
|
||||||
return 2; // I2C bus error. Could not clear. SCL clock line held low by slave clock stretch for >2sec
|
return 2; // I2C bus error. Could not clear. SCL clock line held low by slave clock stretch for >2sec
|
||||||
}
|
}
|
||||||
SDA_LOW = (digitalRead(SDA) == LOW); // and check SDA input again and loop
|
SDA_LOW = (digitalRead(SDA) == LOW); // and check SDA input again and loop
|
||||||
}
|
}
|
||||||
if (SDA_LOW)
|
if (SDA_LOW)
|
||||||
{ // still low
|
{ // still low
|
||||||
dbprintln("WireUtils::ClearBus: Failed! SDA data line still held low");
|
logger.error(TAG, "WireUtils::ClearBus: Failed! SDA data line still held low");
|
||||||
return 3; // I2C bus error. Could not clear. SDA data line held low
|
return 3; // I2C bus error. Could not clear. SDA data line held low
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +104,7 @@ int WireUtilsC::clearBus()
|
||||||
delayMicroseconds(10); // x. wait >5uS
|
delayMicroseconds(10); // x. wait >5uS
|
||||||
pinMode(SDA, INPUT); // and reset pins as tri-state inputs which is the default state on reset
|
pinMode(SDA, INPUT); // and reset pins as tri-state inputs which is the default state on reset
|
||||||
pinMode(SCL, INPUT);
|
pinMode(SCL, INPUT);
|
||||||
dbprintln("WireUtils::ClearBus: Success!");
|
logger.info(TAG, "WireUtils::ClearBus: Success!");
|
||||||
return 0; // all ok
|
return 0; // all ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user