Cypress AN6077, FX2LP manual Expanded Master in Code, Syncdelay Gpiftrig = Gpiftrigwr GPIFEP2

Page 6

AN6077

IOA = 0x80;

xFIFOTC_OUT = ( ( EP2FIFOBCH << 8 ) + EP2FIFOBCL );

//setup GPIF transaction count

SYNCDELAY;

EP2GPIFTCH = EP2FIFOBCH; SYNCDELAY;

EP2GPIFTCL = EP2FIFOBCL;

//trigger FIFO write transaction(s)

SYNCDELAY;

GPIFTRIG = GPIFTRIGWR GPIF_EP2;

//once master (GPIF) drains OUT packet, it (re)arms to usb domain

//this path is always auto, meaning core handles it

if( xFIFOTC_OUT < enum_pkt_size )

{

//handle short packet to peripheral

//wait for the transaction to terminate naturally

while( !( GPIFTRIG & 0x80 ) )

{

; // poll GPIFTRIG.7, DONE bit

}

//signal short packet to peripheral here

//in this implementation CTL2 is tied to PKTEND of slave strobe PKTEND of slave

GPIFIDLECTL = 0x04; GPIFIDLECTL &= 0xFB; GPIFIDLECTL = 0x04;

}

else

{

//was max packet size

//let transaction terminate naturally

}

}

else

{

//RDY1=0, when peripheral is FULL

}

}

}

else

{

//DONE=0 when GPIF is "not" IDLE

}

Expanded Master IN Code

// is the GPIF idle

if( GPIFTRIG & 0x80 )

{

//check if peripheral is "not empty" if( GPIFREADYSTAT & 0x01 )

{

//RDY0=1, when peripheral is "not empty"

//drive FIFOADDR lines

OEA = 0xC0;

IOA = 0x00;

February 19, 2008

Document No. 001-15342 Rev. **

6

[+] Feedback

Image 6
Contents Application Note Abstract IntroductionGpif Master Pin Descriptions Slave Fifo Pin DescriptionsCreating Gpif Waveforms Fifowr Firmware Programming Master Firmware ArchitecturePsuedocode for Master OUT Psuedocode for MasterExpanded Master OUT Code Syncdelay Gpiftrig = Gpiftrigwr GPIFEP2 Expanded Master in CodeSummary SyncdelayFirmware for the Slave 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 = True EzusbirqclearUsbirq 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