LCOV - code coverage report
Current view: top level - AP_BattMonitor - AP_BattMonitor_INA2xx.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 4 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 4 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AP_Common/AP_Common.h>
       4             : #include <AP_HAL/I2CDevice.h>
       5             : #include "AP_BattMonitor_Backend.h"
       6             : #include <AP_Param/AP_Param.h>
       7             : #include <utility>
       8             : 
       9             : #if AP_BATTERY_INA2XX_ENABLED
      10             : 
      11             : class AP_BattMonitor_INA2XX : public AP_BattMonitor_Backend
      12             : {
      13             : public:
      14             :     /// Constructor
      15             :     AP_BattMonitor_INA2XX(AP_BattMonitor &mon,
      16             :                           AP_BattMonitor::BattMonitor_State &mon_state,
      17             :                           AP_BattMonitor_Params &params);
      18             : 
      19           0 :     bool has_cell_voltages() const override { return false; }
      20           0 :     bool has_temperature() const override { return has_temp; }
      21           0 :     bool has_current() const override { return true; }
      22           0 :     bool get_cycle_count(uint16_t &cycles) const override { return false; }
      23             :     bool get_temperature(float &temperature) const override;
      24             : 
      25             :     void init(void) override;
      26             :     void read() override;
      27             : 
      28             :     static const struct AP_Param::GroupInfo var_info[];
      29             : 
      30             : private:
      31             :     AP_HAL::I2CDevice *dev;
      32             : 
      33             :     enum class DevType : uint8_t {
      34             :         UNKNOWN = 0,
      35             :         INA226,
      36             :         INA228,
      37             :         INA238,
      38             :         INA231,
      39             :         INA260,
      40             :     };
      41             : 
      42             :     static const uint8_t i2c_probe_addresses[];
      43             :     uint8_t i2c_probe_next;
      44             : 
      45             :     bool configure(DevType dtype);
      46             :     bool read_word16(const uint8_t reg, int16_t& data) const;
      47             :     bool read_word24(const uint8_t reg, int32_t& data) const;
      48             :     bool write_word(const uint8_t reg, const uint16_t data) const;
      49             :     void timer(void);
      50             :     bool detect_device(void);
      51             : 
      52             :     DevType dev_type;
      53             :     uint32_t last_detect_ms;
      54             : 
      55             :     AP_Int8 i2c_bus;
      56             :     AP_Int8 i2c_address;
      57             :     AP_Float max_amps;
      58             :     AP_Float rShunt;
      59             :     uint32_t failed_reads;
      60             : 
      61             :     struct {
      62             :         uint16_t count;
      63             :         float volt_sum;
      64             :         float current_sum;
      65             :         HAL_Semaphore sem;
      66             :     } accumulate;
      67             :     float current_LSB;
      68             :     float voltage_LSB;
      69             : 
      70             :     float temperature;
      71             : 
      72             :     bool has_temp;
      73             : };
      74             : 
      75             : #endif // AP_BATTERY_INA2XX_ENABLED

Generated by: LCOV version 1.14