OpenBIC
OpenSource Bridge-IC
ina238.c File Reference
#include <stdio.h>
#include <string.h>
#include "ina238.h"
#include "sensor.h"
#include "hal_i2c.h"
#include <logging/log.h>
Include dependency graph for ina238.c:

Macros

#define I2C_RETRY   5
 
#define MSB_MASK   BIT(15)
 
#define ADCRANGE_SET_TO_1   BIT(4)
 
#define SHUNT_CAL_MAX_VAL   0x7FFF
 
#define INTERNAL_FIXED_VALUE   819200000
 
#define ADCRANGE_1S_1   0x10
 
#define MAX_CURRENT_LSB   0x80
 
#define ADCRANGE_0_CONVERSION_FACTOR   0.000005
 
#define ADCRANGE_1_CONVERSION_FACTOR   0.00000125
 
#define VBUS_CONVERSION_FACTOR   0.000003125
 
#define DIETEMP_CONVERSION_FACTOR   0.125
 

Functions

 LOG_MODULE_REGISTER (dev_ina238)
 
uint8_t ina238_read (sensor_cfg *cfg, int *reading)
 
uint8_t ina238_init (sensor_cfg *cfg)
 

Macro Definition Documentation

◆ ADCRANGE_0_CONVERSION_FACTOR

#define ADCRANGE_0_CONVERSION_FACTOR   0.000005

◆ ADCRANGE_1_CONVERSION_FACTOR

#define ADCRANGE_1_CONVERSION_FACTOR   0.00000125

◆ ADCRANGE_1S_1

#define ADCRANGE_1S_1   0x10

◆ ADCRANGE_SET_TO_1

#define ADCRANGE_SET_TO_1   BIT(4)

◆ DIETEMP_CONVERSION_FACTOR

#define DIETEMP_CONVERSION_FACTOR   0.125

◆ I2C_RETRY

#define I2C_RETRY   5

◆ INTERNAL_FIXED_VALUE

#define INTERNAL_FIXED_VALUE   819200000

◆ MAX_CURRENT_LSB

#define MAX_CURRENT_LSB   0x80

◆ MSB_MASK

#define MSB_MASK   BIT(15)

◆ SHUNT_CAL_MAX_VAL

#define SHUNT_CAL_MAX_VAL   0x7FFF

◆ VBUS_CONVERSION_FACTOR

#define VBUS_CONVERSION_FACTOR   0.000003125

Function Documentation

◆ ina238_init()

uint8_t ina238_init ( sensor_cfg cfg)
Here is the call graph for this function:

◆ ina238_read()

uint8_t ina238_read ( sensor_cfg cfg,
int *  reading 
)
Here is the call graph for this function:

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( dev_ina238  )