diff --git a/platforms/qurt/src/px4/tasks.cpp b/platforms/qurt/src/px4/tasks.cpp index 2dd044da44..de6c685233 100644 --- a/platforms/qurt/src/px4/tasks.cpp +++ b/platforms/qurt/src/px4/tasks.cpp @@ -35,8 +35,11 @@ #include #include #include +#include +#include #include +#include "hrt_work.h" #define PX4_TASK_STACK_SIZE 8192 #define PX4_TASK_MAX_NAME_LENGTH 32 @@ -338,25 +341,25 @@ const char *px4_get_taskname() } -// static void timer_cb(void *data) -// { -// px4_sem_t *sem = reinterpret_cast(data); +static void timer_cb(void *data) +{ + px4_sem_t *sem = reinterpret_cast(data); -// sem_post(sem); -// } + sem_post(sem); +} int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *ts) { - // work_s _hpwork = {}; + work_s _hpwork = {}; - // struct timespec ts_now; - // px4_clock_gettime(CLOCK_MONOTONIC, &ts_now); + struct timespec ts_now; + px4_clock_gettime(CLOCK_MONOTONIC, &ts_now); - // hrt_abstime timeout_us = ts_to_abstime((struct timespec *)ts) - ts_to_abstime(&ts_now); + hrt_abstime timeout_us = ts_to_abstime((struct timespec *)ts) - ts_to_abstime(&ts_now); - // hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)sem, timeout_us); - // sem_wait(sem); - // hrt_work_cancel(&_hpwork); + hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)sem, timeout_us); + sem_wait(sem); + hrt_work_cancel(&_hpwork); return 0; }