Skip to content

Commit 8a317c0

Browse files
authored
Rename DriveMode with PinMode (#6)
***NO_CI***
1 parent 790428a commit 8a317c0

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

System.Device.Gpio/GpioController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public PinMode GetPinMode(int pinNumber)
179179
{
180180
if (((GpioPinBundle)s_GpioPins[i]).PinNumber == pinNumber)
181181
{
182-
return ((GpioPinBundle)s_GpioPins[i]).GpioPin.GetDriveMode();
182+
return ((GpioPinBundle)s_GpioPins[i]).GpioPin.GetPinMode();
183183
}
184184
}
185185

System.Device.Gpio/GpioPin.cs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public sealed class Gpio​Pin : IDisposable
2525
private readonly object _syncLock = new object();
2626

2727
private readonly int _pinNumber;
28-
private PinMode _driveMode = PinMode.Input;
28+
29+
private PinMode _pinMode = PinMode.Input;
2930
private TimeSpan _debounceTimeout = TimeSpan.Zero;
3031
private PinValueChangedEventHandler _callbacks = null;
3132
private PinValue _lastOutputValue = PinValue.Low;
@@ -90,66 +91,66 @@ public int PinNumber
9091
}
9192

9293
/// <summary>
93-
/// Gets the current drive mode for the general-purpose I/O (GPIO) pin. The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.
94+
/// Gets the current pin mode for the general-purpose I/O (GPIO) pin. The pin mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.
9495
/// </summary>
95-
/// <returns>An enumeration value that indicates the current drive mode for the GPIO pin.
96-
/// The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.</returns>
97-
public PinMode GetDriveMode()
96+
/// <returns>An enumeration value that indicates the current pin mode for the GPIO pin.
97+
/// The pin mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.</returns>
98+
public PinMode GetPinMode()
9899
{
99100
lock (_syncLock)
100101
{
101102
// check if pin has been disposed
102-
if (!_disposedValue) { return _driveMode; }
103+
if (!_disposedValue) { return _pinMode; }
103104

104105
throw new ObjectDisposedException();
105106
}
106107
}
107108

108109
/// <summary>
109-
/// Gets whether the general-purpose I/O (GPIO) pin supports the specified drive mode.
110+
/// Gets whether the general-purpose I/O (GPIO) pin supports the specified pin mode.
110111
/// </summary>
111-
/// <param name="driveMode">The drive mode that you want to check for support.</param>
112+
/// <param name="pinMode">The pin mode that you want to check for support.</param>
112113
/// <returns>
113-
/// <see langword="true"/> if the GPIO pin supports the drive mode that driveMode specifies; otherwise false.
114-
/// If you specify a drive mode for which this method returns false when you call <see cref="SetDriveMode"/>, <see cref="SetDriveMode"/> generates an exception.
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.
115116
/// </returns>
116117

117-
public bool IsDriveModeSupported(PinMode driveMode)
118+
public bool IsPinModeSupported(PinMode pinMode)
118119
{
119120
lock (_syncLock)
120121
{
121122
// check if pin has been disposed
122-
if (!_disposedValue) { return NativeIsDriveModeSupported(driveMode); }
123+
if (!_disposedValue) { return NativeIsPinModeSupported(pinMode); }
123124

124125
throw new ObjectDisposedException();
125126
}
126127
}
127128

128129
/// <summary>
129-
/// Sets the drive mode of the general-purpose I/O (GPIO) pin.
130-
/// The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.
130+
/// Sets the pin mode of the general-purpose I/O (GPIO) pin.
131+
/// The pin mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.
131132
/// </summary>
132-
/// <param name="value">An enumeration value that specifies drive mode to use for the GPIO pin.
133-
/// The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.</param>
133+
/// <param name="value">An enumeration value that specifies pin mode to use for the GPIO pin.
134+
/// 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>
134135
/// <remarks>The following exceptions can be thrown by this method:
135136
/// <list type="bullet">
136-
/// <item><term>E_INVALIDARG : The GPIO pin does not support the specified drive mode.</term></item>
137-
/// <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 drive mode of the pin.</term></item>
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>
138139
/// </list>
139140
/// </remarks>
140-
public void SetDriveMode(PinMode value)
141+
public void SetPinMode(PinMode value)
141142
{
142143
lock (_syncLock)
143144
{
144145
// check if pin has been disposed
145146
if (_disposedValue) { throw new ObjectDisposedException(); }
146147

147-
// check if the request drive mode is supported
148+
// check if the request pin mode is supported
148149
// need to call the native method directly because we are already inside a lock
149-
if (NativeIsDriveModeSupported(value))
150+
if (NativeIsPinModeSupported(value))
150151
{
151-
NativeSetDriveMode(value);
152-
_driveMode = value;
152+
NativeSetPinMode(value);
153+
_pinMode = value;
153154
}
154155
}
155156
}
@@ -162,11 +163,11 @@ public void SetDriveMode(PinMode value)
162163
public extern PinValue Read();
163164

164165
/// <summary>
165-
/// Drives the specified value onto the general purpose I/O (GPIO) pin according to the current drive mode for the pin
166+
/// Drives the specified value onto the general purpose I/O (GPIO) pin according to the current pin mode for the pin
166167
/// if the pin is configured as an output, or updates the latched output value for the pin if the pin is configured as an input.
167168
/// </summary>
168169
/// <param name="value">The enumeration value to write to the GPIO pin.
169-
/// <para>If the GPIO pin is configured as an output, the method drives the specified value onto the pin according to the current drive mode for the pin.</para>
170+
/// <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>
170171
/// <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>
171172
/// </param>
172173
/// <remarks>The following exceptions can be thrown by this method:
@@ -224,7 +225,7 @@ public event PinValueChangedEventHandler ValueChanged
224225
try
225226
{
226227
_callbacks = callbacksNew;
227-
NativeSetDriveMode(_driveMode);
228+
NativeSetPinMode(_pinMode);
228229
}
229230
catch
230231
{
@@ -249,7 +250,7 @@ public event PinValueChangedEventHandler ValueChanged
249250
try
250251
{
251252
_callbacks = callbacksNew;
252-
NativeSetDriveMode(_driveMode);
253+
NativeSetPinMode(_pinMode);
253254
}
254255
catch
255256
{
@@ -334,10 +335,10 @@ public void Dispose()
334335
#region external calls to native implementations
335336

336337
[MethodImpl(MethodImplOptions.InternalCall)]
337-
private extern bool NativeIsDriveModeSupported(PinMode driveMode);
338+
private extern bool NativeIsPinModeSupported(PinMode pinMode);
338339

339340
[MethodImpl(MethodImplOptions.InternalCall)]
340-
private extern void NativeSetDriveMode(PinMode driveMode);
341+
private extern void NativeSetPinMode(PinMode pinMode);
341342

342343
[MethodImpl(MethodImplOptions.InternalCall)]
343344
private extern bool NativeInit(int pinNumber);

System.Device.Gpio/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
////////////////////////////////////////////////////////////////
1414
// update this whenever the native assembly signature changes //
15-
[assembly: AssemblyNativeVersion("100.1.0.1")]
15+
[assembly: AssemblyNativeVersion("100.1.0.2")]
1616
////////////////////////////////////////////////////////////////
1717

1818
// Setting ComVisible to false makes the types in this assembly not visible

0 commit comments

Comments
 (0)