コード例 #1
0
 public static ISSComm getComm()
 {
     lock (myselfLock) { if (myself == null)
                         {
                             myself = new ISSComm();
                         }
                         return(myself); }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: rajeshwarn/USB-ISS-driver
        public Form1()
        {
            InitializeComponent();

            foreach (string s in ISSComm.getPorts())
            {
                comboBox_comport.Items.Add(s);
            }
        }
コード例 #3
0
            public static RESULTS setSPI_MODE(ISS_MODES_SPI mode, byte clkDiv)
            {
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)mode, clkDiv });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #4
0
            /// <summary>This uses the standard baud rates defined by the SERIAL_BAUD enumerated type</summary>
            public static RESULTS setI2C_MODE(ISS_MODES_I2C mode, SERIAL_BAUD_RATES baud)
            {
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)((byte)mode | (byte)ISS_MODES.SERIAL), (byte)(((uint)baud) >> 8), (byte)baud });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #5
0
            /// <summary>Should only be used when in Serial or I2C mode</summary>
            public static RESULTS setIO_CHANGE(IO_TYPES pin1, IO_TYPES pin2, IO_TYPES pin3, IO_TYPES pin4)
            {
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)ISS_MODES.IO_CHANGE, (byte)(((int)pin4 << 6) | ((int)pin3 << 4) | ((int)pin2 << 2) | (int)pin1) });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #6
0
            /// <summary>This uses the standard baud rates defined by the SERIAL_BAUD enumerated type</summary>
            private static RESULTS setModeSerial(ISS_MODES mode, IO_TYPES pin3, IO_TYPES pin4, SERIAL_BAUD_RATES baud)
            {
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)((byte)mode | (byte)ISS_MODES.SERIAL), (byte)(((uint)baud) >> 8), (byte)baud, (byte)(((int)pin4 << 6) | ((int)pin3 << 4)) });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #7
0
            private static RESULTS setMode(ISS_MODES mode, IO_TYPES pin1, IO_TYPES pin2, IO_TYPES pin3, IO_TYPES pin4)
            {
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)mode, (byte)(((int)pin4 << 6) | ((int)pin3 << 4) | ((int)pin2 << 2) | (int)pin1) });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #8
0
            /// <summary>This uses the custom specified baud rate. Eg: baud = 57600</summary>
            public static RESULTS setI2C_MODE(ISS_MODES_I2C mode, uint baud)
            {
                baud = (48000000 / (16 + baud)) - 1; // convert to baud rate divisor
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)((byte)mode | (byte)ISS_MODES.SERIAL), (byte)(((uint)baud) >> 8), (byte)baud });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #9
0
            /// <summary>This uses the custom specified baud rate. Eg: baud = 57600</summary>
            private static RESULTS setModeSerial(ISS_MODES mode, IO_TYPES pin3, IO_TYPES pin4, uint baud)
            {
                baud = (48000000 / (16 + baud)) - 1; // convert to baud rate divisor
                ISSComm comm = ISSComm.getComm();

                comm.Write(new byte[] { 0x5A, 0x02, (byte)((byte)mode | (byte)ISS_MODES.SERIAL), (byte)(((uint)baud) >> 8), (byte)baud, (byte)(((int)pin4 << 6) | ((int)pin3 << 4)) });
                comm.Read(2);
                //if (comm.readData[0] == 0xFF) // is Ack
                return((RESULTS)comm.readData[1]);
            }
コード例 #10
0
ファイル: Form1.cs プロジェクト: rajeshwarn/USB-ISS-driver
        private void comboBox_comport_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ISSComm.getComm().connect(comboBox_comport.Text))
            {
                comboBox_comport.Text = "";
            }
            txtMode.Text = "";
            ISSComm.ISS_VERSION data = new ISSComm.ISS_VERSION();

            if ((!data.isValid) || (data.moduleID != 7))   // if the module id is not that of the USB-ISS
            {
                lblDeviceData.Text = "Not Found";
                return;
            }
            lblDeviceData.Text = "USB-ISS V" + data.fwVersion + ", SN: " + (new ISSComm.GET_SER_NUM()).getSerNum(); //print the software version on screen
            switch (data.operMode & 0xFE)
            {
            case (int)ISSComm.ISS_MODE.ISS_MODES.IO_MODE: txtMode.Text = "IO_MODE"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_H_1000KHZ: txtMode.Text = "I2C 1MHz HW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_H_100KHZ: txtMode.Text = "I2C 100KHz HW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_H_400KHZ: txtMode.Text = "I2C 400KHz HW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_S_100KHZ: txtMode.Text = "I2C 100KHz SW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_S_20KHZ: txtMode.Text = "I2C 20KHz SW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_S_500KHZ: txtMode.Text = "I2C 500KHz SW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_I2C.I2C_S_50KHZ: txtMode.Text = "I2C 50KHz SW"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_SPI.A2I_L: txtMode.Text = "SPI TX on Act->Idle, Clock idle = low"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_SPI.A2I_H: txtMode.Text = "SPI TX on Act->Idle, Clock idle = high"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_SPI.I2A_L: txtMode.Text = "SPI TX on Idle->Act, Clock idle = low"; break;

            case (int)ISSComm.ISS_MODE.ISS_MODES_SPI.I2A_H: txtMode.Text = "SPI TX on Idle->Act, Clock idle = high"; break;

            default: txtMode.Text = "Unknown mode: 0x" + data.operMode.ToString("X2"); break;
            }
            if ((data.operMode & (int)ISSComm.ISS_MODE.ISS_MODES.SERIAL) == (int)ISSComm.ISS_MODE.ISS_MODES.SERIAL)
            {
                txtMode.Text += ", with Serial";
            }
        }
コード例 #11
0
 public GET_SER_NUM()
 {
     ISSComm.getComm().Write(new byte[] { 0x5A, 0x03 });
     ISSComm.getComm().Read(8);
     data = ISSComm.getComm().readData;
 }
コード例 #12
0
 public ISS_VERSION()
 {
     ISSComm.getComm().Write(new byte[] { 0x5A, 0x01 });
     ISSComm.getComm().Read(3);
     data = ISSComm.getComm().readData;
 }