From cc71f3f5d41e3a6b93fa19db647a60945aac82e9 Mon Sep 17 00:00:00 2001 From: Bartek Szatkowski Date: Fri, 31 Mar 2017 16:17:39 +0100 Subject: [PATCH 1/4] Introduce MBED_DEBUG macro for debug build profile --- tools/profiles/debug.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/profiles/debug.json b/tools/profiles/debug.json index 948372fb3c0..95ab1a10862 100644 --- a/tools/profiles/debug.json +++ b/tools/profiles/debug.json @@ -5,7 +5,7 @@ "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections", "-funsigned-char", "-MMD", "-fno-delete-null-pointer-checks", - "-fomit-frame-pointer", "-O0", "-g3"], + "-fomit-frame-pointer", "-O0", "-g3", "-DMBED_DEBUG"], "asm": ["-x", "assembler-with-cpp"], "c": ["-std=gnu99"], "cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"], @@ -17,7 +17,7 @@ "ARM": { "common": ["-c", "--gnu", "-Otime", "--split_sections", "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O0", "-g"], + "--multibyte_chars", "-O0", "-g", "-DMBED_DEBUG"], "asm": [], "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], "cxx": ["--cpp", "--no_rtti", "--no_vla"], @@ -27,7 +27,7 @@ "common": ["-c", "--gnu", "-Otime", "--split_sections", "--apcs=interwork", "--brief_diagnostics", "--restrict", "--multibyte_chars", "-O0", "-D__MICROLIB", "-g", - "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD"], + "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DMBED_DEBUG"], "asm": [], "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], "cxx": ["--cpp", "--no_rtti", "--no_vla"], @@ -35,8 +35,8 @@ }, "IAR": { "common": [ - "--no_wrap_diagnostics", "-e", - "--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-On", "-r"], + "--no_wrap_diagnostics", "-e", + "--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-On", "-r", "-DMBED_DEBUG"], "asm": [], "c": ["--vla"], "cxx": ["--guard_calls", "--no_static_destruction"], From 57dc2a540c05cd1e83b1639b20395d0a2c2e81e7 Mon Sep 17 00:00:00 2001 From: Bartek Szatkowski Date: Fri, 31 Mar 2017 16:18:26 +0100 Subject: [PATCH 2/4] Disable sleep and deepsleep when MBED_DEBUG macro is defined --- platform/mbed_sleep.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/mbed_sleep.h b/platform/mbed_sleep.h index 013bef1db1f..9d1e9556ff2 100644 --- a/platform/mbed_sleep.h +++ b/platform/mbed_sleep.h @@ -28,7 +28,7 @@ extern "C" { /** Send the microcontroller to sleep * * @note This function can be a noop if not implemented by the platform. - * @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined). + * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined) * * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates @@ -44,17 +44,17 @@ extern "C" { */ __INLINE static void sleep(void) { -#ifdef NDEBUG +#ifndef MBED_DEBUG #if DEVICE_SLEEP hal_sleep(); #endif /* DEVICE_SLEEP */ -#endif /* NDEBUG */ +#endif /* MBED_DEBUG */ } /** Send the microcontroller to deep sleep * * @note This function can be a noop if not implemented by the platform. - * @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined). + * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined) * * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode * has the same sleep features as sleep plus it powers down peripherals and clocks. All state @@ -69,11 +69,11 @@ __INLINE static void sleep(void) */ __INLINE static void deepsleep(void) { -#ifdef NDEBUG +#ifndef MBED_DEBUG #if DEVICE_SLEEP hal_deepsleep(); #endif /* DEVICE_SLEEP */ -#endif /* NDEBUG */ +#endif /* MBED_DEBUG */ } #ifdef __cplusplus From 4cd6068b73df8c24ac2fbeecb5f477be25174cde Mon Sep 17 00:00:00 2001 From: Bartek Szatkowski Date: Tue, 4 Apr 2017 09:50:16 +0100 Subject: [PATCH 3/4] MAX32630: Fix sleep definitions --- targets/TARGET_Maxim/TARGET_MAX32630/sleep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/sleep.c b/targets/TARGET_Maxim/TARGET_MAX32630/sleep.c index 560a4409293..3984b4aca33 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32630/sleep.c +++ b/targets/TARGET_Maxim/TARGET_MAX32630/sleep.c @@ -34,13 +34,13 @@ #include "sleep_api.h" #include "lp.h" -void sleep(void) +void hal_sleep(void) { LP_EnterLP2(); } // Low-power stop mode -void deepsleep(void) +void hal_deepsleep(void) { - sleep(); + hal_sleep(); } From c5f0ad506e2f59cee108ed67328fa365eb3ec039 Mon Sep 17 00:00:00 2001 From: Bartek Szatkowski Date: Wed, 5 Apr 2017 15:33:31 +0100 Subject: [PATCH 4/4] Disable sleep when uVisor is in use --- platform/mbed_sleep.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/mbed_sleep.h b/platform/mbed_sleep.h index 9d1e9556ff2..91546259da2 100644 --- a/platform/mbed_sleep.h +++ b/platform/mbed_sleep.h @@ -28,7 +28,8 @@ extern "C" { /** Send the microcontroller to sleep * * @note This function can be a noop if not implemented by the platform. - * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined) + * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined). + * @note This function will be a noop while uVisor is in use. * * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates @@ -44,17 +45,20 @@ extern "C" { */ __INLINE static void sleep(void) { +#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) #ifndef MBED_DEBUG #if DEVICE_SLEEP hal_sleep(); #endif /* DEVICE_SLEEP */ #endif /* MBED_DEBUG */ +#endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */ } /** Send the microcontroller to deep sleep * * @note This function can be a noop if not implemented by the platform. * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined) + * @note This function will be a noop while uVisor is in use. * * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode * has the same sleep features as sleep plus it powers down peripherals and clocks. All state @@ -69,11 +73,13 @@ __INLINE static void sleep(void) */ __INLINE static void deepsleep(void) { +#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) #ifndef MBED_DEBUG #if DEVICE_SLEEP hal_deepsleep(); #endif /* DEVICE_SLEEP */ #endif /* MBED_DEBUG */ +#endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */ } #ifdef __cplusplus