/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Opens the port. Throws an exception on failure /// /// </summary> /// <history> /// 01 Dec 16 Cynic - Originally written /// </history> protected override void OpenPort() { string deviceFileName; // set up now deviceFileName = RPIDefinitions.I2CDEV_FILENAME; // set up the i2c port number if (I2CPort == I2CPortEnum.I2CPORT_1) { deviceFileName = deviceFileName.Replace("%port%", "1"); } else { // should never happen throw new Exception("Unknown I2C Port:" + I2CPort.ToString()); } // we open the file. We have to have an open file descriptor // note this is an external call. It has to be because the // ioctl needs an open file descriptor it can use i2CPortFD = ExternalFileOpen(deviceFileName, O_RDWR | O_NONBLOCK); if (i2CPortFD <= 0) { throw new Exception("Could not open i2c device file:" + deviceFileName); } portIsOpen = true; // Console.WriteLine("I2CPort Port Device Enabled: "+ deviceFileName); }
public static void I2CStatusCheck(int status, I2CPort handle) { StatusCheckForce(status); }
public static int Write(I2CPort port, int deviceAddress, byte *dataToSend, int sendSize) { return(lowLevel.HAL_WriteI2C(port, deviceAddress, dataToSend, sendSize)); }
public static int Transaction(I2CPort port, int deviceAddress, byte *dataToSend, int sendSize, byte *dataReceived, int receiveSize) { return(lowLevel.HAL_TransactionI2C(port, deviceAddress, dataToSend, sendSize, dataReceived, receiveSize)); }
public static int Read(I2CPort port, int deviceAddress, byte *buffer, int count) { return(lowLevel.HAL_ReadI2C(port, deviceAddress, buffer, count)); }
public static void Initialize(I2CPort port) { lowLevel.HAL_InitializeI2C(port); }
public static void Close(I2CPort port) { lowLevel.HAL_CloseI2C(port); }