Skip to main content

IGpioControllerProvider Interface

NuGet: GHIElectronics.TinyCLR.Devices.Gpio
Assembly: GHIElectronics.TinyCLR.Devices.Gpio
Namespace: GHIElectronics.TinyCLR.Devices.Gpio.Provider

Provider contract for a GPIO controller. Most users call GpioController / GpioPin directly; implement this interface only when supplying a custom or virtual controller.

public interface IGpioControllerProvider : IDisposable

Properties​

PinCount​

int PinCount { get; }

Total number of pins exposed by this controller.

Methods​

OpenPin(int pin)​

void OpenPin(int pin)

Acquires exclusive access to the specified pin.

ParameterTypeDescription
pinintController-relative pin index.

ClosePin(int pin)​

void ClosePin(int pin)

Releases a previously opened pin.

ParameterTypeDescription
pinintController-relative pin index.

IsDriveModeSupported(int pin, GpioPinDriveMode mode)​

bool IsDriveModeSupported(int pin, GpioPinDriveMode mode)

Tests whether the pin supports a given drive mode.

ParameterTypeDescription
pinintController-relative pin index.
modeGpioPinDriveModeThe drive mode to test.

Returns bool — True if the mode is supported on that pin.

SetPinChangedHandler(int pin, GpioPinEdge edge, GpioPinValueChangedEventHandler value)​

void SetPinChangedHandler(int pin, GpioPinEdge edge, GpioPinValueChangedEventHandler value)

Installs or replaces the edge-change handler for a pin.

ParameterTypeDescription
pinintController-relative pin index.
edgeGpioPinEdgeWhich edges should raise the event.
valueGpioPinValueChangedEventHandlerDelegate to invoke on a matching edge.

ClearPinChangedHandler(int pin)​

void ClearPinChangedHandler(int pin)

Removes any previously installed edge-change handler.

ParameterTypeDescription
pinintController-relative pin index.

GetDebounceTimeout(int pin)​

TimeSpan GetDebounceTimeout(int pin)

Returns the pin's current debounce window.

ParameterTypeDescription
pinintController-relative pin index.

Returns TimeSpan

SetDebounceTimeout(int pin, TimeSpan value)​

void SetDebounceTimeout(int pin, TimeSpan value)

Sets the pin's debounce window.

ParameterTypeDescription
pinintController-relative pin index.
valueTimeSpanMinimum stable interval before an edge is reported.

GetDriveMode(int pin)​

GpioPinDriveMode GetDriveMode(int pin)

Returns the pin's currently configured drive mode.

ParameterTypeDescription
pinintController-relative pin index.

Returns GpioPinDriveMode

SetDriveMode(int pin, GpioPinDriveMode value)​

void SetDriveMode(int pin, GpioPinDriveMode value)

Configures the pin's drive mode.

ParameterTypeDescription
pinintController-relative pin index.
valueGpioPinDriveModeDrive mode to apply.

Read(int pin)​

GpioPinValue Read(int pin)

Samples the pin and returns its current logical level.

ParameterTypeDescription
pinintController-relative pin index.

Returns GpioPinValue

Write(int pin, GpioPinValue value)​

void Write(int pin, GpioPinValue value)

Drives an output pin to the specified level.

ParameterTypeDescription
pinintController-relative pin index.
valueGpioPinValueLevel to drive.

TransferFeature(int pinSource, int pinDestination, uint mode, uint type, uint direction, uint speed, uint alternate)​

void TransferFeature(int pinSource, int pinDestination, uint mode, uint type, uint direction, uint speed, uint alternate)

Re-routes a pin's signal through the controller's alternate-function fabric. Advanced; used by peripheral drivers (UART/SPI/I2C/etc.) to claim package pins.

ParameterTypeDescription
pinSourceintSource pin index.
pinDestinationintDestination pin index.
modeuintPlatform-specific mode bits.
typeuintPlatform-specific type bits.
directionuintPlatform-specific direction bits.
speeduintPlatform-specific speed/slew bits.
alternateuintAlternate-function index.