Merge pull request #56 from Nox-404/patch-2

Add altX modes for pins
This commit is contained in:
Drahoslav Bednář 2020-07-05 11:27:35 +02:00 committed by GitHub
commit acc952dac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

23
rpio.go
View File

@ -3,7 +3,7 @@ Package rpio provides GPIO access on the Raspberry PI without any need
for external c libraries (eg. WiringPi or BCM2835).
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 read (high/low)
- Pin edge detection (no/rise/fall/any)
@ -132,6 +132,12 @@ const (
Clock
Pwm
Spi
Alt0
Alt1
Alt2
Alt3
Alt4
Alt5
)
// State of pin, High / Low
@ -296,6 +302,9 @@ func PinMode(pin Pin, mode Mode) {
const in = 0 // 000
const out = 1 // 001
const alt0 = 4 // 100
const alt1 = 5 // 101
const alt2 = 6 // 110
const alt3 = 7 // 111
const alt4 = 3 // 011
const alt5 = 2 // 010
@ -335,6 +344,18 @@ func PinMode(pin Pin, mode Mode) {
default:
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()