char Write_Ord(char i) { int dat; int j; j = 0; if(i != 0x22) { while((IO0PIN&USB_INT)==0) { j++; if(j>300000) return 1; } }
LoopNop(USBdelay); //延时3us IO1SET = USB_A0; Loop(USBdelay);
IO0DIR = IO0DIR|0x0003fc00; Loop(5); //延时150ns dat = i<<10; Loop(5); IO0CLR = 0x0003fc00; Loop(5); IO0SET = dat&0x0003fc00; Loop(5); IO1CLR = DATA_WR; Loop(10); IO1SET = DATA_WR; Loop(5); IO0DIR = IO0DIR&(~0x0003fc00); Loop(5); if(i!=0x22) LoopNop(USBdelay); return 0; }
char ReadUSBData(void) { char i; LoopNop(USBdelay); IO1CLR = USB_A0; IO1CLR = DATA_RD; Loop(10); IO1SET = DATA_RD; i = ( IO0PIN >> 10 ) & 0xff; LoopNop(USBdelay); return i; }
void WriteUSBData(char i) { int dat; LoopNop(USBdelay); IO0DIR = IO0DIR|0x0003fc00; Loop(5); dat = i<<10; Loop(5); IO0CLR = 0x0003fc00; Loop(5); IO0SET = dat&0x0003fc00; Loop(5); IO1CLR = USB_A0; Loop(5); IO1CLR = DATA_WR; Loop(10); IO1SET = DATA_WR; Loop(5); IO0DIR = IO0DIR&(~0x0003fc00); LoopNop(USBdelay);
}