void EnsurePinFunction(GpioPin pin, GpioFunction function) { GpioFunction oldFunction; if (ConnectedPins.TryGetValue(pin, out oldFunction)) { if (oldFunction == function) { return; } ConnectedPins[pin] = function; } else { ConnectedPins.Add(pin, function); PinStates.Add(pin, false); } Gpio.SetFunction(pin, function); }
// esp32-hal-gpio.h: 500~ // void pinMode(uint8_t pin, uint8_t mode); // private const int PIN_MODE = 500; public void pinMode(int pin, GpioFunction mode) { GpioCommand(PIN_MODE, pin, (int)mode); }
public static void SetFunction(GpioPin pin, GpioFunction function) { Native.bcm2835_gpio_fsel(pin, (byte)function); }