Ejemplo n.º 1
0
        private bool downloadFirmware(string FirmwareFile)
        {
            if (m_handle == 0)
            {
                throw new Exception("Invalid Handle");
            }
            if (!File.Exists(FirmwareFile))
            {
                throw new Exception("Firmware file does not exist");
            }


            IntPtr filePtr = Marshal.StringToHGlobalAnsi(FirmwareFile);

            try
            {
                if (0 == AD_CYUSB_USB4.Download_Firmware(m_handle, filePtr))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(filePtr);
            }
        }
Ejemplo n.º 2
0
 private bool disconnect()
 {
     if (m_handle != 0)
     {
         if (0 == AD_CYUSB_USB4.Disconnect(m_handle))
         {
             m_handle = 0;
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        private void writeToPort(byte Address, byte Value)
        {
            if (m_handle == 0)
            {
                throw new Exception("Invalid Handle");
            }

            ushort addrval = (ushort)((Value << 8) | Address);

            if (0 != AD_CYUSB_USB4.Vendor_Request(m_handle, RW_REQUEST, 0x0D, addrval, DIR_WRITE, 0, IntPtr.Zero))
            {
                throw new Exception("WriteToPort: Vendor_Request");
            }
        }
Ejemplo n.º 4
0
        private bool connect(byte PartPath)
        {
            IntPtr handlePtr = Marshal.AllocHGlobal(sizeof(UInt16));

            try
            {
                if (AD_CYUSB_USB4.Connect(VID_ANALOG, PID_EVAL_AD5933EBZ, PartPath, handlePtr) == 0)
                {
                    m_handle = (UInt16)Marshal.ReadInt16(handlePtr, 0);
                    return(true);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(handlePtr);
            }
            return(false);
        }
Ejemplo n.º 5
0
        private byte readFromPort(byte Address)
        {
            if (m_handle == 0)
            {
                throw new Exception("Invalid Handle");
            }

            IntPtr valPtr = Marshal.AllocHGlobal(1);

            try
            {
                if (0 != AD_CYUSB_USB4.Vendor_Request(m_handle, RW_REQUEST, 0x0D, Address, DIR_READ, 1, valPtr))
                {
                    throw new Exception("ReadFromPort: Vendor_Request");
                }
                byte result = Marshal.ReadByte(valPtr);
                return(result);
            }
            finally
            {
                Marshal.FreeHGlobal(valPtr);
            }
        }