-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform: Add sleep/deepsleep user facing functions #3607
Conversation
53eec5f
to
fb1ea6a
Compare
@bulislaw This seems a bit misleading to me, though I may not understand all the implications of this. Without this patch if I call Perhaps we could add a |
__INLINE void sleep(void) | ||
{ | ||
#ifdef NDEBUG | ||
#ifdef DEVICE_SLEEP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe #if DEVICE_SLEEP
is slightly better as more inline with other usages of this macro.
__INLINE void deepsleep(void) | ||
{ | ||
#ifdef NDEBUG | ||
#ifdef DEVICE_SLEEP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe #if DEVICE_SLEEP is slightly better as more inline with other usages of this macro.
Does this mean that I should remove the |
That was partially my point, I think usage of sleep shouldn't be surrounded in flag checking which is pointless. Also going to sleep it's an optimization rather then an functional action. I was wondering on adding a bool return value that indicates if the platform actually went to sleep, but decided that it's not like user can do anything useful with that.
Yeah I guess #warning would be good.
Yeah no need to have it twice. I'll replace #ifdef with #if according to your comments. |
fb1ea6a
to
6a045a4
Compare
Add sleep/deepsleep functions to platform layer which are replacing HAL functions with the same name, rename existing symbols in HAL layer to hal_sleep/hal_deepsleep. This way sleep functions are always available, even if target doesn't implement them, which makes the code using sleep clearer. It also enables us to make decision on in which builds (debug/release) the sleep will be enabled.
@0xc0170 please review. |
{ | ||
// ensure debug is disconnected if semihost is enabled.... | ||
NRF_POWER->TASKS_LOWPWR = 1; | ||
// wait for interrupt | ||
__WFE(); | ||
} | ||
|
||
MBED_WEAK void deepsleep(void) | ||
MBED_WEAK void hal_deepsleep(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to remove weak linkage, as it's not applied to any other implementations.
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be | ||
* able to access the LocalFileSystem | ||
*/ | ||
__INLINE void sleep(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions in these header should be defined with static
specifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why static?
#warning Sleep is not supported on this platform. | ||
#else /* DEVICE_SLEEP */ | ||
#ifndef NDEBUG | ||
#warning Sleep is disabled for debug builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this warning active by default (default profile)? means if I use mbed compile -m K64F -t GCC_ARM
I would get always this warning? If that's the case, I would comment out this code straight away just to remove this annoyance.
As I recall only small-build defines NDEBUG
symbol. Is default profile debug build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not like our builds are clean of warnings. And yes default build is debug, which is probably the correct behavior for mbed-os. So you think that the documentation note (which i will submit separately to the handbook) is enough of a info?
To summarize our discussion and changes :
|
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
I'm actually going to suggest we run a full nightly on this, just because there are tests that call sleep that are only ran during the nightly. /morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change though, yes? Previously calling sleep in the default build profile would actually put the target to sleep. Now this won't be the case. Just double checking this is an intended API break.
Yes the platform won't go to sleep for default & debug profile, but I would say it's not really a breaking change as sleep is an optimization and more of a express of a intent for user, which should be opaque. Ideally platform should go to sleep whenever it can without being explicitly told to (and accidentally @betzw PR achieves just that). This PR clarifies the API and hides ugly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be the next steps for this PR & PR #3566? |
@bulislaw seems as we if have the "ready to merge" go from @0xc0170. cc @screamerbg |
I don't have the powers, someone will merge it soon. |
The `sleep` function as been changed into `hal_sleep` by ARMmbed#3607. Unfortunately the call to `sleep` in the hal_patch for the NRF51822 has not been updated to `hal_sleep`. The result was a link time error for targets based on NRF51822_LEGACY compiling with the mbed OS 5 tree.
The `sleep` function as been changed into `hal_sleep` by #3607. Unfortunately the call to `sleep` in the hal_patch for the NRF51822 has not been updated to `hal_sleep`. The result was a link time error for targets based on NRF51822_LEGACY compiling with the mbed OS 5 tree.
The `sleep` function as been changed into `hal_sleep` by #3607. Unfortunately the call to `sleep` in the hal_patch for the NRF51822 has not been updated to `hal_sleep`. The result was a link time error for targets based on NRF51822_LEGACY compiling with the mbed OS 5 tree.
Add sleep/deepsleep functions to platform layer which are replacing HAL
functions with the same name, rename existing symbols in HAL layer
to hal_sleep/hal_deepsleep. This way sleep functions
are always available, even if target doesn't implement them, which makes
the code using sleep clearer. It also enables us to make decision on in
which builds (debug/release) the sleep will be enabled.
Status
READY
Related PRs
#3566
CC: @0xc0170 @sg- @betzw