CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Generic.h
Views: 1798
1
#pragma once
2
3
#include "AP_BattMonitor_SMBus.h"
4
5
#if AP_BATTERY_SMBUS_GENERIC_ENABLED
6
7
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
8
#define BATTMONITOR_SMBUS_NUM_CELLS_MAX 14
9
#else
10
#define BATTMONITOR_SMBUS_NUM_CELLS_MAX 12
11
#endif
12
13
class AP_BattMonitor_SMBus_Generic : public AP_BattMonitor_SMBus
14
{
15
public:
16
17
// Constructor
18
AP_BattMonitor_SMBus_Generic(AP_BattMonitor &mon,
19
AP_BattMonitor::BattMonitor_State &mon_state,
20
AP_BattMonitor_Params &params);
21
22
private:
23
24
void timer(void) override;
25
26
// check if PEC supported with the version value in SpecificationInfo() function
27
// returns true once PEC is confirmed as working or not working
28
bool check_pec_support();
29
30
uint8_t _pec_confirmed; // count of the number of times PEC has been confirmed as working
31
uint32_t _last_cell_update_us[BATTMONITOR_SMBUS_NUM_CELLS_MAX]; // system time of last successful read of cell voltage
32
uint32_t _cell_count_check_start_us; // system time we started attempting to count the number of cells
33
uint8_t _cell_count; // number of cells returning voltages
34
bool _cell_count_fixed; // true when cell count check is complete
35
};
36
37
#endif // AP_BATTERY_SMBUS_GENERIC_ENABLED
38
39