Skip to content

Commit fb8fda3

Browse files
Merge pull request #4097 from bulislaw/build_debug_macro
Debug build flag + change to sleep behavior in debug mode
2 parents 65adf44 + c5f0ad5 commit fb8fda3

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

platform/mbed_sleep.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ extern "C" {
2828
/** Send the microcontroller to sleep
2929
*
3030
* @note This function can be a noop if not implemented by the platform.
31-
* @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined).
31+
* @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined).
32+
* @note This function will be a noop while uVisor is in use.
3233
*
3334
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
3435
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
@@ -44,17 +45,20 @@ extern "C" {
4445
*/
4546
__INLINE static void sleep(void)
4647
{
47-
#ifdef NDEBUG
48+
#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED))
49+
#ifndef MBED_DEBUG
4850
#if DEVICE_SLEEP
4951
hal_sleep();
5052
#endif /* DEVICE_SLEEP */
51-
#endif /* NDEBUG */
53+
#endif /* MBED_DEBUG */
54+
#endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
5255
}
5356

5457
/** Send the microcontroller to deep sleep
5558
*
5659
* @note This function can be a noop if not implemented by the platform.
57-
* @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined).
60+
* @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined)
61+
* @note This function will be a noop while uVisor is in use.
5862
*
5963
* This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
6064
* 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)
6973
*/
7074
__INLINE static void deepsleep(void)
7175
{
72-
#ifdef NDEBUG
76+
#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED))
77+
#ifndef MBED_DEBUG
7378
#if DEVICE_SLEEP
7479
hal_deepsleep();
7580
#endif /* DEVICE_SLEEP */
76-
#endif /* NDEBUG */
81+
#endif /* MBED_DEBUG */
82+
#endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
7783
}
7884

7985
#ifdef __cplusplus

targets/TARGET_Maxim/TARGET_MAX32630/sleep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
#include "sleep_api.h"
3535
#include "lp.h"
3636

37-
void sleep(void)
37+
void hal_sleep(void)
3838
{
3939
LP_EnterLP2();
4040
}
4141

4242
// Low-power stop mode
43-
void deepsleep(void)
43+
void hal_deepsleep(void)
4444
{
45-
sleep();
45+
hal_sleep();
4646
}

tools/profiles/debug.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
77
"-MMD", "-fno-delete-null-pointer-checks",
8-
"-fomit-frame-pointer", "-O0", "-g3"],
8+
"-fomit-frame-pointer", "-O0", "-g3", "-DMBED_DEBUG"],
99
"asm": ["-x", "assembler-with-cpp"],
1010
"c": ["-std=gnu99"],
1111
"cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
@@ -17,7 +17,7 @@
1717
"ARM": {
1818
"common": ["-c", "--gnu", "-Otime", "--split_sections",
1919
"--apcs=interwork", "--brief_diagnostics", "--restrict",
20-
"--multibyte_chars", "-O0", "-g"],
20+
"--multibyte_chars", "-O0", "-g", "-DMBED_DEBUG"],
2121
"asm": [],
2222
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
2323
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
@@ -27,16 +27,16 @@
2727
"common": ["-c", "--gnu", "-Otime", "--split_sections",
2828
"--apcs=interwork", "--brief_diagnostics", "--restrict",
2929
"--multibyte_chars", "-O0", "-D__MICROLIB", "-g",
30-
"--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD"],
30+
"--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DMBED_DEBUG"],
3131
"asm": [],
3232
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
3333
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
3434
"ld": ["--library_type=microlib"]
3535
},
3636
"IAR": {
3737
"common": [
38-
"--no_wrap_diagnostics", "-e",
39-
"--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-On", "-r"],
38+
"--no_wrap_diagnostics", "-e",
39+
"--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-On", "-r", "-DMBED_DEBUG"],
4040
"asm": [],
4141
"c": ["--vla"],
4242
"cxx": ["--guard_calls", "--no_static_destruction"],

0 commit comments

Comments
 (0)