vendorer periiph host

This commit is contained in:
didier committed 2024-07-27 09:53:26 -04:00
1 parent 4bed603e6d
commit b2305a992b
6 files changed
+76 -7

No files matched your search

+5 -1
View File
@@ -5,6 +5,7 @@
package bcm283x
import (
"sync/atomic"
"time"
"periph.io/x/host/v3/cpu"
@@ -17,7 +18,10 @@ func ReadTime() time.Duration {
if drvDMA.timerMemory == nil {
return 0
}
return (time.Duration(drvDMA.timerMemory.high)<<32 | time.Duration(drvDMA.timerMemory.low)) * time.Microsecond
// Use atomic package to safely access memory
high := atomic.LoadUint32(&drvDMA.timerMemory.high)
low := atomic.LoadUint32(&drvDMA.timerMemory.low)
return (time.Duration(high)<<32 | time.Duration(low)) * time.Microsecond
}
// Nanospin spins the CPU without calling into the kernel code if possible.