X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Ffpga.git;a=blobdiff_plain;f=fx2%2Ffx2.c;fp=fx2%2Ffx2.c;h=a8f0467e88f90c5000c52696de78af4889fffd48;hp=3a57b12c4e83456709715a195c1f90af059087d3;hb=dc754367536310b01e2ea0fc7225ac899a8e8539;hpb=542e7de0178f5f23dabfe92f649b5e989f22e551 diff --git a/fx2/fx2.c b/fx2/fx2.c index 3a57b12..a8f0467 100644 --- a/fx2/fx2.c +++ b/fx2/fx2.c @@ -11,10 +11,7 @@ */ /* constant definitions */ -#define TRUE 1 -#define FALSE 0 -#define POWER_ON 1; -#define POWER_OFF 0; +#define GET_TDO 0x20 /* type definitions */ typedef unsigned char u8; @@ -227,6 +224,9 @@ void ep1_init() { void fx2_init() { + /* syncdelay */ + SYNCDELAY; + /* cpu init */ cpu_init(); @@ -239,11 +239,14 @@ void fx2_init() { /* ep1 init */ ep1_init(); + + /* jtag init */ + jtag_init(); } void main() { - u8 buf; + u8 buf,set; /* initialize the fx2 */ fx2_init(); @@ -252,14 +255,18 @@ void main() { while(1) { if(!(EP1OUTCS&BUSY)) { buf=EP1OUTBUF[0]; - buf&=0x1c; - IOD|=buf; - EP1OUTBC=1; - } - if(!(EP1INCS&BUSY)) { - buf=IOD&0x01?1:0; - EP1INBUF[0]=buf; - EP1INBC=1; + if(buf!=GET_TDO) { + set=(IOD&(~0x1c))|(buf&0x1c); + IOD=set; + EP1OUTBC=1; + } + else { + while(EP1INCS&BUSY) + continue; + buf=IOD&0x01?1:0; + EP1INBUF[0]=buf; + EP1INBC=1; + } } }