mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-14 19:01:37 +08:00
i2c_spi_buses:Support devices that may change address
This commit is contained in:
committed by
Daniel Agar
parent
84066f574d
commit
f70381dfdd
@@ -642,7 +642,7 @@ void I2CSPIDriverBase::print_status()
|
|||||||
bool is_i2c_bus = _bus_option == I2CSPIBusOption::I2CExternal || _bus_option == I2CSPIBusOption::I2CInternal;
|
bool is_i2c_bus = _bus_option == I2CSPIBusOption::I2CExternal || _bus_option == I2CSPIBusOption::I2CInternal;
|
||||||
|
|
||||||
if (is_i2c_bus) {
|
if (is_i2c_bus) {
|
||||||
PX4_INFO("Running on I2C Bus %i, Address 0x%02X", _bus, _i2c_address);
|
PX4_INFO("Running on I2C Bus %i, Address 0x%02X", _bus, get_i2c_address());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PX4_INFO("Running on SPI Bus %i", _bus);
|
PX4_INFO("Running on SPI Bus %i", _bus);
|
||||||
|
|||||||
@@ -62,11 +62,13 @@ class I2CSPIInstance : public ListNode<I2CSPIInstance *>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~I2CSPIInstance() = default;
|
virtual ~I2CSPIInstance() = default;
|
||||||
|
virtual int8_t get_i2c_address() {return _i2c_address;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
I2CSPIInstance(const char *module_name, I2CSPIBusOption bus_option, int bus, uint8_t i2c_address, uint16_t type)
|
I2CSPIInstance(const char *module_name, I2CSPIBusOption bus_option, int bus, uint8_t i2c_address, uint16_t type)
|
||||||
: _module_name(module_name), _bus_option(bus_option), _bus(bus), _type(type), _i2c_address(i2c_address) {}
|
: _module_name(module_name), _bus_option(bus_option), _bus(bus), _type(type), _i2c_address(i2c_address) {}
|
||||||
|
|
||||||
|
|
||||||
friend class BusInstanceIterator;
|
friend class BusInstanceIterator;
|
||||||
friend class I2CSPIDriverBase;
|
friend class I2CSPIDriverBase;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user