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

TE_USB_FX2_CYAPI int TE_USB_FX2_SendCommand(CCyUSBDevice USBDeviceList, byte Command, long CmdLength, byte* Reply, long ReplyLength, unsigned long Timeout)

Function Call

Your application program shall call this function like this:

TE_USB_FX2_SendCommand(  USBDeviceList, Command, CmdLength, Reply, ReplyLength, Timeout);

Parameters

CCyUSBDevice *USBDeviceList

CCyUSBDevice is a type defined in CyAPI.lib. Its name is misleading because it is not a class that represents a single USB device, but it rather represents a list of USB devices.
CCyUSBDevice is the list of devices served by the CyUSB.sys driver (or a derivative like TE_USB_FX2_xx.sys). This parameter is passed by pointer. See page 7 and pages 23-49 of CyAPI.pdf (Cypress CyAPI Programmer's Reference).

byte* Command

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

long CmdLength

This parameter 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.

byte* Reply

This parameter (passed by pointer) is the pointer to 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.

long ReplyLength

This parameter 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.

unsigned long Timeout

The unsigned integer value is the time in milliseconds assigned to the synchronous method XferData() of data transfer used by CyAPI.lib.
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

int : integer type

This function returns true (ST_OK=0) if it is able to send a command to EP1 and receive a response within 2*Timeout milliseconds. This function returns false (ST_ERROR=1) otherwise.

enum ST_Status
{
     ST_OK = 0,
     ST_ERROR = 1
}; 
  • No labels