mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-12 10:53:59 -04:00
AP_HAL_ChibiOS: add get_device_ptr to HAL I2CDevice API
This commit is contained in:
parent
061f3825a7
commit
97e87dfcdb
@ -449,18 +449,17 @@ bool I2CDevice::adjust_periodic_callback(AP_HAL::Device::PeriodicHandle h, uint3
|
||||
return bus.adjust_timer(h, period_usec);
|
||||
}
|
||||
|
||||
AP_HAL::OwnPtr<AP_HAL::I2CDevice>
|
||||
I2CDeviceManager::get_device(uint8_t bus, uint8_t address,
|
||||
uint32_t bus_clock,
|
||||
bool use_smbus,
|
||||
uint32_t timeout_ms)
|
||||
AP_HAL::I2CDevice *
|
||||
I2CDeviceManager::get_device_ptr(uint8_t bus, uint8_t address,
|
||||
uint32_t bus_clock,
|
||||
bool use_smbus,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
bus -= HAL_I2C_BUS_BASE;
|
||||
if (bus >= ARRAY_SIZE(I2CD)) {
|
||||
return AP_HAL::OwnPtr<AP_HAL::I2CDevice>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
auto dev = AP_HAL::OwnPtr<AP_HAL::I2CDevice>(NEW_NOTHROW I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms));
|
||||
return dev;
|
||||
return NEW_NOTHROW I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -126,10 +126,12 @@ public:
|
||||
return static_cast<I2CDeviceManager*>(i2c_mgr);
|
||||
}
|
||||
|
||||
AP_HAL::OwnPtr<AP_HAL::I2CDevice> get_device(uint8_t bus, uint8_t address,
|
||||
uint32_t bus_clock=400000,
|
||||
bool use_smbus = false,
|
||||
uint32_t timeout_ms=4) override;
|
||||
/* Get a pointer to a newly-allocated I2CDevice handle. Lifetime
|
||||
* is externally handled */
|
||||
AP_HAL::I2CDevice *get_device_ptr(uint8_t bus, uint8_t address,
|
||||
uint32_t bus_clock=400000,
|
||||
bool use_smbus = false,
|
||||
uint32_t timeout_ms=4) override;
|
||||
|
||||
/*
|
||||
get mask of bus numbers for all configured I2C buses
|
||||
|
Loading…
Reference in New Issue
Block a user