muorb: abs time on aDSP in sync with Linux side

This adds a call on startup of the muorb on the aDSP side to use an
offset for hrt_absolute_call(). This means that the hrt_absolute_call()
on the appsproc (Linux) side should now match the one on the aDSP
(QURT) side.
The accuracy still needs to be determined.
This commit is contained in:
Julian Oes
2016-04-08 15:51:16 +02:00
parent ae2c28677d
commit 2bce8f2803
6 changed files with 164 additions and 6 deletions
+28
View File
@@ -66,7 +66,11 @@ static void hrt_call_reschedule(void);
static px4_sem_t _hrt_lock;
static struct work_s _hrt_work;
#ifndef __PX4_QURT
static hrt_abstime px4_timestart = 0;
#else
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;
@@ -150,6 +154,19 @@ hrt_abstime _hrt_absolute_time_internal(void)
{
struct timespec ts;
#if defined(__PX4_QURT)
// Don't use the timestart on the DSP on Snapdragon because we manually
// set the px4_timestart using the hrt_set_absolute_time_offset().
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
return ts_to_abstime(&ts) + dsp_offset;
#elif defined(__PX4_POSIX_EAGLE)
// Don't do any offseting on the Linux side on the Snapdragon.
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
return ts_to_abstime(&ts);
#else
if (!px4_timestart) {
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
px4_timestart = ts_to_abstime(&ts);
@@ -157,8 +174,17 @@ hrt_abstime _hrt_absolute_time_internal(void)
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
return ts_to_abstime(&ts) - px4_timestart;
#endif
}
#ifdef __PX4_QURT
int hrt_set_absolute_time_offset(int32_t time_diff_us)
{
dsp_offset = time_diff_us;
return 0;
}
#endif
/*
* Get absolute time.
*/
@@ -190,7 +216,9 @@ hrt_abstime hrt_absolute_time(void)
__EXPORT hrt_abstime hrt_reset(void)
{
#ifndef __PX4_QURT
px4_timestart = 0;
#endif
max_time = 0;
return _hrt_absolute_time_internal();
}