2019-12-06 22:24:34 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Unosquare.RaspberryIO.Abstractions {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interfaces a device on the I2C Bus.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface II2CDevice {
|
2019-12-04 18:57:18 +01:00
|
|
|
|
/// <summary>
|
2019-12-06 22:24:34 +01:00
|
|
|
|
/// Gets the device identifier.
|
2019-12-04 18:57:18 +01:00
|
|
|
|
/// </summary>
|
2019-12-06 22:24:34 +01:00
|
|
|
|
/// <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);
|
|
|
|
|
}
|
2019-12-04 18:57:18 +01:00
|
|
|
|
}
|