diff --git a/src/machine/machine_atsamd21e18.go b/src/machine/machine_atsamd21e18.go index 692be17e..fd4f5d09 100644 --- a/src/machine/machine_atsamd21e18.go +++ b/src/machine/machine_atsamd21e18.go @@ -58,7 +58,8 @@ func (p Pin) Set(high bool) { } } -// Get returns the current value of a GPIO pin. +// Get returns the current value of a GPIO pin when configured as an input or as +// an output. func (p Pin) Get() bool { return (sam.PORT.IN0.Get()>>uint8(p))&1 > 0 } diff --git a/src/machine/machine_atsamd21g18.go b/src/machine/machine_atsamd21g18.go index 82fc57fe..44cc5828 100644 --- a/src/machine/machine_atsamd21g18.go +++ b/src/machine/machine_atsamd21g18.go @@ -82,7 +82,8 @@ func (p Pin) Set(high bool) { } } -// Get returns the current value of a GPIO pin. +// Get returns the current value of a GPIO pin when configured as an input or as +// an output. func (p Pin) Get() bool { if p < 32 { return (sam.PORT.IN0.Get()>>uint8(p))&1 > 0 diff --git a/src/machine/machine_atsamd51.go b/src/machine/machine_atsamd51.go index b7c96339..8723e82a 100644 --- a/src/machine/machine_atsamd51.go +++ b/src/machine/machine_atsamd51.go @@ -542,7 +542,8 @@ func (p Pin) Set(high bool) { } } -// Get returns the current value of a GPIO pin. +// Get returns the current value of a GPIO pin when configured as an input or as +// an output. func (p Pin) Get() bool { group, pin_in_group := p.getPinGrouping() return (sam.PORT.GROUP[group].IN.Get()>>pin_in_group)&1 > 0 diff --git a/src/machine/machine_avr.go b/src/machine/machine_avr.go index 14ba5020..ce9b7803 100644 --- a/src/machine/machine_avr.go +++ b/src/machine/machine_avr.go @@ -63,7 +63,8 @@ func (p Pin) Configure(config PinConfig) { } } -// Get returns the current value of a GPIO pin. +// Get returns the current value of a GPIO pin when the pin is configured as an +// input or as an output. func (p Pin) Get() bool { port, mask := p.getPortMask() // As noted above, the PINx register is always two registers below the PORTx diff --git a/src/machine/machine_esp32.go b/src/machine/machine_esp32.go index 1c5f7ef7..90dc2c66 100644 --- a/src/machine/machine_esp32.go +++ b/src/machine/machine_esp32.go @@ -159,7 +159,7 @@ func (p Pin) portMaskClear() (*volatile.Register32, uint32) { } // Get returns the current value of a GPIO pin when the pin is configured as an -// input. +// input or as an output. func (p Pin) Get() bool { if p < 32 { return esp.GPIO.IN.Get()&(1< 0) diff --git a/src/machine/machine_nrf.go b/src/machine/machine_nrf.go index 7af22000..a288298c 100644 --- a/src/machine/machine_nrf.go +++ b/src/machine/machine_nrf.go @@ -17,7 +17,7 @@ const ( PinInput PinMode = (nrf.GPIO_PIN_CNF_DIR_Input << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Connect << nrf.GPIO_PIN_CNF_INPUT_Pos) PinInputPullup PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pullup << nrf.GPIO_PIN_CNF_PULL_Pos) PinInputPulldown PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pulldown << nrf.GPIO_PIN_CNF_PULL_Pos) - PinOutput PinMode = (nrf.GPIO_PIN_CNF_DIR_Output << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Disconnect << nrf.GPIO_PIN_CNF_INPUT_Pos) + PinOutput PinMode = (nrf.GPIO_PIN_CNF_DIR_Output << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Connect << nrf.GPIO_PIN_CNF_INPUT_Pos) ) type PinChange uint8 @@ -64,7 +64,8 @@ func (p Pin) PortMaskClear() (*uint32, uint32) { return &port.OUTCLR.Reg, 1 << pin } -// Get returns the current value of a GPIO pin. +// Get returns the current value of a GPIO pin when the pin is configured as an +// input or as an output. func (p Pin) Get() bool { port, pin := p.getPortPin() return (port.IN.Get()>>pin)&1 != 0 diff --git a/src/machine/machine_stm32.go b/src/machine/machine_stm32.go index 9acf22ae..865ab68f 100644 --- a/src/machine/machine_stm32.go +++ b/src/machine/machine_stm32.go @@ -51,7 +51,8 @@ func (p Pin) Set(high bool) { } } -// Get returns the current value of a GPIO pin. +// Get returns the current value of a GPIO pin when the pin is configured as an +// input or as an output. func (p Pin) Get() bool { port := p.getPort() pin := uint8(p) % 16