-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add I2cTransferResult and I2cTransferStatus (#11)
- Loading branch information
1 parent
b388ba4
commit 96aab04
Showing
5 changed files
with
171 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Device.I2c | ||
{ | ||
/// <summary> | ||
/// Provides information about whether the data transfers that the <see cref="I2cDevice.Read"/>, <see cref="I2cDevice.Write"/>, or <see cref="I2cDevice.WriteRead"/> method performed succeeded, and the actual number | ||
/// of bytes the method transferred. | ||
/// </summary> | ||
public struct I2cTransferResult | ||
{ | ||
[Diagnostics.DebuggerBrowsable(Diagnostics.DebuggerBrowsableState.Never)] | ||
private readonly uint _bytesTransferred; | ||
|
||
[Diagnostics.DebuggerBrowsable(Diagnostics.DebuggerBrowsableState.Never)] | ||
private readonly I2cTransferStatus _status; | ||
|
||
/// <summary> | ||
/// The actual number of bytes that the operation actually transferred. The following table describes what this value represents for each method. | ||
/// </summary> | ||
public uint BytesTransferred { get => _bytesTransferred; } | ||
|
||
/// <summary> | ||
/// An enumeration value that indicates if the read or write operation transferred the full number of bytes that the method requested, or the reason | ||
/// that the full transfer did not succeed. For WriteReadPartial, the value indicates whether the data for both the write and the read operations was entirely transferred. | ||
/// </summary> | ||
public I2cTransferStatus Status { get => _status; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Device.I2c | ||
{ | ||
/// <summary> | ||
/// Describes whether the data transfers that the <see cref="I2cDevice.Read"/>, <see cref="I2cDevice.Write"/>, or <see cref="I2cDevice.WriteRead"/> methods performed succeeded, or provides the reason that the transfers did not succeed. | ||
/// </summary> | ||
public enum I2cTransferStatus | ||
{ | ||
/// <summary> | ||
/// The transfer failed for an unknown reason. | ||
/// </summary> | ||
UnknownError, | ||
|
||
/// <summary> | ||
/// The data was entirely transferred. For WriteRead, the data for both the write and the read operations was entirely transferred. | ||
/// For this status code, the value of the <see cref="I2cTransferResult.BytesTransferred"/> member that the method returns is the same as the size of the buffer | ||
/// you specified when you called the method, or is equal to the sum of the sizes of two buffers that you specified for WriteRead. | ||
/// </summary> | ||
FullTransfer, | ||
|
||
/// <summary> | ||
/// The transfer failed due to the clock being stretched for too long. Ensure the clock line is not being held low. | ||
/// </summary> | ||
ClockStretchTimeout, | ||
|
||
/// <summary> | ||
/// The I2C device negatively acknowledged the data transfer before all of the data was transferred. | ||
/// For this status code, the value of the <see cref="I2cTransferResult.BytesTransferred"/> member that the method returns is the number of bytes actually transferred. | ||
/// For <see cref="I2cDevice.WriteRead"/>, the value is the sum of the number of bytes that the operation wrote and the number of bytes that the operation read. | ||
/// </summary> | ||
PartialTransfer, | ||
|
||
/// <summary> | ||
/// The bus address was not acknowledged. For this status code, the value of the <see cref="I2cTransferResult.BytesTransferred"/> member that the method returns of the method is 0. | ||
/// </summary> | ||
SlaveAddressNotAcknowledged, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters