/* usb.c Test code for USB and GLCD expansion board for 8051SBC V1.0 The usb board is FT245BM based. copyright 2003,2004 W.SIRICHOTE */ #include <8051io.h> /* include i/o header file */ #include <8051reg.h> #include <8051int.h> #include "lcddrv.c" char *usb_port; char buffer,n; #define GPIO2 (*((unsigned char *)0x0200)) // read byte from usb module, print on LCD INTERRUPT(_IE0_) external0_interrupt() { buffer = *usb_port; putch_lcd(buffer); } main() { usb_port = 0x0300; buffer = -1; n = 0; IE = 0x81; TCON |= 1; // negative going detection InitLcd(); Puts("USB Testing"); for(;;) { while(!(GPIO2&0x20)) { while(P3&0x08) ; // wait until TXE low printf("\n%d",n); *usb_port = n++; } } }