summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-01-06 18:07:27 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-02-22 00:48:25 +0000
commit9305b84ab2a844393b90b897c394a557d8dfa8fb (patch)
tree1cd7fe0ebaccce6d909e736ced277a31090e2721 /include
parent8df483bf594d6251005a88de211078e2a445a55d (diff)
downloadchrome-ec-9305b84ab2a844393b90b897c394a557d8dfa8fb.tar.gz
rambi: Accelerometer driver for kxcj9.
Added accelerometer driver for kxcj9 accelerometers. Currently the accelerometers aren't being used by anything, but there are console commands, accelwrite and accelread, to perform transactions. BUG=none BRANCH=rambi TEST=Used EC console commands to test that accelerometers respond and data looks reasonable. Original-Change-Id: I6ddcf04ec278adeacb148c19b10c3c296b467954 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184693 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 5e1d2052b034b2400b98b2126243e01397a2ce56) Conflicts: board/clapper/board.c board/clapper/board.h board/glimmer/board.c board/glimmer/board.h Change-Id: If8744ddc3273fc08e29830adfd068dc302dd120a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187432 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/accelerometer.h36
-rw-r--r--include/config.h4
2 files changed, 40 insertions, 0 deletions
diff --git a/include/accelerometer.h b/include/accelerometer.h
new file mode 100644
index 0000000000..48d61ac3ab
--- /dev/null
+++ b/include/accelerometer.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* This array must be defined in board.c. */
+extern const int accel_addr[];
+
+/* This enum must be defined in board.h. */
+enum accel_id;
+
+/* Number of counts from accelerometer that represents 1G acceleration. */
+#define ACCEL_G 1024
+
+/**
+ * Read all three accelerations of an accelerometer. Note that all three
+ * accelerations come back in counts, where ACCEL_G can be used to convert
+ * counts to engineering units.
+ *
+ * @param id Target accelerometer
+ * @param x_acc Pointer to store X-axis acceleration (in counts).
+ * @param y_acc Pointer to store Y-axis acceleration (in counts).
+ * @param z_acc Pointer to store Z-axis acceleration (in counts).
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int accel_read(enum accel_id id, int *x_acc, int *y_acc, int *z_acc);
+
+/**
+ * Initiailze accelerometers.
+ *
+ * @param id Target accelerometer
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int accel_init(enum accel_id id);
diff --git a/include/config.h b/include/config.h
index 479a68e61a..114e6e982f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -36,6 +36,9 @@
* BOARD_*, CHIP_*, and CHIP_FAMILY_*.
*/
+/* Specify type of accelerometers attached. */
+#undef CONFIG_ACCEL_KXCJ9
+
/* Compile chip support for analog-to-digital convertor */
#undef CONFIG_ADC
@@ -234,6 +237,7 @@
* console.
*/
+#undef CONFIG_CMD_ACCELS
#undef CONFIG_CMD_BATDEBUG
#undef CONFIG_CMD_CLOCKGATES
#undef CONFIG_CMD_COMXTEST