runtime: update to avoid //go:volatile

There was exactly one change in the output of the smoke tests:
examples/test. However, it still runs just fine on a PCA10040.
This commit is contained in:
Ayke van Laethem
2019-06-06 14:18:47 +02:00
committed by Ron Evans
parent 9673ad3774
commit c84c625585
5 changed files with 23 additions and 33 deletions
+5 -7
View File
@@ -6,6 +6,7 @@ import (
"device/arm"
"device/nrf"
"machine"
"runtime/volatile"
)
type timeUnit int64
@@ -79,14 +80,11 @@ func ticks() timeUnit {
return timestamp
}
//go:volatile
type isrFlag bool
var rtc_wakeup isrFlag
var rtc_wakeup volatile.Register8
func rtc_sleep(ticks uint32) {
nrf.RTC1.INTENSET.Set(nrf.RTC_INTENSET_COMPARE0)
rtc_wakeup = false
rtc_wakeup.Set(0)
if ticks == 1 {
// Race condition (even in hardware) at ticks == 1.
// TODO: fix this in a better way by detecting it, like the manual
@@ -94,7 +92,7 @@ func rtc_sleep(ticks uint32) {
ticks = 2
}
nrf.RTC1.CC[0].Set((nrf.RTC1.COUNTER.Get() + ticks) & 0x00ffffff)
for !rtc_wakeup {
for rtc_wakeup.Get() == 0 {
arm.Asm("wfi")
}
}
@@ -103,5 +101,5 @@ func rtc_sleep(ticks uint32) {
func handleRTC1() {
nrf.RTC1.INTENCLR.Set(nrf.RTC_INTENSET_COMPARE0)
nrf.RTC1.EVENTS_COMPARE[0].Set(0)
rtc_wakeup = true
rtc_wakeup.Set(1)
}