Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Dewesoft C++ DLL

Trenz Electronic C# DLL

void ResetFX2FifoStatus(HANDLE handle)
{






    cout << endl << "Resetting all FIFOs" << endl;
    byte cmd[64], reply[64];
 

    int cmd_length = 64;
    int reply_length = 64;



    cmd[0] = 0xA4;//command RESET_FIFO_STATUS
    cmd[1] = 0;//RESET all FIFOs

    if (TE0300_SendCommand(handle, cmd, cmd_length, reply, &reply_length, 1000))
        cout << "Error" << endl;

    cmd[0] = 0xA0;//command INITIALIZE
    cmd[1] = 1;//FIFO mode

    if (TE0300_SendCommand(handle, cmd, cmd_length, reply, &reply_length, 1000))
        cout << "Error" << endl;
}


Code Block
languagec#
static void ResetFX2FifoStatus(CyUSBDevice TE_USB_FX2_USBDevice)

{
    if
 {

    if (TE_USB_FX2_USBDevice == null)

    {
       

    {
        Console.WriteLine("Error,no device is selected");

        return;
    }
   

        return;
    }
    Console.WriteLine("Resetting all FIFOs");

   

    byte[] cmd = new byte[64];

   

    byte[] reply = new byte[64];

    int

    int cmd_length = 64;

    int

    int reply_length = 64;

    uint


    uint TIMEOUT_MS = 100000;

   


    cmd[0] = (byte)FX2_Commands.RESET_FIFO_STATUS;

   

    cmd[1] = 0; //reset all
fifos
    if
 fifos

    if (TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_SendCommand(ref TE_USB_FX2_USBDevice, ref cmd, ref cmd_length, ref reply, ref reply_length, TIMEOUT_MS) == false)

       

        Console.WriteLine("Error Send Command Reset all fifos");

   


    cmd[0] = (byte)FX2_Commands.INITALIZE; //0xA0;//command
INITIALIZE
   
 INITIALIZE
    cmd[1] = 1;//FIFO
mode
    if
 mode

    if (TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_SendCommand(ref TE_USB_FX2_USBDevice, ref cmd, ref cmd_length, ref reply, ref reply_length, TIMEOUT_MS) == false)

       

        Console.WriteLine("Error Switch Mode Fifo Mode");

 }

Dewesoft C++ DLL

Trenz Electronic C# DLL

void ReadData(unsigned int handle)
{








int packetlen = RX_PACKET_LEN;
unsigned int packets = 1200;
byte * data;

unsigned int total_cnt = 0;
unsigned int errors = 0;
data = new byte [RX_PACKET_LEN*packets];
//allocate memory

ResetFX2FifoStatus(handle);
SendFPGAcommand(handle,FX22MB_REG0_START_TX);
//starts test



ElapsedTime.Start();
//StopWatch start

for (unsigned int i = 0; i < packets; i++)
{
packetlen = RX_PACKET_LEN;




if (TE0300_GetData(handle, data+total_cnt, &packetlen, PI_EP6,TIMEOUT_MS))
{




cout << "ERROR" << endl;
errors++;
break;
}
total_cnt += packetlen;
}
TheElapsedTime = ElapsedTime.Stop(false);
//DEBUG StopWatch timer

SendFPGAcommand(handle,FX22MB_REG0_STOP);
//stops test
delete data;
}

static void ReadDataFPGAIntegrity(CyUSBDevice TE_USB_FX2_USBDevice, int BUFFER_SIZE, uint TIMEOUT_MS)
{

if (TE_USB_FX2_USBDevice == null)
{
Console.WriteLine("Error,no device is selected");
return;
}

int packetlen = RX_PACKET_LEN;
int packets = 1200;
byte[] data = new byte[packetlen*packets];
byte[] buffer = new byte[packetlen];
int total_cnt = 0;
int errors = 0;
int PI_EP6 = 6;

bool bResultXfer = false;
ResetFX2FifoStatus(TE_USB_FX2_USBDevice);
SendFPGAcommand(ref TE_USB_FX2_USBDevice, MB_Commands.FX22MB_REG0_START_TX, TIMEOUT_MS);
//starts test
test_cnt = 0;
total_cnt = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();

for (int i = 0; i < packets; i++)
{
packetlen = RX_PACKET_LEN;
//fixed (byte* buf = &data[total_cnt])
//bResultXfer = TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_GetDataP(ref inEndpointPipeNo, buf, ref packetlen, PI_EP6, TIMEOUT_MS);
bResultXfer = TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_GetData(ref TE_USB_FX2_USBDevice, ref buffer, ref packetlen, PI_EP6, TIMEOUT_MS,BUFFER_SIZE);
Buffer.BlockCopy(buffer,0, data, total_cnt, packetlen);
if (bResultXfer == false)
{
Console.WriteLine("Error Get Data");
errors++;
break;
}
total_cnt += packetlen;
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;

SendFPGAcommand(ref TE_USB_FX2_USBDevice, MB_Commands.FX22MB_REG0_STOP, TIMEOUT_MS);
//stops test
}

...