GpioController.TryOpenPin 方法

定义

在指定模式下打开指定的常规用途 I/O (GPIO) 引脚,并获取可用于处理失败以编程方式打开引脚的状态值。

public:
 virtual bool TryOpenPin(int pinNumber, GpioSharingMode sharingMode, [Out] GpioPin ^ & pin, [Out] GpioOpenStatus & openStatus) = TryOpenPin;
bool TryOpenPin(int const& pinNumber, GpioSharingMode const& sharingMode, [Out] GpioPin const& & pin, [Out] GpioOpenStatus & openStatus);
public bool TryOpenPin(int pinNumber, GpioSharingMode sharingMode, out GpioPin pin, out GpioOpenStatus openStatus);
Public Function TryOpenPin (pinNumber As Integer, sharingMode As GpioSharingMode, ByRef pin As GpioPin, ByRef openStatus As GpioOpenStatus) As Boolean

参数

pinNumber
Int32

int

要打开的 GPIO 引脚的引脚编号。 某些固定在用户模式下可能不可用。 有关引脚编号如何对应于物理引脚的信息,请参阅电路板的文档。

sharingMode
GpioSharingMode

要打开 GPIO 引脚的模式,该模式确定在引脚打开时是否可以打开与引脚的其他连接。

pin
GpioPin

如果返回值为 true,则为打开的 GPIO 引脚;否则为 null。

openStatus
GpioOpenStatus

一个枚举值,该值指示尝试打开 GPIO 引脚成功,或者尝试打开 GPIO 引脚失败的原因。

返回

Boolean

bool

如果方法成功打开引脚,则其值为 True;否则为 false。

如果方法返回 true, 则 pin 参数接收 GpioPin 的实例, openStatus 参数接收 GpioOpenStatus.PinOpened。 如果方法返回 false,则 pin 参数为 null, openStatus 参数接收操作失败的原因。

Windows 要求

应用功能
lowLevel

适用于

另请参阅