From a7c9601d08c3084e2c1324669a676304f03f6c39 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Mon, 18 May 2020 10:49:31 +0200 Subject: [PATCH] OS timer uses LPTICKER by default, then USTICKER This PR makes the bare-metal mode work automatically regardless of the tickless-from-us-ticker setting - in non RTOS mode - and in RTOS tickless mode --- platform/source/mbed_os_timer.cpp | 12 +++++------- rtos/source/TARGET_CORTEX/mbed_rtx_idle.cpp | 4 ---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/platform/source/mbed_os_timer.cpp b/platform/source/mbed_os_timer.cpp index eaedbab4c2..17126eea9b 100644 --- a/platform/source/mbed_os_timer.cpp +++ b/platform/source/mbed_os_timer.cpp @@ -22,7 +22,7 @@ #include "us_ticker_api.h" #include "lp_ticker_api.h" #include "mbed_critical.h" -#include "mbed_assert.h" +#include "mbed_error.h" #include /* This provides the marshalling point for a system global SysTimer, which @@ -47,15 +47,13 @@ OsTimer *init_os_timer() // Locking not required as it will be first called during // OS init, or else we're a non-RTOS single-threaded setup. if (!os_timer) { -#if MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && DEVICE_USTICKER - os_timer = new (os_timer_data) OsTimer(get_us_ticker_data()); -#elif !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && DEVICE_LPTICKER +#if DEVICE_LPTICKER && !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER os_timer = new (os_timer_data) OsTimer(get_lp_ticker_data()); +#elif DEVICE_USTICKER + os_timer = new (os_timer_data) OsTimer(get_us_ticker_data()); #else - MBED_ASSERT("OS timer not available - check MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER" && false); - return NULL; + MBED_ERROR("OS timer not available"); #endif - //os_timer->setup_irq(); } return os_timer; diff --git a/rtos/source/TARGET_CORTEX/mbed_rtx_idle.cpp b/rtos/source/TARGET_CORTEX/mbed_rtx_idle.cpp index 1902e70326..1fdf070bde 100644 --- a/rtos/source/TARGET_CORTEX/mbed_rtx_idle.cpp +++ b/rtos/source/TARGET_CORTEX/mbed_rtx_idle.cpp @@ -42,10 +42,6 @@ extern "C" { #if MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && !DEVICE_USTICKER #error Microsecond ticker required when MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER is true -#endif - -#if !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && !DEVICE_LPTICKER -#error Low power ticker required when MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER is false #endif // Setup OS Tick timer to generate periodic RTOS Kernel Ticks