From df487df053f077577b20802d6f493f0af1e6c443 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Fri, 28 Jan 2022 11:37:17 +0100 Subject: [PATCH 1/4] Allow unit tests to be compiled with -fno-exception --- platform/tests/UNITTESTS/doubles/mbed_assert_stub.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/tests/UNITTESTS/doubles/mbed_assert_stub.cpp b/platform/tests/UNITTESTS/doubles/mbed_assert_stub.cpp index baea5f221cd..4b046d7f41c 100644 --- a/platform/tests/UNITTESTS/doubles/mbed_assert_stub.cpp +++ b/platform/tests/UNITTESTS/doubles/mbed_assert_stub.cpp @@ -26,7 +26,11 @@ extern "C" void mbed_assert_internal(const char *expr, const char *file, int lin { fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); if (mbed_assert_throw_errors) { +#ifdef __EXCEPTIONS throw 1; +#else + FAIL(); +#endif } /* Ensure we fail the unit test if the Mbed assertion fails. Without this, From d5506b0fcc3de04a7d3cdd6e26a770f094b8dcec Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Wed, 13 Apr 2022 16:10:37 +0200 Subject: [PATCH 2/4] Fix rtos::Mutex stub, add trylock() method --- rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp b/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp index d90ae20002f..963ad87b73d 100644 --- a/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp +++ b/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp @@ -19,20 +19,25 @@ rtos::Mutex::Mutex() { - return; + return; } rtos::Mutex::~Mutex() { - return; + return; } osStatus rtos::Mutex::lock() { - return osOK; + return osOK; } osStatus rtos::Mutex::unlock() { - return osOK; + return osOK; +} + +bool rtos::Mutex::trylock() +{ + return true; } From 0311e5d55d9a6354108b7be6b71fefd036d8208f Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Tue, 10 May 2022 22:29:21 +0200 Subject: [PATCH 3/4] LowPowerTicker - Add ::attach(...) method + call callback --- .../UNITTESTS/doubles/drivers/LowPowerTicker.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/tests/UNITTESTS/doubles/drivers/LowPowerTicker.h b/drivers/tests/UNITTESTS/doubles/drivers/LowPowerTicker.h index 1d0bb6b5da2..968d698e84e 100644 --- a/drivers/tests/UNITTESTS/doubles/drivers/LowPowerTicker.h +++ b/drivers/tests/UNITTESTS/doubles/drivers/LowPowerTicker.h @@ -17,6 +17,8 @@ #ifndef MBED_LOWPOWERTICKER_H #define MBED_LOWPOWERTICKER_H +#include + #include "hal/ticker_api.h" #include "Callback.h" @@ -28,21 +30,23 @@ namespace mbed { class LowPowerTicker { public: - LowPowerTicker() - { - } + LowPowerTicker() = default; + + virtual ~LowPowerTicker() = default; - virtual ~LowPowerTicker() + void attach(Callback func, std::chrono::microseconds t) { + func(); } void attach_us(Callback func, us_timestamp_t t) { - + func(); } + void detach() { - + // nothing to do } }; From 0246e94fad8d3f5f4d52a48d03da89d55d9c0725 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Sun, 6 Nov 2022 15:35:33 +0100 Subject: [PATCH 4/4] mbed_power_management - rename sleep --> mbed_sleep to avoid conflicts Fixes conflicts w/ unistd.h and boost::ut --- platform/include/platform/mbed_power_mgmt.h | 2 +- platform/source/mbed_os_timer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/include/platform/mbed_power_mgmt.h b/platform/include/platform/mbed_power_mgmt.h index caf1d02d738..1fad877675a 100644 --- a/platform/include/platform/mbed_power_mgmt.h +++ b/platform/include/platform/mbed_power_mgmt.h @@ -192,7 +192,7 @@ void sleep_manager_sleep_auto(void); * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be * able to access the LocalFileSystem */ -static inline void sleep(void) +static inline void mbed_sleep(void) { #if DEVICE_SLEEP #if (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_SYSTICK_CLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) diff --git a/platform/source/mbed_os_timer.cpp b/platform/source/mbed_os_timer.cpp index d7b2f075b19..1ea0563c1c5 100644 --- a/platform/source/mbed_os_timer.cpp +++ b/platform/source/mbed_os_timer.cpp @@ -170,7 +170,7 @@ void do_sleep_operation(OpT &op) // we go round to set the timer again. if (op.sleep_prepared()) { // Enter HAL sleep (normal or deep) - sleep(); + mbed_sleep(); } }