Skip to content

Commit

Permalink
rp2040:add NoPin support
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat authored and deadprogram committed Jul 18, 2023
1 parent ccd9ab7 commit 54bed76
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/machine/machine_rp2040_gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func (p Pin) init() {

// Configure configures the gpio pin as per mode.
func (p Pin) Configure(config PinConfig) {
if p == NoPin {
return
}
p.init()
mask := uint32(1) << p
switch config.Mode {
Expand Down Expand Up @@ -213,6 +216,9 @@ func (p Pin) Configure(config PinConfig) {

// Set drives the pin high if value is true else drives it low.
func (p Pin) Set(value bool) {
if p == NoPin {
return
}
if value {
p.set()
} else {
Expand Down Expand Up @@ -251,6 +257,9 @@ var (
// nil func to unset the pin change interrupt. If you do so, the change
// parameter is ignored and can be set to any value (such as 0).
func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error {
if p == NoPin {
return nil
}
if p > 31 || p < 0 {
return ErrInvalidInputPin
}
Expand Down

0 comments on commit 54bed76

Please sign in to comment.