diff --git a/libraries/AP_HAL_Linux/I2CDevice.cpp b/libraries/AP_HAL_Linux/I2CDevice.cpp index 84a1cbcd16..c11fffac66 100644 --- a/libraries/AP_HAL_Linux/I2CDevice.cpp +++ b/libraries/AP_HAL_Linux/I2CDevice.cpp @@ -137,6 +137,14 @@ int I2CBus::open(uint8_t n) return fd; } +I2CDevice::I2CDevice(I2CBus &bus, uint8_t address) + : _bus(bus) + , _address(address) +{ + set_device_bus(bus.bus); + set_device_address(address); +} + I2CDevice::~I2CDevice() { // Unregister itself from the I2CDeviceManager diff --git a/libraries/AP_HAL_Linux/I2CDevice.h b/libraries/AP_HAL_Linux/I2CDevice.h index 2ca12e66b0..cede381460 100644 --- a/libraries/AP_HAL_Linux/I2CDevice.h +++ b/libraries/AP_HAL_Linux/I2CDevice.h @@ -38,11 +38,7 @@ public: /* AP_HAL::I2CDevice implementation */ - I2CDevice(I2CBus &bus, uint8_t address) - : _bus(bus) - , _address(address) - { - } + I2CDevice(I2CBus &bus, uint8_t address); ~I2CDevice(); diff --git a/libraries/AP_HAL_Linux/SPIDevice.cpp b/libraries/AP_HAL_Linux/SPIDevice.cpp index 811ba04c5e..ef548ddcee 100644 --- a/libraries/AP_HAL_Linux/SPIDevice.cpp +++ b/libraries/AP_HAL_Linux/SPIDevice.cpp @@ -212,6 +212,9 @@ SPIDevice::SPIDevice(SPIBus &bus, SPIDesc &device_desc) : _bus(bus) , _desc(device_desc) { + set_device_bus(_bus.bus); + set_device_address(_desc.subdev); + if (_desc.cs_pin != SPI_CS_KERNEL) { _cs = hal.gpio->channel(_desc.cs_pin); if (!_cs) {