diff options
author | Randy Mackay <rmackay9@yahoo.com> | 2015-03-19 11:54:21 +0900 |
---|---|---|
committer | Randy Mackay <rmackay9@yahoo.com> | 2015-03-19 12:09:40 +0900 |
commit | 4e83f43ea3f66c02d3f982948728f611f2daa220 (patch) | |
tree | 7ef14ca39f1fb0cf531ddd555891f68f7cbfffc1 /src/drivers/batt_smbus/batt_smbus.cpp | |
parent | 23075f6dab4fc3584cd17eed44196169488af626 (diff) | |
download | px4-firmware-4e83f43ea3f66c02d3f982948728f611f2daa220.tar.gz px4-firmware-4e83f43ea3f66c02d3f982948728f611f2daa220.tar.bz2 px4-firmware-4e83f43ea3f66c02d3f982948728f611f2daa220.zip |
batt_smbus: remove usleep
Also restore I2C address after performing command line search for
devices
Diffstat (limited to 'src/drivers/batt_smbus/batt_smbus.cpp')
-rw-r--r-- | src/drivers/batt_smbus/batt_smbus.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/drivers/batt_smbus/batt_smbus.cpp b/src/drivers/batt_smbus/batt_smbus.cpp index 4fd82de49..9f72bd56f 100644 --- a/src/drivers/batt_smbus/batt_smbus.cpp +++ b/src/drivers/batt_smbus/batt_smbus.cpp @@ -282,6 +282,7 @@ BATT_SMBUS::search() { bool found_slave = false; uint16_t tmp; + int16_t orig_addr = get_address(); // search through all valid SMBus addresses for (uint8_t i = BATT_SMBUS_ADDR_MIN; i <= BATT_SMBUS_ADDR_MAX; i++) { @@ -296,6 +297,9 @@ BATT_SMBUS::search() usleep(1); } + // restore original i2c address + set_address(orig_addr); + // display completion message if (found_slave) { warnx("Done."); @@ -367,7 +371,6 @@ BATT_SMBUS::cycle() new_report.voltage_v = ((float)tmp) / 1000.0f; // read current - usleep(1); uint8_t buff[4]; if (read_block(BATT_SMBUS_CURRENT, buff, 4, false) == 4) { @@ -376,7 +379,6 @@ BATT_SMBUS::cycle() // read battery design capacity if (_batt_design_capacity == 0) { - usleep(1); if (read_reg(BATT_SMBUS_DESIGN_CAPACITY, tmp) == OK) { _batt_design_capacity = tmp; } @@ -384,7 +386,6 @@ BATT_SMBUS::cycle() // read remaining capacity if (_batt_design_capacity > 0) { - usleep(1); if (read_reg(BATT_SMBUS_REMAINING_CAPACITY, tmp) == OK) { if (tmp < _batt_design_capacity) { new_report.discharged_mah = _batt_design_capacity - tmp; @@ -451,8 +452,6 @@ BATT_SMBUS::read_block(uint8_t reg, uint8_t *data, uint8_t max_len, bool append_ { uint8_t buff[max_len + 2]; // buffer to hold results - usleep(1); - // read bytes including PEC int ret = transfer(®, 1, buff, max_len + 2); |