Support Pi3 and earlier boards

This commit is contained in:
Walt Drummond 2019-11-28 11:39:57 -08:00
parent be82a08f8a
commit 9f58572951

View File

@ -98,7 +98,7 @@ const (
memLength = 4096 memLength = 4096
) )
// BCM 2711 has a differnet mechanism for pin pull-up/pull-down/enable // BCM 2711 has a different mechanism for pull-up/pull-down/enable
const ( const (
GPPUPPDN0 = 57 // Pin pull-up/down for pins 15:0 GPPUPPDN0 = 57 // Pin pull-up/down for pins 15:0
GPPUPPDN1 = 58 // Pin pull-up/down for pins 31:16 GPPUPPDN1 = 58 // Pin pull-up/down for pins 31:16
@ -145,6 +145,7 @@ const (
PullOff Pull = iota PullOff Pull = iota
PullDown PullDown
PullUp PullUp
PullNone
) )
// Edge events // Edge events
@ -252,7 +253,7 @@ func (pin Pin) PullOff() {
func (pin Pin) ReadPull() Pull { func (pin Pin) ReadPull() Pull {
if !isBCM2711() { if !isBCM2711() {
return PullOff // TODO: Can you read pull state on other Pi boards? return PullNone // Can't read pull-up/pull-down state on other Pi boards
} }
reg := GPPUPPDN0 + (uint8(pin) >> 4) reg := GPPUPPDN0 + (uint8(pin) >> 4)
@ -265,7 +266,7 @@ func (pin Pin) ReadPull() Pull {
case 2: case 2:
return PullDown return PullDown
default: default:
return PullOff return PullNone // Invalid
} }
} }