Joy Chu | 6ba8a4d | 2019-07-24 16:28:52 +0800 | [diff] [blame] | 1 | From d614a89e71564d8d300e25fb76c5a4553fe35876 Mon Sep 17 00:00:00 2001 |
| 2 | From: joy_chu <joy_chu@wistron.com> |
| 3 | Date: Mon, 22 Jul 2019 18:57:17 +0800 |
| 4 | Subject: [PATCH] Modify: modify amec power sensor calculation |
| 5 | |
| 6 | The offset value will be added to APSS raw value when APSS raw value is not 0. |
| 7 | |
| 8 | Signed-off-by: joy_chu <joy_chu@wistron.com> |
| 9 | --- |
| 10 | src/occ_405/amec/amec_sensors_power.c | 18 +++++++++++------- |
| 11 | 1 file changed, 11 insertions(+), 7 deletions(-) |
| 12 | |
| 13 | diff --git a/src/occ_405/amec/amec_sensors_power.c b/src/occ_405/amec/amec_sensors_power.c |
| 14 | index 5c0ec54..2612598 100755 |
| 15 | --- a/src/occ_405/amec/amec_sensors_power.c |
| 16 | +++ b/src/occ_405/amec/amec_sensors_power.c |
| 17 | @@ -173,14 +173,18 @@ uint32_t amec_value_from_apss_adc(uint8_t i_chan) |
| 18 | // Read Raw Value in mA (divide masked channel data by 2) |
| 19 | l_raw = (G_dcom_slv_inbox_rx.adc[i_chan] & APSS_12BIT_ADC_MASK)/2; |
| 20 | // Apply offset and gain |
| 21 | - if (l_offset & 0x80000000) |
| 22 | + // Add offset if Raw Value is not zero |
| 23 | + if (l_raw != 0) |
| 24 | { |
| 25 | - // Negative offset |
| 26 | - l_raw -= (~l_offset + 1); |
| 27 | - } |
| 28 | - else |
| 29 | - { |
| 30 | - l_raw += l_offset; |
| 31 | + if (l_offset & 0x80000000) |
| 32 | + { |
| 33 | + // Negative offset |
| 34 | + l_raw -= (~l_offset + 1); |
| 35 | + } |
| 36 | + else |
| 37 | + { |
| 38 | + l_raw += l_offset; |
| 39 | + } |
| 40 | } |
| 41 | //Check to see if l_raw is negative. If so, set raw to 0 |
| 42 | if (l_raw & 0x8000) |
| 43 | -- |
| 44 | 2.7.4 |
| 45 | |