mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 14:33:41 +00:00
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:
committed by
Ron Evans
parent
6f6afb0515
commit
e0cf74e638
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user