aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-08-24 08:18:18 -0700
committerpx4dev <px4@purgatory.org>2012-08-24 08:18:18 -0700
commitd55dd67d77e8187440f9c52ae26438250566d997 (patch)
tree56b9ef9ed1ba527dc958a900d78c4cf39c62cc35
parentd12c09cc869c09de4cf670e58f900e42f7fc5f0f (diff)
downloadpx4-firmware-d55dd67d77e8187440f9c52ae26438250566d997.tar.gz
px4-firmware-d55dd67d77e8187440f9c52ae26438250566d997.tar.bz2
px4-firmware-d55dd67d77e8187440f9c52ae26438250566d997.zip
Remove spurious I2C clock frequency resets.
-rw-r--r--apps/drivers/device/i2c.cpp13
-rw-r--r--apps/system/i2c/i2c_bus.c2
2 files changed, 7 insertions, 8 deletions
diff --git a/apps/drivers/device/i2c.cpp b/apps/drivers/device/i2c.cpp
index 42dfd7300..f5f29fde3 100644
--- a/apps/drivers/device/i2c.cpp
+++ b/apps/drivers/device/i2c.cpp
@@ -73,11 +73,8 @@ I2C::init()
{
int ret = OK;
- // attach to the i2c bus
+ /* attach to the i2c bus */
_dev = up_i2cinitialize(_bus);
- // set the bus speed again to a reasonable number of 400 KHz
- I2C_SETFREQUENCY(_dev, 400000);
-
if (_dev == nullptr) {
debug("failed to init I2C");
@@ -147,8 +144,12 @@ I2C::transfer(uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len
if (msgs == 0)
return -EINVAL;
- // set the bus speed again to a reasonable number of 400 KHz
- I2C_SETFREQUENCY(_dev, 400000);
+ /*
+ * 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[0], msgs);
if (ret == OK)
diff --git a/apps/system/i2c/i2c_bus.c b/apps/system/i2c/i2c_bus.c
index 4bca13c66..07e6d2da3 100644
--- a/apps/system/i2c/i2c_bus.c
+++ b/apps/system/i2c/i2c_bus.c
@@ -84,8 +84,6 @@ int i2ccmd_bus(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
for (i = CONFIG_I2CTOOL_MINBUS; i <= CONFIG_I2CTOOL_MAXBUS; i++)
{
dev = up_i2cinitialize(i);
- // set the bus speed again to a reasonable number of 400 KHz
- I2C_SETFREQUENCY(_dev, 400000);
if (dev)
{
i2ctool_printf(i2ctool, "Bus %d: YES\n", i);