Skip to content

Commit

Permalink
Merge pull request #4097 from bulislaw/build_debug_macro
Browse files Browse the repository at this point in the history
Debug build flag + change to sleep behavior in debug mode
  • Loading branch information
theotherjimmy committed Apr 18, 2017
2 parents 65adf44 + c5f0ad5 commit fb8fda3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
18 changes: 12 additions & 6 deletions platform/mbed_sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 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).
* @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
Expand All @@ -44,17 +45,20 @@ extern "C" {
*/
__INLINE static void sleep(void)
{
#ifdef NDEBUG
#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED))
#ifndef MBED_DEBUG
#if DEVICE_SLEEP
hal_sleep();
#endif /* DEVICE_SLEEP */
#endif /* NDEBUG */
#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 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)
* @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
Expand All @@ -69,11 +73,13 @@ __INLINE static void sleep(void)
*/
__INLINE static void deepsleep(void)
{
#ifdef NDEBUG
#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED))
#ifndef MBED_DEBUG
#if DEVICE_SLEEP
hal_deepsleep();
#endif /* DEVICE_SLEEP */
#endif /* NDEBUG */
#endif /* MBED_DEBUG */
#endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
}

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions targets/TARGET_Maxim/TARGET_MAX32630/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
10 changes: 5 additions & 5 deletions tools/profiles/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand All @@ -27,16 +27,16 @@
"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"],
"ld": ["--library_type=microlib"]
},
"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"],
Expand Down

0 comments on commit fb8fda3

Please sign in to comment.