#include "system.h" #include "basic_io.h" #include "LCD.h" #include "Test.h" #include "Open_I2C.h" #include "sys/alt_irq.h" #include "VGA.h" int maxmin(int no, int max, int min) { if(no>max) {no=max;} if(no>8); Y=(rbuf[5]&0x00FF); B=(rbuf[4]&0x000F); } else { X=0; Y=0; B=0; } oX=pX; oY=pY; pX=pX+X; pY=pY+Y; pX=maxmin(pX,639,0); pY=maxmin(pY,479,0); if(timecnt!=0) {tog++;} //line(pX,pY,oX,oY); // gotoxy(5,2); //w16(HcControl,0x6c0); // printf("|X|:%4d |Y|:%4d B:%4X ",X,Y,B); // printf(" pX:%4d pY:%4d \n",pX,pY);//<<<<< IOWR(LED_RED_BASE,0,pX); Set_Cursor_XY(pX,pY); if(B==1) Vga_Set_Pixel(VGA_0_BASE,pX,pY); else if(B==2) Vga_Clr_Pixel(VGA_0_BASE,pX,pY); //printf("w16(HcUpIntEnable,0x120)t=0x%04X ",r16(HcUpIntEnable)); //printf("HcUpInt=0x%04X ",r16(HcUpInt)); //printf("HcControl=0x%04X ",r16(HcControl)); //printf("HcRhP2 =0x%04X ",r16(HcRhP2)); } while((r16(HcRhP2) & 0x01) ==0x01); printf("\nend mouse"); } void mouse(void) { unsigned int user_in; unsigned int cbuf[128]; unsigned int rbuf[128]; unsigned int dev_req[4]={0x0680,0x0100,0x0000,0x0008}; unsigned int uni_req[4]={0x0500,3,0x0000,0x0000}; unsigned char udn[64]; //buffer information unsigned int atllen,ptllen,intllen; unsigned int atl_start; //atl parameters unsigned long atl_skip=0xFFFFFFFE; unsigned long atl_done=0; unsigned long atl_last=0x00000001; unsigned int atl_blk_size=64; unsigned int atl_cnt=1; unsigned int atl_timeout=200; unsigned int mycode; unsigned int cnt,name_length; unsigned int iManufacturer,iProduct; unsigned long rhp1,rhp2; unsigned int starty=5; unsigned int status; unsigned int mouse01=0,mouse02=0; unsigned long g,gg; start_enu: dev_req[0]=0x0680; dev_req[1]=0x0100; dev_req[2]=0x0000; dev_req[3]=0x0008; uni_req[0]=0x0500; uni_req[1]=3; uni_req[2]=0x0000; uni_req[3]=0x0000; //atl parameters atl_skip=0xFFFFFFFE; atl_done=0; atl_last=0x00000001; atl_blk_size=64; atl_cnt=1; atl_timeout=200; starty=5; mouse01=0,mouse02=0; set_operational(); enable_port(); // delay(300); reset_usb(); erase_all(); set_operational(); enable_port(); w16(HcControl,0x6c0); w16(HcUpInt,0x1a9); //delay(300); w16(HcBufStatus,0x00); //Setup ATL Parameters w32(HcATLSkip,atl_skip); w32(HcATLLast,atl_last); w16(HcATLBlkSize,atl_blk_size); w16(HcATLThrsCnt,atl_cnt); w16(HcATLTimeOut,atl_timeout); //Setup ATL Buffer atllen =r16(HcATLLen); ptllen =r16(HcPTLLen); intllen =r16(HcINTLen); atl_start=ptllen+ptllen+intllen; status=assign_address(1,2,0); status=assign_address(1,2,0); // gotoxy(1,1); printf("ISP1362 Mouse Demo"); // gotoxy(1,2); printf("Probing USB downstream ports... "); if(status==0x0100) {printf("Connection detected at port 1.");} else if(status==0x0001) {printf("Connection detected at port 2.");} else if(status==0x0101) {printf("Connection detected at port 1 and 2.");} else {printf("No connection detected.");} w16(HcUpIntEnable,0x120); if( (status&0x0100)!=0) //port 1 active { //Check port 1 for mouse printf("\nGetting device descriptor for device at port 1... "); mycode=get_control(rbuf,1,'D',0,1); printf("%04X",mycode); if(mycode==0x0300) { iManufacturer = rbuf[7]&0xFF; iProduct = (rbuf[7]&0xFF00)>>8; addr_info(1,'W','O',iManufacturer); addr_info(1,'W','P',iProduct); mycode=get_control(rbuf,1,'H',addr_info(1,'R','P',0),1); if( *(rbuf+1)==0x0209 ) { printf("\nMouse Detected @Port1!!! "); mouse01=1; } } } if( (status&0x0001)!=0) //port 2 active { // Check port 2 for mouse mycode=get_control(rbuf,2,'D',0,2); printf("\nGetting device descriptor for device at port 2... "); printf("%04X",mycode); if(mycode==0x0300) { iManufacturer = rbuf[7]&0xFF; iProduct = (rbuf[7]&0xFF00)>>8; addr_info(2,'W','O',iManufacturer); addr_info(2,'W','P',iProduct); mycode=get_control(rbuf,2,'H',addr_info(2,'R','P',0),2); if( *(rbuf+1)==0x0209 ) { printf("\nMouse Detected @Port2!!! "); mouse02=1; } } } if((mouse01==1)&&(mouse02==0)) { mycode=set_config(1,1); printf("\nSetting config of device 1 to config 1... %04X",mycode); if(mycode==0) { play_mouse(1); } } if((mouse02==1)&&(mouse01==0)) { mycode=set_config(2,1); printf("\nSetting config of device 2 to config 2... %04X",mycode); if(mycode==0) { play_mouse(2); } } if((mouse02==1)&&(mouse01==1)) { printf("\nUSB Mouse detected at both ports, using mouse @Port1"); printf("\nPress any key to confirm..."); // getch(); mycode=set_config(1,1); printf("\nSetting config of device 1 to config 1... %04X",mycode); if(mycode==0) { play_mouse(1); } } if((mouse02==0)&&(mouse01==0)) { printf("\nUSB Mouse NOT detected, press any keys to continue..."); // getch(); } while((r16(HcRhP2) & 0x001) !=0x001) {} printf("\go mouse"); for (g=0;g <0xffff;g++) { for (g=0;g <0xfffff;g++) { } } goto start_enu; }