Description

This function takes an already initialized USB device list (USBDeviceList) and previously selected TE USB FX2 device selected by TE_USB_FX2_Open() and sends a command (API command) to the USB FX2 microcontroller of the selected device (TE USB FX2 module)

This function is normally used to send 64 bytes packets to the USB endpoint EP1 (0x01).

This function is also able to obtain the response of the USB FX2 microcontroller,  MicroBlaze embedded processor or SPI Flash through the USB FX2 microcontroller endpoint EP1 (0x81).

Using API command, TE_USB_FX2_SendCommand() is able to communicate with:

  • the EZ-USB FX2 microcontroller endpoint EP1 (link); 
  • the MicroBlaze implemented on the FPGA (link)
  • the SPI Flash (link).

The connection with EP1 command is used to:

  • send command to EZ-USB FX2 microcontroller (for example, reset the FPGA or power on/off the FPGA);
  • interrogate registers;
  • dipatching of API Commands to MicroBlaze and SPI Flash;
  • read/write from MicroBlaze I2C bus address;
  • read/write from SPI Flash.

Use of the code

Declaration

public static bool TE_USB_FX2_SendCommand(ref CyUSBDevice TE_USB_FX2_USBDevice, ref byte[] Command, ref int CmdLength,ref byte[] Reply, ref int ReplyLength, uint Timeout);

Function Call

Your application program shall call this function like this:

TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_SendCommand(ref TE_USB_FX2_USBDevice, ref Command, ref CmdLength, ref Reply, ref ReplyLength, Timeout);

Parameters

ref CyUSBDevice TE_USB-FX2_USBDevice

CyUSBDevice is a type defined in CyUSB.dll. This parameter points to the module selected by TE_USB_FX2_Open(). This parameter is passed by reference (ref). See pages 70-93 of CyUSB.NET.pdf (Cypress CyUSB .NET DLL Programmer's Reference)

ref byte[] Command

This parameter is passed by reference (ref). It is the byte array that contains the commands to send to USB FX2 microcontroller (FX2_Commands), to the MicroBlaze embedded processor (MB_Commands) and/or to SPI Flash.

ref int CmdLength

This parameter (passed by reference (ref)) is the length (in bytes) of the previous byte array; it is the length of the packet to transmit to USB FX2 controller endpoint EP1 (0x01). It is typically initialized to 64 bytes.

ref byte[] Reply

This parameter (passed by reference (ref)) is the byte array that contains the response to the command sent to the USB FX2 microcontroller (FX2_Commands), to the MicroBlaze embedded processor (MB_Commands) and/or to SPI Flash.

ref int ReplyLength

This parameter (passed by reference (ref)) is the length (in bytes) of the previous byte array; it is the length of the packet to transmit to the USB FX2 microcontroller endpoint EP1 (0x81). It is typically initialized to 64 byes, but normally the meaningful bytes are less. The parameter is a reference, meaning that the method can modify its value. The number of bytes actually received is passed back in ReplyLength.

uint Timeout

The unsigned integer value is the time in milliseconds assigned to the synchronous method XferData() of data transfer used by CyUSB.dll.
Timeout is the time that is allowed to the function for sending/receiving the data packet passed to the function; this timeout shall be large enough to allow the data/command transmission/reception. Otherwise the transmission/reception will fail. See Timeout Setting.

Return Value

bool : logical type

This function returns true if it is able to send a command to EP1 and receive a response within 2*Timeout milliseconds. This function returns false otherwise.

 

  • No labels