Browse Source

BattMon: Bebop always uses bebop batt monitor

master
Randy Mackay 10 years ago
parent
commit
9482578c60
  1. 46
      libraries/AP_BattMonitor/AP_BattMonitor.cpp
  2. 3
      libraries/AP_BattMonitor/AP_BattMonitor.h

46
libraries/AP_BattMonitor/AP_BattMonitor.cpp

@ -133,33 +133,37 @@ AP_BattMonitor::init() @@ -133,33 +133,37 @@ AP_BattMonitor::init()
return;
}
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
// force monitor for bebop
_monitoring[0] = BattMonitor_TYPE_BEBOP;
#endif
// create each instance
for (uint8_t instance=0; instance<AP_BATT_MONITOR_MAX_INSTANCES; instance++) {
uint8_t monitor_type = _monitoring[instance];
// check for analog instance
#if CONFIG_HAL_BOARD_TYPE == CONFIG_HAL_BOARD_TYPE_LINUX && \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
if (monitor_type == BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT) {
state[instance].instance = instance;
drivers[instance] = new AP_BattMonitor_Bebop(*this, instance, state[instance]);
_num_instances++;
} else
#endif
if (monitor_type == BattMonitor_TYPE_ANALOG_VOLTAGE_ONLY || monitor_type == BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT) {
state[instance].instance = instance;
drivers[instance] = new AP_BattMonitor_Analog(*this, instance, state[instance]);
_num_instances++;
// check for SMBus
} else if (monitor_type == BattMonitor_TYPE_SMBUS) {
state[instance].instance = instance;
switch (monitor_type) {
case BattMonitor_TYPE_ANALOG_VOLTAGE_ONLY:
case BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT:
state[instance].instance = instance;
drivers[instance] = new AP_BattMonitor_Analog(*this, instance, state[instance]);
_num_instances++;
break;
case BattMonitor_TYPE_SMBUS:
state[instance].instance = instance;
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
drivers[instance] = new AP_BattMonitor_SMBus_PX4(*this, instance, state[instance]);
drivers[instance] = new AP_BattMonitor_SMBus_PX4(*this, instance, state[instance]);
#else
drivers[instance] = new AP_BattMonitor_SMBus_I2C(*this, instance, state[instance]);
drivers[instance] = new AP_BattMonitor_SMBus_I2C(*this, instance, state[instance]);
#endif
_num_instances++;
break;
case BattMonitor_TYPE_BEBOP:
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
state[instance].instance = instance;
drivers[instance] = new AP_BattMonitor_Bebop(*this, instance, state[instance]);
_num_instances++;
#endif
_num_instances++;
break;
}
// call init function for each backend

3
libraries/AP_BattMonitor/AP_BattMonitor.h

@ -40,7 +40,8 @@ public: @@ -40,7 +40,8 @@ public:
BattMonitor_TYPE_NONE = 0,
BattMonitor_TYPE_ANALOG_VOLTAGE_ONLY = 3,
BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT = 4,
BattMonitor_TYPE_SMBUS = 5
BattMonitor_TYPE_SMBUS = 5,
BattMonitor_TYPE_BEBOP = 6
};
// The BattMonitor_State structure is filled in by the backend driver

Loading…
Cancel
Save