Add a mechanism for sending multi-part messages to the I2C driver base class.

This commit is contained in:
px4dev
2013-01-14 00:18:05 -08:00
parent 4e38615595
commit 6e291ddedc
2 changed files with 30 additions and 0 deletions
+20
View File
@@ -166,4 +166,24 @@ I2C::transfer(const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned re
}
int
I2C::transfer(i2c_msg_s *msgv, unsigned msgs)
{
for (unsigned i = 0; i < msgs; i++)
msgv[i].addr = _address;
/*
* I2C architecture means there is an unavoidable race here
* if there are any devices on the bus with a different frequency
* preference. Really, this is pointless.
*/
I2C_SETFREQUENCY(_dev, _frequency);
ret = I2C_TRANSFER(_dev, msgv, msgs);
if (ret != OK)
up_i2creset(_dev);
return ret;
}
} // namespace device