Skip to content

Commit b75f042

Browse files
aykevldeadprogram
authored andcommitted
runtime: use waitForEvents when appropriate
This is better than using the wfe or wfi instruction directly as it can be replaced with build tags.
1 parent 32c7f3b commit b75f042

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/runtime/runtime_atsamd21.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func timerSleep(ticks uint32) bool {
308308
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
309309

310310
wait:
311-
arm.Asm("wfe")
311+
waitForEvents()
312312
if timerWakeup.Get() != 0 {
313313
return true
314314
}

src/runtime/runtime_atsamd51.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func timerSleep(ticks uint32) bool {
292292
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
293293

294294
wait:
295-
arm.Asm("wfe")
295+
waitForEvents()
296296
if timerWakeup.Get() != 0 {
297297
return true
298298
}

src/runtime/runtime_nrf.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package runtime
44

55
import (
6-
"device/arm"
76
"device/nrf"
87
"machine"
98
"runtime/interrupt"
@@ -114,6 +113,6 @@ func rtc_sleep(ticks uint32) {
114113
}
115114
nrf.RTC1.CC[0].Set((nrf.RTC1.COUNTER.Get() + ticks) & 0x00ffffff)
116115
for rtc_wakeup.Get() == 0 {
117-
arm.Asm("wfi")
116+
waitForEvents()
118117
}
119118
}

0 commit comments

Comments
 (0)