mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-13 01:54:18 -03:00
AP_HAL_Linux: add get_device-ptr to HAL DeviceMananger API
This commit is contained in:
parent
a6794d5ec0
commit
be99f5452f
@ -21,7 +21,6 @@
|
||||
|
||||
#include <AP_HAL/HAL.h>
|
||||
#include <AP_HAL/I2CDevice.h>
|
||||
#include <AP_HAL/utility/OwnPtr.h>
|
||||
|
||||
#include "Semaphores.h"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user