using System; using System.Runtime.InteropServices; namespace Unosquare.WiringPi.Native { public partial class WiringPi { /// /// Simple device read. Some devices present data when you read them without having to do any register transactions. /// /// The fd. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CRead", SetLastError = true)] public static extern Int32 WiringPiI2CRead(Int32 fd); /// /// These read an 8-bit value from the device register indicated. /// /// The fd. /// The reg. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CReadReg8", SetLastError = true)] public static extern Int32 WiringPiI2CReadReg8(Int32 fd, Int32 reg); /// /// These read a 16-bit value from the device register indicated. /// /// The fd. /// The reg. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CReadReg16", SetLastError = true)] public static extern Int32 WiringPiI2CReadReg16(Int32 fd, Int32 reg); /// /// Simple device write. Some devices accept data this way without needing to access any internal registers. /// /// The fd. /// The data. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CWrite", SetLastError = true)] public static extern Int32 WiringPiI2CWrite(Int32 fd, Int32 data); /// /// These write an 8-bit data value into the device register indicated. /// /// The fd. /// The reg. /// The data. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CWriteReg8", SetLastError = true)] public static extern Int32 WiringPiI2CWriteReg8(Int32 fd, Int32 reg, Int32 data); /// /// These write a 16-bit data value into the device register indicated. /// /// The fd. /// The reg. /// The data. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CWriteReg16", SetLastError = true)] public static extern Int32 WiringPiI2CWriteReg16(Int32 fd, Int32 reg, Int32 data); /// /// This initializes the I2C system with your given device identifier. /// The ID is the I2C number of the device and you can use the i2cdetect program to find this out. wiringPiI2CSetup() /// will work out which revision Raspberry Pi you have and open the appropriate device in /dev. /// The return value is the standard Linux filehandle, or -1 if any error – in which case, you can consult errno as usual. /// E.g. the popular MCP23017 GPIO expander is usually device Id 0x20, so this is the number you would pass into wiringPiI2CSetup(). /// /// The dev identifier. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "wiringPiI2CSetup", SetLastError = true)] public static extern Int32 WiringPiI2CSetup(Int32 devId); } }