diff options
author | soypat <[email protected]> | 2023-07-15 11:07:39 -0300 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-07-16 16:25:30 +0200 |
commit | 4da1f6bcbeb0aac18cf7c49184d0038720fe640d (patch) | |
tree | 8386bf9cbcb220ec240b3b5faac0889b2fe3d3b7 /src/machine/machine_rp2040_gpio.go | |
parent | 14ddba851903177b26fff97644b6979fea7ade3a (diff) | |
download | tinygo-4da1f6bcbeb0aac18cf7c49184d0038720fe640d.tar.gz tinygo-4da1f6bcbeb0aac18cf7c49184d0038720fe640d.zip |
rp2040:add NoPin support
Diffstat (limited to 'src/machine/machine_rp2040_gpio.go')
-rw-r--r-- | src/machine/machine_rp2040_gpio.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/machine/machine_rp2040_gpio.go b/src/machine/machine_rp2040_gpio.go index fa2051af8..94715d963 100644 --- a/src/machine/machine_rp2040_gpio.go +++ b/src/machine/machine_rp2040_gpio.go @@ -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 { @@ -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 { @@ -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 } |