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 10:39:13 -0700
commitc6e5d592cbfe95bd9978e14aba30a5bb17c19d90 (patch)
treec6f25e20c155c76744c2e98006cbfbba75c89b9f
parent4d96bf649de38e989016fd9a467ab243ace436f7 (diff)
downloadchrome-ec-c6e5d592cbfe95bd9978e14aba30a5bb17c19d90.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 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>
-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 dc16a20f79..721be45d41 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 f1a5af092c..f0d32d495e 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, const 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 */