public static int DDR_MassWrite(uint wCmd, int wCmdLen, byte[] xferBuf, int wDataLen) { bool ret = true; if (wDataLen > xferBuf.Length) { return(Chip.ERROR_BUFLEN_ERR); } if (wCmdLen < 1 || wCmdLen > 4) { return(Chip.ERROR_BUFLEN_ERR); } IntPtr WriteDataPtr = Marshal.AllocHGlobal(wDataLen); for (int i = wCmdLen; i > 0; i--) { if (!SL_AddrWrite((byte)((wCmd >> (8 * (wCmdLen - 1))) & 0xff))) { return(Chip.ERROR_DISDATAWR); } } Marshal.Copy(xferBuf, 0, WriteDataPtr, wDataLen); // xferBuf to WriteDataPtr ret = Epp2USB.UsbWriteScanner(WriteDataPtr, (uint)wDataLen, RWSCANNER_EPPCTL_8BIT); Marshal.FreeHGlobal(WriteDataPtr); return((ret == true) ? Chip.ERROR_RESULT_OK : Chip.ERROR_DISDATAWR); }
public static int SL_CommBase_MassDataWrite(byte[] xferBuf) { bool Ret = true; int xferLen = xferBuf.Length; if (!SL_AddrWrite(DATAWRMODE)) { return(Chip.ERROR_DISADDRWR); } IntPtr WriteDataPtr = Marshal.AllocHGlobal(xferLen); Marshal.Copy(xferBuf, 0, WriteDataPtr, xferLen); // xferBuf to WriteDataPtr Ret = Epp2USB.UsbWriteScanner(WriteDataPtr, (uint)xferLen, RWSCANNER_EPPCTL_8BIT); Marshal.FreeHGlobal(WriteDataPtr); return((Ret == true) ? Chip.ERROR_RESULT_OK : Chip.ERROR_DISDATAWR); }