Twinkie v2: Changes to support Twinkie v2.1 HW design.
1) Removes the 1.22 magic number multiplier. This was originally added
to compensate for bias caused by the ADC sampling capacitor.
Now that we have a input cap on the ADC pin, we use the true ADC value.
2) CC_EN lines are now active low
3) VBUS voltage calibration is no longer run on each sample
4) VBUS oversampling is enabled for better accuracy (more effective ADC bits)
BUG=b:287131048
TEST=build and flash the image. Validate Twinkie v2.1 reports expected
measurement values, especially for VBUS, CC1, and CC2
`west build -p always twinkie_v2`
`sudo dfu-util -a 0 -s 0x8000000:leave -D build/zephyr/zephyr.bin`
Change-Id: I4c7c06fd4a3cd2fb250d8b33890a1664e9dddb00
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/hdctools_firmware/+/5924152
Auto-Submit: Christopher Buck <cmbuck@google.com>
Tested-by: Christopher Buck <cmbuck@google.com>
Reviewed-by: Brian Nemec <bnemec@google.com>
Reviewed-by: zhi cheng yuan <jasonyuan@chromium.org>
diff --git a/zephyr_projects/twinkie_v2/app.overlay b/zephyr_projects/twinkie_v2/app.overlay
index f5422fd..0369770 100644
--- a/zephyr_projects/twinkie_v2/app.overlay
+++ b/zephyr_projects/twinkie_v2/app.overlay
@@ -12,11 +12,11 @@
cc_config {
compatible = "gpio-leds";
cc1_en: cc1en {
- gpios = <&gpiob 2 GPIO_ACTIVE_HIGH>;
+ gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
};
cc2_en: cc2en {
- gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
+ gpios = <&gpiob 13 GPIO_ACTIVE_LOW>;
};
};
diff --git a/zephyr_projects/twinkie_v2/src/meas.c b/zephyr_projects/twinkie_v2/src/meas.c
index a966064..346a1d5 100644
--- a/zephyr_projects/twinkie_v2/src/meas.c
+++ b/zephyr_projects/twinkie_v2/src/meas.c
@@ -37,7 +37,8 @@
.buffer = &sample_buffer,
/* buffer size in bytes, not number of samples */
.buffer_size = sizeof(sample_buffer),
- .calibrate = true,
+ .calibrate = false,
+ .oversampling = 8
};
adc_sequence_init_dt(&adc_vbus_v.port, &sequence);
@@ -57,8 +58,6 @@
return ret;
}
- *v *= 1.22;
-
return 0;
}
diff --git a/zephyr_projects/twinkie_v2/src/shell.c b/zephyr_projects/twinkie_v2/src/shell.c
index 57cdd8b..3bedcfb 100644
--- a/zephyr_projects/twinkie_v2/src/shell.c
+++ b/zephyr_projects/twinkie_v2/src/shell.c
@@ -68,7 +68,7 @@
ARG_UNUSED(argc);
ARG_UNUSED(argv);
- shell_print(shell, "Twinkie version 2.2.1");
+ shell_print(shell, "Twinkie version 2.2.2");
return 0;
}