runtime: use waitForEvents when appropriate

This is better than using the wfe or wfi instruction directly as it can
be replaced with build tags.
This commit is contained in:
Ayke van Laethem
2020-08-01 17:55:26 +02:00
committed by Ron Evans
parent 32c7f3baf9
commit b75f042c23
3 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -308,7 +308,7 @@ func timerSleep(ticks uint32) bool {
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
wait:
arm.Asm("wfe")
waitForEvents()
if timerWakeup.Get() != 0 {
return true
}
+1 -1
View File
@@ -292,7 +292,7 @@ func timerSleep(ticks uint32) bool {
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
wait:
arm.Asm("wfe")
waitForEvents()
if timerWakeup.Get() != 0 {
return true
}
+1 -2
View File
@@ -3,7 +3,6 @@
package runtime
import (
"device/arm"
"device/nrf"
"machine"
"runtime/interrupt"
@@ -114,6 +113,6 @@ func rtc_sleep(ticks uint32) {
}
nrf.RTC1.CC[0].Set((nrf.RTC1.COUNTER.Get() + ticks) & 0x00ffffff)
for rtc_wakeup.Get() == 0 {
arm.Asm("wfi")
waitForEvents()
}
}