Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            short err;

            m_delegate = new CallbackDelegate(Callback);
            gr         = pbxDisplay.CreateGraphics();

            blackBrush = new SolidBrush(Color.Black);
            // Create rectangle.
            PanelRect = new Rectangle(0, 0, pbxDisplay.Width, pbxDisplay.Height);


            TXT_SAMPLERATE.Text = dSamplerate.ToString();
            TXT_DATACOUNT.Text  = dwDataNum.ToString();
            Module_Num1         = USBDASK.UD_Register_Card(USBDASK.USB_1210, 0);
            if (Module_Num1 < 0)
            {
                MessageBox.Show("Register card Fail, Code:" + Module_Num1.ToString());
                Close();
                return;
            }
            Module_Num2 = USBDASK.UD_Register_Card(USBDASK.USB_1210, 1);
            if (Module_Num2 < 0)
            {
                MessageBox.Show("Register card Fail, Code:" + Module_Num2.ToString());
                Close();
                return;
            }

            tbxYup.Text          = "10V";
            tbxYdown.Text        = "-10V";
            textYZero.Text       = "0V";
            pbxDisplay.BackColor = Color.Black;

            err = USBDASK.UD_DIO_Config((ushort)Module_Num1, USBDASK.GPTC0_GPO1, USBDASK.GPTC2_GPO3);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_DIO_Config error = :" + err.ToString());
                Close();
                return;
            }

            err = USBDASK.UD_GPTC_Setup_N((ushort)Module_Num1, 0, USBDASK.ContGatedPulseGen, USBDASK.GPTC_GATE_SRC_Int, 0x00, 40, 40, 1);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Setup_N Error: {0}", err));
                return;
            }
            err = USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntUpDnCTR, 0);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntUpDnCTR Error: {0}", err));
                return;
            }

            // Added on 2018/2/27 Ming-Yen
            USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntGate, 1);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntGate Error: {0}", err));
                return;
            }
            // Added on 2018/2/27 Ming-Yen
            // The 80M / 40 = 2MHz Clock will be sent out when IntEnable is set to 1
            // The 80M / 40 = 2MHz Clock will be stopped when IntEnable is set to 0
            err = USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntENABLE, 0);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntENABLE Error: {0}", err));
                return;
            }
            btnGPO0.Text = "GPO0 2MHz OFF";
        }