Skip to main content

GpioControllerApiWrapper Class

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

Concrete IGpioControllerProvider backed by the native TinyCLR GPIO HAL. Constructed internally by GpioController; you don't normally need to use this type directly.

public sealed class GpioControllerApiWrapper : IGpioControllerProvider

Constructors​

GpioControllerApiWrapper(NativeApi api)​

public GpioControllerApiWrapper(NativeApi api)

Wraps the given native API as a provider.

ParameterTypeDescription
apiNativeApiThe native GPIO API to bind to.

Properties​

Api​

public NativeApi Api { get; }

The underlying native API descriptor.

PinCount​

public extern int PinCount { get; }

Total number of pins exposed by this controller. (inherited)

Methods​

Dispose()​

public void Dispose()

Releases the native controller.

OpenPin(int pin)​

public extern void OpenPin(int pin)

Acquires exclusive access to the specified pin. (inherited)

ParameterTypeDescription
pinintController-relative pin index.

ClosePin(int pin)​

public extern void ClosePin(int pin)

Releases a previously opened pin. (inherited)

ParameterTypeDescription
pinintController-relative pin index.

GetDebounceTimeout(int pin)​

public extern TimeSpan GetDebounceTimeout(int pin)

Returns the pin's current debounce window. (inherited)

ParameterTypeDescription
pinintController-relative pin index.

Returns TimeSpan

SetDebounceTimeout(int pin, TimeSpan value)​

public extern void SetDebounceTimeout(int pin, TimeSpan value)

Sets the pin's debounce window. (inherited)

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

GetDriveMode(int pin)​

public extern GpioPinDriveMode GetDriveMode(int pin)

Returns the pin's currently configured drive mode. (inherited)

ParameterTypeDescription
pinintController-relative pin index.

Returns GpioPinDriveMode

SetDriveMode(int pin, GpioPinDriveMode value)​

public extern void SetDriveMode(int pin, GpioPinDriveMode value)

Configures the pin's drive mode. (inherited)

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

Read(int pin)​

public extern GpioPinValue Read(int pin)

Samples the pin and returns its current logical level. (inherited)

ParameterTypeDescription
pinintController-relative pin index.

Returns GpioPinValue

Write(int pin, GpioPinValue value)​

public extern void Write(int pin, GpioPinValue value)

Drives an output pin to the specified level. (inherited)

ParameterTypeDescription
pinintController-relative pin index.
valueGpioPinValueLevel to drive.

IsDriveModeSupported(int pin, GpioPinDriveMode mode)​

public extern bool IsDriveModeSupported(int pin, GpioPinDriveMode mode)

Tests whether the pin supports a given drive mode. (inherited)

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)​

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

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

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

ClearPinChangedHandler(int pin)​

public void ClearPinChangedHandler(int pin)

Removes any previously installed edge-change handler. (inherited)

ParameterTypeDescription
pinintController-relative pin index.

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

public extern 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. (inherited)

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.