aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2020-01-04 23:18:19 +0100
committerRon Evans <[email protected]>2020-01-05 12:08:33 +0100
commit27fafb7ab5883392f1c33145dce5df83fb18a7aa (patch)
tree71e7971b40ee6c9cee85365c4cfa97ddea774c3a /src/runtime
parentd1cc3c109d28a1ea46ece0a213ad3aa1e6c206ac (diff)
downloadtinygo-27fafb7ab5883392f1c33145dce5df83fb18a7aa.tar.gz
tinygo-27fafb7ab5883392f1c33145dce5df83fb18a7aa.zip
runtime: fix atsamd51 volatile usage
It was still using the (long removed) //go:volatile pragma for volatile variables, thus it was only accidentally working.
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/runtime_atsamd51.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/runtime/runtime_atsamd51.go b/src/runtime/runtime_atsamd51.go
index 04e0546a1..0b97b2783 100644
--- a/src/runtime/runtime_atsamd51.go
+++ b/src/runtime/runtime_atsamd51.go
@@ -6,6 +6,7 @@ import (
"device/arm"
"device/sam"
"machine"
+ "runtime/volatile"
)
type timeUnit int64
@@ -218,10 +219,7 @@ var (
timerLastCounter uint64
)
-//go:volatile
-type isrFlag bool
-
-var timerWakeup isrFlag
+var timerWakeup volatile.Register8
const asyncScheduler = false
@@ -248,7 +246,7 @@ func ticks() timeUnit {
// ticks are in microseconds
func timerSleep(ticks uint32) {
- timerWakeup = false
+ timerWakeup.Set(0)
if ticks < 260 {
// due to delay waiting for the register value to sync, the minimum sleep value
// for the SAMD51 is 260us.
@@ -268,7 +266,7 @@ func timerSleep(ticks uint32) {
// enable IRQ for CMP0 compare
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
- for !timerWakeup {
+ for timerWakeup.Get() == 0 {
arm.Asm("wfi")
}
}
@@ -278,7 +276,7 @@ func handleRTC() {
// disable IRQ for CMP0 compare
sam.RTC_MODE0.INTFLAG.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
- timerWakeup = true
+ timerWakeup.Set(1)
}
func initUSBClock() {