From 27cae912d13f86851a31d62f9adabde74f86c130 Mon Sep 17 00:00:00 2001 From: Lorenz Meier <lorenz@px4.io> Date: Sun, 20 Jan 2019 17:29:28 +0100 Subject: [PATCH] Kinetis: Add atomic and non-atomic HRT calls This reduces interrupt load significantly. --- src/drivers/kinetis/drv_hrt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/drivers/kinetis/drv_hrt.c b/src/drivers/kinetis/drv_hrt.c index 4b20d5f2f3..f1c046ff84 100644 --- a/src/drivers/kinetis/drv_hrt.c +++ b/src/drivers/kinetis/drv_hrt.c @@ -599,6 +599,17 @@ abstime_to_ts(struct timespec *ts, hrt_abstime abstime) */ hrt_abstime hrt_elapsed_time(const volatile hrt_abstime *then) +{ + hrt_abstime delta = hrt_absolute_time() - *then; + + return delta; +} + +/** + * Compare a time value with the current time as atomic operation. + */ +hrt_abstime +hrt_elapsed_time_atomic(const volatile hrt_abstime *then) { irqstate_t flags = px4_enter_critical_section(); -- GitLab