avr: implement Get() function on AVR, and leave stubs for NRF and dummy machines

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2018-09-13 11:39:38 +02:00
committed by Ayke van Laethem
parent ec50db729d
commit ab6757fe11
4 changed files with 49 additions and 0 deletions
+11
View File
@@ -47,3 +47,14 @@ func (p GPIO) Set(value bool) {
}
}
}
// Get returns the current value of a GPIO pin.
func (p GPIO) Get() bool {
if p.Pin < 8 {
val := *avr.PIND & (1 << p.Pin)
return (val > 0)
} else {
val := *avr.PINB & (1 << (p.Pin - 8))
return (val > 0)
}
}
+4
View File
@@ -25,3 +25,7 @@ func (p GPIO) Configure(config GPIOConfig) {
func (p GPIO) Set(value bool) {
}
func (p GPIO) Get() bool {
return false
}
+6
View File
@@ -39,3 +39,9 @@ func (p GPIO) Set(high bool) {
nrf.P0.OUTCLR = 1 << p.Pin
}
}
// Get returns the current value of a GPIO pin.
func (p GPIO) Get() bool {
// TODO: implement
return false
}