Browse Source

HAL_Chibios: prevent creation of i2c devices on invalid bus

master
Andrew Tridgell 7 years ago
parent
commit
9812fc9574
  1. 3
      libraries/AP_HAL_ChibiOS/I2CDevice.cpp

3
libraries/AP_HAL_ChibiOS/I2CDevice.cpp

@ -190,6 +190,9 @@ bool I2CDevice::adjust_periodic_callback(AP_HAL::Device::PeriodicHandle h, uint3 @@ -190,6 +190,9 @@ bool I2CDevice::adjust_periodic_callback(AP_HAL::Device::PeriodicHandle h, uint3
AP_HAL::OwnPtr<AP_HAL::I2CDevice>
I2CDeviceManager::get_device(uint8_t bus, uint8_t address)
{
if (bus >= ARRAY_SIZE(I2CD)) {
return AP_HAL::OwnPtr<AP_HAL::I2CDevice>(nullptr);
}
auto dev = AP_HAL::OwnPtr<AP_HAL::I2CDevice>(new I2CDevice(bus, address));
return dev;
}

Loading…
Cancel
Save