LCOV - code coverage report
Current view: top level - zephyr/dt-bindings/sensor - ina237.h Hit Total Coverage
Test: new.info Lines: 2 42 4.8 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           0 : /*
       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             : 
       9             : #include <zephyr/dt-bindings/dt-util.h>
      10             : 
      11             : /* Operating Mode */
      12           0 : #define INA237_CFG_HIGH_PRECISION                       BIT(4)
      13           0 : #define INA237_OPER_MODE_SHUTDOWN                       0x00
      14           0 : #define INA237_OPER_MODE_BUS_VOLTAGE_TRIG               0x01
      15           0 : #define INA237_OPER_MODE_SHUNT_VOLTAGE_TRIG             0x02
      16           0 : #define INA237_OPER_MODE_SHUNT_BUS_VOLTAGE_TRIG         0x03
      17           0 : #define INA237_OPER_MODE_TEMP_TRIG                      0x04
      18           0 : #define INA237_OPER_MODE_TEMP_BUS_VOLTAGE_TRIG          0x05
      19           0 : #define INA237_OPER_MODE_TEMP_SHUNT_VOLTAGE_TRIG        0x06
      20           0 : #define INA237_OPER_MODE_BUS_SHUNT_VOLTAGE_TEMP_TRIG    0x07
      21           0 : #define INA237_OPER_MODE_BUS_VOLTAGE_CONT               0x09
      22           0 : #define INA237_OPER_MODE_SHUNT_VOLTAGE_CONT             0x0A
      23           0 : #define INA237_OPER_MODE_SHUNT_BUS_VOLTAGE_CONT         0x0B
      24           0 : #define INA237_OPER_MODE_TEMP_CONT                      0x0C
      25           0 : #define INA237_OPER_MODE_BUS_VOLTAGE_TEMP_CONT          0x0D
      26           0 : #define INA237_OPER_MODE_TEMP_SHUNT_VOLTAGE_CONT        0x0E
      27           0 : #define INA237_OPER_MODE_BUS_SHUNT_VOLTAGE_TEMP_CONT    0x0F
      28             : 
      29             : /* Conversion time for bus, shunt and temp in micro-seconds */
      30           0 : #define INA237_CONV_TIME_50   0x00
      31           0 : #define INA237_CONV_TIME_84   0x01
      32           0 : #define INA237_CONV_TIME_150  0x02
      33           0 : #define INA237_CONV_TIME_280  0x03
      34           0 : #define INA237_CONV_TIME_540  0x04
      35           0 : #define INA237_CONV_TIME_1052 0x05
      36           0 : #define INA237_CONV_TIME_2074 0x06
      37           0 : #define INA237_CONV_TIME_4120 0x07
      38             : 
      39             : /* Averaging Mode */
      40           0 : #define INA237_AVG_MODE_1    0x00
      41           0 : #define INA237_AVG_MODE_4    0x01
      42           0 : #define INA237_AVG_MODE_16   0x02
      43           0 : #define INA237_AVG_MODE_64   0x03
      44           0 : #define INA237_AVG_MODE_128  0x04
      45           0 : #define INA237_AVG_MODE_256  0x05
      46           0 : #define INA237_AVG_MODE_512  0x06
      47           0 : #define INA237_AVG_MODE_1024 0x07
      48             : 
      49             : /* Reset Mode */
      50           0 : #define INA237_RST_NORMAL_OPERATION     0x00
      51           0 : #define INA237_RST_SYSTEM_RESET         0x01
      52             : 
      53             : /* Delay for initial ADC conversion in steps of 2 ms */
      54           0 : #define INA237_INIT_ADC_DELAY_0_S       0x00
      55           0 : #define INA237_INIT_ADC_DELAY_2_MS      0x01
      56           0 : #define INA237_INIT_ADC_DELAY_510_MS    0xFF
      57             : 
      58             : /* Shunt full scale range selection across IN+ and IN–. */
      59           0 : #define INA237_ADC_RANGE_163_84 0x00
      60           0 : #define INA237_ADC_RANGE_40_96  0x01
      61             : 
      62             : /**
      63             :  * @brief Macro for creating the INA237 configuration value
      64             :  *
      65             :  * @param rst_mode      Reset mode.
      66             :  * @param convdly       Delay for initial ADC conversion in steps of 2 ms.
      67             :  * @param adc_range     Shunt full scale range selection across IN+ and IN–.
      68             :  *
      69             :  */
      70             : #define INA237_CONFIG(rst_mode, \
      71             :                       convdly, \
      72           1 :                       adc_range) \
      73             :         (((rst_mode) << 15) | ((convdly) << 6) | ((adc_range) << 4))
      74             : 
      75             : /**
      76             :  * @brief Macro for creating the INA237 ADC configuration value
      77             :  *
      78             :  * @param mode   Operating mode.
      79             :  * @param vshct  Conversion time for shunt voltage.
      80             :  * @param vbusct Conversion time for bus voltage.
      81             :  * @param vtct   Conversion time for temperature.
      82             :  * @param avg    Averaging mode.
      83             :  */
      84             : #define INA237_ADC_CONFIG(mode, \
      85             :                       vshct, \
      86             :                       vbusct, \
      87             :                       vtct, \
      88           1 :                       avg)  \
      89             :         (((mode) << 12) | ((vbusct) << 9) | ((vshct) << 6) | ((vtct) << 3) | (avg))
      90             : 
      91             : #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_INA237_H_ */

Generated by: LCOV version 1.14