You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// this field is used in native so it must be kept here despite "not being used"
36
36
privatePinValue_lastInputValue=PinValue.Low;
37
-
#pragma warning restore 0414
37
+
#pragma warning restore 0414
38
38
39
39
internalGpioPin(intpinNumber)
40
40
{
@@ -43,7 +43,7 @@ public sealed class GpioPin : IDisposable
43
43
44
44
internalboolInit()
45
45
{
46
-
if(NativeInit(_pinNumber))
46
+
if(NativeInit(_pinNumber))
47
47
{
48
48
// add the pin to the event listener in order to receive the callbacks from the native interrupts
49
49
s_gpioPinEventManager.AddPin(this);
@@ -82,7 +82,7 @@ public TimeSpan DebounceTimeout
82
82
/// <value>
83
83
/// The pin number of the GPIO pin.
84
84
/// </value>
85
-
publicintPinNumber
85
+
publicintPinNumber
86
86
{
87
87
get
88
88
{
@@ -112,9 +112,8 @@ public PinMode GetPinMode()
112
112
/// <param name="pinMode">The pin mode that you want to check for support.</param>
113
113
/// <returns>
114
114
/// <see langword="true"/> if the GPIO pin supports the pin mode that pinMode specifies; otherwise false.
115
-
/// If you specify a pin mode for which this method returns false when you call <see cref="SetPinMode"/>, <see cref="SetPinMode"/> generates an exception.
115
+
/// If you specify a pin mode for which this method returns <see langword="false"/> when you call <see cref="SetPinMode"/>, <see cref="SetPinMode"/> generates an exception.
116
116
/// </returns>
117
-
118
117
publicboolIsPinModeSupported(PinModepinMode)
119
118
{
120
119
lock(_syncLock)
@@ -132,27 +131,20 @@ public bool IsPinModeSupported(PinMode pinMode)
132
131
/// </summary>
133
132
/// <param name="value">An enumeration value that specifies pin mode to use for the GPIO pin.
134
133
/// The pin mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.</param>
135
-
/// <remarks>The following exceptions can be thrown by this method:
136
-
/// <list type="bullet">
137
-
/// <item><term>E_INVALIDARG : The GPIO pin does not support the specified pin mode.</term></item>
138
-
/// <item><term>E_ACCESSDENIED : The pin is open in shared read-only mode. Close the pin and reopen it in exclusive mode to change the pin mode of the pin.</term></item>
139
-
/// </list>
140
-
/// </remarks>
134
+
/// <exception cref="ArgumentException">The GPIO pin does not support the specified pin mode.</exception>
// need to call the native method directly because we are already inside a lock
150
-
if(NativeIsPinModeSupported(value))
151
-
{
152
-
NativeSetPinMode(value);
153
-
_pinMode=value;
154
-
}
155
-
}
142
+
// the native call takes care of:
143
+
// 1) validating if the requested pin mode is supported
144
+
// 2) throwing ArgumentException otherwise
145
+
// 3) store the requested pin mode in _pinMode field
146
+
NativeSetPinMode(value);
147
+
}
156
148
}
157
149
158
150
/// <summary>
@@ -170,11 +162,7 @@ public void SetPinMode(PinMode value)
170
162
/// <para>If the GPIO pin is configured as an output, the method drives the specified value onto the pin according to the current pin mode for the pin.</para>
171
163
/// <para>If the GPIO pin is configured as an input, the method updates the latched output value for the pin. The latched output value is driven onto the pin when the configuration for the pin changes to output.</para>
172
164
/// </param>
173
-
/// <remarks>The following exceptions can be thrown by this method:
174
-
/// <list type="bullet">
175
-
/// <item><term>E_ACCESSDENIED : The GPIO pin is open in shared read-only mode. To write to the pin, close the pin and reopen the pin in exclusive mode.</term></item>
176
-
/// </list>
177
-
/// </remarks>
165
+
/// <exception cref="InvalidOperationException">This exception will be thrown on an attempt to write to a pin that hasn't been opened or is not configured as output.</exception>
0 commit comments