PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <string.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/getopt.h>
#include <drivers/device/i2c.h>
#include <lib/parameters/param.h>
#include <lib/perf/perf_counter.h>
#include <drivers/drv_hrt.h>
#include <uORB/uORB.h>
#include <uORB/topics/power_monitor.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
Go to the source code of this file.
Classes | |
class | INA226 |
Namespaces | |
ina226 | |
Local functions in support of the shell command. | |
Functions | |
__EXPORT int | ina226_main (int argc, char *argv[]) |
int | ina226::start () |
Attempt to start driver on all available I2C busses. More... | |
int | ina226::start_bus (int i2c_bus) |
Start the driver on a specific bus. More... | |
int | ina226::stop () |
Stop the driver. More... | |
int | ina226::info () |
Print a little info about the driver. More... | |
static void | ina2262_usage () |
Variables | |
INA226 * | ina226::g_dev |
Driver for the I2C attached INA226
Definition in file ina226.cpp.
#define DN_MAX 32768.0f /* 2^15 */ |
Definition at line 139 of file ina226.cpp.
Referenced by INA226::INA226().
#define INA226_AFF (1 << 4) |
Definition at line 128 of file ina226.cpp.
#define INA226_APOL (1 << 1) |
Definition at line 125 of file ina226.cpp.
#define INA226_AVERAGES_1 (0 << INA226_AVERAGES_SHIFTS) |
Definition at line 109 of file ina226.cpp.
#define INA226_AVERAGES_1024 (7 << INA226_AVERAGES_SHIFTS) |
Definition at line 116 of file ina226.cpp.
#define INA226_AVERAGES_128 (4 << INA226_AVERAGES_SHIFTS) |
Definition at line 113 of file ina226.cpp.
#define INA226_AVERAGES_16 (2 << INA226_AVERAGES_SHIFTS) |
Definition at line 111 of file ina226.cpp.
#define INA226_AVERAGES_256 (5 << INA226_AVERAGES_SHIFTS) |
Definition at line 114 of file ina226.cpp.
#define INA226_AVERAGES_4 (1 << INA226_AVERAGES_SHIFTS) |
Definition at line 110 of file ina226.cpp.
#define INA226_AVERAGES_512 (6 << INA226_AVERAGES_SHIFTS) |
Definition at line 115 of file ina226.cpp.
#define INA226_AVERAGES_64 (3 << INA226_AVERAGES_SHIFTS) |
Definition at line 112 of file ina226.cpp.
#define INA226_AVERAGES_MASK (7 << INA226_AVERAGES_SHIFTS) |
Definition at line 108 of file ina226.cpp.
#define INA226_AVERAGES_SHIFTS (9) |
Definition at line 107 of file ina226.cpp.
#define INA226_BASEADDR 0x41 /* 7-bit address. 8-bit address is 0x41 */ |
Definition at line 56 of file ina226.cpp.
Referenced by INA226::init().
#define INA226_BOL (1 << 13) |
Definition at line 133 of file ina226.cpp.
#define INA226_BUL (1 << 12) |
Definition at line 132 of file ina226.cpp.
#define INA226_BUS_DEFAULT PX4_I2C_BUS_EXPANSION |
Definition at line 55 of file ina226.cpp.
Referenced by ina2262_usage(), and ina226_main().
#define INA226_CNVR (1 << 10) |
Definition at line 130 of file ina226.cpp.
#define INA226_CONFIG (INA226_MODE_SHUNT_BUS_CONT | INA226_VSHCT_588US | INA226_VBUSCT_588US | INA226_AVERAGES_64) |
Definition at line 118 of file ina226.cpp.
Referenced by INA226::INA226().
#define INA226_CONST 0.00512f /* is an internal fixed value used to ensure scaling is maintained properly */ |
Definition at line 140 of file ina226.cpp.
Referenced by INA226::init().
#define INA226_CONVERSION_INTERVAL (100000-7) /* 100 ms / 10 Hz */ |
Definition at line 137 of file ina226.cpp.
Referenced by INA226::Run(), and INA226::start().
#define INA226_CVRF (1 << 3) |
Definition at line 127 of file ina226.cpp.
#define INA226_LEN (1 << 0) |
Definition at line 124 of file ina226.cpp.
#define INA226_MFG_DIE (0x2260) |
Definition at line 71 of file ina226.cpp.
Referenced by INA226::probe().
#define INA226_MFG_DIEID (0xff) |
Definition at line 68 of file ina226.cpp.
Referenced by INA226::probe().
#define INA226_MFG_ID (0xfe) |
Definition at line 67 of file ina226.cpp.
Referenced by INA226::probe().
#define INA226_MFG_ID_TI (0x5449) |
Definition at line 70 of file ina226.cpp.
Referenced by INA226::probe().
#define INA226_MODE_ADC_OFF (4 << INA226_MODE_SHIFTS) |
Definition at line 80 of file ina226.cpp.
#define INA226_MODE_BUS_CONT (6 << INA226_MODE_SHIFTS) |
Definition at line 82 of file ina226.cpp.
#define INA226_MODE_BUS_TRIG (2 << INA226_MODE_SHIFTS) |
Definition at line 78 of file ina226.cpp.
#define INA226_MODE_MASK (7 << INA226_MODE_SHIFTS) |
Definition at line 75 of file ina226.cpp.
Referenced by INA226::INA226().
#define INA226_MODE_SHIFTS (0) |
Definition at line 74 of file ina226.cpp.
Referenced by INA226::INA226().
#define INA226_MODE_SHUNT_BUS_CONT (7 << INA226_MODE_SHIFTS) |
Definition at line 83 of file ina226.cpp.
#define INA226_MODE_SHUNT_BUS_TRIG (3 << INA226_MODE_SHIFTS) |
Definition at line 79 of file ina226.cpp.
Referenced by INA226::INA226().
#define INA226_MODE_SHUNT_CONT (5 << INA226_MODE_SHIFTS) |
Definition at line 81 of file ina226.cpp.
#define INA226_MODE_SHUNT_TRIG (1 << INA226_MODE_SHIFTS) |
Definition at line 77 of file ina226.cpp.
#define INA226_MODE_SHUTDOWN (0 << INA226_MODE_SHIFTS) |
Definition at line 76 of file ina226.cpp.
#define INA226_OVF (1 << 2) |
Definition at line 126 of file ina226.cpp.
#define INA226_POL (1 << 11) |
Definition at line 131 of file ina226.cpp.
#define INA226_RAW |
Definition at line 40 of file ina226.cpp.
#define INA226_REG_ALERTLIMIT (0x07) |
Definition at line 66 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_REG_BUSVOLTAGE (0x02) |
Definition at line 61 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_REG_CALIBRATION (0x05) |
Definition at line 64 of file ina226.cpp.
Referenced by INA226::collect(), and INA226::init().
#define INA226_REG_CONFIGURATION (0x00) |
Definition at line 59 of file ina226.cpp.
Referenced by INA226::collect(), INA226::init(), and INA226::measure().
#define INA226_REG_CURRENT (0x04) |
Definition at line 63 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_REG_MASKENABLE (0x06) |
Definition at line 65 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_REG_POWER (0x03) |
Definition at line 62 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_REG_SHUNTVOLTAGE (0x01) |
Definition at line 60 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_RST (1 << 15) |
Definition at line 120 of file ina226.cpp.
Referenced by INA226::init().
#define INA226_SHUNT 0.0005f /* Shunt is 500 uOhm */ |
Definition at line 141 of file ina226.cpp.
Referenced by INA226::INA226(), and INA226::init().
#define INA226_SOL (1 << 15) |
Definition at line 135 of file ina226.cpp.
#define INA226_SUL (1 << 14) |
Definition at line 134 of file ina226.cpp.
#define INA226_VBUSCT_1100US (4 << INA226_VBUSCT_SHIFTS) |
Definition at line 102 of file ina226.cpp.
#define INA226_VBUSCT_140US (0 << INA226_VBUSCT_SHIFTS) |
Definition at line 98 of file ina226.cpp.
#define INA226_VBUSCT_204US (1 << INA226_VBUSCT_SHIFTS) |
Definition at line 99 of file ina226.cpp.
#define INA226_VBUSCT_2116US (5 << INA226_VBUSCT_SHIFTS) |
Definition at line 103 of file ina226.cpp.
#define INA226_VBUSCT_332US (2 << INA226_VBUSCT_SHIFTS) |
Definition at line 100 of file ina226.cpp.
#define INA226_VBUSCT_4156US (6 << INA226_VBUSCT_SHIFTS) |
Definition at line 104 of file ina226.cpp.
#define INA226_VBUSCT_588US (3 << INA226_VBUSCT_SHIFTS) |
Definition at line 101 of file ina226.cpp.
#define INA226_VBUSCT_8244US (7 << INA226_VBUSCT_SHIFTS) |
Definition at line 105 of file ina226.cpp.
#define INA226_VBUSCT_MASK (7 << INA226_VBUSCT_SHIFTS) |
Definition at line 97 of file ina226.cpp.
#define INA226_VBUSCT_SHIFTS (6) |
Definition at line 96 of file ina226.cpp.
#define INA226_VSCALE 0.00125f /* LSB of voltage is 1.25 mV */ |
Definition at line 142 of file ina226.cpp.
Referenced by INA226::collect().
#define INA226_VSHCT_1100US (4 << INA226_VSHCT_SHIFTS) |
Definition at line 91 of file ina226.cpp.
#define INA226_VSHCT_140US (0 << INA226_VSHCT_SHIFTS) |
Definition at line 87 of file ina226.cpp.
#define INA226_VSHCT_204US (1 << INA226_VSHCT_SHIFTS) |
Definition at line 88 of file ina226.cpp.
#define INA226_VSHCT_2116US (5 << INA226_VSHCT_SHIFTS) |
Definition at line 92 of file ina226.cpp.
#define INA226_VSHCT_332US (2 << INA226_VSHCT_SHIFTS) |
Definition at line 89 of file ina226.cpp.
#define INA226_VSHCT_4156US (6 << INA226_VSHCT_SHIFTS) |
Definition at line 93 of file ina226.cpp.
#define INA226_VSHCT_588US (3 << INA226_VSHCT_SHIFTS) |
Definition at line 90 of file ina226.cpp.
#define INA226_VSHCT_8244US (7 << INA226_VSHCT_SHIFTS) |
Definition at line 94 of file ina226.cpp.
#define INA226_VSHCT_MASK (7 << INA226_VSHCT_SHIFTS) |
Definition at line 86 of file ina226.cpp.
#define INA226_VSHCT_SHIFTS (3) |
Definition at line 85 of file ina226.cpp.
#define MAX_CURRENT 164.0f /* 164 Amps */ |
Definition at line 138 of file ina226.cpp.
Referenced by INA226::INA226().
#define swap16 | ( | w | ) | __builtin_bswap16((w)) |
Definition at line 144 of file ina226.cpp.
Referenced by INA226::read().
|
static |
Definition at line 613 of file ina226.cpp.
References INA226_BUS_DEFAULT.
Referenced by ina226_main().
int ina226_main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 624 of file ina226.cpp.
References ina2262_usage(), INA226_BUS_DEFAULT, ina226::info(), ina226::start(), ina226::start_bus(), and ina226::stop().