uncomment I2C debug so it can be used
This commit is contained in:
parent
0cd62852da
commit
28be506ce3
@ -157,7 +157,7 @@ i2c_err_t i2cWrite(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * dat
|
||||
|
||||
if (i2c->dev->status_reg.bus_busy == 1)
|
||||
{
|
||||
//log_w( "Busy Timeout! Addr: %x", address >> 1 );
|
||||
log_e( "Busy Timeout! Addr: %x", address >> 1 );
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_BUSY;
|
||||
}
|
||||
@ -207,28 +207,28 @@ i2c_err_t i2cWrite(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * dat
|
||||
while(1) {
|
||||
//have been looping for too long
|
||||
if((millis() - startAt)>50){
|
||||
//log_e("Timeout! Addr: %x", address >> 1);
|
||||
log_e("Timeout! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_BUS;
|
||||
}
|
||||
|
||||
//Bus failed (maybe check for this while waiting?
|
||||
if(i2c->dev->int_raw.arbitration_lost) {
|
||||
//log_e("Bus Fail! Addr: %x", address >> 1);
|
||||
log_e("Bus Fail! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_BUS;
|
||||
}
|
||||
|
||||
//Bus timeout
|
||||
if(i2c->dev->int_raw.time_out) {
|
||||
//log_e("Bus Timeout! Addr: %x", address >> 1);
|
||||
log_e("Bus Timeout! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_TIMEOUT;
|
||||
}
|
||||
|
||||
//Transmission did not finish and ACK_ERR is set
|
||||
if(i2c->dev->int_raw.ack_err) {
|
||||
//log_w("Ack Error! Addr: %x", address >> 1);
|
||||
log_w("Ack Error! Addr: %x", address >> 1);
|
||||
while((i2c->dev->status_reg.bus_busy) && ((millis() - startAt)>50));
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_ACK;
|
||||
@ -260,7 +260,7 @@ i2c_err_t i2cRead(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * data
|
||||
|
||||
if (i2c->dev->status_reg.bus_busy == 1)
|
||||
{
|
||||
//log_w( "Busy Timeout! Addr: %x", address >> 1 );
|
||||
log_w( "Busy Timeout! Addr: %x", address >> 1 );
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_BUSY;
|
||||
}
|
||||
@ -310,28 +310,28 @@ i2c_err_t i2cRead(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * data
|
||||
while(1) {
|
||||
//have been looping for too long
|
||||
if((millis() - startAt)>50){
|
||||
//log_e("Timeout! Addr: %x", address >> 1);
|
||||
log_e("Timeout! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_BUS;
|
||||
}
|
||||
|
||||
//Bus failed (maybe check for this while waiting?
|
||||
if(i2c->dev->int_raw.arbitration_lost) {
|
||||
//log_e("Bus Fail! Addr: %x", address >> 1);
|
||||
log_e("Bus Fail! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_BUS;
|
||||
}
|
||||
|
||||
//Bus timeout
|
||||
if(i2c->dev->int_raw.time_out) {
|
||||
//log_e("Bus Timeout! Addr: %x", address >> 1);
|
||||
log_e("Bus Timeout! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_TIMEOUT;
|
||||
}
|
||||
|
||||
//Transmission did not finish and ACK_ERR is set
|
||||
if(i2c->dev->int_raw.ack_err) {
|
||||
//log_w("Ack Error! Addr: %x", address >> 1);
|
||||
log_w("Ack Error! Addr: %x", address >> 1);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
return I2C_ERROR_ACK;
|
||||
}
|
||||
@ -462,7 +462,7 @@ void i2cInitFix(i2c_t * i2c){
|
||||
i2cSetCmd(i2c, 2, I2C_CMD_STOP, 0, false, false, false);
|
||||
if (i2c->dev->status_reg.bus_busy) // If this condition is true, the while loop will timeout as done will not be set
|
||||
{
|
||||
//log_e("Busy at initialization!");
|
||||
log_e("Busy at initialization!");
|
||||
}
|
||||
i2c->dev->ctr.trans_start = 1;
|
||||
uint16_t count = 50000;
|
||||
|
Loading…
Reference in New Issue
Block a user