Skip to content

Commit

Permalink
Modify: modify amec power sensor calculation
Browse files Browse the repository at this point in the history
The offset value will be added to APSS raw value when APSS raw value is not 0.

Change-Id: Iba5ecc6d979ea3cc771c6cd25f6e7bab44bb2d78
Signed-off-by: joy_chu <joy_chu@wistron.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/81383
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christopher J Cain <cjcain@us.ibm.com>
Reviewed-by: William A Bryan <wilbryan@us.ibm.com>
  • Loading branch information
chcyjoy authored and wilbryan committed Jul 30, 2019
1 parent 0ac1770 commit 1e8731f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/occ_405/amec/amec_sensors_power.c
Expand Up @@ -173,14 +173,18 @@ uint32_t amec_value_from_apss_adc(uint8_t i_chan)
// Read Raw Value in mA (divide masked channel data by 2)
l_raw = (G_dcom_slv_inbox_rx.adc[i_chan] & APSS_12BIT_ADC_MASK)/2;
// Apply offset and gain
if (l_offset & 0x80000000)
// Add offset if Raw Value is not zero
if (l_raw != 0)
{
// Negative offset
l_raw -= (~l_offset + 1);
}
else
{
l_raw += l_offset;
if (l_offset & 0x80000000)
{
// Negative offset
l_raw -= (~l_offset + 1);
}
else
{
l_raw += l_offset;
}
}
//Check to see if l_raw is negative. If so, set raw to 0
if (l_raw & 0x8000)
Expand Down

0 comments on commit 1e8731f

Please sign in to comment.