mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-03 06:50:59 +08:00
fix(boards/airbrainh743): mark I2C1 external for external compass scan (#27814)
The AirBrainH743 breaks out a single I2C bus (I2C1) that also carries the onboard DPS310 baro and IIS2MDC mag. Because the bus was marked internal, the external-compass autostart (which scans external buses with -X) never probed it, so an external GPS/compass on that bus was never bound. Mark I2C1 external so the external-mag autostart scans it, and add a px4_i2c_device_external() override (guarded by BOARD_OVERRIDE_I2C_DEVICE_EXTERNAL) that keeps the onboard baro and mag classified as internal. This mirrors the approach used on fmu-v6c. The onboard baro/mag are now started explicitly by bus and address (-X -b 1) since -I no longer matches the external bus. Also enable the i2cdetect command, which is handy for probing the shared external bus on this board. Signed-off-by: Julian Oes <julian@oes.ch>
This commit is contained in:
1 parent
4af6fbeabf
commit
a201b24287
4 files changed
+54
-8
No files matched your search
@@ -88,3 +88,4 @@ CONFIG_SYSTEMCMDS_UORB=y
|
||||
CONFIG_SYSTEMCMDS_USB_CONNECTED=y
|
||||
CONFIG_SYSTEMCMDS_VER=y
|
||||
CONFIG_SYSTEMCMDS_WORK_QUEUE=y
|
||||
CONFIG_SYSTEMCMDS_I2CDETECT=y
|
||||
@@ -8,9 +8,11 @@ board_adc start
|
||||
# Internal SPI bus IMU - ICM42688P (Invensensev3)
|
||||
icm42688p -R 2 -b 1 -s start
|
||||
|
||||
# Internal I2C bus barometer - DPS310 @ 0x76 (118 decimal)
|
||||
dps310 -I -a 118 start
|
||||
# Onboard baro/mag are on I2C1, which is marked external because the bus is
|
||||
# also broken out. Start them explicitly by bus + address.
|
||||
|
||||
# Internal I2C bus magnetometer - LIS2MDL @ 0x1E (30 decimal)
|
||||
# Using iis2mdc driver (functionally equivalent to LIS2MDL)
|
||||
iis2mdc -I -R 2 -a 30 start
|
||||
# Onboard I2C1 barometer - DPS310 @ 0x76 (118 decimal)
|
||||
dps310 -X -b 1 -a 118 start
|
||||
|
||||
# Onboard I2C1 magnetometer - IIS2MDC @ 0x1E (30 decimal)
|
||||
iis2mdc -X -b 1 -R 2 -a 30 start
|
||||
@@ -180,6 +180,10 @@
|
||||
|
||||
#define BOARD_ENABLE_CONSOLE_BUFFER
|
||||
|
||||
/* The onboard baro/mag share I2C1, which is broken out externally, so the
|
||||
* board provides its own px4_i2c_device_external() (see src/i2c.cpp). */
|
||||
#define BOARD_OVERRIDE_I2C_DEVICE_EXTERNAL
|
||||
|
||||
#define BOARD_NUM_IO_TIMERS 4
|
||||
|
||||
|
||||
|
||||
@@ -33,15 +33,54 @@
|
||||
|
||||
#include <px4_arch/i2c_hw_description.h>
|
||||
|
||||
#include <lib/drivers/device/Device.hpp>
|
||||
#include <px4_platform_common/i2c.h>
|
||||
|
||||
/*
|
||||
* I2C bus configuration for AirBrainH743
|
||||
*
|
||||
* I2C1: Internal bus - PB6 (SCL), PB7 (SDA)
|
||||
* Devices: DPS310 baro @ 0x76, LIS2MDL compass @ 0x1E
|
||||
* I2C1: PB6 (SCL), PB7 (SDA)
|
||||
* Devices: DPS310 baro @ 0x76, IIS2MDC compass @ 0x1E
|
||||
* This single bus is also broken out externally, so it is marked
|
||||
* external to allow scanning for external compasses. The onboard baro
|
||||
* and mag are forced back to internal in px4_i2c_device_external().
|
||||
* I2C4: External bus - PD12 (SCL), PD13 (SDA)
|
||||
*/
|
||||
|
||||
constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = {
|
||||
initI2CBusInternal(1),
|
||||
initI2CBusExternal(1),
|
||||
initI2CBusExternal(4),
|
||||
};
|
||||
|
||||
bool px4_i2c_device_external(const uint32_t device_id)
|
||||
{
|
||||
// The onboard baro and mag are on I2C1, which is marked external because
|
||||
// the same bus is also broken out externally. Keep these known onboard
|
||||
// devices classified as internal.
|
||||
|
||||
// DPS310 baro @ 0x76 on I2C1
|
||||
device::Device::DeviceId device_id_baro{};
|
||||
device_id_baro.devid_s.bus_type = device::Device::DeviceBusType_I2C;
|
||||
device_id_baro.devid_s.bus = 1;
|
||||
device_id_baro.devid_s.address = 0x76;
|
||||
device_id_baro.devid_s.devtype = DRV_BARO_DEVTYPE_DPS310;
|
||||
|
||||
if (device_id_baro.devid == device_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// IIS2MDC mag @ 0x1E on I2C1
|
||||
device::Device::DeviceId device_id_mag{};
|
||||
device_id_mag.devid_s.bus_type = device::Device::DeviceBusType_I2C;
|
||||
device_id_mag.devid_s.bus = 1;
|
||||
device_id_mag.devid_s.address = 0x1E;
|
||||
device_id_mag.devid_s.devtype = DRV_MAG_DEVTYPE_IIS2MDC;
|
||||
|
||||
if (device_id_mag.devid == device_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
device::Device::DeviceId dev_id{};
|
||||
dev_id.devid = device_id;
|
||||
return px4_i2c_bus_external(dev_id.devid_s.bus);
|
||||
}
|
||||
Reference in new issue
Block a user