summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-04-22 14:53:01 +0800
committerChromeBot <chrome-bot@google.com>2013-04-23 23:06:15 -0700
commit053997e4b516a8d7bb94c17d5a345debce261d5d (patch)
treeab28d2646084bf9f1541867920b0f574c19068e8
parentcb5407d8e70b9a261a76d4a841973984916a9617 (diff)
downloadchrome-ec-053997e4b516a8d7bb94c17d5a345debce261d5d.tar.gz
Add LP5562 functions to control engine execution state
This gives us better control over the execution state of lighting engine. BUG=chromium:233832 TEST=Build success BRANCH=spring Original-Change-Id: Ibfa86be0eef2b7dff8495f770649577295d4cb6f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48773 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit c6e5d592cbfe95bd9978e14aba30a5bb17c19d90) Change-Id: Idf1ce9ebc8972c3ae7441d994d0f4e8558ecf44e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49010 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/lp5562.c22
-rw-r--r--include/lp5562.h10
2 files changed, 32 insertions, 0 deletions
diff --git a/common/lp5562.c b/common/lp5562.c
index 09ee0df2c5..5c7d21f02a 100644
--- a/common/lp5562.c
+++ b/common/lp5562.c
@@ -82,6 +82,15 @@ int lp5562_engine_control(int eng1, int eng2, int eng3)
return lp5562_write(LP5562_REG_ENABLE, val);
}
+int lp5562_get_engine_state(int engine)
+{
+ int val;
+
+ if (lp5562_read(LP5562_REG_ENABLE, &val))
+ return 0xee;
+ return (val >> (6 - engine * 2)) & 0x3;
+}
+
int lp5562_poweron(void)
{
int ret = 0;
@@ -100,6 +109,19 @@ int lp5562_poweroff(void)
return lp5562_write(LP5562_REG_ENABLE, 0x0);
}
+int lp5562_get_pc(int engine)
+{
+ int ret;
+ if (lp5562_read(LP5562_REG_ENG1_PC + engine - 1, &ret))
+ return 0xee;
+ return ret;
+}
+
+int lp5562_set_pc(int engine, int val)
+{
+ return lp5562_write(LP5562_REG_ENG1_PC + engine - 1, val);
+}
+
/*****************************************************************************/
/* Console commands */
diff --git a/include/lp5562.h b/include/lp5562.h
index b993825c7a..400612ede7 100644
--- a/include/lp5562.h
+++ b/include/lp5562.h
@@ -39,6 +39,7 @@
#define LP5562_ENG_SEL_3 0x3
#define LP5562_ENG_HOLD 0x0
+#define LP5562_ENG_STEP 0x1
#define LP5562_ENG_RUN 0x2
/* Power on and initialize LP5562. */
@@ -62,4 +63,13 @@ int lp5562_engine_load(int engine, uint8_t *program, int size);
/* Control lighting engine execution state */
int lp5562_engine_control(int eng1, int eng2, int eng3);
+/* Get engine execution state. Return 0xee on error. */
+int lp5562_get_engine_state(int engine);
+
+/* Get current program counter. Return 0xee on error. */
+int lp5562_get_pc(int engine);
+
+/* Set program counter */
+int lp5562_set_pc(int engine, int val);
+
#endif /* LP5562_H */