Loading...
Searching...
No Matches
ina3221.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
70#ifndef INA3221_H
71#define INA3221_H
72
73#include <assert.h>
74#include <errno.h>
75#include <stdint.h>
76#include <stdbool.h>
77
78#include "kernel_defines.h"
79#include "periph/gpio.h"
80#include "periph/i2c.h"
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
89#define INA3221_NUM_CH (3)
93#define INA3221_NUM_ALERTS (4)
94
99typedef void (*ina3221_alert_cb_t)(void *arg);
100
110
114typedef enum ina3221_channel {
115 INA3221_CH1 = (1U << 0),
116 INA3221_CH2 = (1U << 1),
117 INA3221_CH3 = (1U << 2)
119
129
146#define INA3221_MODE_MASK (0x0007)
147
164#define INA3221_CONV_TIME_SADC_MASK (0x0038)
165
182#define INA3221_CONV_TIME_BADC_MASK (0x01C0)
183
200#define INA3221_NUM_SAMPLES_MASK (0x0E00)
201
213#define INA3221_ENABLE_CH_MASK (INA3221_ENABLE_CH1 \
214 | INA3221_ENABLE_CH2 \
215 | INA3221_ENABLE_CH3)
216
228#define INA3221_ENABLE_SUM_CH_MASK (INA3221_ENABLE_SUM_CH1 \
229 | INA3221_ENABLE_SUM_CH2 \
230 | INA3221_ENABLE_SUM_CH3)
231
242#define INA3221_ENABLE_LATCH_MASK (INA3221_ENABLE_WARN_LATCH \
243 | INA3221_ENABLE_CRIT_LATCH)
244
248typedef unsigned ina3221_ch_t;
249
253typedef struct {
255 uint8_t addr;
256 union {
257 struct {
258 gpio_t pin_warn;
259 gpio_t pin_crit;
260 gpio_t pin_tc;
261 gpio_t pin_pv;
262 } pins;
263 struct {
264 gpio_t alert_pins[INA3221_NUM_ALERTS];
265 } apins;
266 } upins;
267 /*
268 For each pin 1 bit states whether to use internal pull up resistors.
269 d = don´t care
270 [d][d][d][d][pu PV][pu TC][pu CRT][pu WRN]
271 */
272 uint8_t gpio_config;
273 uint16_t config;
274 uint16_t rshunt_mohm[INA3221_NUM_CH];
276
277/* ( INA3221_ENABLE_CH_1
278 | INA3221_ENABLE_CH_2
279 | INA3221_ENABLE_CH_2
280 | INA3221_NUM_SAMPLES_1
281 | INA3221_CONV_TIME_BADC_1100US
282 | INA3221_CONV_TIME_SADC_1100US
283 | INA3221_MODE_CONTINUOUS_SHUNT_BUS ) */
284#define INA3221_DEFCONFIG (0x7127)
286#define INA3221_RESET (0x8000)
288#define INA3221_FLAG_CRIT_ALERT_CH1 (0x0200)
289#define INA3221_FLAG_CRIT_ALERT_CH2 (0x0100)
290#define INA3221_FLAG_CRIT_ALERT_CH3 (0x0080)
292#define INA3221_FLAG_SHUNT_SUM_ALERT (0x0040)
294#define INA3221_FLAG_WARN_ALERT_CH1 (0x0020)
295#define INA3221_FLAG_WARN_ALERT_CH2 (0x0010)
296#define INA3221_FLAG_WARN_ALERT_CH3 (0x0008)
298#define INA3221_FLAG_POWER_VALID (0x0004)
300#define INA3221_FLAG_TIMING_CONTROL (0x0002)
302#define INA3221_FLAG_CONV_READY (0x0001)
307#define INA3221_FLAGS_MASK (INA3221_FLAG_CRIT_ALERT_CH1 \
308 | INA3221_FLAG_CRIT_ALERT_CH2 \
309 | INA3221_FLAG_CRIT_ALERT_CH3 \
310 | INA3221_FLAG_SHUNT_SUM_ALERT \
311 | INA3221_FLAG_WARN_ALERT_CH1 \
312 | INA3221_FLAG_WARN_ALERT_CH2 \
313 | INA3221_FLAG_WARN_ALERT_CH3 \
314 | INA3221_FLAG_POWER_VALID \
315 | INA3221_FLAG_TIMING_CONTROL \
316 | INA3221_FLAG_CONV_READY)
317
321typedef struct {
323#if IS_USED(MODULE_INA3221_ALERTS) || defined(DOXYGEN)
324 union {
325 struct {
330 };
331 struct {
333 };
334 };
335 union {
336 struct {
339 void *arg_tc_cb;
340 void *arg_pv_cb;
341 };
342 struct {
343 void *alert_callback_arguments[INA3221_NUM_ALERTS];
344 };
345 };
346#endif /* MODULE_INA3221_ALERTS */
347} ina3221_t;
348
361
377int ina3221_init(ina3221_t *dev, const ina3221_params_t *params);
378
379#if IS_USED(MODULE_INA3221_ALERTS) || defined(DOXYGEN)
393 ina3221_alert_cb_t cb, void *arg);
394
407 void *arg)
408{
409 return ina3221_enable_alert(dev, INA3221_ALERT_WRN, cb, arg);
410}
411
424 void *arg)
425{
426 return ina3221_enable_alert(dev, INA3221_ALERT_CRT, cb, arg);
427}
428
441 void *arg)
442{
443 return ina3221_enable_alert(dev, INA3221_ALERT_TC, cb, arg);
444}
445
458 void *arg)
459{
460 return ina3221_enable_alert(dev, INA3221_ALERT_PV, cb, arg);
461}
462
474
484{
486}
487
497{
499}
500
513
523{
525}
526
527#endif /* MODULE_INA3221_ALERTS */
528
537{
538 return ((cfg & INA3221_ENABLE_CH1) ? INA3221_CH1 : 0) |
539 ((cfg & INA3221_ENABLE_CH2) ? INA3221_CH2 : 0) |
540 ((cfg & INA3221_ENABLE_CH3) ? INA3221_CH3 : 0);
541}
542
549static inline void ina3221_config_set_enabled_channels(uint16_t *cfg, ina3221_ch_t ch)
550{
551 assert(cfg);
552 uint16_t u16 = ((ch & INA3221_CH1) ? INA3221_ENABLE_CH1 : 0) |
553 ((ch & INA3221_CH2) ? INA3221_ENABLE_CH2 : 0) |
554 ((ch & INA3221_CH3) ? INA3221_ENABLE_CH3 : 0);
555 *cfg &= ~INA3221_ENABLE_CH_MASK;
556 *cfg |= (u16 & INA3221_ENABLE_CH_MASK);
557}
558
570
577static inline void ina3221_config_set_num_samples(uint16_t *cfg,
579{
580 assert(cfg);
581 uint16_t u16 = (uint16_t)ns;
582 *cfg &= ~INA3221_NUM_SAMPLES_MASK;
583 *cfg |= (u16 & INA3221_NUM_SAMPLES_MASK);
584}
585
597
604static inline void ina3221_config_set_conv_time_bus(uint16_t *cfg,
606{
607 assert(cfg);
608 uint16_t u16 = (uint16_t)bus;
609 *cfg &= ~INA3221_CONV_TIME_BADC_MASK;
610 *cfg |= (u16 & INA3221_CONV_TIME_BADC_MASK);
611}
612
624
631static inline void ina3221_config_set_conv_time_shunt(uint16_t *cfg,
633{
634 assert(cfg);
635 uint16_t u16 = (uint16_t)shunt;
636 *cfg &= ~INA3221_CONV_TIME_SADC_MASK;
637 *cfg |= (u16 & INA3221_CONV_TIME_SADC_MASK);
638}
639
647static inline ina3221_mode_t ina3221_config_get_mode(uint16_t cfg)
648{
649 return (ina3221_mode_t)(cfg & INA3221_MODE_MASK);
650}
651
658static inline void ina3221_config_set_mode(uint16_t *cfg,
659 ina3221_mode_t mode)
660{
661 assert(cfg);
662 uint16_t u16 = (uint16_t)mode;
663 *cfg &= ~INA3221_MODE_MASK;
664 *cfg |= (u16 & INA3221_MODE_MASK);
665}
666
677int ina3221_set_config(ina3221_t *dev, uint16_t cfg);
678
689int ina3221_get_config(const ina3221_t *dev, uint16_t *cfg);
690
703
710static inline void ina3221_get_enable_channel(const ina3221_t *dev,
711 ina3221_ch_t *ch)
712{
714}
715
728
735static inline void ina3221_get_num_samples(const ina3221_t *dev,
737{
739}
740
754
766
780
792
805
812static inline void ina3221_get_mode(const ina3221_t *dev, ina3221_mode_t *mode)
813{
815}
816
832
844
857int ina3221_set_latch(const ina3221_t *dev, bool warn, bool crit);
858
870int ina3221_get_latch(const ina3221_t *dev, bool *warn, bool *crit);
871
882 ina3221_ch_t ch, int32_t in_uv);
883
894 int32_t out_uv[INA3221_NUM_CH]);
895
906 ina3221_ch_t ch, int32_t in_uv);
907
918 int32_t out_uv[INA3221_NUM_CH]);
919
932 int32_t in_uv);
933
945 int32_t *out_uv);
946
958int ina3221_set_power_valid_upper_limit(const ina3221_t *dev, int32_t in_mv);
959
970int ina3221_get_power_valid_upper_limit(const ina3221_t *dev, int32_t *out_mv);
971
983int ina3221_set_power_valid_lower_limit(const ina3221_t *dev, int32_t in_mv);
984
995int ina3221_get_power_valid_lower_limit(const ina3221_t *dev, int32_t *out_mv);
996
1007int ina3221_read_flags(const ina3221_t *dev, uint16_t *flags);
1008
1020int ina3221_read_shunt_sum_uv(const ina3221_t *dev, int32_t *out_uv,
1021 uint16_t *flags);
1022
1033 int32_t out_uv[INA3221_NUM_CH],
1034 uint16_t *flags);
1035
1046 int16_t out_mv[INA3221_NUM_CH],
1047 uint16_t *flags);
1048
1058 const uint16_t in_mohm[INA3221_NUM_CH],
1059 const int32_t in_uv[INA3221_NUM_CH],
1060 int32_t out_ua[INA3221_NUM_CH]);
1061
1071 const int16_t in_mv[INA3221_NUM_CH],
1072 const int32_t in_ua[INA3221_NUM_CH],
1073 int32_t out_mw[INA3221_NUM_CH]);
1074
1081#define INA3221_TRIGGER_SHUNT(dev) \
1082 ina3221_set_mode(dev, INA3221_MODE_TRIGGER_SHUNT_ONLY)
1083
1090#define INA3221_TRIGGER_BUS(dev) \
1091 ina3221_set_mode(dev, INA3221_MODE_TRIGGER_BUS_ONLY)
1092
1099#define INA3221_TRIGGER_SHUNT_AND_BUS(dev) \
1100 ina3221_set_mode(dev, INA3221_MODE_TRIGGER_SHUNT_BUS)
1101
1102#ifdef __cplusplus
1103}
1104#endif
1105
1106#endif /* INA3221_H */
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:136
Low-level GPIO peripheral driver interface definitions.
ina3221_ch_t ina3221_set_crit_alert_limit(const ina3221_t *dev, ina3221_ch_t ch, int32_t in_uv)
Set critical shunt voltage alert limit to in_uv for each channel in ch.
static void ina3221_get_num_samples(const ina3221_t *dev, ina3221_num_samples_t *ns)
Read currently applied number of samples.
Definition ina3221.h:735
int ina3221_set_config(ina3221_t *dev, uint16_t cfg)
Write configuration register value to configuration register.
int ina3221_set_power_valid_upper_limit(const ina3221_t *dev, int32_t in_mv)
Set bus voltage power valid upper limit to in_mv.
ina3221_ch_t ina3221_get_crit_alert_limit(const ina3221_t *dev, ina3221_ch_t ch, int32_t out_uv[INA3221_NUM_CH])
Read critical shunt voltage alert limit for each channel in ch.
unsigned ina3221_ch_t
Flags ina3221_channel_t.
Definition ina3221.h:248
int ina3221_enable_alert(ina3221_t *dev, ina3221_alert_t alert, ina3221_alert_cb_t cb, void *arg)
Enable alert and set callback and argument for alert alert.
ina3221_mode
Device operation modes.
Definition ina3221.h:133
ina3221_num_samples
Number of samples to calculate average shunt/bus voltage value.
Definition ina3221.h:187
static ina3221_conv_time_shunt_adc_t ina3221_config_get_conv_time_shunt(uint16_t cfg)
Get shunt voltage conversion time from configuration value.
Definition ina3221.h:620
ina3221_conv_time_shunt_adc
ADC shunt voltage conversion times.
Definition ina3221.h:151
#define INA3221_NUM_SAMPLES_MASK
Number of samples to calculate average shunt/bus voltage value bit mask.
Definition ina3221.h:200
int ina3221_set_mode(ina3221_t *dev, ina3221_mode_t mode)
Update device operation mode.
static void ina3221_get_conv_time_bus_adc(const ina3221_t *dev, ina3221_conv_time_bus_adc_t *ctb)
Read currently applied bus voltage ADC conversion time.
Definition ina3221.h:761
ina3221_ch_t ina3221_read_bus_mv(const ina3221_t *dev, int16_t out_mv[INA3221_NUM_CH], uint16_t *flags)
Read bus voltages for each channel in ch.
#define INA3221_CONV_TIME_SADC_MASK
ADC shunt voltage conversion times bit mask.
Definition ina3221.h:164
static int ina3221_enable_warning_alert(ina3221_t *dev, ina3221_alert_cb_t cb, void *arg)
Wrapper around ina3221_enable_alert, to enable warning alert.
Definition ina3221.h:405
int ina3221_get_enable_sum_channel(const ina3221_t *dev, ina3221_ch_t *ch)
Read enabled channels for shunt voltage sum calculation.
ina3221_ch_t ina3221_get_warn_alert_limit(const ina3221_t *dev, ina3221_ch_t ch, int32_t out_uv[INA3221_NUM_CH])
Read warning shunt voltage alert limit for each channel in ch.
enum ina3221_enable_ch ina3221_enable_ch_t
Enable channel flags.
ina3221_dev_addr
I2C device addresses.
Definition ina3221.h:104
int ina3221_set_enable_channel(ina3221_t *dev, ina3221_ch_t ch)
Enable channels.
static ina3221_mode_t ina3221_config_get_mode(uint16_t cfg)
Get operation mode from configuration value.
Definition ina3221.h:647
ina3221_alert
Alert indices.
Definition ina3221.h:123
ina3221_enable_ch
Enable channel flags.
Definition ina3221.h:205
enum ina3221_alert ina3221_alert_t
Alert indices.
int ina3221_get_shunt_voltage_sum_alert_limit(const ina3221_t *dev, int32_t *out_uv)
Read shunt voltage sum alert limit.
ina3221_conv_time_bus_adc
ADC bus voltage conversion times.
Definition ina3221.h:169
enum ina3221_mode ina3221_mode_t
Device operation modes.
int ina3221_set_num_samples(ina3221_t *dev, ina3221_num_samples_t ns)
Update number of samples and write to configuration register.
static void ina3221_config_set_conv_time_shunt(uint16_t *cfg, ina3221_conv_time_shunt_adc_t shunt)
Set shunt voltage conversion time in configuration value.
Definition ina3221.h:631
static ina3221_num_samples_t ina3221_config_get_num_samples(uint16_t cfg)
Get number of samples from configuration value.
Definition ina3221.h:566
static void ina3221_get_enable_channel(const ina3221_t *dev, ina3221_ch_t *ch)
Read which channels are currently enabled.
Definition ina3221.h:710
enum ina3221_conv_time_shunt_adc ina3221_conv_time_shunt_adc_t
ADC shunt voltage conversion times.
static ina3221_conv_time_bus_adc_t ina3221_config_get_conv_time_bus(uint16_t cfg)
Get bus voltage conversion time from configuration value.
Definition ina3221.h:593
#define INA3221_NUM_CH
Number of channels.
Definition ina3221.h:89
static void ina3221_config_set_conv_time_bus(uint16_t *cfg, ina3221_conv_time_bus_adc_t bus)
Set bus voltage conversion time in configuration value.
Definition ina3221.h:604
int ina3221_set_latch(const ina3221_t *dev, bool warn, bool crit)
Enable latches for critical/warning alert pins.
#define INA3221_NUM_ALERTS
Number of alerts.
Definition ina3221.h:93
#define INA3221_CONV_TIME_BADC_MASK
ADC bus voltage conversion times bit mask.
Definition ina3221.h:182
int ina3221_read_shunt_sum_uv(const ina3221_t *dev, int32_t *out_uv, uint16_t *flags)
Read sum of shunt voltages.
static int ina3221_disable_power_valid_alert(ina3221_t *dev)
Wrapper around ina3221_disable_alert, to disable power valid alert.
Definition ina3221.h:522
void ina3221_calculate_current_ua(ina3221_ch_t ch, const uint16_t in_mohm[INA3221_NUM_CH], const int32_t in_uv[INA3221_NUM_CH], int32_t out_ua[INA3221_NUM_CH])
Calculate current for each channel in ch.
int ina3221_disable_alert(ina3221_t *dev, ina3221_alert_t alert)
Disable alert alert.
enum ina3221_num_samples ina3221_num_samples_t
Number of samples to calculate average shunt/bus voltage value.
ina3221_enable_sum_ch
Enable shunt voltage sum calculation channel flags.
Definition ina3221.h:220
static int ina3221_disable_critical_alert(ina3221_t *dev)
Wrapper around ina3221_disable_alert, to disable critical alert.
Definition ina3221.h:496
int ina3221_get_latch(const ina3221_t *dev, bool *warn, bool *crit)
Read enabled latches for critical/warning alert pins.
enum ina3221_conv_time_bus_adc ina3221_conv_time_bus_adc_t
ADC bus voltage conversion times.
int ina3221_init(ina3221_t *dev, const ina3221_params_t *params)
Initialize device.
static int ina3221_enable_power_valid_alert(ina3221_t *dev, ina3221_alert_cb_t cb, void *arg)
Wrapper around ina3221_enable_alert, to enable power valid alert.
Definition ina3221.h:456
enum ina3221_dev_addr ina3221_dev_addr_t
I2C device addresses.
int ina3221_get_power_valid_lower_limit(const ina3221_t *dev, int32_t *out_mv)
Read bus voltage power valid lower limit.
int ina3221_read_flags(const ina3221_t *dev, uint16_t *flags)
Read status flags.
int ina3221_set_enable_sum_channel(const ina3221_t *dev, ina3221_ch_t ch)
Enable channels for shunt voltage sum calculation.
enum ina3221_enable_latch ina3221_enable_latch_t
Enable latch flags.
static int ina3221_disable_warning_alert(ina3221_t *dev)
Wrapper around ina3221_disable_alert, to disable warning alert.
Definition ina3221.h:483
ina3221_ch_t ina3221_set_warn_alert_limit(const ina3221_t *dev, ina3221_ch_t ch, int32_t in_uv)
Set warning shunt voltage alert limit to in_uv for each channel in ch.
ina3221_ch_t ina3221_read_shunt_uv(const ina3221_t *dev, int32_t out_uv[INA3221_NUM_CH], uint16_t *flags)
Read shunt voltages for each channel in ch.
ina3221_channel
Channel flags.
Definition ina3221.h:114
static int ina3221_enable_critical_alert(ina3221_t *dev, ina3221_alert_cb_t cb, void *arg)
Wrapper around ina3221_enable_alert, to enable critical alert.
Definition ina3221.h:422
void(* ina3221_alert_cb_t)(void *arg)
INA3221 alert callback for alert pins CRT, WRN, TC, PV.
Definition ina3221.h:99
ina3221_enable_latch
Enable latch flags.
Definition ina3221.h:235
static void ina3221_get_mode(const ina3221_t *dev, ina3221_mode_t *mode)
Read currently applied device operation mode.
Definition ina3221.h:812
int ina3221_set_shunt_voltage_sum_alert_limit(const ina3221_t *dev, int32_t in_uv)
Set shunt voltage sum alert limit to in_uv.
enum ina3221_enable_sum_ch ina3221_enable_sum_ch_t
Enable shunt voltage sum calculation channel flags.
int ina3221_get_config(const ina3221_t *dev, uint16_t *cfg)
Read currently saved configuration register value.
static int ina3221_disable_timing_control_alert(ina3221_t *dev)
Wrapper around ina3221_disable_alert, to disable timing control alert.
Definition ina3221.h:509
int ina3221_get_power_valid_upper_limit(const ina3221_t *dev, int32_t *out_mv)
Read bus voltage power valid upper limit.
#define INA3221_ENABLE_CH_MASK
Enable channel bit mask.
Definition ina3221.h:213
int ina3221_reset(ina3221_t *dev)
Reset device, i.e.
static void ina3221_config_set_enabled_channels(uint16_t *cfg, ina3221_ch_t ch)
Enable measurement channels in configuration value.
Definition ina3221.h:549
enum ina3221_channel ina3221_channel_t
Channel flags.
static int ina3221_enable_timing_control_alert(ina3221_t *dev, ina3221_alert_cb_t cb, void *arg)
Wrapper around ina3221_enable_alert, to enable timing control alert.
Definition ina3221.h:439
int ina3221_set_conv_time_shunt_adc(ina3221_t *dev, ina3221_conv_time_shunt_adc_t cts)
Update conversion time of shunt voltage ADC and write to configuration register.
int ina3221_set_conv_time_bus_adc(ina3221_t *dev, ina3221_conv_time_bus_adc_t ctb)
Update conversion time of bus voltage ADC and write to configuration register.
void ina3221_calculate_power_uw(ina3221_ch_t ch, const int16_t in_mv[INA3221_NUM_CH], const int32_t in_ua[INA3221_NUM_CH], int32_t out_mw[INA3221_NUM_CH])
Calculate power from bus voltage and current values.
#define INA3221_MODE_MASK
Device operation mode bit mask.
Definition ina3221.h:146
static ina3221_ch_t ina3221_config_get_enabled_channels(uint16_t cfg)
Get enabled measurement channels from configuration value.
Definition ina3221.h:536
int ina3221_set_power_valid_lower_limit(const ina3221_t *dev, int32_t in_mv)
Set bus voltage power valid lower limit to in_mv.
static void ina3221_get_conv_time_shunt_adc(const ina3221_t *dev, ina3221_conv_time_shunt_adc_t *cts)
Read currently applied shunt voltage ADC conversion time.
Definition ina3221.h:787
static void ina3221_config_set_mode(uint16_t *cfg, ina3221_mode_t mode)
Set operation mode in configuration value.
Definition ina3221.h:658
static void ina3221_config_set_num_samples(uint16_t *cfg, ina3221_num_samples_t ns)
Set number of samples in configuration value.
Definition ina3221.h:577
@ INA3221_MODE_CONTINUOUS_SHUNT_ONLY
Continuous shunt voltage measurement only.
Definition ina3221.h:139
@ INA3221_MODE_CONTINUOUS_SHUNT_BUS
Continuous shunt and bus voltage measurement.
Definition ina3221.h:141
@ INA3221_MODE_POWER_DOWN
Sleep mode.
Definition ina3221.h:134
@ INA3221_MODE_TRIGGER_BUS_ONLY
Trigger bus voltage measurement only.
Definition ina3221.h:136
@ INA3221_MODE_TRIGGER_SHUNT_BUS
Trigger shunt and bus voltage measurement.
Definition ina3221.h:137
@ INA3221_MODE_TRIGGER_SHUNT_ONLY
Trigger shunt voltage measurement only.
Definition ina3221.h:135
@ INA3221_MODE_CONTINUOUS_BUS_ONLY
Continuous bus voltage measurement only.
Definition ina3221.h:140
@ INA3221_MODE_POWER_DOWN_
Also power down (see datasheet)
Definition ina3221.h:138
@ INA3221_NUM_SAMPLES_4
4
Definition ina3221.h:189
@ INA3221_NUM_SAMPLES_64
64
Definition ina3221.h:191
@ INA3221_NUM_SAMPLES_16
16
Definition ina3221.h:190
@ INA3221_NUM_SAMPLES_128
128
Definition ina3221.h:192
@ INA3221_NUM_SAMPLES_1024
1024
Definition ina3221.h:195
@ INA3221_NUM_SAMPLES_1
1
Definition ina3221.h:188
@ INA3221_NUM_SAMPLES_512
512
Definition ina3221.h:194
@ INA3221_NUM_SAMPLES_256
256
Definition ina3221.h:193
@ INA3221_CONV_TIME_SADC_332US
332 us
Definition ina3221.h:154
@ INA3221_CONV_TIME_SADC_204US
204 us
Definition ina3221.h:153
@ INA3221_CONV_TIME_SADC_4156US
4156 us
Definition ina3221.h:158
@ INA3221_CONV_TIME_SADC_140US
140 us
Definition ina3221.h:152
@ INA3221_CONV_TIME_SADC_1100US
1100 us
Definition ina3221.h:156
@ INA3221_CONV_TIME_SADC_588US
588 us
Definition ina3221.h:155
@ INA3221_CONV_TIME_SADC_2116US
2116 us
Definition ina3221.h:157
@ INA3221_CONV_TIME_SADC_8244US
8244 us
Definition ina3221.h:159
@ INA3221_ADDR_00
A0 connected to GND.
Definition ina3221.h:105
@ INA3221_ADDR_11
A0 connected to SCL.
Definition ina3221.h:108
@ INA3221_ADDR_10
A0 connected to SDA.
Definition ina3221.h:107
@ INA3221_ADDR_01
A0 connected to VS
Definition ina3221.h:106
@ INA3221_ALERT_WRN
Warning alert.
Definition ina3221.h:124
@ INA3221_ALERT_TC
Timing control.
Definition ina3221.h:126
@ INA3221_ALERT_CRT
Critical alert.
Definition ina3221.h:125
@ INA3221_ALERT_PV
Power valid alert.
Definition ina3221.h:127
@ INA3221_ENABLE_CH3
Enable channel 3.
Definition ina3221.h:208
@ INA3221_ENABLE_CH2
Enable channel 2.
Definition ina3221.h:207
@ INA3221_ENABLE_CH1
Enable channel 1.
Definition ina3221.h:206
@ INA3221_CONV_TIME_BADC_4156US
4156 us
Definition ina3221.h:176
@ INA3221_CONV_TIME_BADC_140US
140 us
Definition ina3221.h:170
@ INA3221_CONV_TIME_BADC_2116US
2116 us
Definition ina3221.h:175
@ INA3221_CONV_TIME_BADC_204US
204 us
Definition ina3221.h:171
@ INA3221_CONV_TIME_BADC_332US
332 us
Definition ina3221.h:172
@ INA3221_CONV_TIME_BADC_1100US
1100 us
Definition ina3221.h:174
@ INA3221_CONV_TIME_BADC_8244US
8244 us
Definition ina3221.h:177
@ INA3221_CONV_TIME_BADC_588US
588 us
Definition ina3221.h:173
@ INA3221_ENABLE_SUM_CH1
Enable sum channel 1.
Definition ina3221.h:221
@ INA3221_ENABLE_SUM_CH2
Enable sum channel 2.
Definition ina3221.h:222
@ INA3221_ENABLE_SUM_CH3
Enable sum channel 3.
Definition ina3221.h:223
@ INA3221_CH3
Channel 3.
Definition ina3221.h:117
@ INA3221_CH1
Channel 1.
Definition ina3221.h:115
@ INA3221_CH2
Channel 2.
Definition ina3221.h:116
@ INA3221_ENABLE_WARN_LATCH
Enable warning alert latch.
Definition ina3221.h:236
@ INA3221_ENABLE_CRIT_LATCH
Enable critical alert latch.
Definition ina3221.h:237
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
Common macros and compiler attributes/pragmas configuration.
INA3221 device parameters.
Definition ina3221.h:253
gpio_t pin_warn
Warning alert pin, becomes configured as input.
Definition ina3221.h:258
gpio_t pin_crit
Critical alert pin, becomes configured as input.
Definition ina3221.h:259
uint8_t gpio_config
Configure pull up resistors for gpio pins.
Definition ina3221.h:272
i2c_t i2c
I2C bus.
Definition ina3221.h:254
uint8_t addr
I2C address.
Definition ina3221.h:255
gpio_t pin_pv
Power valid alert pin, becomes configured as input.
Definition ina3221.h:261
uint16_t config
Configuration.
Definition ina3221.h:273
gpio_t pin_tc
Timing control alert pin, becomes configured as input.
Definition ina3221.h:260
INA3221 device handle struct.
Definition ina3221.h:321
void * arg_crit_cb
Argument for Critical alert callback.
Definition ina3221.h:338
ina3221_params_t params
Device parameters.
Definition ina3221.h:322
ina3221_alert_cb_t pv_cb
Power Valid alert callback: executed when PV is pulled low.
Definition ina3221.h:329
ina3221_alert_cb_t warn_cb
Warning alert callback: executed when WRN is pulled low.
Definition ina3221.h:326
void * arg_warn_cb
Argument for Warning alert callback.
Definition ina3221.h:337
ina3221_alert_cb_t crit_cb
Critical alert callback: executed when CRT is pulled low.
Definition ina3221.h:327
void * arg_pv_cb
Argument for Power Valid alert callback.
Definition ina3221.h:340
ina3221_alert_cb_t tc_cb
Timing control alert callback: executed when TC is pulled low.
Definition ina3221.h:328
void * arg_tc_cb
Argument for Timing control alert callback.
Definition ina3221.h:339