From d139fa5e0f330a6ee6a86b496d82023d896ac18a Mon Sep 17 00:00:00 2001 From: sago35 Date: Mon, 24 Jan 2022 20:45:10 +0900 Subject: [PATCH] esp32c3: add support for input pin --- src/machine/machine_esp32c3.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/machine/machine_esp32c3.go b/src/machine/machine_esp32c3.go index 1393f2cd..39ac78bb 100644 --- a/src/machine/machine_esp32c3.go +++ b/src/machine/machine_esp32c3.go @@ -95,6 +95,13 @@ func (p Pin) Set(value bool) { } } +// Get returns the current value of a GPIO pin when configured as an input or as +// an output. +func (p Pin) Get() bool { + reg := &esp.GPIO.IN + return (reg.Get()>>p)&1 > 0 +} + // Return the register and mask to enable a given GPIO pin. This can be used to // implement bit-banged drivers. //