From 4ea565e4edf4ded5c3afa7aa24b6cc81e654e367 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Tue, 2 Jun 2020 16:44:38 +0900 Subject: [PATCH] AP_BattMonitor: Maxell driver inherits from SMBus_Generic --- libraries/AP_BattMonitor/AP_BattMonitor.cpp | 6 ++++++ libraries/AP_BattMonitor/AP_BattMonitor.h | 2 ++ libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h | 1 + libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h | 9 +++++++++ 4 files changed, 18 insertions(+) create mode 100644 libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.cpp b/libraries/AP_BattMonitor/AP_BattMonitor.cpp index 856f642aec..84a78df7f9 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor.cpp @@ -121,6 +121,12 @@ AP_BattMonitor::init() hal.i2c_mgr->get_device(_params[instance]._i2c_bus, AP_BATTMONITOR_SMBUS_I2C_ADDR, 100000, true, 20)); break; + case AP_BattMonitor_Params::BattMonitor_TYPE_MAXELL: + _params[instance]._i2c_bus.set_default(AP_BATTMONITOR_SMBUS_BUS_EXTERNAL); + drivers[instance] = new AP_BattMonitor_SMBus_Maxell(*this, state[instance], _params[instance], + hal.i2c_mgr->get_device(_params[instance]._i2c_bus, AP_BATTMONITOR_SMBUS_I2C_ADDR, + 100000, true, 20)); + break; case AP_BattMonitor_Params::BattMonitor_TYPE_SUI3: _params[instance]._i2c_bus.set_default(AP_BATTMONITOR_SMBUS_BUS_INTERNAL), drivers[instance] = new AP_BattMonitor_SMBus_SUI(*this, state[instance], _params[instance], diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.h b/libraries/AP_BattMonitor/AP_BattMonitor.h index 9f8b00fdc1..885b9678c3 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor.h @@ -33,6 +33,7 @@ class AP_BattMonitor_Analog; class AP_BattMonitor_SMBus; class AP_BattMonitor_SMBus_Solo; class AP_BattMonitor_SMBus_Generic; +class AP_BattMonitor_SMBus_Maxell; class AP_BattMonitor_UAVCAN; class AP_BattMonitor @@ -42,6 +43,7 @@ class AP_BattMonitor friend class AP_BattMonitor_SMBus; friend class AP_BattMonitor_SMBus_Solo; friend class AP_BattMonitor_SMBus_Generic; + friend class AP_BattMonitor_SMBus_Maxell; friend class AP_BattMonitor_UAVCAN; friend class AP_BattMonitor_Sum; friend class AP_BattMonitor_FuelFlow; diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h index 3b9613b4d2..2993c7dfff 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h @@ -100,3 +100,4 @@ protected: // include specific implementations #include "AP_BattMonitor_SMBus_Solo.h" #include "AP_BattMonitor_SMBus_Generic.h" +#include "AP_BattMonitor_SMBus_Maxell.h" diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h new file mode 100644 index 0000000000..3df29dd402 --- /dev/null +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h @@ -0,0 +1,9 @@ +#pragma once + +#include "AP_BattMonitor_SMBus_Generic.h" + +class AP_BattMonitor_SMBus_Maxell : public AP_BattMonitor_SMBus_Generic +{ + using AP_BattMonitor_SMBus_Generic::AP_BattMonitor_SMBus_Generic; + +};