Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions common/dev/ina238.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define MAX_CURRENT_LSB 0x80
#define ADCRANGE_0_CONVERSION_FACTOR 0.000005 // 5uV/LSB
#define ADCRANGE_1_CONVERSION_FACTOR 0.00000125 // 1.25uV/LSB
#define VBUS_CONVERSION_FACTOR 0.000003125 // 3.125mV/LSB
#define VBUS_CONVERSION_FACTOR 0.003125 // 3.125mV/LSB
#define DIETEMP_CONVERSION_FACTOR 0.125 // 125 m°C/LSB

LOG_MODULE_REGISTER(dev_ina238);
Expand All @@ -52,7 +52,7 @@
CHECK_NULL_ARG_WITH_RETURN(reading, SENSOR_UNSPECIFIED_ERROR);
CHECK_NULL_ARG_WITH_RETURN(cfg->init_args, SENSOR_INIT_UNSPECIFIED_ERROR);

ina238_init_arg *init_args = (ina238_init_arg *)cfg->init_args;

Check failure on line 55 in common/dev/ina238.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Variable 'init_args' can be declared as pointer to const Raw Output: common/dev/ina238.c:55:19:Variable 'init_args' can be declared as pointer to const

if (cfg->num > SENSOR_NUM_MAX) {
LOG_ERR("sensor num: 0x%x is invalid", cfg->num);
Expand Down Expand Up @@ -139,7 +139,7 @@
}

pwr_val = ((msg.data[0] << 16) | msg.data[1] << 8) | msg.data[2];
val = 0.2 * twoscomplement_to_decimal(pwr_val) * (init_args->cur_lsb);
val = 0.2 * pwr_val * init_args->cur_lsb;

break;
default:
Expand Down Expand Up @@ -177,12 +177,13 @@
msg.tx_len = 1;
msg.rx_len = 2;
msg.data[0] = INA238_CFG_OFFSET;
config_val = msg.data[0] << 8 | msg.data[1];
if (i2c_master_read(&msg, I2C_RETRY)) {
LOG_ERR("Failed to read config from INA238 ");
return SENSOR_INIT_UNSPECIFIED_ERROR;
}

config_val = msg.data[0] << 8 | msg.data[1];

/* Configure the chip using default values */
if (init_args->adc_range) {
WRITE_BIT(config_val, 4, 1);
Expand Down
Loading