aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/Head_Card_IO.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Stubs Collection/stubs/Head_Card_IO.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Stubs Collection/stubs/Head_Card_IO.cs')
-rw-r--r--Software/Stubs Collection/stubs/Head_Card_IO.cs160
1 files changed, 0 insertions, 160 deletions
diff --git a/Software/Stubs Collection/stubs/Head_Card_IO.cs b/Software/Stubs Collection/stubs/Head_Card_IO.cs
deleted file mode 100644
index 161b622f2..000000000
--- a/Software/Stubs Collection/stubs/Head_Card_IO.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-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_I2C3
-const Int32 TCA9548A_address = 0xE2; // Main Mux
-Int32 I2C_Slave_Add ; // //eeprom address - 32kByte
-int Head_Mux_Channel_ID = 4; //Head MUX channel
-//----------------------
-
-uint[] write_Buf = new uint[5];
-
-
-int enable_channel(int Channel_ID)
-{
- uint Const_temp = 0x01;
-
- StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();
- stubI2CWriteBytesRequest.I2CId = I2C_ID;
- stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address;
-
- Const_temp = Const_temp << Channel_ID;
- stubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp);
-
- var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);
-
- return 1;
-}
-
-
-int adc_write(uint I2C_Slave_Add, uint No_Bytes)
-{
-uint i = 0;
- StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();
- stubI2CWriteBytesRequest.I2CId = I2C_ID;
- stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add;
-
- UInt32 uInt32 = new UInt32();
-
- //--------------------------------------------------------------
- for(i=0;i<No_Bytes;i++)
- stubI2CWriteBytesRequest.BytesTWrite.Add(write_Buf[i]);//Data to write
-
- var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);
-
- return 1;
-}
-
-int adc_set_for_read_ch(uint I2C_Slave_Add)
-{
- StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();
- stubI2CWriteBytesRequest.I2CId = I2C_ID;
- stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add;
-
-
- UInt32 uInt32 = new UInt32();
- stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write
- stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write
-
- var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);
-
- return 1;
-}
-
-int adc_read_ch(uint I2C_Slave_Add, uint No_Bytes)
-{
- adc_set_for_read_ch(I2C_Slave_Add );
-
- StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest();
- stubI2CReadBytesRequest.I2CId = I2C_ID;
- stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1;
- stubI2CReadBytesRequest.NumberOfBytesToRead = No_Bytes; // Number of bytes to read
-
- var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest);
- uint temph=0;
-
- for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++)
- {
- temph=response1.ReadBytes[i];
- stubManager.WriteLineHex(temph,2);
- }
-
- return 1;
-}
-
-
-public void OnExecute(StubManager stubManager)
-{
-
- enable_channel(Head_Mux_Channel_ID);
-
- //ZN_Latch_RST off
- write_Buf[0] = 0x03;
- write_Buf[1] = 0xD8;
- adc_write(0x42, 2);
- adc_read_ch(0x42, 2);
-
-
- //Turn ON mixer
- write_Buf[0] = 0x02;
- write_Buf[1] = 0x10;
- adc_write(0x42, 2);
- adc_read_ch(0x42, 2);
- stubManager.WriteLine("");
-
- //Turn ON 12 (0..7)
- write_Buf[0] = 0x02;
- write_Buf[1] = 0xFF;
- adc_write(0x40, 2);
- adc_read_ch(0x40, 2);
- stubManager.WriteLine("");
-
- //Turn ON 12 (8..11)
- write_Buf[0] = 0x03;
- write_Buf[1] = 0x0F;
- adc_write(0x40, 2);
- adc_read_ch(0x40, 2);
- stubManager.WriteLine("");
-
- //ZN_Latch_RST ON
- write_Buf[0] = 0x03;
- write_Buf[1] = 0xF8;
- adc_write(0x42, 2);
- adc_read_ch(0x42, 2);
-
- Thread.Sleep(5000);
- stubManager.WriteLine("-------------");
-
- //Turn OFF mixer
- write_Buf[0] = 0x02;
- write_Buf[1] = 0x00;
- adc_write(0x42, 2);
- adc_read_ch(0x42, 2);
- stubManager.WriteLine("");
-
- //Turn OFF 12 (0..7)
- write_Buf[0] = 0x02;
- write_Buf[1] = 0x00;
- adc_write(0x40, 2);
- adc_read_ch(0x40, 2);
- stubManager.WriteLine("");
-
- //Turn OFF 12 (8..11)
- write_Buf[0] = 0x03;
- write_Buf[1] = 0x00;
- adc_write(0x40, 2);
- adc_read_ch(0x40, 2);
- stubManager.WriteLine("");
-
-
-} \ No newline at end of file