From 27fafb7ab5883392f1c33145dce5df83fb18a7aa Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 4 Jan 2020 23:18:19 +0100 Subject: [PATCH] runtime: fix atsamd51 volatile usage It was still using the (long removed) //go:volatile pragma for volatile variables, thus it was only accidentally working. --- src/runtime/runtime_atsamd51.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/runtime/runtime_atsamd51.go b/src/runtime/runtime_atsamd51.go index 04e0546a..0b97b278 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() {