mirror of
https://github.com/stianeikeland/go-rpio.git
synced 2025-01-23 02:31:05 +01:00
commit
acc952dac3
23
rpio.go
23
rpio.go
|
@ -3,7 +3,7 @@ Package rpio provides GPIO access on the Raspberry PI without any need
|
||||||
for external c libraries (eg. WiringPi or BCM2835).
|
for external c libraries (eg. WiringPi or BCM2835).
|
||||||
|
|
||||||
Supports simple operations such as:
|
Supports simple operations such as:
|
||||||
- Pin mode/direction (input/output/clock/pwm)
|
- Pin mode/direction (input/output/clock/pwm,alt0,alt1,alt2,alt3,alt4,alt5)
|
||||||
- Pin write (high/low)
|
- Pin write (high/low)
|
||||||
- Pin read (high/low)
|
- Pin read (high/low)
|
||||||
- Pin edge detection (no/rise/fall/any)
|
- Pin edge detection (no/rise/fall/any)
|
||||||
|
@ -132,6 +132,12 @@ const (
|
||||||
Clock
|
Clock
|
||||||
Pwm
|
Pwm
|
||||||
Spi
|
Spi
|
||||||
|
Alt0
|
||||||
|
Alt1
|
||||||
|
Alt2
|
||||||
|
Alt3
|
||||||
|
Alt4
|
||||||
|
Alt5
|
||||||
)
|
)
|
||||||
|
|
||||||
// State of pin, High / Low
|
// State of pin, High / Low
|
||||||
|
@ -296,6 +302,9 @@ func PinMode(pin Pin, mode Mode) {
|
||||||
const in = 0 // 000
|
const in = 0 // 000
|
||||||
const out = 1 // 001
|
const out = 1 // 001
|
||||||
const alt0 = 4 // 100
|
const alt0 = 4 // 100
|
||||||
|
const alt1 = 5 // 101
|
||||||
|
const alt2 = 6 // 110
|
||||||
|
const alt3 = 7 // 111
|
||||||
const alt4 = 3 // 011
|
const alt4 = 3 // 011
|
||||||
const alt5 = 2 // 010
|
const alt5 = 2 // 010
|
||||||
|
|
||||||
|
@ -335,6 +344,18 @@ func PinMode(pin Pin, mode Mode) {
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case Alt0:
|
||||||
|
f = alt0
|
||||||
|
case Alt1:
|
||||||
|
f = alt1
|
||||||
|
case Alt2:
|
||||||
|
f = alt2
|
||||||
|
case Alt3:
|
||||||
|
f = alt3
|
||||||
|
case Alt4:
|
||||||
|
f = alt4
|
||||||
|
case Alt5:
|
||||||
|
f = alt5
|
||||||
}
|
}
|
||||||
|
|
||||||
memlock.Lock()
|
memlock.Lock()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user