AP_HAL: Device: add bus_type field

Sometimes it's necessary to know the type of bus to make some decisions where
AP_HAL::Device abstraction is used.
This commit is contained in:
Gustavo Jose de Sousa 2016-06-24 14:17:01 -03:00 committed by Lucas De Marchi
parent 7edb6e76f0
commit 4693501d9d
3 changed files with 15 additions and 0 deletions

View File

@ -26,6 +26,11 @@
*/
class AP_HAL::Device {
public:
enum BusType {
I2C,
SPI,
};
enum Speed {
SPEED_HIGH,
SPEED_LOW,
@ -33,6 +38,12 @@ public:
typedef void PeriodicHandle;
const enum BusType bus_type;
Device(enum BusType type)
: bus_type(type)
{ }
virtual ~Device() { }
/*

View File

@ -27,6 +27,8 @@ namespace AP_HAL {
class I2CDevice : public Device {
public:
I2CDevice() : Device(I2C) { }
virtual ~I2CDevice() { }
/*

View File

@ -27,6 +27,8 @@ namespace AP_HAL {
class SPIDevice : public Device {
public:
SPIDevice() : Device(SPI) { }
virtual ~SPIDevice() { }
/* Device implementation */