differential_pressure drivers: allow multiple instances of each driver

- the device path needs to be removed, as startup fails if it already
  exists
- sdp3x broadcasts a reset on startup, so do it only for the first I2C
  address
This commit is contained in:
Beat Küng
2020-03-17 23:31:17 -04:00
committed by Daniel Agar
parent 3b7b2dc871
commit 68ef14002a
7 changed files with 29 additions and 35 deletions
@@ -57,21 +57,25 @@ int SDP3X::write_command(uint16_t command)
bool
SDP3X::init_sdp3x()
{
// step 1 - reset on broadcast
uint16_t prev_addr = get_device_address();
set_device_address(SDP3X_RESET_ADDR);
uint8_t reset_cmd = SDP3X_RESET_CMD;
int ret = transfer(&reset_cmd, 1, nullptr, 0);
set_device_address(prev_addr);
int ret;
if (ret != PX4_OK) {
perf_count(_comms_errors);
return false;
if (get_device_address() == I2C_ADDRESS_1_SDP3X) { // since we are broadcasting, only do it for the first device address
// step 1 - reset on broadcast
uint16_t prev_addr = get_device_address();
set_device_address(SDP3X_RESET_ADDR);
uint8_t reset_cmd = SDP3X_RESET_CMD;
ret = transfer(&reset_cmd, 1, nullptr, 0);
set_device_address(prev_addr);
if (ret != PX4_OK) {
perf_count(_comms_errors);
return false;
}
// wait until sensor is ready
px4_usleep(20000);
}
// wait until sensor is ready
px4_usleep(20000);
// step 2 - configure
ret = write_command(SDP3X_CONT_MEAS_AVG_MODE);