Loading...
Searching...
No Matches
ina2xx.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Eistec AB
3 * 2019 Otto-von-Guericke-Universität Magdeburg
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
47#ifndef INA2XX_H
48#define INA2XX_H
49
50#include <stdint.h>
51
52#include "periph/i2c.h"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
71
103
135
145
153
172
176typedef struct {
178 uint8_t addr;
179 uint16_t config;
180 uint16_t rshunt_mohm;
183
187typedef struct {
189} ina2xx_t;
190
206int ina2xx_init(ina2xx_t *dev, const ina2xx_params_t *params);
207
217int ina2xx_read_shunt(const ina2xx_t *dev, int16_t *voltage);
218
231int ina2xx_read_bus(const ina2xx_t *dev, uint16_t *voltage);
232
242int ina2xx_read_current(const ina2xx_t *dev, int32_t *current);
243
253int ina2xx_read_power(const ina2xx_t *dev, uint32_t *power);
254
255#ifdef __cplusplus
256}
257#endif
258
259#endif /* INA2XX_H */
enum ina2xx_mode ina2xx_mode_t
INA2XX possible mode settings.
int ina2xx_read_bus(const ina2xx_t *dev, uint16_t *voltage)
Read bus voltage in mV.
int ina2xx_read_current(const ina2xx_t *dev, int32_t *current)
Read shunt current in E-05 A.
ina2xx_pga
Shunt voltage measurement range (PGA settings)
Definition ina2xx.h:139
enum ina2xx_badc ina2xx_badc_t
Bus ADC settings.
enum ina2xx_i_range ina2xx_i_range_t
Current measurement range.
ina2xx_mode
INA2XX possible mode settings.
Definition ina2xx.h:61
ina2xx_i_range
Current measurement range.
Definition ina2xx.h:164
enum ina2xx_sadc ina2xx_sadc_t
Shunt ADC settings.
ina2xx_sadc
Shunt ADC settings.
Definition ina2xx.h:77
int ina2xx_read_shunt(const ina2xx_t *dev, int16_t *voltage)
Read shunt voltage in E-05 V.
int ina2xx_init(ina2xx_t *dev, const ina2xx_params_t *params)
Initialize a current sensor.
ina2xx_brng
Bus voltage measurement range.
Definition ina2xx.h:149
enum ina2xx_pga ina2xx_pga_t
Shunt voltage measurement range (PGA settings)
int ina2xx_read_power(const ina2xx_t *dev, uint32_t *power)
Read power consumption in E-04 W.
ina2xx_badc
Bus ADC settings.
Definition ina2xx.h:109
enum ina2xx_brng ina2xx_brng_t
Bus voltage measurement range.
@ INA2XX_SHUNT_RANGE_320MV
+/- 320 mV range, default
Definition ina2xx.h:143
@ INA2XX_SHUNT_RANGE_40MV
+/- 40 mV range
Definition ina2xx.h:140
@ INA2XX_SHUNT_RANGE_160MV
+/- 160 mV range
Definition ina2xx.h:142
@ INA2XX_SHUNT_RANGE_80MV
+/- 80 mV range
Definition ina2xx.h:141
@ INA2XX_MODE_TRIGGER_SHUNT_BUS
Shunt and Bus, Triggered.
Definition ina2xx.h:65
@ INA2XX_MODE_CONTINUOUS_SHUNT_BUS
Shunt and Bus, Continuous, default.
Definition ina2xx.h:69
@ INA2XX_MODE_CONTINUOUS_BUS_ONLY
Bus Voltage, Continuous.
Definition ina2xx.h:68
@ INA2XX_MODE_TRIGGER_BUS_ONLY
Bus Voltage, Triggered.
Definition ina2xx.h:64
@ INA2XX_MODE_TRIGGER_SHUNT_ONLY
Shunt Voltage, Triggered.
Definition ina2xx.h:63
@ INA2XX_MODE_CONTINUOUS_SHUNT_ONLY
Shunt Voltage, Continuous.
Definition ina2xx.h:67
@ INA2XX_MODE_ADC_DISABLE
ADC Off (disabled)
Definition ina2xx.h:66
@ INA2XX_MODE_POWERDOWN
Power down.
Definition ina2xx.h:62
@ INA2XX_CURRENT_RANGE_655_MA
±655.36 mA, 0.02mA resolution
Definition ina2xx.h:166
@ INA2XX_CURRENT_RANGE_10485_MA
±10485.76 mA, 0.32mA resolution
Definition ina2xx.h:170
@ INA2XX_CURRENT_RANGE_1310_MA
±1310.72 mA, 0.04mA resolution
Definition ina2xx.h:167
@ INA2XX_CURRENT_RANGE_2621_MA
±2621.44 mA, 0.08mA resolution
Definition ina2xx.h:168
@ INA2XX_CURRENT_RANGE_327_MA
±327.68 mA, 0.01mA resolution
Definition ina2xx.h:165
@ INA2XX_CURRENT_RANGE_5242_MA
±5242.88 mA, 0.16mA resolution
Definition ina2xx.h:169
@ INA2XX_SADC_11BIT
11 bit resolution, 276 us conversion time
Definition ina2xx.h:83
@ INA2XX_SADC_AVG_4_SAMPLES
4 sample average, 2.13 ms conversion time
Definition ina2xx.h:91
@ INA2XX_SADC_9BIT
9 bit resolution, 84 us conversion time
Definition ina2xx.h:79
@ INA2XX_SADC_AVG_1_SAMPLE
12 bit resolution, 532 us conversion time, same as INA2XX_SADC_12BIT
Definition ina2xx.h:87
@ INA2XX_SADC_AVG_2_SAMPLES
2 sample average, 1.06 ms conversion time
Definition ina2xx.h:89
@ INA2XX_SADC_AVG_16_SAMPLES
16 sample average, 8.51 ms conversion time
Definition ina2xx.h:95
@ INA2XX_SADC_AVG_128_SAMPLES
128 sample average, 68.10 ms conversion time
Definition ina2xx.h:101
@ INA2XX_SADC_AVG_8_SAMPLES
8 sample average, 4.26 ms conversion time
Definition ina2xx.h:93
@ INA2XX_SADC_10BIT
10 bit resolution, 148 us conversion time
Definition ina2xx.h:81
@ INA2XX_SADC_12BIT
12 bit resolution, 532 us conversion time, default
Definition ina2xx.h:85
@ INA2XX_SADC_AVG_32_SAMPLES
32 sample average, 17.02 ms conversion time
Definition ina2xx.h:97
@ INA2XX_SADC_AVG_64_SAMPLES
64 sample average, 34.05 ms conversion time
Definition ina2xx.h:99
@ INA2XX_BUS_RANGE_16V
16 V bus voltage full scale range
Definition ina2xx.h:150
@ INA2XX_BUS_RANGE_32V
32 V bus voltage full scale range, default.
Definition ina2xx.h:151
@ INA2XX_BADC_AVG_32_SAMPLES
32 sample average, 17.02 ms conversion time
Definition ina2xx.h:129
@ INA2XX_BADC_12BIT
12 bit resolution, 532 us conversion time, default
Definition ina2xx.h:117
@ INA2XX_BADC_AVG_1_SAMPLE
12 bit resolution, 532 us conversion time, same as INA2XX_BADC_12BIT
Definition ina2xx.h:119
@ INA2XX_BADC_AVG_2_SAMPLES
2 sample average, 1.06 ms conversion time
Definition ina2xx.h:121
@ INA2XX_BADC_AVG_4_SAMPLES
4 sample average, 2.13 ms conversion time
Definition ina2xx.h:123
@ INA2XX_BADC_10BIT
10 bit resolution, 148 us conversion time
Definition ina2xx.h:113
@ INA2XX_BADC_AVG_8_SAMPLES
8 sample average, 4.26 ms conversion time
Definition ina2xx.h:125
@ INA2XX_BADC_AVG_64_SAMPLES
64 sample average, 34.05 ms conversion time
Definition ina2xx.h:131
@ INA2XX_BADC_11BIT
11 bit resolution, 276 us conversion time
Definition ina2xx.h:115
@ INA2XX_BADC_AVG_128_SAMPLES
128 sample average, 68.10 ms conversion time
Definition ina2xx.h:133
@ INA2XX_BADC_AVG_16_SAMPLES
16 sample average, 8.51 ms conversion time
Definition ina2xx.h:127
@ INA2XX_BADC_9BIT
9 bit resolution, 84 us conversion time
Definition ina2xx.h:111
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
Configuration parameters of the INA2xx driver.
Definition ina2xx.h:176
ina2xx_i_range_t i_range
Range of the measured current.
Definition ina2xx.h:181
i2c_t i2c
I2C device the sensor is connected to.
Definition ina2xx.h:177
uint16_t config
Configuration to apply.
Definition ina2xx.h:179
uint8_t addr
I2C address of the sensr.
Definition ina2xx.h:178
uint16_t rshunt_mohm
Size of the shunt resistor in mΩ
Definition ina2xx.h:180
Device descriptor for INA2XX sensors.
Definition ina2xx.h:187
ina2xx_params_t params
Configuration parameters of the driver.
Definition ina2xx.h:188