runtime: fix atsamd51 volatile usage

It was still using the (long removed) //go:volatile pragma for volatile
variables, thus it was only accidentally working.
Этот коммит содержится в:
Ayke van Laethem 2020-01-04 23:18:19 +01:00 коммит произвёл Ron Evans
родитель d1cc3c109d
коммит 27fafb7ab5

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

@ -6,6 +6,7 @@ import (
"device/arm" "device/arm"
"device/sam" "device/sam"
"machine" "machine"
"runtime/volatile"
) )
type timeUnit int64 type timeUnit int64
@ -218,10 +219,7 @@ var (
timerLastCounter uint64 timerLastCounter uint64
) )
//go:volatile var timerWakeup volatile.Register8
type isrFlag bool
var timerWakeup isrFlag
const asyncScheduler = false const asyncScheduler = false
@ -248,7 +246,7 @@ func ticks() timeUnit {
// ticks are in microseconds // ticks are in microseconds
func timerSleep(ticks uint32) { func timerSleep(ticks uint32) {
timerWakeup = false timerWakeup.Set(0)
if ticks < 260 { if ticks < 260 {
// due to delay waiting for the register value to sync, the minimum sleep value // due to delay waiting for the register value to sync, the minimum sleep value
// for the SAMD51 is 260us. // for the SAMD51 is 260us.
@ -268,7 +266,7 @@ func timerSleep(ticks uint32) {
// enable IRQ for CMP0 compare // enable IRQ for CMP0 compare
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0) sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
for !timerWakeup { for timerWakeup.Get() == 0 {
arm.Asm("wfi") arm.Asm("wfi")
} }
} }
@ -278,7 +276,7 @@ func handleRTC() {
// disable IRQ for CMP0 compare // disable IRQ for CMP0 compare
sam.RTC_MODE0.INTFLAG.SetBits(sam.RTC_MODE0_INTENSET_CMP0) sam.RTC_MODE0.INTFLAG.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
timerWakeup = true timerWakeup.Set(1)
} }
func initUSBClock() { func initUSBClock() {