blob: a0aebf7439d4697687a62a50c09939dd72f422d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
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<StubI2CWriteBytesResponse>(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<StubI2CWriteBytesResponse>(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<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);
Thread.Sleep(10);
return 1;
}
public void OnExecute(StubManager stubManager)
{
disable_all_channel1();
disable_all_channel2();
disable_all_channel3();
}
|