machine/hifive1: add GPIO Get() implementation and update other implementation to match latest SVD wrappers

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2019-10-08 20:22:53 +02:00
committed by Ayke
parent 92e07ec8af
commit 2168b1b516
3 changed files with 38 additions and 8 deletions
+23
View File
@@ -2,6 +2,29 @@
package machine
const (
D0 = P16
D1 = P17
D2 = P18
D3 = P19 // Green LED/PWM
D4 = P20 // PWM
D5 = P21 // Blue LED/PWM
D6 = P22 // Red LED/PWM
D7 = P16
D8 = NoPin // PWM?
D9 = P01
D10 = P02
D11 = P03
D12 = P04
D13 = P05
D14 = NoPin // not connected
D15 = P09 // does not seem to work?
D16 = P10 // PWM
D17 = P11 // PWM
D18 = P12 // SDA/PWM
D19 = P13 // SDL/PWM
)
const (
LED = LED1
LED1 = LED_RED
+7
View File
@@ -30,6 +30,13 @@ func (p Pin) Set(high bool) {
}
}
// Get returns the current value of a GPIO pin.
func (p Pin) Get() bool {
val := sifive.GPIO0.VALUE.Get() & (1 << uint8(p))
println(sifive.GPIO0.VALUE.Get())
return (val > 0)
}
type UART struct {
Bus *sifive.UART_Type
Buffer *RingBuffer