summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-10 15:33:03 -0700
committerGerrit <chrome-bot@google.com>2012-10-11 10:06:56 -0700
commitbea56570f3105830a9df92cc7c9ea1185bf0dbef (patch)
tree9f1bdda2b66a6fc4dfab06c7180703cf18344a60 /common
parent0b6b6b7754359546d4fd6684156bc7b120328721 (diff)
downloadchrome-ec-bea56570f3105830a9df92cc7c9ea1185bf0dbef.tar.gz
Add t6cal console command to set/print TMP006 calibration
Note that radix must be specified as an integer, because we don't have floating-point parsing. So to set the first sensor's S0 to 3.600e-14, do: t6cal 0 S0 3600 BUG=chrome-os-partner:14955 BRANCH=link TEST=manual From EC console, t6cal 0 s0 3500 t6cal 1 b0 -3000 t6cal 1 b1 -5600 t6cal 2 b2 4700 t6cal The final t6cal should show the changes from the previous commands Change-Id: I2f8f71890e8e64a427cc29c3ef86ca991ce6b039 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35204
Diffstat (limited to 'common')
-rw-r--r--common/tmp006.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/common/tmp006.c b/common/tmp006.c
index 3aa305b475..ecc55ee14f 100644
--- a/common/tmp006.c
+++ b/common/tmp006.c
@@ -308,7 +308,7 @@ static int command_sensor_info(int argc, char **argv)
int rv, rv1;
rv1 = EC_SUCCESS;
- for (i = 0; i < TMP006_COUNT; ++i) {
+ for (i = 0; i < TMP006_COUNT; i++) {
rv = tmp006_print(i);
if (rv != EC_SUCCESS)
rv1 = rv;
@@ -321,3 +321,57 @@ DECLARE_CONSOLE_COMMAND(tmp006, command_sensor_info,
NULL,
"Print TMP006 sensors",
NULL);
+
+static int command_t6cal(int argc, char **argv)
+{
+ struct tmp006_data_t *tdata;
+ char *e;
+ int v;
+ int i;
+
+ if (argc < 2) {
+ ccprintf("# Name S0 B0"
+ " B1 B2\n");
+ for (i = 0; i < TMP006_COUNT; i++) {
+ tdata = tmp006_data + i;
+ ccprintf("%d %-11s"
+ "%7de-17 %7de-8 %7de-10 %7de-12\n",
+ i, tmp006_sensors[i].name,
+ (int)(tdata->S0 * 1e17f),
+ (int)(tdata->B0 * 1e8f),
+ (int)(tdata->B1 * 1e10f),
+ (int)(tdata->B2 * 1e12f));
+ }
+
+ return EC_SUCCESS;
+ }
+
+ if (argc != 4)
+ return EC_ERROR_PARAM_COUNT;
+
+ i = strtoi(argv[1], &e, 0);
+ if (*e || i < 0 || i >= TMP006_COUNT)
+ return EC_ERROR_PARAM1;
+ tdata = tmp006_data + i;
+
+ v = strtoi(argv[3], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM3;
+
+ if (!strcasecmp(argv[2], "S0"))
+ tdata->S0 = (float)v * 1e-17f;
+ else if (!strcasecmp(argv[2], "B0"))
+ tdata->B0 = (float)v * 1e-8f;
+ else if (!strcasecmp(argv[2], "B1"))
+ tdata->B1 = (float)v * 1e-10f;
+ else if (!strcasecmp(argv[2], "B2"))
+ tdata->B2 = (float)v * 1e-12f;
+ else
+ return EC_ERROR_PARAM2;
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(t6cal, command_t6cal,
+ "[<index> <coeff_name> <radix>]",
+ "Set/print TMP006 calibration",
+ NULL);