mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-08 17:08:28 -04:00
AP_BattMonitor: support selective enable of SMBUS and fuel battery monitors
This commit is contained in:
parent
d40671b8d8
commit
943e495f34
@ -112,6 +112,7 @@ AP_BattMonitor::init()
|
|||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT:
|
||||||
drivers[instance] = new AP_BattMonitor_Analog(*this, state[instance], _params[instance]);
|
drivers[instance] = new AP_BattMonitor_Analog(*this, state[instance], _params[instance]);
|
||||||
break;
|
break;
|
||||||
|
#if HAL_BATTMON_SMBUS_ENABLE
|
||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_SOLO:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_SOLO:
|
||||||
drivers[instance] = new AP_BattMonitor_SMBus_Solo(*this, state[instance], _params[instance],
|
drivers[instance] = new AP_BattMonitor_SMBus_Solo(*this, state[instance], _params[instance],
|
||||||
hal.i2c_mgr->get_device(AP_BATTMONITOR_SMBUS_BUS_INTERNAL, AP_BATTMONITOR_SMBUS_I2C_ADDR,
|
hal.i2c_mgr->get_device(AP_BATTMONITOR_SMBUS_BUS_INTERNAL, AP_BATTMONITOR_SMBUS_I2C_ADDR,
|
||||||
@ -122,6 +123,7 @@ AP_BattMonitor::init()
|
|||||||
hal.i2c_mgr->get_device(AP_BATTMONITOR_SMBUS_BUS_EXTERNAL, AP_BATTMONITOR_SMBUS_I2C_ADDR,
|
hal.i2c_mgr->get_device(AP_BATTMONITOR_SMBUS_BUS_EXTERNAL, AP_BATTMONITOR_SMBUS_I2C_ADDR,
|
||||||
100000, true, 20));
|
100000, true, 20));
|
||||||
break;
|
break;
|
||||||
|
#endif // HAL_BATTMON_SMBUS_ENABLE
|
||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_BEBOP:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_BEBOP:
|
||||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
||||||
drivers[instance] = new AP_BattMonitor_Bebop(*this, state[instance], _params[instance]);
|
drivers[instance] = new AP_BattMonitor_Bebop(*this, state[instance], _params[instance]);
|
||||||
@ -140,12 +142,14 @@ AP_BattMonitor::init()
|
|||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_Sum:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_Sum:
|
||||||
drivers[instance] = new AP_BattMonitor_Sum(*this, state[instance], _params[instance], instance);
|
drivers[instance] = new AP_BattMonitor_Sum(*this, state[instance], _params[instance], instance);
|
||||||
break;
|
break;
|
||||||
|
#if HAL_BATTMON_FUEL_ENABLE
|
||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_FuelFlow:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_FuelFlow:
|
||||||
drivers[instance] = new AP_BattMonitor_FuelFlow(*this, state[instance], _params[instance]);
|
drivers[instance] = new AP_BattMonitor_FuelFlow(*this, state[instance], _params[instance]);
|
||||||
break;
|
break;
|
||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_FuelLevel_PWM:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_FuelLevel_PWM:
|
||||||
drivers[instance] = new AP_BattMonitor_FuelLevel_PWM(*this, state[instance], _params[instance]);
|
drivers[instance] = new AP_BattMonitor_FuelLevel_PWM(*this, state[instance], _params[instance]);
|
||||||
break;
|
break;
|
||||||
|
#endif // HAL_BATTMON_FUEL_ENABLE
|
||||||
case AP_BattMonitor_Params::BattMonitor_TYPE_NONE:
|
case AP_BattMonitor_Params::BattMonitor_TYPE_NONE:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -19,6 +19,14 @@
|
|||||||
#define AP_BATT_MONITOR_RES_EST_TC_1 0.5f
|
#define AP_BATT_MONITOR_RES_EST_TC_1 0.5f
|
||||||
#define AP_BATT_MONITOR_RES_EST_TC_2 0.1f
|
#define AP_BATT_MONITOR_RES_EST_TC_2 0.1f
|
||||||
|
|
||||||
|
#ifndef HAL_BATTMON_SMBUS_ENABLE
|
||||||
|
#define HAL_BATTMON_SMBUS_ENABLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAL_BATTMON_FUEL_ENABLE
|
||||||
|
#define HAL_BATTMON_FUEL_ENABLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// declare backend class
|
// declare backend class
|
||||||
class AP_BattMonitor_Backend;
|
class AP_BattMonitor_Backend;
|
||||||
class AP_BattMonitor_Analog;
|
class AP_BattMonitor_Analog;
|
||||||
|
Loading…
Reference in New Issue
Block a user