diff options
author | Gerrit <chrome-bot@google.com> | 2012-05-03 12:05:25 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2012-05-03 12:05:25 -0700 |
commit | 5ba4576cf3a4bd41ac04b0cb5d05cf7c80d13b8a (patch) | |
tree | a504937935e0c469f6d53728a40b826b32018689 | |
parent | 2d592ca924c500a67429b790889562bcb431e75f (diff) | |
parent | 4935a885ee74f6b803d1720de87ef6b1258b61e1 (diff) | |
download | chrome-ec-5ba4576cf3a4bd41ac04b0cb5d05cf7c80d13b8a.tar.gz |
Merge "timer: Add timestamp_expired() to check for expiry"
-rw-r--r-- | core/cortex-m/timer.c | 6 | ||||
-rw-r--r-- | include/timer.h | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/cortex-m/timer.c b/core/cortex-m/timer.c index ba45bc8783..0078936f5a 100644 --- a/core/cortex-m/timer.c +++ b/core/cortex-m/timer.c @@ -37,6 +37,12 @@ static void expire_timer(task_id_t tskid) task_set_event(tskid, TASK_EVENT_TIMER, 0); } +int timestamp_expired(timestamp_t deadline) +{ + timestamp_t now = get_time(); + + return ((int64_t)(now.val - deadline.val) >= 0); +} void process_timers(int overflow) { diff --git a/include/timer.h b/include/timer.h index 4e132ebd6f..796318a1d0 100644 --- a/include/timer.h +++ b/include/timer.h @@ -30,6 +30,14 @@ int timer_arm(timestamp_t tstamp, task_id_t tskid); /* Cancel a running timer for the specified task id. */ int timer_cancel(task_id_t tskid); +/** + * Check if a timestamp has passed / expired + * + * @param deadline deadline timer value to check + * @return 0 if deadline has not yet passed, 1 if it has passed + */ +int timestamp_expired(timestamp_t deadline); + /* Busy-wait the selected number of microseconds. Note that calling this * with us>1000 may impact system performance; use usleep for longer delays. */ void udelay(unsigned us); |