sensors (accel/gyro/mag) determine if external with device id

This commit is contained in:
Daniel Agar
2022-01-10 10:31:07 -05:00
committed by GitHub
parent 45040be669
commit e731fcdbc0
36 changed files with 187 additions and 205 deletions
+56
View File
@@ -34,9 +34,18 @@
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/log.h>
#include <lib/conversion/rotation.h>
#include <lib/drivers/device/Device.hpp>
#include <lib/mathlib/mathlib.h>
#include <lib/parameters/param.h>
#if defined(CONFIG_I2C)
# include <px4_platform_common/i2c.h>
#endif // CONFIG_I2C
#if defined(CONFIG_SPI)
# include <px4_platform_common/spi.h>
#endif // CONFIG_SPI
using math::radians;
using matrix::Eulerf;
using matrix::Dcmf;
@@ -179,4 +188,51 @@ Dcmf GetBoardRotationMatrix()
return get_rot_matrix(GetBoardRotation());
}
bool DeviceExternal(uint32_t device_id)
{
bool external = true;
// decode device id to determine if external
union device::Device::DeviceId id {};
id.devid = device_id;
const device::Device::DeviceBusType bus_type = id.devid_s.bus_type;
switch (bus_type) {
case device::Device::DeviceBusType_I2C:
#if defined(CONFIG_I2C)
external = px4_i2c_bus_external(id.devid_s.bus);
#endif // CONFIG_I2C
break;
case device::Device::DeviceBusType_SPI:
#if defined(CONFIG_SPI)
external = px4_spi_bus_external(id.devid_s.bus);
#endif // CONFIG_SPI
break;
case device::Device::DeviceBusType_UAVCAN:
external = true;
break;
case device::Device::DeviceBusType_SIMULATION:
external = false;
break;
case device::Device::DeviceBusType_SERIAL:
external = true;
break;
case device::Device::DeviceBusType_MAVLINK:
external = true;
break;
case device::Device::DeviceBusType_UNKNOWN:
external = true;
break;
}
return external;
}
} // namespace calibration