From 15ff7606013e6c4066c8c6173a543cfcbe43068f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jun 2018 13:09:31 +1000 Subject: [PATCH] HAL_Linux: implement I2C bus masks --- libraries/AP_HAL_Linux/I2CDevice.cpp | 24 ++++++++++++++++++++++++ libraries/AP_HAL_Linux/I2CDevice.h | 15 +++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/libraries/AP_HAL_Linux/I2CDevice.cpp b/libraries/AP_HAL_Linux/I2CDevice.cpp index fc50971531..8d679c535e 100644 --- a/libraries/AP_HAL_Linux/I2CDevice.cpp +++ b/libraries/AP_HAL_Linux/I2CDevice.cpp @@ -417,4 +417,28 @@ void I2CDeviceManager::teardown() } } +/* + get mask of bus numbers for all configured I2C buses +*/ +uint32_t I2CDeviceManager::get_bus_mask(void) const +{ + return HAL_LINUX_I2C_BUS_MASK; +} + +/* + get mask of bus numbers for all configured internal I2C buses +*/ +uint32_t I2CDeviceManager::get_bus_mask_internal(void) const +{ + return HAL_LINUX_I2C_INTERNAL_BUS_MASK; +} + +/* + get mask of bus numbers for all configured external I2C buses +*/ +uint32_t I2CDeviceManager::get_bus_mask_external(void) const +{ + return HAL_LINUX_I2C_EXTERNAL_BUS_MASK; +} + } diff --git a/libraries/AP_HAL_Linux/I2CDevice.h b/libraries/AP_HAL_Linux/I2CDevice.h index 1acacca2fc..d26d5860e1 100644 --- a/libraries/AP_HAL_Linux/I2CDevice.h +++ b/libraries/AP_HAL_Linux/I2CDevice.h @@ -110,6 +110,21 @@ public: */ void teardown(); + /* + get mask of bus numbers for all configured I2C buses + */ + uint32_t get_bus_mask(void) const override; + + /* + get mask of bus numbers for all configured external I2C buses + */ + uint32_t get_bus_mask_external(void) const override; + + /* + get mask of bus numbers for all configured internal I2C buses + */ + uint32_t get_bus_mask_internal(void) const override; + protected: void _unregister(I2CBus &b); AP_HAL::OwnPtr _create_device(I2CBus &b, uint8_t address) const;