You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Description

This function takes an already initialized USB device list (USBDeviceList), searches for Trenz Electronic USB FX2 devices (Cypress driver derivative and VID = 0xbd0, PID=0x0300) and counts them.

This function returns the number of Trenz Electronic USB FX2 devices attached to the USB bus of the host computer.

Use of the code

Declaration

E_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) 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) or to the MicroBlaze embedded processor (MB_Commands).

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