bool progSend(FT_HANDLE handle, unsigned char data)
{
int i;
unsigned char outbuff[24];
unsigned char inbuff;
DWORD bytes;
DWORD rx,tx,estat;
FT_STATUS stat;
for (i=0;i<8;i++)
{
if (data&0x80) outbuff[i*3]=PIN_TX;
else outbuff[i*3]=0;
data<<=1;
outbuff[i*3+1]=outbuff[i*3]|PIN_CLOCK;
outbuff[i*3+2]=outbuff[i*3];
}
FT_Write(handle,outbuff,sizeof(outbuff),&bytes);
ByteCount+=sizeof(outbuff);
return true;
}
unsigned char progReadNew(FT_HANDLE handle)
{
int i;
unsigned char retbuff=0, inbuff, outbuff[16]={PIN_CLOCK,0,PIN_CLOCK,0,PIN_CLOCK,0,PIN_CLOCK,0,PIN_CLOCK,0,PIN_CLOCK,0,PIN_CLOCK,0,PIN_CLOCK,0};
DWORD bytes;
DWORD rx;
FT_STATUS status=0;
//Flush all the bytes recorded from the calls to progSend
while (ByteCount)
{
FT_Read(handle,&outbuff[0],1,&bytes);
ByteCount--;
}
FT_Write(handle,outbuff,sizeof(outbuff),&bytes);
FT_Read(handle,outbuff,sizeof(outbuff),&bytes);
retbuff=0;
for (i=0;i<sizeof(outbuff);i+=2)
{
retbuff<<=1;
if (outbuff[i]&PIN_RX) retbuff++;
}
return retbuff;
}