GpioController
GpioController
GpioController
GpioController
Class
Definition
Represents the default general-purpose I/O (GPIO) controller for the system.
public : sealed class GpioController : IGpioControllerpublic sealed class GpioController : IGpioControllerPublic NotInheritable Class GpioController Implements IGpioController// You can use this class in JavaScript.
- Attributes
| Device family |
Windows IoT Extension SDK (introduced v10.0.10240.0)
|
| API contract |
Windows.Devices.DevicesLowLevelContract (introduced v1)
|
Remarks
To get a GpioController object, use the GpioController.GetDefault method.
Properties
PinCount PinCount PinCount PinCount
Gets the number of pins on the general-purpose I/O (GPIO) controller.
public : int PinCount { get; }public int PinCount { get; }Public ReadOnly Property PinCount As int// You can use this property in JavaScript.
- Value
- int int int int
The number of pins on the GPIO controller. Some pins may not be available in user mode. For information about how the pin numbers correspond to physical pins, see the documentation for your circuit board.
| Device family |
Windows IoT Extension SDK (introduced v10.0.10240.0)
|
| API contract |
Windows.Devices.DevicesLowLevelContract (introduced v1)
|
| Capabilities |
lowLevelDevices
|
- See Also
Methods
GetControllersAsync(IGpioProvider) GetControllersAsync(IGpioProvider) GetControllersAsync(IGpioProvider) GetControllersAsync(IGpioProvider)
Gets all the controllers that are connected to the system asynchronously.
public : static IAsyncOperation<IVectorView<GpioController>> GetControllersAsync(IGpioProvider provider)public static IAsyncOperation<IReadOnlyList<GpioController>> GetControllersAsync(IGpioProvider provider)Public Static Function GetControllersAsync(provider As IGpioProvider) As IAsyncOperation( Of IReadOnlyListGpioController )// You can use this method in JavaScript.
The GPIO provider for the controllers on the system.
When the method completes successfully, it returns a list of values that represent the controllers available on the system.
| Device family |
Windows IoT Extension SDK (introduced v10.0.10586.0)
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Devices.DevicesLowLevelContract (introduced v2)
|
GetDefault() GetDefault() GetDefault() GetDefault()
Gets the default general-purpose I/O (GPIO) controller for the system.
public : static GpioController GetDefault()public static GpioController GetDefault()Public Static Function GetDefault() As GpioController// You can use this method in JavaScript.
The default GPIO controller for the system, or null if the system has no GPIO controller.
| Device family |
Windows IoT Extension SDK (introduced v10.0.10240.0)
|
| API contract |
Windows.Devices.DevicesLowLevelContract (introduced v1)
|
| Capabilities |
lowLevelDevices
|
GetDefaultAsync() GetDefaultAsync() GetDefaultAsync() GetDefaultAsync()
Gets the default general-purpose I/O (GPIO) controller for the system.
public : static IAsyncOperation<GpioController> GetDefaultAsync()public static IAsyncOperation<GpioController> GetDefaultAsync()Public Static Function GetDefaultAsync() As IAsyncOperation( Of GpioController )// You can use this method in JavaScript.
The default GPIO controller for the system, or null if the system has no GPIO controller.
| Device family |
Windows IoT Extension SDK (introduced v10.0.10586.0)
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Devices.DevicesLowLevelContract (introduced v2)
|
OpenPin(Int32) OpenPin(Int32) OpenPin(Int32) OpenPin(Int32)
Opens a connection to the specified general-purpose I/O (GPIO) pin in exclusive mode.
public : GpioPin OpenPin(int pinNumber)public GpioPin OpenPin(Int32 pinNumber)Public Function OpenPin(pinNumber As Int32) As GpioPin// You can use this method in JavaScript.
- pinNumber
- int Int32 Int32 Int32
The pin number of the GPIO pin that you want to open. The pin number must be
- in range
- available to usermode applications
Pin numbers start at 0, and increase to the maximum pin number, which is one less than the value returned by GpioController.PinCount.
Which pins are available to usermode depends on the circuit board on which the code is running. For information about how pin numbers correspond to physical pins, see the documentation for your circuit board. Pin mappings for boards such as the Raspberry Pi are available at the IoT developer center.
Remarks
Error codes
E_INVALIDARG (0x80070057)
An invalid parameter was specified. This error will be returned if the pin number is out of range. Pin numbers start at 0 and increase to the maximum pin number, which is one less than the value returned by GpioController.PinCount.
HRESULT_FROM_WIN32(ERROR_NOT_FOUND) (0x80070490)
The pin is not available to usermode applications; it is reserved by the system. See the documentation for your circuit board to find out which pins are available to usermode applications.
HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION) (0x80070020)
The pin is currently open in an incompatible sharing mode. For example:
- The pin is already open in GpioSharingMode.Exclusive mode.
- The pin is already open in GpioSharingMode.SharedReadOnly mode when you request to open it in GpioSharingMode.Exclusive mode.
HRESULT_FROM_WIN32(ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE) (0x80073bde)
The pin is currently muxed to a different function; for example I2C, SPI, or UART. Ensure the pin is not in use by another function.
HRESULT_FROM_WIN32(ERROR_GEN_FAILURE) (0x8007001f)
The GPIO driver returned an error. Ensure that the GPIO driver is running and configured correctly.
OpenPin(Int32, GpioSharingMode) OpenPin(Int32, GpioSharingMode) OpenPin(Int32, GpioSharingMode) OpenPin(Int32, GpioSharingMode)
Opens the specified general-purpose I/O (GPIO) pin in the specified mode.
public : GpioPin OpenPin(int pinNumber, GpioSharingMode sharingMode)public GpioPin OpenPin(Int32 pinNumber, GpioSharingMode sharingMode)Public Function OpenPin(pinNumber As Int32, sharingMode As GpioSharingMode) As GpioPin// You can use this method in JavaScript.
- pinNumber
- int Int32 Int32 Int32
The pin number of the GPIO pin that you want to open. The pin number must be
- in range
- available to usermode applications
Pin numbers start at 0, and increase to the maximum pin number, which is one less than the value returned by GpioController.PinCount.
Which pins are available to usermode depends on the circuit board on which the code is running. For information about how pin numbers correspond to physical pins, see the documentation for your circuit board. Pin mappings for boards such as the Raspberry Pi are available at the IoT developer center.
- sharingMode
- GpioSharingMode GpioSharingMode GpioSharingMode GpioSharingMode
The mode in which you want to open the GPIO pin, which determines whether other connections to the pin can be opened while you have the pin open.
Remarks
Error Codes
E_INVALIDARG (0x80070057)
An invalid parameter was specified. This error will be returned if the pin number is out of range. Pin numbers start at 0 and increase to the maximum pin number, which is one less than the value returned by GpioController.PinCount.
HRESULT_FROM_WIN32(ERROR_NOT_FOUND) (0x80070490)
The pin is not available to usermode applications; it is reserved by the system. See the documentation for your circuit board to find out which pins are available to usermode applications.
HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION) (0x80070020)
The pin is currently open in an incompatible sharing mode. For example:
- The pin is already open in GpioSharingMode.Exclusive mode.
- The pin is already open in GpioSharingMode.SharedReadOnly mode when you request to open it in GpioSharingMode.Exclusive mode.
HRESULT_FROM_WIN32(ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE) (0x80073bde)
The pin is currently muxed to a different function; for example I2C, SPI, or UART. Ensure the pin is not in use by another function.
HRESULT_FROM_WIN32(ERROR_GEN_FAILURE) (0x8007001f)
The GPIO driver returned an error. Ensure that the GPIO driver is running and configured correctly.
- See Also
-
TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus)
Opens the specified general-purpose I/O (GPIO) pin in the specified mode, and gets a status value that you can use to handle a failure to open the pin programmatically.
public : PlatForm::Boolean TryOpenPin(int pinNumber, GpioSharingMode sharingMode, GpioPin pin, GpioOpenStatus openStatus)public bool TryOpenPin(Int32 pinNumber, GpioSharingMode sharingMode, GpioPin pin, GpioOpenStatus openStatus)Public Function TryOpenPin(pinNumber As Int32, sharingMode As GpioSharingMode, pin As GpioPin, openStatus As GpioOpenStatus) As bool// You can use this method in JavaScript.
- pinNumber
- int Int32 Int32 Int32
The pin number of the GPIO pin that you want to open. Some pins may not be available in user mode. For information about how the pin numbers correspond to physical pins, see the documentation for your circuit board.
- sharingMode
- GpioSharingMode GpioSharingMode GpioSharingMode GpioSharingMode
The mode in which you want to open the GPIO pin, which determines whether other connections to the pin can be opened while you have the pin open.
The opened GPIO pin if the return value is true; otherwise null.
- openStatus
- GpioOpenStatus GpioOpenStatus GpioOpenStatus GpioOpenStatus
An enumeration value that indicates either that the attempt to open the GPIO pin succeeded, or the reason that the attempt to open the GPIO pin failed.
True if the method successfully opened the pin; otherwise false.
If the method returns true, the pin parameter receives an instance of a GpioPin, and the openStatus parameter receives GpioOpenStatus.PinOpened. If the method returns false, the pin parameter is null and the openStatus parameter receives the reason that the operation failed.
| Device family |
Windows IoT Extension SDK (introduced v10.0.10240.0)
|
| API contract |
Windows.Devices.DevicesLowLevelContract (introduced v1)
|
| Capabilities |
lowLevelDevices
|
- See Also