mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 14:13:34 +08:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user