summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2011-10-20 23:45:20 +0800
committerLouis Yung-Chieh Lo <yjlou@chromium.org>2011-10-25 14:18:52 +0800
commit53acb3f245b15d4c67a6acc2f304a606de0d337d (patch)
tree9d2aab342d1f553e898ffef39d1e0df7b6697859
parent2b3bef79683061e89d3e3c2823c87f592e2f2e23 (diff)
downloadchrome-ec-53acb3f245b15d4c67a6acc2f304a606de0d337d.tar.gz
The keyboard interface between EC core and EC lib.
BUG=None. TEST=None. Change-Id: I6b58cc1bd98b6d02b8138956ac609577dfb05755
-rw-r--r--chip_interface/keyboard.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/chip_interface/keyboard.h b/chip_interface/keyboard.h
new file mode 100644
index 0000000000..78828678f3
--- /dev/null
+++ b/chip_interface/keyboard.h
@@ -0,0 +1,35 @@
+/* Copyright (c) 2011 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.
+ *
+ * keyboard.h - Keyboard interface between EC core and EC Lib.
+ */
+
+#ifndef __CHIP_INTERFACE_KEYBOARD_H
+#define __CHIP_INTERFACE_KEYBOARD_H
+
+#include "cros_ec/include/ec_common.h"
+
+#define MAX_KEYBOARD_MATRIX_COLS 16
+#define MAX_KEYBOARD_MATRIX_ROWS 8
+
+typedef void (*EcKeyboardCallback)(int col, int row, int is_pressed);
+
+/* Registers a callback function to underlayer EC lib. So that any key state
+ * change would notify the upper EC main code.
+ *
+ * Note that passing NULL removes any previously registered callback.
+ */
+EcError EcKeyboardRegisterCallback(EcKeyboardCallback cb);
+
+/* Asks the underlayer EC lib what keys are pressed right now.
+ *
+ * Sets bit_array to a debounced array of which keys are currently pressed,
+ * where a 1-bit means the key is pressed. For example, if only col=2 row=3
+ * is pressed, it would set bit_array to {0, 0, 0x08, 0, ...}
+ *
+ * bit_array must be at least MAX_KEYBOARD_MATRIX_COLS bytes long.
+ */
+EcError EcKeyboardGetState(uint8_t *bit_array);
+
+#endif /* __CHIP_INTERFACE_KEYBOARD_H */