| void TD_Init( void ) {
 CPUCS = 0x12;
 IFCONFIG = 0x43;
 
 PORTACFG = 0x40;
 SYNCDELAY;
 FIFOPINPOLAR = 0x00;  // set all slave FIFO interface pins as active low PKTEND OR SLOE SLWR LOW AVTIVE
 SYNCDELAY;
 REVCTL = 0x03;        // enable the external master
 
 SYNCDELAY;            //reset the fifos
 FIFORESET = 0x80;
 SYNCDELAY;
 FIFORESET = 0x02;
 SYNCDELAY;
 FIFORESET = 0x04;
 SYNCDELAY;
 FIFORESET = 0x06;
 SYNCDELAY;
 FIFORESET = 0x08;
 SYNCDELAY;
 FIFORESET = 0x00;
 
 SYNCDELAY;
 PINFLAGSAB = 0x00;         // PINFLAGSAB = 0xE0; FLAGA - indexed, FLAGB - EP6 FF ;
 SYNCDELAY;
 PINFLAGSCD = 0x00;        // PINFLAGSCD = 0x08; FLAGC - EP2 EF, FLAGD - indexed;
 
 SYNCDELAY;                    // config the endpoints direction
 EP1OUTCFG = 0xA0;        //enable and bulk type
 EP1INCFG =  0xA0;
 
 SYNCDELAY;                    // see TRM section 15.14
 EP2CFG = 0xA0;
 SYNCDELAY;
 EP8CFG = 0xE0;
 SYNCDELAY;
 EP4CFG = 0x00;
 SYNCDELAY;
 EP6CFG = 0x00;
 SYNCDELAY;
 OUTPKTEND = 0X82;             //arming endpoint 2, perform OUTPKTEND 4 times since EP2 is 4x buffered
 SYNCDELAY;
 OUTPKTEND = 0X82;
 SYNCDELAY;
 OUTPKTEND = 0X82;
 SYNCDELAY;
 OUTPKTEND = 0X82;
 SYNCDELAY;
 EP2FIFOCFG = 0x10;        //EP IS AUTOOUT=0 AUTOIN =1 ZEROLEN=1 WORDIDE=0
 SYNCDELAY;
 EP8FIFOCFG = 0x08;        //EP IS AUTOOUT=0 AUTOIN =1 ZEROLEN=1 WORDIDE=0
 SYNCDELAY;
 INPKTEND = 0x08;
 SYNCDELAY;
 INPKTEND = 0x08;
 SYNCDELAY;
 EP8AUTOINLENH = 0x02;   //set the packet size 512
 SYNCDELAY;
 EP8AUTOINLENL = 0x00;
 SYNCDELAY;
 
 EP2BCL = 0x80;                // arm EP2OUT by writing byte count w/skip.
 SYNCDELAY;
 EP2BCL = 0x80;
 SYNCDELAY;
 }
 |