Skip to content
Snippets Groups Projects
Commit ccefc640 authored by Beat Küng's avatar Beat Küng Committed by Julian Oes
Browse files

drv_hrt posix: remove unused code and remove locking from hrt_absolute_time

parent 5f0e6d70
No related branches found
No related tags found
No related merge requests found
...@@ -67,11 +67,6 @@ static hrt_abstime px4_timestart_monotonic = 0; ...@@ -67,11 +67,6 @@ static hrt_abstime px4_timestart_monotonic = 0;
static int32_t dsp_offset = 0; static int32_t dsp_offset = 0;
#endif #endif
static hrt_abstime _start_delay_time = 0;
static hrt_abstime _delay_interval = 0;
static hrt_abstime max_time = 0;
static pthread_mutex_t _hrt_mutex = PTHREAD_MUTEX_INITIALIZER;
#if defined(ENABLE_LOCKSTEP_SCHEDULER) #if defined(ENABLE_LOCKSTEP_SCHEDULER)
static LockstepScheduler lockstep_scheduler; static LockstepScheduler lockstep_scheduler;
#endif #endif
...@@ -80,7 +75,6 @@ static LockstepScheduler lockstep_scheduler; ...@@ -80,7 +75,6 @@ static LockstepScheduler lockstep_scheduler;
hrt_abstime hrt_absolute_time_offset(); hrt_abstime hrt_absolute_time_offset();
static void hrt_call_reschedule(); static void hrt_call_reschedule();
static void hrt_call_invoke(); static void hrt_call_invoke();
static hrt_abstime _hrt_absolute_time_internal();
__EXPORT hrt_abstime hrt_reset(); __EXPORT hrt_abstime hrt_reset();
hrt_abstime hrt_absolute_time_offset() hrt_abstime hrt_absolute_time_offset()
...@@ -158,7 +152,7 @@ uint64_t hrt_system_time() ...@@ -158,7 +152,7 @@ uint64_t hrt_system_time()
/* /*
* Get absolute time. * Get absolute time.
*/ */
hrt_abstime _hrt_absolute_time_internal() hrt_abstime hrt_absolute_time()
{ {
struct timespec ts; struct timespec ts;
px4_clock_gettime(CLOCK_MONOTONIC, &ts); px4_clock_gettime(CLOCK_MONOTONIC, &ts);
...@@ -177,42 +171,12 @@ int hrt_set_absolute_time_offset(int32_t time_diff_us) ...@@ -177,42 +171,12 @@ int hrt_set_absolute_time_offset(int32_t time_diff_us)
} }
#endif #endif
/*
* Get absolute time.
*/
hrt_abstime hrt_absolute_time()
{
pthread_mutex_lock(&_hrt_mutex);
hrt_abstime ret;
if (_start_delay_time > 0) {
ret = _start_delay_time;
} else {
ret = _hrt_absolute_time_internal();
}
ret -= _delay_interval;
if (ret < max_time) {
PX4_ERR("WARNING! TIME IS NEGATIVE! %d vs %d", (int)ret, (int)max_time);
ret = max_time;
}
max_time = ret;
pthread_mutex_unlock(&_hrt_mutex);
return ret;
}
hrt_abstime hrt_reset() hrt_abstime hrt_reset()
{ {
#ifndef __PX4_QURT #ifndef __PX4_QURT
px4_timestart_monotonic = 0; px4_timestart_monotonic = 0;
#endif #endif
max_time = 0; return hrt_absolute_time();
return _hrt_absolute_time_internal();
} }
/* /*
...@@ -317,41 +281,6 @@ void hrt_init() ...@@ -317,41 +281,6 @@ void hrt_init()
memset(&_hrt_work, 0, sizeof(_hrt_work)); memset(&_hrt_work, 0, sizeof(_hrt_work));
} }
void hrt_start_delay()
{
pthread_mutex_lock(&_hrt_mutex);
_start_delay_time = _hrt_absolute_time_internal();
pthread_mutex_unlock(&_hrt_mutex);
}
void hrt_stop_delay_delta(hrt_abstime delta)
{
pthread_mutex_lock(&_hrt_mutex);
uint64_t delta_measured = _hrt_absolute_time_internal() - _start_delay_time;
if (delta_measured < delta) {
delta = delta_measured;
}
_delay_interval += delta;
_start_delay_time = 0;
pthread_mutex_unlock(&_hrt_mutex);
}
void hrt_stop_delay()
{
pthread_mutex_lock(&_hrt_mutex);
uint64_t delta = _hrt_absolute_time_internal() - _start_delay_time;
_delay_interval += delta;
_start_delay_time = 0;
pthread_mutex_unlock(&_hrt_mutex);
}
static void static void
hrt_call_enter(struct hrt_call *entry) hrt_call_enter(struct hrt_call *entry)
{ {
......
...@@ -173,25 +173,6 @@ __EXPORT extern void hrt_init(void); ...@@ -173,25 +173,6 @@ __EXPORT extern void hrt_init(void);
#ifdef __PX4_POSIX #ifdef __PX4_POSIX
/**
* Start to delay the HRT return value.
*
* Until hrt_stop_delay() is called the HRT calls will return the timestamp
* at the instance then hrt_start_delay() was called.
*/
__EXPORT extern void hrt_start_delay(void);
/**
* Stop to delay the HRT.
*/
__EXPORT extern void hrt_stop_delay(void);
/**
* Stop to delay the HRT, but with an exact delta time.
*/
__EXPORT extern void hrt_stop_delay_delta(hrt_abstime delta);
__EXPORT extern hrt_abstime hrt_reset(void); __EXPORT extern hrt_abstime hrt_reset(void);
__EXPORT extern hrt_abstime hrt_absolute_time_offset(void); __EXPORT extern hrt_abstime hrt_absolute_time_offset(void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment