AP_HAL_Linux: add get_device-ptr to HAL DeviceMananger API

This commit is contained in:
Peter Barker 2025-03-04 16:23:31 +11:00 committed by Peter Barker
parent a6794d5ec0
commit be99f5452f
3 changed files with 7 additions and 8 deletions

View File

@ -21,7 +21,6 @@
#include <AP_HAL/HAL.h>
#include <AP_HAL/I2CDevice.h>
#include <AP_HAL/utility/OwnPtr.h>
#include "Semaphores.h"

View File

@ -342,8 +342,8 @@ bool SPIDevice::adjust_periodic_callback(
}
AP_HAL::OwnPtr<AP_HAL::SPIDevice>
SPIDeviceManager::get_device(const char *name)
AP_HAL::SPIDevice *
SPIDeviceManager::get_device_ptr(const char *name)
{
SPIDesc *desc = nullptr;
@ -356,7 +356,7 @@ SPIDeviceManager::get_device(const char *name)
}
if (!desc) {
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(nullptr);
return nullptr;
}
/* Find if bus already exists */
@ -393,13 +393,13 @@ const char* SPIDeviceManager::get_device_name(uint8_t idx)
}
/* Create a new device increasing the bus reference */
AP_HAL::OwnPtr<AP_HAL::SPIDevice>
AP_HAL::SPIDevice *
SPIDeviceManager::_create_device(SPIBus &b, SPIDesc &desc) const
{
// Ensure bus is open
b.open(desc.subdev);
auto dev = AP_HAL::OwnPtr<AP_HAL::SPIDevice>(NEW_NOTHROW SPIDevice(b, desc));
auto *dev = NEW_NOTHROW SPIDevice(b, desc);
if (!dev) {
return nullptr;
}

View File

@ -110,7 +110,7 @@ public:
}
/* AP_HAL::SPIDeviceManager implementation */
AP_HAL::OwnPtr<AP_HAL::SPIDevice> get_device(const char *name) override;
AP_HAL::SPIDevice *get_device_ptr(const char *name) override;
/*
* Stop all SPI threads and block until they are finalized. This doesn't
@ -127,7 +127,7 @@ public:
protected:
void _unregister(SPIBus &b);
AP_HAL::OwnPtr<AP_HAL::SPIDevice> _create_device(SPIBus &b, SPIDesc &device_desc) const;
AP_HAL::SPIDevice *_create_device(SPIBus &b, SPIDesc &device_desc) const;
std::vector<SPIBus*> _buses;