-
Notifications
You must be signed in to change notification settings - Fork 3k
nRF5x: Fix WFE entry #8366
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
Closed
Closed
nRF5x: Fix WFE entry #8366
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,6 @@ | |
#include "nrf_timer.h" | ||
#include "us_ticker.h" | ||
|
||
// Mask of reserved bits of the register ICSR in the System Control Block peripheral | ||
// In this case, bits which are equal to 0 are the bits reserved in this register | ||
#define SCB_ICSR_RESERVED_BITS_MASK 0x9E43F03F | ||
|
||
#define FPU_EXCEPTION_MASK 0x0000009F | ||
|
||
extern bool us_ticker_initialized; | ||
|
||
void hal_sleep(void) | ||
|
@@ -37,13 +31,6 @@ void hal_sleep(void) | |
// the processor from disabled interrupts. | ||
SCB->SCR |= SCB_SCR_SEVONPEND_Msk; | ||
|
||
#if defined(NRF52) || defined(NRF52840_XXAA) | ||
/* Clear exceptions and PendingIRQ from the FPU unit */ | ||
__set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK)); | ||
(void) __get_FPSCR(); | ||
NVIC_ClearPendingIRQ(FPU_IRQn); | ||
#endif | ||
|
||
// If the SoftDevice is enabled, its API must be used to go to sleep. | ||
if (softdevice_handler_is_enabled()) { | ||
sd_power_mode_set(NRF_POWER_MODE_LOWPWR); | ||
|
@@ -59,21 +46,10 @@ void hal_sleep(void) | |
// by using SEV/WFE pair, and then execute WFE again, unless there is | ||
// a pending interrupt. | ||
|
||
// Set an event and wake up whatsoever, this will clear the event | ||
// register from all previous events set (SVC call included) | ||
__DSB(); | ||
__SEV(); | ||
__WFE(); | ||
|
||
// Test if there is an interrupt pending (mask reserved regions) | ||
if (SCB->ICSR & (SCB_ICSR_RESERVED_BITS_MASK)) { | ||
// Ok, there is an interrut pending, no need to go to sleep | ||
return; | ||
} else { | ||
// next event will wakeup the CPU | ||
// If an interrupt occured between the test of SCB->ICSR and this | ||
// instruction, WFE will just not put the CPU to sleep | ||
__WFE(); | ||
} | ||
__WFE(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens to interrupts that became pending before the first call to |
||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.