Device driver interface for Texas Instruments INA220 High or Low Side, Bi-Directional CURRENT/POWER MONITOR with Two-Wire Interface. More...

Detailed Description

#include <stdint.h>
#include "periph/i2c.h"
+ Include dependency graph for ina220.h:

Go to the source code of this file.

Data Structures

struct  ina220_t
 Device descriptor for INA220 sensors. More...
 

Macros

#define INA220_RESET_BIT   (0x8000)
 INA220 reset command bit (in configuration register)
 
#define INA220_BUS_VOLTAGE_SHIFT   (3)
 Location of the bus voltage in the INA220 bus voltage register.
 

Typedefs

typedef enum ina220_mode ina220_mode_t
 INA220 possible mode settings.
 
typedef enum ina220_range ina220_range_t
 Shunt voltage measurement range (PGA settings)
 
typedef enum ina220_brng ina220_brng_t
 Bus voltage measurement range.
 
typedef enum ina220_sadc ina220_sadc_t
 Shunt ADC settings. More...
 
typedef enum ina220_badc ina220_badc_t
 Bus ADC settings. More...
 

Enumerations

enum  ina220_mode {
  INA220_MODE_POWERDOWN = 0x0000, INA220_MODE_TRIGGER_SHUNT_ONLY = 0x0001, INA220_MODE_TRIGGER_BUS_ONLY = 0x0002, INA220_MODE_TRIGGER_SHUNT_BUS = 0x0003,
  INA220_MODE_ADC_DISABLE = 0x0004, INA220_MODE_CONTINUOUS_SHUNT_ONLY = 0x0005, INA220_MODE_CONTINUOUS_BUS_ONLY = 0x0006, INA220_MODE_CONTINUOUS_SHUNT_BUS = 0x0007
}
 INA220 possible mode settings. More...
 
enum  ina220_range { INA220_RANGE_40MV = 0x0000, INA220_RANGE_80MV = 0x0800, INA220_RANGE_160MV = 0x1000, INA220_RANGE_320MV = 0x1800 }
 Shunt voltage measurement range (PGA settings) More...
 
enum  ina220_brng { INA220_BRNG_16V_FSR = 0x0000, INA220_BRNG_32V_FSR = 0x0200 }
 Bus voltage measurement range. More...
 
enum  ina220_sadc {
  INA220_SADC_9BIT = 0x0000, INA220_SADC_10BIT = 0x0008, INA220_SADC_11BIT = 0x0010, INA220_SADC_12BIT = 0x0018,
  INA220_SADC_AVG_1_SAMPLE = 0x0040, INA220_SADC_AVG_2_SAMPLES = 0x0048, INA220_SADC_AVG_4_SAMPLES = 0x0050, INA220_SADC_AVG_8_SAMPLES = 0x0058,
  INA220_SADC_AVG_16_SAMPLES = 0x0060, INA220_SADC_AVG_32_SAMPLES = 0x0068, INA220_SADC_AVG_64_SAMPLES = 0x0070, INA220_SADC_AVG_128_SAMPLES = 0x0078
}
 Shunt ADC settings. More...
 
enum  ina220_badc {
  INA220_BADC_9BIT = 0x0000, INA220_BADC_10BIT = 0x0080, INA220_BADC_11BIT = 0x0100, INA220_BADC_12BIT = 0x0180,
  INA220_BADC_AVG_1_SAMPLE = 0x0400, INA220_BADC_AVG_2_SAMPLES = 0x0480, INA220_BADC_AVG_4_SAMPLES = 0x0500, INA220_BADC_AVG_8_SAMPLES = 0x0580,
  INA220_BADC_AVG_16_SAMPLES = 0x0600, INA220_BADC_AVG_32_SAMPLES = 0x0680, INA220_BADC_AVG_64_SAMPLES = 0x0700, INA220_BADC_AVG_128_SAMPLES = 0x0780
}
 Bus ADC settings. More...
 

Functions

int ina220_init (ina220_t *dev, i2c_t i2c, uint8_t address)
 Initialize a current sensor. More...
 
int ina220_set_calibration (ina220_t *dev, uint16_t calibration)
 Write to calibration register. More...
 
int ina220_set_config (ina220_t *dev, uint16_t config)
 Write to configuration register. More...
 
int ina220_read_shunt (ina220_t *dev, int16_t *voltage)
 Read shunt voltage. More...
 
int ina220_read_bus (ina220_t *dev, int16_t *voltage)
 Read bus voltage register. More...
 
int ina220_read_current (ina220_t *dev, int16_t *current)
 Read shunt current. More...
 
int ina220_read_power (ina220_t *dev, int16_t *power)
 Read power consumption. More...