diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-08-07 15:36:21 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-08-09 15:44:09 -0700 |
commit | 0c8c2e453ab3960f315050fbb9808f438398624f (patch) | |
tree | 472f7677ac3738338bea389a42d9c1b7f6703bda /test/build.mk | |
parent | 71a3bb0c0746d17e55e1e08322258e555ac80682 (diff) | |
download | chrome-ec-0c8c2e453ab3960f315050fbb9808f438398624f.tar.gz |
Add abstract "cond_t" type to detect state transitions.
We often need to watch for transitions between one state and another, so
that we can issue warnings or take action ONCE. This abstracts that "have I
already reacted to this" stuff into a single set of functions.
For example, this code reads a GPIO every time through the loop, but it only
generates an event when the GPIO value changes from 0 to 1:
cond_t c;
cond_init_false(&c);
while(1) {
int val = read_some_gpio();
cond_set(&c, val);
if (cond_went_true(&c))
host_event(SOMETHING_HAPPENED);
sleep(1);
}
BUG=none
BRANCH=falco,peppy
TEST=manual
make BOARD=falco runtests
Change-Id: I42393fcf3c4eb71b9551118a0f442d55c0691315
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65071
Diffstat (limited to 'test/build.mk')
0 files changed, 0 insertions, 0 deletions