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; //---------------------- //---------------------- const Int32 I2C_ID = 3; //MCU_I2C2 const Int32 TCA9548A_address = 0xe2; //or 0xE0 or 0xE4 const Int32 I2C_Slave_Add = 0xc0; // /MPC9600 address //const Int32 I2C_Slave_Add = 0x46; //must be 0x40, 0x44 or 0x46 //---------------------- int disable_all_channel1() { StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); stubI2CWriteBytesRequest.I2CId = I2C_ID; stubI2CWriteBytesRequest.SlaveAddress = 0xe0; // UInt32 uInt32 = new UInt32(); stubI2CWriteBytesRequest.BytesTWrite.Add(0x10);//enable all 8 i2c channel stubManager.Run(stubI2CWriteBytesRequest); Thread.Sleep(10); return 1; } int disable_all_channel2() { StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); stubI2CWriteBytesRequest.I2CId = I2C_ID; stubI2CWriteBytesRequest.SlaveAddress = 0xe2; // UInt32 uInt32 = new UInt32(); stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//enable all 8 i2c channel stubManager.Run(stubI2CWriteBytesRequest); Thread.Sleep(10); return 1; } int disable_all_channel3() { StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); stubI2CWriteBytesRequest.I2CId = I2C_ID; stubI2CWriteBytesRequest.SlaveAddress = 0xe4; // UInt32 uInt32 = new UInt32(); stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//enable all 8 i2c channel stubManager.Run(stubI2CWriteBytesRequest); Thread.Sleep(10); return 1; } public void OnExecute(StubManager stubManager) { disable_all_channel1(); disable_all_channel2(); disable_all_channel3(); }