Ejemplo n.º 1
0
        private CyFX3Device FindCyDevice(short vid, short pid)
        {
            CyFX3Device device = null;

            for (int i = 0; i < 5; i++)
            {
                usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
                if (0 != usbDevices.Count)
                {
                    break;
                }
            }

            if (0 == usbDevices.Count)
            {
                return(device);
            }

            usbDevices.DeviceRemoved += UsbDevices_DeviceRemoved;

            foreach (var item in usbDevices)
            {
                device = item as CyFX3Device;
                if (null != device)
                {
                    if (device.VendorID == vid && device.ProductID == pid)
                    {
                        return(device);
                    }
                }
            }
            return(device);
        }
Ejemplo n.º 2
0
 private void ConfigFX3Device(string FileName, CyUSBDevice myDevice)
 {
     if (MyDevice != null)
     {
         FX3_FWDWNLOAD_ERROR_CODE enmResult = FX3_FWDWNLOAD_ERROR_CODE.SUCCESS;
         CyFX3Device fx3 = myDevice as CyFX3Device;
         if (fx3 != null)
         {
             enmResult = fx3.DownloadFw(FileName, FX3_FWDWNLOAD_MEDIA_TYPE.RAM);
         }
         else
         {
             MessageBox.Show("Please check whether the device is FX3 device", "Device ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         if (enmResult != FX3_FWDWNLOAD_ERROR_CODE.SUCCESS)
         {
             MessageBox.Show("Config error", "Device ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         string report = string.Format("Program {0}\n", fx3.GetFwErrorString(enmResult));
         tbxInfo.AppendText(report);
     }
     else
     {
         MessageBox.Show("Please select the USB device", "Device ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 3
0
 internal BCamComLayer(CyFX3Device cyFX3Device, bool sensor4M)
 {
     this.fx3Device    = cyFX3Device;
     this.debugOutput  = new BDebugOutput();
     this.camRegisters = new BCamRegistersModel(sensor4M);
     this.LoadBemageFirmwareImg();
     Thread.Sleep(10);
 }
Ejemplo n.º 4
0
        public bool Close()
        {
            if (device != null)
            {
                device.Dispose();
            }
            device    = null;
            bepOut    = null;
            bepIn82   = null;
            isConnect = false;

            return(true);
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            CyFX3Device fx        = myFX3Device as CyFX3Device;
            string      tmpFilter = FOpenDialog.Filter;

            FOpenDialog.Filter = "Firmware Image files (*.img) | *.img";
            if ((fx != null) && (FOpenDialog.ShowDialog() == DialogResult.OK))
            {
                FX3_FWDWNLOAD_ERROR_CODE enmResult = FX3_FWDWNLOAD_ERROR_CODE.SUCCESS;


                rtConsole.AppendText("Programming RAM of ");
                rtConsole.AppendText(fx.FriendlyName);
                rtConsole.AppendText("........\n");

                string filename = FOpenDialog.FileName;
                Refresh();
                enmResult = fx.DownloadFw(filename, FX3_FWDWNLOAD_MEDIA_TYPE.RAM);



                rtConsole.AppendText("Programming");
                rtConsole.AppendText(fx.GetFwErrorString(enmResult));
                rtConsole.AppendText("\n");
                Refresh();
                firmwaredownloaded = true;

                button1.Enabled = false;
            }
            else if (myDevice != null)
            {
                rtConsole.AppendText("FX3 firmware is already downloaded\n");
                StatLabel1.Text = "NEXT STEP: Use Select Bitstream to select the FPGA .bin file ";
            }

            FOpenDialog.FileName = "";
            FOpenDialog.Filter   = tmpFilter;
        }
Ejemplo n.º 6
0
        public bool Open()
        {
            device = FindCyDevice(VID, PID);
            if (null == device)
            {
                return(false);
            }

            foreach (CyUSBEndPoint ept in device.EndPoints)
            {
                if (!ept.bIn && (ept.Attributes == 2) && ept.Address == 0x02)
                {
                    bepOut = ept as CyBulkEndPoint;
                }

                if (ept.bIn && (ept.Attributes == 2) && ept.Address == 0x82)
                {
                    bepIn82 = ept as CyBulkEndPoint;
                }
            }

            //he Attributes member indicates the type of endpoint per the following list.
            //0: Control
            //1: Isochronous
            //2: Bulk
            //3: Interrupt
            isConnect = true;
            Task.Run(() => Bep82USBRecv());
            //Thread t83Recv = new Thread(Bep83USBRecv);
            //t83Recv.Priority = ThreadPriority.Highest;
            //t83Recv.IsBackground = true;
            //t83Recv.Start();

            Task.Run(() => AnalyseBepIn83Packet());
            //Task.Run(() => AnalyseBepIn82Packet());
            return(true);
        }
Ejemplo n.º 7
0
 internal BCam(CyFX3Device cyFX3Device)
 {
     this.camProperties = new BCamProperties();
     this.camSettings   = new BCamSettings();
     this.camComLayer   = new BCamComLayer(cyFX3Device, this.camProperties.sensor4M);
 }