Zephyr Project API  3.2.0
A Scalable Open Source RTOS
ina237.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Grinn
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_INA237_H_
7#define ZEPHYR_INCLUDE_DT_BINDINGS_INA237_H_
8
10
11/* Operating Mode */
12#define INA237_OPER_MODE_SHUTDOWN 0x00
13#define INA237_OPER_MODE_BUS_VOLTAGE_TRIG 0x01
14#define INA237_OPER_MODE_SHUNT_VOLTAGE_TRIG 0x02
15#define INA237_OPER_MODE_SHUNT_BUS_VOLTAGE_TRIG 0x03
16#define INA237_OPER_MODE_TEMP_TRIG 0x04
17#define INA237_OPER_MODE_TEMP_BUS_VOLTAGE_TRIG 0x05
18#define INA237_OPER_MODE_TEMP_SHUNT_VOLTAGE_TRIG 0x06
19#define INA237_OPER_MODE_BUS_SHUNT_VOLTAGE_TEMP_TRIG 0x07
20#define INA237_OPER_MODE_BUS_VOLTAGE_CONT 0x09
21#define INA237_OPER_MODE_SHUNT_VOLTAGE_CONT 0x0A
22#define INA237_OPER_MODE_SHUNT_BUS_VOLTAGE_CONT 0x0B
23#define INA237_OPER_MODE_TEMP_CONT 0x0C
24#define INA237_OPER_MODE_BUS_VOLTAGE_TEMP_CONT 0x0D
25#define INA237_OPER_MODE_TEMP_SHUNT_VOLTAGE_CONT 0x0E
26#define INA237_OPER_MODE_BUS_SHUNT_VOLTAGE_TEMP_CONT 0x0F
27
28/* Conversion time for bus, shunt and temp in micro-seconds */
29#define INA237_CONV_TIME_50 0x00
30#define INA237_CONV_TIME_84 0x01
31#define INA237_CONV_TIME_150 0x02
32#define INA237_CONV_TIME_280 0x03
33#define INA237_CONV_TIME_540 0x04
34#define INA237_CONV_TIME_1052 0x05
35#define INA237_CONV_TIME_2074 0x06
36#define INA237_CONV_TIME_4120 0x07
37
38/* Averaging Mode */
39#define INA237_AVG_MODE_1 0x00
40#define INA237_AVG_MODE_4 0x01
41#define INA237_AVG_MODE_16 0x02
42#define INA237_AVG_MODE_64 0x03
43#define INA237_AVG_MODE_128 0x04
44#define INA237_AVG_MODE_256 0x05
45#define INA237_AVG_MODE_512 0x06
46#define INA237_AVG_MODE_1024 0x07
47
48/* Reset Mode */
49#define INA237_RST_NORMAL_OPERATION 0x00
50#define INA237_RST_SYSTEM_RESET 0x01
51
52/* Delay for initial ADC conversion in steps of 2 ms */
53#define INA237_INIT_ADC_DELAY_0_S 0x00
54#define INA237_INIT_ADC_DELAY_2_MS 0x01
55#define INA237_INIT_ADC_DELAY_510_MS 0xFF
56
57/* Shunt full scale range selection across IN+ and IN–. */
58#define INA237_ADC_RANGE_163_84 0x00
59#define INA237_ADC_RANGE_40_96 0x01
60
69#define INA237_CONFIG(rst_mode, \
70 convdly, \
71 adc_range) \
72 (((rst_mode) << 15) | ((convdly) << 6) | ((adc_range) << 4))
73
83#define INA237_ADC_CONFIG(mode, \
84 vshct, \
85 vbusct, \
86 vtct, \
87 avg) \
88 (((mode) << 12) | ((vbusct) << 9) | ((vshct) << 6) | ((vtct) << 3) | (avg))
89
90#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_INA237_H_ */