-
Notifications
You must be signed in to change notification settings - Fork 13
/
drv_rpio.go
50 lines (40 loc) · 1010 Bytes
/
drv_rpio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"github.com/stianeikeland/go-rpio"
)
type JtagPinDriverRpio struct {
}
func (d *JtagPinDriverRpio) initDriver() {
if err := rpio.Open(); err != nil {
panic(err)
}
}
func (d *JtagPinDriverRpio) closeDriver() {
rpio.Close()
}
func (d *JtagPinDriverRpio) pinWrite(pin JtagPin, state JtagPinState) {
if state == StateHigh {
rpio.WritePin(rpio.Pin(pin), rpio.High)
} else {
rpio.WritePin(rpio.Pin(pin), rpio.Low)
}
}
func (d *JtagPinDriverRpio) pinRead(pin JtagPin) JtagPinState {
if rpio.ReadPin(rpio.Pin(pin)) == rpio.High {
return StateHigh
} else {
return StateLow
}
}
func (d *JtagPinDriverRpio) pinOutput(pin JtagPin) {
rpio.PinMode(rpio.Pin(pin), rpio.Output)
}
func (d *JtagPinDriverRpio) pinInput(pin JtagPin) {
rpio.PinMode(rpio.Pin(pin), rpio.Input)
}
func (d *JtagPinDriverRpio) pinPullUp(pin JtagPin) {
rpio.PullMode(rpio.Pin(pin), rpio.PullUp)
}
func (d *JtagPinDriverRpio) pinPullOff(pin JtagPin) {
rpio.PullMode(rpio.Pin(pin), rpio.PullOff)
}