using System; using System.Text; using System.Linq; using System.Drawing; using System.Diagnostics; using System.Windows.Forms; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using Tango.PMR.Stubs; using Tango.Stubs.UI; //---------------------- //I2C4: // Switches address: 0xE0, 0xE4, 0xE3 //I2C3 // Switches address: 0xE0, 0xE4, 0xE3 // ADC address: 0x40, 0x44, 0x46 //I2C2 // DAC address: 0x98 // EEPROM address: 0xA0 //---------------------- const Int32 I2C_ID = 4; const Int32 I2C_Slave_Add = 0xE0; //---------------------- public void OnExecute(StubManager stubManager) { // --------------------- I2C write multibyte --------------------- StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); stubI2CWriteBytesRequest.I2CId = I2C_ID; stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; UInt32 uInt32 = new UInt32(); stubI2CWriteBytesRequest.BytesTWrite.Add(0x11);//Byte 0 to write //stubI2CWriteBytesRequest.BytesTWrite.Add(0x22);//Byte 1 to Write //and so on,add lines in order to add Bytes - max : 256 var response = stubManager.Run(stubI2CWriteBytesRequest); // --------------------- I2C Read multibyte --------------------- StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); stubI2CReadBytesRequest.I2CId = I2C_ID; stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; stubI2CReadBytesRequest.NumberOfBytesToRead = 1; // Number of bytes to read var response1 = stubManager.Run(stubI2CReadBytesRequest); for(int i=0; i