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>
This commit is contained in:
Vic Yang
2013-04-22 14:53:01 +08:00
committed by ChromeBot
parent 4d96bf649d
commit c6e5d592cb
2 changed files with 32 additions and 0 deletions

View File

@@ -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 */

View File

@@ -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 */