Skip to content

Commit eb5fdf0

Browse files
committed
TARGET_NRF5: corrected 'sleep()' to make it work properly on NRF52 as well.
1 parent 7e8aead commit eb5fdf0

File tree

1 file changed

+3
-1
lines changed
  • hal/targets/hal/TARGET_NORDIC/TARGET_NRF5

1 file changed

+3
-1
lines changed

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/sleep.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
void sleep(void)
2727
{
2828
// ensure debug is disconnected if semihost is enabled....
29-
NRF_POWER->TASKS_LOWPWR = 1;
3029

3130
SCB->SCR |= SCB_SCR_SEVONPEND_Msk; /* send an event when an interrupt is pending.
3231
* This helps with the wakeup from the following app_evt_wait(). */
@@ -37,8 +36,11 @@ void sleep(void)
3736
// and check if the soft device is running
3837
if ((__get_PRIMASK() == 0) && (sd_softdevice_is_enabled(&sd_enabled) == NRF_SUCCESS) && (sd_enabled == 1)) {
3938
// soft device is enabled, use the primitives from the soft device to go to sleep
39+
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
4040
sd_app_evt_wait();
4141
} else {
42+
NRF_POWER->TASKS_LOWPWR = 1;
43+
4244
// Note: it is not possible to just use WFE at this stage because WFE
4345
// will read the event register (not accessible) and if an event occured,
4446
// in the past, it will just clear the event register and continue execution.

0 commit comments

Comments
 (0)