Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Scroll Title
titleReference firmware (Trenz Electronic v3.02 description): pseudocode
steppseudocode functiondescription
1interrupt_disable(); //EA=0Disable interrupts
2

setup_autovectors ();

Setup interrupt table

3

usb_install_handlers ();

Setup/install handlers (aka functions) called to manage the interrupt set in interrupt table
4interrupt_enable(); //EA=1Enable interrupts
5

fx2_renumerate();

Simulates disconnection and then reconnection of TE USB FX2 module USB cable with host computer

6

task0(); //system_init();

Initialization phase.

The reference firmware is used to:

  • initialize VID and PID with the Productor (Trenz Electronic) Values;
  • initialize the USB FX2 microcontroller register, memory, etc..
    to (possibly) establish a conection connection of the TE USB FX2 module
    (FX2 microcontroller) with host computer's though USB.

Step 1,2,3,4,5 can be called pre_task0() or pre_system_init().

7while(1) {Enter the superloop
8task1();

Manage incoming USB setup data packet. See here.

It is used in connection and disconnection (of TE USB FX2 module) phases from
USB host computer: it is used to establish/remove a conection connection of the
TE USB FX2 module (FX2 microcontroller) with host computer's though USB

.

9task2(); 

Manage incoming USB data packet conforming to TE (FW) API
aka USB "command/reply" packet.

It is used:

  • to control the FPGA status (power on/off, etc)
  • to read/write the EEPROM (change of FX2 microcontroller's firmware
    aka Firmware Layer)
  • to read/write the SPI Flash (change of FPGA image
    aka Logic Architecture Layer)
  • to send SPI Flash commands to SPI Flash
  • to read/write the device connected to I2C bus
  • to read/write the TE USB FX2 module's DRAM

from host computer's software though USB.

The previous activities are realized by TE API Commands (FW APIs)
and can be controlled by SW API Layer's functions.


 

10task3();Manage interruption interrupt request (INT0 pin) incoming from FPGA chip
(normally, FPGA's MicroBlaze soft-processor): used with
(some) MB Command
11}While running the FX2 microcontroller should never exit fromthe from the superloop
and repeat (until a reset) step 8,9 and 10

...

  1. manage incoming USB setup data packet (used for device registration by OS of USB host);
  2. manage incoming USB data packet (this data packet should normally contains TE API Commands (FW APIs));
  3. manage interruption (INT0 pin) incoming from FPGA chip (normally FPGA's MicroBlaze soft-processor).

Task 1 is realized implemented (carried out) by 

Code Block
languagecpp
titlefw.c, Trenz Electronic v3.02
if(usb_setup_packet_avail()) usb_handle_setup_packet();

Task 2 is realized 2 is implemented (carried out) by

Code Block
languagecpp
titlete_api.c, Trenz Electronic v3.02
void ep1_pool(void)

Task 3 is realized implemented (carried out) by

Code Block
languagecpp
titlete_api.c, Trenz Electronic v3.02
void int_pin_pool(void)

Task 2 and task 3 are grouped in a singole single function called activity() running in the superloop of fw.c;

...

Handles the setup package and the basic device requests like reading descriptors, get/set confifuration configuration etc. It is used in phase of connection/disconnection of the TE USB FX2 module from host computer's USB port. It is also used by CyControl, CyConsole (and other similar programs) to retrieve information about the cofiguration configuration of the USB device (TE USB FX2 module view as USB device).

See this link for further explanationexplanations.

Note

At this moment (Trenz Electronic v3.02), this part of code does not calls the app_class_cmd or app_vendor_cmd functions when needed, because CLASS command and VENDOR commands are not supported.

...

Manage incoming USB data packet (task2)

This process is realized process is implemented (carried out) by function ep1_pool().

This function pull 64 bytes from EP1IN EP1OUTBUF FIFO; in thid FIFO the FX2_API_Commands (MicroBlaze Commands and SPI Flash Commnads) from USB connection with this FIFO are stored possible TE API Commands (FW APIs) sent by host computer's SW through USB connection.

EP1OUTBUF[0] and EP1OUTBUF[1:63] are written by host computer's software C++ TE_USB_FX2_SendCommand(...,command,...)  or C# TE_USB_FX2_SendCommand(...,command,...) or libusb(x) C libusb_bulk_transfer(usbDeviceHandle, LIBUSB_ENDPOINT_OUT | 1, command, x, &actual_length, 1000) used with command[0] = USB FX2 API Command.

ep1_pool() function uses a switch construct (EP1OUTBUF[0] decodeded decoded as USB FX2 API Command ) to select the proper code (calling other functions,if any) to execute the task requested by the decoded USB FX2 API Command .

...

The host computer's SW should use a polling procedure to retrieve the I2C bytes read (and stored) by FX2 microcontroller (the pull response to host computer's pull is realized pull is implemented (carried out) by task2: ep1_pool())

Pull INT pool.  Longer description true for every Logical Architecture Layer

...

  • an autoresponse interrupt is preconfigured (by host computer's SW using SET_INTERRUPT => CMD_SET_AUTORESPONSE => sts_int_auto_configured = 1) and
  • an FPGA_INT0 "interrupt" rised risen by FPGA chip should be managed (FPGA_INT0=1),

...

The registers value are copied in the byte array auto_response_data by the int_pin_pool() firmware function.

This byte array coul could be pulled out by host computer's SW using SET_INTERRUPT ( => CMD_GET_AUTORESPONSE => for(i = 0; i < 32; i++) EP1INBUF[i+1] = auto_response_data[i];).

...