avr: use register wrappers that use runtime/volatile.*Uint8 calls

This avoids the //go:volatile pragma on types in Go source code, at
least for AVR targets.
This commit is contained in:
Ayke van Laethem
2019-05-10 22:25:24 +02:00
committed by Ron Evans
parent 6f6afb0515
commit e0cf74e638
5 changed files with 116 additions and 76 deletions
+4 -4
View File
@@ -17,19 +17,19 @@ func sleepWDT(period uint8) {
avr.Asm("cli")
avr.Asm("wdr")
// Start timed sequence.
*avr.WDTCSR |= avr.WDTCSR_WDCE | avr.WDTCSR_WDE
avr.WDTCSR.SetBits(avr.WDTCSR_WDCE | avr.WDTCSR_WDE)
// Enable WDT and set new timeout
*avr.WDTCSR = avr.WDTCSR_WDIE | avr.RegValue(period)
avr.WDTCSR.SetBits(avr.WDTCSR_WDIE | period)
avr.Asm("sei")
// Set sleep mode to idle and enable sleep mode.
// Note: when using something other than idle, the UART won't work
// correctly. This needs to be fixed, though, so we can truly sleep.
*avr.SMCR = (0 << 1) | avr.SMCR_SE
avr.SMCR.Set((0 << 1) | avr.SMCR_SE)
// go to sleep
avr.Asm("sleep")
// disable sleep
*avr.SMCR = 0
avr.SMCR.Set(0)
}