diff options
Diffstat (limited to 'src/runtime/runtime_nrf.go')
-rw-r--r-- | src/runtime/runtime_nrf.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/runtime/runtime_nrf.go b/src/runtime/runtime_nrf.go index e6009abe2..60d6fc8da 100644 --- a/src/runtime/runtime_nrf.go +++ b/src/runtime/runtime_nrf.go @@ -32,16 +32,16 @@ func init() { func initLFCLK() { if machine.HasLowFrequencyCrystal { - nrf.CLOCK.LFCLKSRC = nrf.CLOCK_LFCLKSTAT_SRC_Xtal + nrf.CLOCK.LFCLKSRC.Set(nrf.CLOCK_LFCLKSTAT_SRC_Xtal) } - nrf.CLOCK.TASKS_LFCLKSTART = 1 - for nrf.CLOCK.EVENTS_LFCLKSTARTED == 0 { + nrf.CLOCK.TASKS_LFCLKSTART.Set(1) + for nrf.CLOCK.EVENTS_LFCLKSTARTED.Get() == 0 { } - nrf.CLOCK.EVENTS_LFCLKSTARTED = 0 + nrf.CLOCK.EVENTS_LFCLKSTARTED.Set(0) } func initRTC() { - nrf.RTC1.TASKS_START = 1 + nrf.RTC1.TASKS_START.Set(1) arm.SetPriority(nrf.IRQ_RTC1, 0xc0) // low priority arm.EnableIRQ(nrf.IRQ_RTC1) } @@ -72,7 +72,7 @@ var ( // overflow the counter, leading to incorrect results. This might be fixed by // handling the overflow event. func ticks() timeUnit { - rtcCounter := uint32(nrf.RTC1.COUNTER) + rtcCounter := uint32(nrf.RTC1.COUNTER.Get()) offset := (rtcCounter - rtcLastCounter) & 0xffffff // change since last measurement rtcLastCounter = rtcCounter timestamp += timeUnit(offset) // TODO: not precise @@ -85,7 +85,7 @@ type isrFlag bool var rtc_wakeup isrFlag func rtc_sleep(ticks uint32) { - nrf.RTC1.INTENSET = nrf.RTC_INTENSET_COMPARE0 + nrf.RTC1.INTENSET.Set(nrf.RTC_INTENSET_COMPARE0) rtc_wakeup = false if ticks == 1 { // Race condition (even in hardware) at ticks == 1. @@ -93,7 +93,7 @@ func rtc_sleep(ticks uint32) { // describes. ticks = 2 } - nrf.RTC1.CC[0] = (nrf.RTC1.COUNTER + nrf.RegValue(ticks)) & 0x00ffffff + nrf.RTC1.CC[0].Set((nrf.RTC1.COUNTER.Get() + ticks) & 0x00ffffff) for !rtc_wakeup { arm.Asm("wfi") } @@ -101,7 +101,7 @@ func rtc_sleep(ticks uint32) { //go:export RTC1_IRQHandler func handleRTC1() { - nrf.RTC1.INTENCLR = nrf.RTC_INTENSET_COMPARE0 - nrf.RTC1.EVENTS_COMPARE[0] = 0 + nrf.RTC1.INTENCLR.Set(nrf.RTC_INTENSET_COMPARE0) + nrf.RTC1.EVENTS_COMPARE[0].Set(0) rtc_wakeup = true } |