drv_hrt posix: remove unused code and remove locking from hrt_absolute_time

This commit is contained in:
Beat Küng 2019-01-07 07:12:19 +01:00 committed by Julian Oes
parent 5f0e6d70c5
commit ccefc640ac
2 changed files with 2 additions and 92 deletions

View File

@ -67,11 +67,6 @@ static hrt_abstime px4_timestart_monotonic = 0;
static int32_t dsp_offset = 0;
#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)
static LockstepScheduler lockstep_scheduler;
#endif
@ -80,7 +75,6 @@ static LockstepScheduler lockstep_scheduler;
hrt_abstime hrt_absolute_time_offset();
static void hrt_call_reschedule();
static void hrt_call_invoke();
static hrt_abstime _hrt_absolute_time_internal();
__EXPORT hrt_abstime hrt_reset();
hrt_abstime hrt_absolute_time_offset()
@ -158,7 +152,7 @@ uint64_t hrt_system_time()
/*
* Get absolute time.
*/
hrt_abstime _hrt_absolute_time_internal()
hrt_abstime hrt_absolute_time()
{
struct timespec ts;
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
@ -177,42 +171,12 @@ int hrt_set_absolute_time_offset(int32_t time_diff_us)
}
#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()
{
#ifndef __PX4_QURT
px4_timestart_monotonic = 0;
#endif
max_time = 0;
return _hrt_absolute_time_internal();
return hrt_absolute_time();
}
/*
@ -317,41 +281,6 @@ void hrt_init()
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
hrt_call_enter(struct hrt_call *entry)
{

View File

@ -173,25 +173,6 @@ __EXPORT extern void hrt_init(void);
#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_absolute_time_offset(void);