Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_INA2xx.h
Views: 1798
#pragma once12#include <AP_Common/AP_Common.h>3#include <AP_HAL/I2CDevice.h>4#include "AP_BattMonitor_Backend.h"5#include <AP_Param/AP_Param.h>6#include <utility>78#if AP_BATTERY_INA2XX_ENABLED910class AP_BattMonitor_INA2XX : public AP_BattMonitor_Backend11{12public:13/// Constructor14AP_BattMonitor_INA2XX(AP_BattMonitor &mon,15AP_BattMonitor::BattMonitor_State &mon_state,16AP_BattMonitor_Params ¶ms);1718bool has_cell_voltages() const override { return false; }19bool has_temperature() const override { return has_temp; }20bool has_current() const override { return true; }21bool get_cycle_count(uint16_t &cycles) const override { return false; }22bool get_temperature(float &temperature) const override;2324void init(void) override;25void read() override;2627static const struct AP_Param::GroupInfo var_info[];2829private:30AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;3132enum class DevType : uint8_t {33UNKNOWN = 0,34INA226,35INA228,36INA238,37INA231,38};3940static const uint8_t i2c_probe_addresses[];41uint8_t i2c_probe_next;4243bool configure(DevType dtype);44bool read_word16(const uint8_t reg, int16_t& data) const;45bool read_word24(const uint8_t reg, int32_t& data) const;46bool write_word(const uint8_t reg, const uint16_t data) const;47void timer(void);48bool detect_device(void);4950DevType dev_type;51uint32_t last_detect_ms;5253AP_Int8 i2c_bus;54AP_Int8 i2c_address;55AP_Float max_amps;56AP_Float rShunt;57uint32_t failed_reads;5859struct {60uint16_t count;61float volt_sum;62float current_sum;63HAL_Semaphore sem;64} accumulate;65float current_LSB;66float voltage_LSB;6768float temperature;6970bool has_temp;71};7273#endif // AP_BATTERY_INA2XX_ENABLED747576