runtime: use waitForEvents when appropriate

This is better than using the wfe or wfi instruction directly as it can
be replaced with build tags.
Этот коммит содержится в:
Ayke van Laethem 2020-08-01 17:55:26 +02:00 коммит произвёл Ron Evans
родитель 32c7f3baf9
коммит b75f042c23
3 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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()
}
}