Skip to content

Commit

Permalink
SAMv7: Add atomic and non-atomic HRT calls
Browse files Browse the repository at this point in the history
This reduces interrupt load significantly.
  • Loading branch information
LorenzMeier committed Jan 22, 2019
1 parent 27cae91 commit bca0f79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/drivers/samv7/drv_hrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,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 = enter_critical_section();

Expand Down

0 comments on commit bca0f79

Please sign in to comment.