summaryrefslogtreecommitdiff
path: root/board/fluffy
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2019-10-20 20:10:19 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-21 23:36:56 +0000
commit01fc0279a26f340c8aa4805199f1cd2bd1284a82 (patch)
tree8f44000b62fae0d07640d8e8762cdb35edf79aab /board/fluffy
parent5e97ef02ffb701739d1bc525bb3fe999313a2ff5 (diff)
downloadchrome-ec-01fc0279a26f340c8aa4805199f1cd2bd1284a82.tar.gz
fluffy: Fix voltage conversion accuracy
When converting the ADC reads into mV, I had used the wrong value which was leading to some errors that would grow with the voltage. This commit simply uses the right values and attempts to gain more accuracy by increasing the number of significant figures. BUG=b:140393065 BRANCH=None TEST=Flash fluffy; measure the VBUS voltage with a multimeter, verify that the fluffy reported value is now closer to the multimeter. Change-Id: I9dfd749eb533d96c8bc45454f968d7bcb095b9ef Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1871123 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/fluffy')
-rw-r--r--board/fluffy/board.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/board/fluffy/board.c b/board/fluffy/board.c
index bf2c204366..264ffc4478 100644
--- a/board/fluffy/board.c
+++ b/board/fluffy/board.c
@@ -366,13 +366,14 @@ DECLARE_CONSOLE_COMMAND(status, command_status, NULL, "show current status");
*/
void show_output_voltage_on_leds(void)
{
- int vbus_mv = adc_read_channel(ADC_PPVAR_VBUS_DUT);
+ int read = adc_read_channel(ADC_PPVAR_VBUS_DUT);
+ uint32_t vbus_mv = (uint32_t)read;
static int prev_vbus_mv;
int i;
int act;
enum led_ch max_on_exclusive = LED_5V;
- if (vbus_mv != ADC_READ_ERROR) {
+ if (read != ADC_READ_ERROR) {
if (vbus_mv >= 2405)
max_on_exclusive = LED_COUNT;
else if (vbus_mv >= 1788)
@@ -387,7 +388,7 @@ void show_output_voltage_on_leds(void)
for (i = 0; i < LED_COUNT; i++)
set_led(i, i < max_on_exclusive);
- act = (vbus_mv * 7692) / 1000;
+ act = (vbus_mv * 76667) / 10000;
if ((vbus_mv > prev_vbus_mv+2) || (vbus_mv < prev_vbus_mv-2)) {
CPRINTS("PPVAR_VBUS_DUT: %d mV (raw: %d)", act,
vbus_mv);