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); } }
private bool disconnect() { if (m_handle != 0) { if (0 == AD_CYUSB_USB4.Disconnect(m_handle)) { m_handle = 0; return(true); } } return(false); }
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"); } }
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); }
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); } }