AP_HAL: move get_device() method from AP_HAL_Linux

This way it's possible to use the method in platform-independent code
without a need to up cast.
This commit is contained in:
Lucas De Marchi 2018-03-25 22:18:24 -07:00
parent 4f2498947b
commit 2000e17646
2 changed files with 15 additions and 8 deletions

View File

@ -17,6 +17,7 @@
#pragma once
#include <inttypes.h>
#include <vector>
#include "AP_HAL_Namespace.h"
#include "Device.h"
@ -75,6 +76,19 @@ public:
uint32_t bus_clock=400000,
bool use_smbus = false,
uint32_t timeout_ms=4) = 0;
/*
* Get device by looking up the I2C bus on the buses from @devpaths.
*
* Each string in @devpaths are possible locations for the bus. How the
* strings are implemented are HAL-specific. On Linux this is the info
* returned by 'udevadm info -q path /dev/i2c-X'. The first I2C bus
* matching a prefix in @devpaths is used to create a I2CDevice object.
*/
virtual OwnPtr<I2CDevice> get_device(std::vector<const char *> devpaths,
uint8_t address) {
// Not implemented
return nullptr;
}
};
}

View File

@ -94,15 +94,8 @@ public:
I2CDeviceManager();
/*
* Get device by looking up the I2C bus on the buses from @devpaths.
*
* Each string in @devpaths are possible locations for the bus as
* returned by 'udevadm info -q path /dev/i2c-X'. The first I2C bus
* matching a prefix in @devpaths is returned.
*/
AP_HAL::OwnPtr<AP_HAL::I2CDevice> get_device(
std::vector<const char *> devpaths, uint8_t address);
std::vector<const char *> devpaths, uint8_t address) override;
/* AP_HAL::I2CDeviceManager implementation */
AP_HAL::OwnPtr<AP_HAL::I2CDevice> get_device(uint8_t bus, uint8_t address,