From dc3e345a05331eefd38be47b5628b7b690ae70e8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 4 Jan 2020 11:05:51 +1100 Subject: [PATCH] AP_RTC: added get_semaphore() --- libraries/AP_RTC/AP_RTC.cpp | 1 + libraries/AP_RTC/AP_RTC.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/libraries/AP_RTC/AP_RTC.cpp b/libraries/AP_RTC/AP_RTC.cpp index c3e978d3fb..781e1602fb 100644 --- a/libraries/AP_RTC/AP_RTC.cpp +++ b/libraries/AP_RTC/AP_RTC.cpp @@ -63,6 +63,7 @@ void AP_RTC::set_utc_usec(uint64_t time_utc_usec, source_type type) // can't allow time to go backwards, ever return; } + WITH_SEMAPHORE(rsem); rtc_shift = tmp; diff --git a/libraries/AP_RTC/AP_RTC.h b/libraries/AP_RTC/AP_RTC.h index 373cc6b62d..d0c9f79a37 100644 --- a/libraries/AP_RTC/AP_RTC.h +++ b/libraries/AP_RTC/AP_RTC.h @@ -49,9 +49,15 @@ public: return _singleton; } + // allow threads to lock against RTC update + HAL_Semaphore &get_semaphore(void) { + return rsem; + } + private: static AP_RTC *_singleton; + HAL_Semaphore_Recursive rsem; source_type rtc_source_type = SOURCE_NONE; int64_t rtc_shift;