Skip to content
Snippets Groups Projects
Commit 443023bb authored by Randy Mackay's avatar Randy Mackay
Browse files

AP_HAL: add ignore_errors to I2C driver

parent bbc4cb26
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,10 @@ public:
uint8_t len, uint8_t* data) = 0;
virtual uint8_t lockup_count() = 0;
void ignore_errors(bool b) { _ignore_errors = b; }
virtual AP_HAL::Semaphore* get_semaphore() = 0;
protected:
bool _ignore_errors;
};
#endif // __AP_HAL_I2C_DRIVER_H__
......
......@@ -133,7 +133,9 @@ uint8_t AVRI2CDriver::writeRegisters(uint8_t addr, uint8_t reg,
if (stat) goto error;
return stat;
error:
_lockup_count++;
if (!_ignore_errors) {
_lockup_count++;
}
return stat;
}
......
......@@ -127,11 +127,12 @@ uint8_t FLYMAPLEI2CDriver::_transfer(i2c_msg *msgs, uint16 num)
// ALERT: patch to libmaple required for this to work else
// crashes next line due to a bug in latest git libmaple see http://forums.leaflabs.com/topic.php?id=13458
int32 result = i2c_master_xfer(I2C1, msgs, num, _timeout_ms);
if (result != 0)
{
// Some sort of I2C bus fault, or absent device, reinitialise the bus
_reset();
_lockup_count++;
if (result != 0) {
// Some sort of I2C bus fault, or absent device, reinitialise the bus
_reset();
if (!_ignore_errors) {
_lockup_count++;
}
}
return result != 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment