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
@@ -9,19 +9,19 @@ import (
// Configure sets the pin to input or output.
func (p GPIO) Configure(config GPIOConfig) {
if config.Mode == GPIO_OUTPUT { // set output bit
*avr.DDRB |= 1 << p.Pin
avr.DDRB.SetBits(1 << p.Pin)
} else { // configure input: clear output bit
*avr.DDRB &^= 1 << p.Pin
avr.DDRB.ClearBits(1 << p.Pin)
}
}
func (p GPIO) getPortMask() (*avr.RegValue, uint8) {
func (p GPIO) getPortMask() (*avr.Register8, uint8) {
return avr.PORTB, 1 << p.Pin
}
// Get returns the current value of a GPIO pin.
func (p GPIO) Get() bool {
val := *avr.PINB & (1 << p.Pin)
val := avr.PINB.Get() & (1 << p.Pin)
return (val > 0)
}