Cypress AN6077, FX2LP manual Firmware Programming Master, Firmware Architecture

Page 4

AN6077

Figure 4. FIFO Read Waveform in gpif.c

Figure 5. FIFO Write Waveform in gpif.c

8051 Firmware Programming (Master)

This section describes how to configure the 8051 to support the interface on the master side (register settings and others) and discusses the firmware implemented to perform data transactions over the local bus and the USB. The complete code listing is provided at the end of this document.

Firmware Architecture

The firmware is designed to handle USB INs and OUTs arbi- trarily (for example, the direction of transfer is not favored).

It is also fairly deterministic in its approach and is ‘event- driven’ by the following key conditions:

OUTs (FIFO Writes)

Endpoint 2 OUT Has Data

Peripheral Interface Not Busy (GPIF IDLE)

Slave Interface FIFO Not Full

INs (FIFO Reads)

Peripheral Interface Not Busy (GPIF IDLE)

Slave Interface FIFO Not Empty

Endpoint 6IN Available Not Full

Since the GPIF is a shared resource between FIFO Reads and Writes, the peripheral interface status is always checked before committing the GPIF to launch any form of physical bus transactions. The firmware is optimized for 512-byte FIFO Reads and Writes with other mechanisms in place to handle short packets (1–511 bytes).

February 19, 2008

Document No. 001-15342 Rev. **

4

[+] Feedback

Image 4
Contents Application Note Abstract IntroductionSlave Fifo Pin Descriptions Gpif Master Pin DescriptionsCreating Gpif Waveforms Fifowr Firmware Programming Master Firmware ArchitecturePsuedocode for Master Psuedocode for Master OUTExpanded Master OUT Code Syncdelay Gpiftrig = Gpiftrigwr GPIFEP2 Expanded Master in CodeSyncdelay Firmware for the SlaveSummary Gpiftrig = Gpiftrigrd GPIFEP6Code Listing for Master Side EP4 and EP8 are not used in this implementation Gpiftrig Trigger Fifo write transactions, using SFR Syncdelay Gpiftrig = Gpiftrigrd GPIFEP6 Setupdat Ezusbirqclear = TrueUsbirq Clear Ures IRQ + Feedback Code Listing for the Slave Side AUTOOUT=0, WORDWIDE=0 Syncdelay AUTOOUT=1, WORDWIDE=0 AUTOIN=1, ZEROLENIN=1, WORDWIDE=0EP0BCH EP0BCL Clear Ures IRQ + Feedback + Feedback