PX4 Firmware
PX4 Autopilot Software http://px4.io
INA226 Class Reference
Inheritance diagram for INA226:
Collaboration diagram for INA226:

Public Member Functions

 INA226 (int bus=INA226_BUS_DEFAULT, int address=INA226_BASEADDR)
 
virtual ~INA226 ()
 
virtual int init ()
 
void print_info ()
 Diagnostics - print some basic information about the driver. More...
 

Protected Member Functions

virtual int probe ()
 

Private Member Functions

int read (uint8_t address)
 Test whetpower_monitorhe device supported by the driver is present at a specific address. More...
 
int write (uint8_t address, uint16_t data)
 
void start ()
 Initialise the automatic measurement state machine and start it. More...
 
void stop ()
 Stop the automatic measurement state machine. More...
 
void Run () override
 Perform a poll cycle; collect from the previous measurement and start a new one. More...
 
int measure ()
 
int collect ()
 

Private Attributes

bool _sensor_ok {false}
 
int _measure_interval {0}
 
bool _collect_phase {false}
 
orb_advert_t _power_monitor_topic {nullptr}
 
perf_counter_t _sample_perf
 
perf_counter_t _comms_errors
 
int16_t _bus_volatage {0}
 
int16_t _power {-1}
 
int16_t _current {-1}
 
int16_t _shunt {0}
 
int16_t _cal {0}
 
bool _mode_trigged {false}
 
float _max_current {MAX_CURRENT}
 
float _rshunt {INA226_SHUNT}
 
uint16_t _config {INA226_CONFIG}
 
float _current_lsb {_max_current / DN_MAX}
 
float _power_lsb {25.0f * _current_lsb}
 

Detailed Description

Definition at line 146 of file ina226.cpp.

Constructor & Destructor Documentation

◆ INA226()

INA226::INA226 ( int  bus = INA226_BUS_DEFAULT,
int  address = INA226_BASEADDR 
)

Definition at line 224 of file ina226.cpp.

References _config, _current_lsb, _max_current, _mode_trigged, _power_lsb, _rshunt, DN_MAX, INA226_CONFIG, INA226_MODE_MASK, INA226_MODE_SHIFTS, INA226_MODE_SHUNT_BUS_TRIG, INA226_SHUNT, MAX_CURRENT, param_find(), param_get(), and PARAM_INVALID.

Referenced by ina226::start_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~INA226()

INA226::~INA226 ( )
virtual

Definition at line 262 of file ina226.cpp.

References _comms_errors, _sample_perf, perf_free(), and stop().

Here is the call graph for this function:

Member Function Documentation

◆ collect()

int INA226::collect ( )
private

◆ init()

int INA226::init ( )
virtual

Definition at line 297 of file ina226.cpp.

References _cal, _config, _current_lsb, _mode_trigged, _sensor_ok, INA226_BASEADDR, INA226_CONST, INA226_REG_CALIBRATION, INA226_REG_CONFIGURATION, INA226_RST, INA226_SHUNT, ToneAlarmInterface::init(), OK, start(), and write().

Referenced by ina226::start_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ measure()

int INA226::measure ( )
private

Definition at line 360 of file ina226.cpp.

References _comms_errors, _config, _mode_trigged, INA226_REG_CONFIGURATION, OK, perf_count(), and write().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_info()

void INA226::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 490 of file ina226.cpp.

References _comms_errors, _measure_interval, _sample_perf, and perf_print_counter().

Referenced by ina226::info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe()

int INA226::probe ( )
protectedvirtual

Definition at line 332 of file ina226.cpp.

References _comms_errors, INA226_MFG_DIE, INA226_MFG_DIEID, INA226_MFG_ID, INA226_MFG_ID_TI, OK, perf_count(), and read().

Here is the call graph for this function:

◆ read()

int INA226::read ( uint8_t  address)
private

Test whetpower_monitorhe device supported by the driver is present at a specific address.

Parameters
addressThe I2C bus address to read or write.
Returns
.

Definition at line 272 of file ina226.cpp.

References _comms_errors, data, OK, perf_count(), and swap16.

Referenced by collect(), and probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Run()

void INA226::Run ( )
overrideprivate

Perform a poll cycle; collect from the previous measurement and start a new one.

Definition at line 452 of file ina226.cpp.

References _collect_phase, _measure_interval, _mode_trigged, collect(), INA226_CONVERSION_INTERVAL, measure(), OK, and start().

Here is the call graph for this function:

◆ start()

void INA226::start ( )
private

Initialise the automatic measurement state machine and start it.

Note
This function is called at open and error time. It might make sense to make it more aggressive about resetting the bus in case of errors.

Definition at line 432 of file ina226.cpp.

References _collect_phase, _measure_interval, and INA226_CONVERSION_INTERVAL.

Referenced by init(), and Run().

Here is the caller graph for this function:

◆ stop()

void INA226::stop ( )
private

Stop the automatic measurement state machine.

Definition at line 446 of file ina226.cpp.

Referenced by ~INA226().

Here is the caller graph for this function:

◆ write()

int INA226::write ( uint8_t  address,
uint16_t  data 
)
private

Definition at line 290 of file ina226.cpp.

References data.

Referenced by init(), and measure().

Here is the caller graph for this function:

Member Data Documentation

◆ _bus_volatage

int16_t INA226::_bus_volatage {0}
private

Definition at line 172 of file ina226.cpp.

Referenced by collect().

◆ _cal

int16_t INA226::_cal {0}
private

Definition at line 176 of file ina226.cpp.

Referenced by init().

◆ _collect_phase

bool INA226::_collect_phase {false}
private

Definition at line 165 of file ina226.cpp.

Referenced by Run(), and start().

◆ _comms_errors

perf_counter_t INA226::_comms_errors
private

Definition at line 170 of file ina226.cpp.

Referenced by collect(), measure(), print_info(), probe(), read(), and ~INA226().

◆ _config

uint16_t INA226::_config {INA226_CONFIG}
private

Definition at line 181 of file ina226.cpp.

Referenced by INA226(), init(), and measure().

◆ _current

int16_t INA226::_current {-1}
private

Definition at line 174 of file ina226.cpp.

Referenced by collect().

◆ _current_lsb

float INA226::_current_lsb {_max_current / DN_MAX}
private

Definition at line 182 of file ina226.cpp.

Referenced by collect(), INA226(), and init().

◆ _max_current

float INA226::_max_current {MAX_CURRENT}
private

Definition at line 179 of file ina226.cpp.

Referenced by INA226().

◆ _measure_interval

int INA226::_measure_interval {0}
private

Definition at line 164 of file ina226.cpp.

Referenced by print_info(), Run(), and start().

◆ _mode_trigged

bool INA226::_mode_trigged {false}
private

Definition at line 177 of file ina226.cpp.

Referenced by INA226(), init(), measure(), and Run().

◆ _power

int16_t INA226::_power {-1}
private

Definition at line 173 of file ina226.cpp.

Referenced by collect().

◆ _power_lsb

float INA226::_power_lsb {25.0f * _current_lsb}
private

Definition at line 183 of file ina226.cpp.

Referenced by collect(), and INA226().

◆ _power_monitor_topic

orb_advert_t INA226::_power_monitor_topic {nullptr}
private

Definition at line 167 of file ina226.cpp.

Referenced by collect().

◆ _rshunt

float INA226::_rshunt {INA226_SHUNT}
private

Definition at line 180 of file ina226.cpp.

Referenced by INA226().

◆ _sample_perf

perf_counter_t INA226::_sample_perf
private

Definition at line 169 of file ina226.cpp.

Referenced by collect(), print_info(), and ~INA226().

◆ _sensor_ok

bool INA226::_sensor_ok {false}
private

Definition at line 163 of file ina226.cpp.

Referenced by init().

◆ _shunt

int16_t INA226::_shunt {0}
private

Definition at line 175 of file ina226.cpp.

Referenced by collect().


The documentation for this class was generated from the following file: