News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Te0300 - Raspberry Pi communication via USB

Started by nielsvh, October 22, 2013, 06:31:59 PM

Previous topic - Next topic

nielsvh

I've been looking around for a FPGA with a USB connector that isn't dedicated to programming the FPGA and found that the TE0300 fix all my specifications except for one: all the drivers are written for Windows, which the Raspberry Pi I hope to communicate with does not run. My main question is what the difference between the cypress drivers for the USB micro-controller and the TE drivers for the card are. If I have to, I will write my own drivers, but I'd like to know what I would be loosing/trying to replicate.
Has there ever been a successful TE03xx-linux connection via USB?
Niels

Horsa

#1
As a starting point, you can try to use LinuxFUT documented here.
It makes use of libusb, but you might be better off with libusbx.

You can use all TE API Commands (FW API), but you should recreate a SW API (in a way you like) that wraps the FW API. The SW API wrapper could be from very complex down to simply not existing. The latter case makes directly use of the libusb(x) library functions with TE API Commands (FW API), but you have to abide to the correct command construction and use a command buffer.

For example, the TE API Command POWER aka CMD_FX2_POWER_ON is referred to as CMD_FPGA_POWER in the firmware <=> te_api.c @ line 273.

CMD_FPGA_POWER example from LinuxFUT (line 243).


void switchFpgaPower (Switch theSwitch)
{
        unsigned char        aCmdBuffer[USB_BLOCK_SIZE];
        int actual_length;

        /** Clean Buffer        */
        memset(aCmdBuffer, 0, sizeof(aCmdBuffer));

        if (theSwitch == ON)
        {
                CMDMSG("Switch fpga power on");
                aCmdBuffer[1] = 1;        /** <- Parameter 0 = OFF */
        } else
        {
                CMDMSG("Switch fpga power off");
                aCmdBuffer[1] = 0;        /** <- Parameter 0 = OFF */
        }

        aCmdBuffer[0] = CMD_FX2_POWER_ON; /** ON with Parameter 0 means OFF. It looks strange, but not my fault :-) */

        /** Send the command         */
        //Send the TE API command aCmdBuffer[0] = CMD_FX2_POWER_ON; and aCmdBuffer[1] = 1; => switch on the FPGA
        CHECK_USB( libusb_bulk_transfer(usbDeviceHandle, LIBUSB_ENDPOINT_OUT | 1, aCmdBuffer,2, &actual_length, 1000) );

//This is the reply[]
        CHECK_USB( libusb_bulk_transfer(usbDeviceHandle, LIBUSB_ENDPOINT_IN | 1, aCmdBuffer,USB_BLOCK_SIZE, &actual_length, 1000) );

/** OK */
        return;

xerror:
        printf("\n");
        exit(1);
}




Official Trenz Electronic USB FX2 version.

byte Command[64], Reply[64];
long CmdLength = 64;
long ReplyLength = 64;

Command[0] = CMD_FX2_POWER_ON;
Command[1] = 0; /** <- Parameter 0 = OFF */
/** ON with Parameter 0 means FPGA POWER OFF. It looks strange, but not my fault :-) */

//Send the command and wait the reply for 1 seconds
if (TE_USB_FX2_SendCommand(USBdevList, Command, CmdLength, Reply, ReplyLength, 1000))
    cout << "Error" << endl;




Unofficial libusb(x) version.

aCmdBuffer[0] = CMD_FX2_POWER_ON;
aCmdBuffer[1] = 0;        /** <- Parameter 0 = OFF */
/** ON with Parameter 0 means FPGA POWER OFF. It looks strange, but not my fault :-) */

/** Send the command         */
//Send the TE API command aCmdBuffer[0] = CMD_FX2_POWER_ON; and aCmdBuffer[1] = 1; => switch on the FPGA
CHECK_USB( libusb_bulk_transfer(usbDeviceHandle, LIBUSB_ENDPOINT_OUT | 1, aCmdBuffer,2, &actual_length, 1000) );

//This is the reply[]
CHECK_USB( libusb_bulk_transfer(usbDeviceHandle, LIBUSB_ENDPOINT_IN | 1, aCmdBuffer,USB_BLOCK_SIZE, &actual_length, 1000) );


In this particular case, the community contributor chose to use the transmit buffer for capturing the response packet. We rather recommend to use two different buffers.