RaspberryIO_26/Unosquare.RaspberryIO.Abstractions/II2CDevice.cs
2019-12-06 22:24:34 +01:00

82 lines
2.3 KiB
C#

using System;
namespace Unosquare.RaspberryIO.Abstractions {
/// <summary>
/// Interfaces a device on the I2C Bus.
/// </summary>
public interface II2CDevice {
/// <summary>
/// Gets the device identifier.
/// </summary>
/// <value>
/// The device identifier.
/// </value>
Int32 DeviceId {
get;
}
/// <summary>
/// Gets the standard POSIX file descriptor.
/// </summary>
/// <value>
/// The file descriptor.
/// </value>
Int32 FileDescriptor {
get;
}
/// <summary>
/// Reads a byte from the specified file descriptor.
/// </summary>
/// <returns>The byte from device.</returns>
Byte Read();
/// <summary>
/// Reads a buffer of the specified length, one byte at a time.
/// </summary>
/// <param name="length">The length.</param>
/// <returns>The byte array from device.</returns>
Byte[] Read(Int32 length);
/// <summary>
/// Writes a byte of data the specified file descriptor.
/// </summary>
/// <param name="data">The data.</param>
void Write(Byte data);
/// <summary>
/// Writes a set of bytes to the specified file descriptor.
/// </summary>
/// <param name="data">The data.</param>
void Write(Byte[] data);
/// <summary>
/// These write an 8 or 16-bit data value into the device register indicated.
/// </summary>
/// <param name="address">The register.</param>
/// <param name="data">The data.</param>
void WriteAddressByte(Int32 address, Byte data);
/// <summary>
/// These write an 8 or 16-bit data value into the device register indicated.
/// </summary>
/// <param name="address">The register.</param>
/// <param name="data">The data.</param>
void WriteAddressWord(Int32 address, UInt16 data);
/// <summary>
/// These read an 8 or 16-bit value from the device register indicated.
/// </summary>
/// <param name="address">The register.</param>
/// <returns>The address byte from device.</returns>
Byte ReadAddressByte(Int32 address);
/// <summary>
/// These read an 8 or 16-bit value from the device register indicated.
/// </summary>
/// <param name="address">The register.</param>
/// <returns>The address word from device.</returns>
UInt16 ReadAddressWord(Int32 address);
}
}