aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/stm32/drv_hrt.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/drivers/stm32/drv_hrt.c')
-rw-r--r--apps/drivers/stm32/drv_hrt.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/drivers/stm32/drv_hrt.c b/apps/drivers/stm32/drv_hrt.c
index cd9cb45b1..bb67d5e6d 100644
--- a/apps/drivers/stm32/drv_hrt.c
+++ b/apps/drivers/stm32/drv_hrt.c
@@ -646,6 +646,36 @@ abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
}
/*
+ * Compare a time value with the current time.
+ */
+hrt_abstime
+hrt_elapsed_time(const volatile hrt_abstime *then)
+{
+ irqstate_t flags = irqsave();
+
+ hrt_abstime delta = hrt_absolute_time() - *then;
+
+ irqrestore(flags);
+
+ return delta;
+}
+
+/*
+ * Store the absolute time in an interrupt-safe fashion
+ */
+hrt_abstime
+hrt_store_absolute_time(volatile hrt_abstime *now)
+{
+ irqstate_t flags = irqsave();
+
+ hrt_abstime ts = hrt_absolute_time();
+
+ irqrestore(flags);
+
+ return ts;
+}
+
+/*
* Initalise the high-resolution timing module.
*/
void