diff options
author | px4dev <px4@purgatory.org> | 2013-02-24 11:41:26 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-02-24 11:41:26 -0800 |
commit | 923a7cc505971ab6d04115d18108152f62d46283 (patch) | |
tree | 149c502582ed80f539dd622da6d8ea688c615107 /apps/drivers/drv_hrt.h | |
parent | a11a71ec9c1b04cd5ca515862605008038804c8d (diff) | |
download | px4-firmware-923a7cc505971ab6d04115d18108152f62d46283.tar.gz px4-firmware-923a7cc505971ab6d04115d18108152f62d46283.tar.bz2 px4-firmware-923a7cc505971ab6d04115d18108152f62d46283.zip |
Add an interrupt-safe way of comparing a timestamp with the current time.
Add an interrupt-safe way of storing the current time into a timestamp.
Diffstat (limited to 'apps/drivers/drv_hrt.h')
-rw-r--r-- | apps/drivers/drv_hrt.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/drivers/drv_hrt.h b/apps/drivers/drv_hrt.h index 3b493a81a..2e30725bd 100644 --- a/apps/drivers/drv_hrt.h +++ b/apps/drivers/drv_hrt.h @@ -92,6 +92,22 @@ __EXPORT extern hrt_abstime ts_to_abstime(struct timespec *ts); __EXPORT extern void abstime_to_ts(struct timespec *ts, hrt_abstime abstime); /* + * Compute the delta between a timestamp taken in the past + * and now. + * + * This function is safe to use even if the timestamp is updated + * by an interrupt during execution. + */ +__EXPORT extern hrt_abstime hrt_elapsed_time(const volatile hrt_abstime *then); + +/* + * Store the absolute time in an interrupt-safe fashion. + * + * This function ensures that the timestamp cannot be seen half-written by an interrupt handler. + */ +__EXPORT extern hrt_absolute_time hrt_store_absolute_time(volatile hrt_abstime *now); + +/* * Call callout(arg) after delay has elapsed. * * If callout is NULL, this can be used to implement a timeout by testing the call |