From db5530e1b59d08291a570b693cd11b869286faa3 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 2 Jun 2015 00:40:43 -0700 Subject: [PATCH] POSIX: Fixes for HRT implementation of simulated HW clock polling There is a race condition for the accel and mag polling rates. Whichever one gets set first, the other will be uninitialized. Set the mag polling rate to 1ms if uninitilized. Signed-off-by: Mark Charlebois --- src/platforms/posix/px4_layer/hrt_work_lock.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/platforms/posix/px4_layer/hrt_work_lock.h b/src/platforms/posix/px4_layer/hrt_work_lock.h index 86aa3913a2..69c5f204a3 100644 --- a/src/platforms/posix/px4_layer/hrt_work_lock.h +++ b/src/platforms/posix/px4_layer/hrt_work_lock.h @@ -33,22 +33,33 @@ #include #include -#include +#include #pragma once + +__BEGIN_DECLS + extern sem_t _hrt_work_lock; +extern struct wqueue_s g_hrt_work; + +void hrt_work_queue_init(void); +int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t delay); +int hrt_work_cancel(struct work_s *work); inline void hrt_work_lock(); +inline void hrt_work_unlock(); + inline void hrt_work_lock() { - PX4_INFO("hrt_work_lock"); + //PX4_INFO("hrt_work_lock"); sem_wait(&_hrt_work_lock); } -inline void hrt_work_unlock(); inline void hrt_work_unlock() { - PX4_INFO("hrt_work_unlock"); + //PX4_INFO("hrt_work_unlock"); sem_post(&_hrt_work_lock); } +__END_DECLS +