From 58388b7e5ee79ee9ff55ae4ccd4f9023da485b49 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Fri, 3 Apr 2020 16:07:08 +0300 Subject: [PATCH] Out-of-line LowPowerTimeout etc, lock To match Timer etc, make LowPowerTimer et al out-of-line. Correct LowPowerTimeout to not lock deep sleep. --- drivers/LowPowerTicker.h | 5 +---- drivers/LowPowerTimer.h | 6 +----- drivers/source/Ticker.cpp | 8 ++++++++ drivers/source/Timeout.cpp | 12 ++++++------ drivers/source/Timer.cpp | 8 ++++++++ 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/LowPowerTicker.h b/drivers/LowPowerTicker.h index 09ce9ec3c1..16e69dc6d5 100644 --- a/drivers/LowPowerTicker.h +++ b/drivers/LowPowerTicker.h @@ -40,11 +40,8 @@ namespace mbed { * @note Synchronization level: Interrupt safe */ class LowPowerTicker : public TickerBase { - public: - LowPowerTicker() : TickerBase(get_lp_ticker_data()) - { - } + LowPowerTicker(); }; /** @}*/ diff --git a/drivers/LowPowerTimer.h b/drivers/LowPowerTimer.h index 2000ef9ca8..d62677b9c4 100644 --- a/drivers/LowPowerTimer.h +++ b/drivers/LowPowerTimer.h @@ -37,12 +37,8 @@ namespace mbed { * @note Synchronization level: Interrupt safe */ class LowPowerTimer : public TimerBase { - public: - LowPowerTimer() : TimerBase(get_lp_ticker_data()) - { - } - + LowPowerTimer(); }; /** @}*/ diff --git a/drivers/source/Ticker.cpp b/drivers/source/Ticker.cpp index 68f128625d..5a37b0e002 100644 --- a/drivers/source/Ticker.cpp +++ b/drivers/source/Ticker.cpp @@ -15,8 +15,10 @@ * limitations under the License. */ #include "drivers/Ticker.h" +#include "drivers/LowPowerTicker.h" #include "hal/us_ticker_api.h" +#include "hal/lp_ticker_api.h" #include "platform/CriticalSectionLock.h" #include "platform/mbed_power_mgmt.h" @@ -103,4 +105,10 @@ Ticker::Ticker() : TickerBase(get_us_ticker_data(), true) { } +#if DEVICE_LPTICKER +LowPowerTicker::LowPowerTicker() : TickerBase(get_lp_ticker_data(), false) +{ +} +#endif + } // namespace mbed diff --git a/drivers/source/Timeout.cpp b/drivers/source/Timeout.cpp index 4b7746809b..c6000a8279 100644 --- a/drivers/source/Timeout.cpp +++ b/drivers/source/Timeout.cpp @@ -39,6 +39,12 @@ Timeout::Timeout() : TimeoutBase(get_us_ticker_data(), true) { } +#if DEVICE_LPTICKER +LowPowerTimeout::LowPowerTimeout() : TimeoutBase(get_lp_ticker_data(), false) +{ +} +#endif + /* A few miscellaneous out-of-line static members from various related classes, * just to save them getting needing their own cpp file for one line. * (In C++17 could avoid the need for this by making the members inline). @@ -49,10 +55,4 @@ const bool LowPowerClock::is_steady; #endif const bool RealTimeClock::is_steady; -#if DEVICE_LPTICKER -LowPowerTimeout::LowPowerTimeout() : TimeoutBase(get_lp_ticker_data(), true) -{ -} -#endif - } // namespace mbed diff --git a/drivers/source/Timer.cpp b/drivers/source/Timer.cpp index 233731ca48..3b344909d2 100644 --- a/drivers/source/Timer.cpp +++ b/drivers/source/Timer.cpp @@ -15,8 +15,10 @@ * limitations under the License. */ #include "drivers/Timer.h" +#include "drivers/LowPowerTimer.h" #include "hal/ticker_api.h" #include "hal/us_ticker_api.h" +#include "hal/lp_ticker_api.h" #include "platform/CriticalSectionLock.h" #include "platform/mbed_critical.h" #include "platform/mbed_power_mgmt.h" @@ -121,4 +123,10 @@ Timer::Timer() : TimerBase(get_us_ticker_data(), true) { } +#if DEVICE_LPTICKER +LowPowerTimer::LowPowerTimer() : TimerBase(get_lp_ticker_data(), false) +{ +} +#endif + } // namespace mbed