Skip to content

Commit

Permalink
minerva ag: Modify ubc u50su4p180 getting Pout value (#2149)
Browse files Browse the repository at this point in the history
Summary:
- Modify ubc u50su4p180 getting Pout value

  TestPlan:
  - BuildCode: PASS
  - Getting Pout value from u50su4p180:PASS

 Log:
```
[0xa ] AEGIS_UBC_2_PWR_W                       : u50su4p180pmdafc   | access[O] | poll    1( 1) sec | sensor_enabled        |     26.000
```

Pull Request resolved: #2149

Reviewed By: wangx6f

Differential Revision: D67754559

fbshipit-source-id: 169370cf8b70365f3f6f7f533f961372aac18fef
  • Loading branch information
ArthurTu0624 authored and facebook-github-bot committed Jan 2, 2025
1 parent abfb5ed commit 614abb9
Showing 1 changed file with 16 additions and 42 deletions.
58 changes: 16 additions & 42 deletions common/dev/u50su4p180pmdafc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,55 +43,29 @@ uint8_t u50su4p180pmdafc_read(sensor_cfg *cfg, int *reading)
memset(sval, 0, sizeof(sensor_val));

float val;
if (cfg->offset == PMBUS_READ_POUT) {
float vout_val;
float iout_val;

msg.bus = cfg->port;
msg.target_addr = cfg->target_addr;
msg.tx_len = 1;
msg.rx_len = 2;
msg.data[0] = PMBUS_READ_VOUT;
msg.bus = cfg->port;
msg.target_addr = cfg->target_addr;
msg.tx_len = 1;
msg.rx_len = 2;
msg.data[0] = cfg->offset;

if (i2c_master_read(&msg, retry))
return SENSOR_FAIL_TO_ACCESS;
if (i2c_master_read(&msg, retry))
return SENSOR_FAIL_TO_ACCESS;

uint16_t vout_read_value = (msg.data[1] << 8) | msg.data[0];
vout_val = vout_read_value * U50SU4P180PMDAFC_READ_VOUT_EXP_VALUE;
if (cfg->offset == PMBUS_READ_VOUT) {
uint16_t read_value = (msg.data[1] << 8) | msg.data[0];
val = read_value * U50SU4P180PMDAFC_READ_VOUT_EXP_VALUE;

msg.data[0] = PMBUS_READ_IOUT;

if (i2c_master_read(&msg, retry))
return SENSOR_FAIL_TO_ACCESS;

uint16_t iout_read_value = (msg.data[1] << 8) | msg.data[0];
iout_val = slinear11_to_float(iout_read_value);

val = vout_val * iout_val;
} else if (cfg->offset == PMBUS_READ_TEMPERATURE_1 || cfg->offset == PMBUS_READ_VIN ||
cfg->offset == PMBUS_READ_IOUT || cfg->offset == PMBUS_READ_POUT) {
uint16_t read_value = (msg.data[1] << 8) | msg.data[0];
val = slinear11_to_float(read_value);

} else {
msg.bus = cfg->port;
msg.target_addr = cfg->target_addr;
msg.tx_len = 1;
msg.rx_len = 2;
msg.data[0] = cfg->offset;

if (i2c_master_read(&msg, retry))
return SENSOR_FAIL_TO_ACCESS;

if (cfg->offset == PMBUS_READ_VOUT) {
uint16_t read_value = (msg.data[1] << 8) | msg.data[0];
val = read_value * U50SU4P180PMDAFC_READ_VOUT_EXP_VALUE;

} else if (cfg->offset == PMBUS_READ_TEMPERATURE_1 ||
cfg->offset == PMBUS_READ_VIN || cfg->offset == PMBUS_READ_IOUT) {
uint16_t read_value = (msg.data[1] << 8) | msg.data[0];
val = slinear11_to_float(read_value);

} else {
return SENSOR_FAIL_TO_ACCESS;
}
return SENSOR_FAIL_TO_ACCESS;
}

sval->integer = val;
sval->fraction = (val - sval->integer) * 1000;

Expand Down

0 comments on commit 614abb9

Please sign in to comment.