C51 COMPILER V7.06 MOUSE 08/02/2005 13:30:01 PAGE 1 C51 COMPILER V7.06, COMPILATION OF MODULE MOUSE OBJECT MODULE PLACED IN MOUSE.OBJ COMPILER INVOKED BY: d:\Keil777\C51\BIN\C51.EXE MOUSE.C BROWSE DEBUG OBJECTEXTEND stmt level source 1 #include 2 #include *** WARNING C318 IN LINE 2 OF MOUSE.C: can't open file 'conio.h' 3 #include *** WARNING C318 IN LINE 3 OF MOUSE.C: can't open file 'dos.h' 4 #include 5 #include *** WARNING C318 IN LINE 5 OF MOUSE.C: can't open file 'bios.h' 6 #include *** WARNING C318 IN LINE 6 OF MOUSE.C: can't open file 'mem.h' 7 #include *** WARNING C318 IN LINE 7 OF MOUSE.C: can't open file 'graphics.h' 8 #include 9 #include *** WARNING C318 IN LINE 9 OF MOUSE.C: can't open file 'io.h' 10 #include *** WARNING C318 IN LINE 10 OF MOUSE.C: can't open file 'fcntl.h' 11 #include 12 13 #include "isp1362.h" 14 #include "isa290.h" 15 #include "reg.h" 16 #include "cheeyu.h" 17 18 int maxmin(int no, int max, int min) 19 { 20 1 if(no>max) {no=max;} 21 1 if(no>8); 99 3 Y=(rbuf[5]&0x00FF); 100 3 B=(rbuf[4]&0x000F); 101 3 } 102 2 103 2 else 104 2 { 105 3 X=0; 106 3 Y=0; C51 COMPILER V7.06 MOUSE 08/02/2005 13:30:01 PAGE 3 107 3 B=0; 108 3 } 109 2 110 2 if( (B&0x01)!=0) 111 2 { 112 3 setfillstyle(SOLID_FILL,YELLOW); 113 3 floodfill(bx,by,WHITE); 114 3 } 115 2 else 116 2 { 117 3 setfillstyle(SOLID_FILL,BLUE); 118 3 floodfill(bx,by,WHITE); 119 3 } 120 2 121 2 if( (B&0x02)!=0) 122 2 { 123 3 setfillstyle(SOLID_FILL,GREEN); 124 3 floodfill(bx+100,by,WHITE); 125 3 } 126 2 else 127 2 { 128 3 setfillstyle(SOLID_FILL,BLUE); 129 3 floodfill(bx+100,by,WHITE); 130 3 } 131 2 132 2 if( (B&0x04)!=0) 133 2 { 134 3 setfillstyle(SOLID_FILL,CYAN); 135 3 floodfill(bx+50,by,WHITE); 136 3 } 137 2 else 138 2 { 139 3 setfillstyle(SOLID_FILL,BLUE); 140 3 floodfill(bx+50,by,WHITE); 141 3 } 142 2 143 2 oX=pX; 144 2 oY=pY; 145 2 146 2 pX=pX+X; 147 2 pY=pY+Y; 148 2 149 2 pX=maxmin(pX,605,35); 150 2 pY=maxmin(pY,320,65); 151 2 152 2 if(timecnt!=0) {tog++;} 153 2 154 2 line(pX,pY,oX,oY); 155 2 156 2 gotoxy(5,2); 157 2 printf("X:%4d Y:%4d B:%4X",X,Y,B); 158 2 gotoxy(5,3); 159 2 printf("pX:%4d pY:%4d Press '1' to Exit",pX,pY); 160 2 user_in=read_key(0); 161 2 } 162 1 while(user_in!='1'); 163 1 164 1 close_gui(); 165 1 } 166 167 void mouse(void) 168 { C51 COMPILER V7.06 MOUSE 08/02/2005 13:30:01 PAGE 4 169 1 unsigned int user_in; 170 1 unsigned int cbuf[128]; 171 1 unsigned int rbuf[128]; 172 1 unsigned int dev_req[4]={0x0680,0x0100,0x0000,0x0008}; 173 1 unsigned int uni_req[4]={0x0500,3,0x0000,0x0000}; 174 1 unsigned char udn[64]; 175 1 176 1 //buffer information 177 1 unsigned int atllen,ptllen,intllen; 178 1 unsigned int atl_start; 179 1 180 1 //atl parameters 181 1 unsigned long atl_skip=0xFFFFFFFE; 182 1 unsigned long atl_done=0; 183 1 unsigned long atl_last=0x00000001; 184 1 unsigned int atl_blk_size=64; 185 1 unsigned int atl_cnt=1; 186 1 unsigned int atl_timeout=200; 187 1 unsigned int mycode; 188 1 unsigned int cnt,name_length; 189 1 unsigned int iManufacturer,iProduct; 190 1 unsigned long rhp1,rhp2; 191 1 unsigned int starty=5; 192 1 unsigned int status; 193 1 unsigned int mouse01=0,mouse02=0; 194 1 195 1 clrscr(); 196 1 197 1 set_operational(); 198 1 enable_port(); 199 1 delay(300); 200 1 201 1 reset_usb(); 202 1 erase_all(); 203 1 set_operational(); 204 1 enable_port(); 205 1 delay(300); 206 1 207 1 w16(HcBufStatus,0x00); 208 1 209 1 //Setup ATL Parameters 210 1 w32(HcATLSkip,atl_skip); 211 1 w32(HcATLLast,atl_last); 212 1 w16(HcATLBlkSize,atl_blk_size); 213 1 w16(HcATLThrsCnt,atl_cnt); 214 1 w16(HcATLTimeOut,atl_timeout); 215 1 216 1 //Setup ATL Buffer 217 1 atllen =r16(HcATLLen); 218 1 ptllen =r16(HcPTLLen); 219 1 intllen =r16(HcINTLen); 220 1 221 1 atl_start=ptllen+ptllen+intllen; 222 1 223 1 status=assign_address(1,2,0); 224 1 status=assign_address(1,2,0); 225 1 226 1 gotoxy(1,1); 227 1 printf("ISP1362 Mouse Demo"); 228 1 229 1 gotoxy(1,2); 230 1 printf("Probing USB downstream ports... "); C51 COMPILER V7.06 MOUSE 08/02/2005 13:30:01 PAGE 5 231 1 if(status==0x0100) {printf("Connection detected at port 1.");} 232 1 else if(status==0x0001) {printf("Connection detected at port 2.");} 233 1 else if(status==0x0101) {printf("Connection detected at port 1 and 2.");} 234 1 else {printf("No connection detected.");} 235 1 236 1 w16(HcUpIntEnable,0x100); 237 1 238 1 if( (status&0x0100)!=0) //port 1 active 239 1 { 240 2 //Check port 1 for mouse 241 2 printf("\nGetting device descriptor for device at port 1... "); 242 2 243 2 mycode=get_control(rbuf,1,'D',0,1); 244 2 printf("%04X",mycode); 245 2 246 2 if(mycode==0x0300) 247 2 { 248 3 iManufacturer = rbuf[7]&0xFF; 249 3 iProduct = (rbuf[7]&0xFF00)>>8; 250 3 251 3 addr_info(1,'W','O',iManufacturer); 252 3 addr_info(1,'W','P',iProduct); 253 3 254 3 mycode=get_control(rbuf,1,'H',addr_info(1,'R','P',0),1); 255 3 256 3 if( *(rbuf+1)==0x0209 ) 257 3 { 258 4 printf("\nMouse Detected @Port1!!! "); 259 4 260 4 mouse01=1; 261 4 } 262 3 } 263 2 } 264 1 265 1 if( (status&0x0001)!=0) //port 2 active 266 1 { 267 2 //Check port 2 for mouse 268 2 mycode=get_control(rbuf,2,'D',0,2); 269 2 printf("\nGetting device descriptor for device at port 2... "); 270 2 printf("%04X",mycode); 271 2 if(mycode==0x0300) 272 2 { 273 3 iManufacturer = rbuf[7]&0xFF; 274 3 iProduct = (rbuf[7]&0xFF00)>>8; 275 3 276 3 addr_info(2,'W','O',iManufacturer); 277 3 addr_info(2,'W','P',iProduct); 278 3 279 3 mycode=get_control(rbuf,2,'H',addr_info(2,'R','P',0),2); 280 3 281 3 if( *(rbuf+1)==0x0209 ) 282 3 { 283 4 printf("\nMouse Detected @Port2!!! "); 284 4 285 4 mouse02=1; 286 4 } 287 3 } 288 2 } 289 1 290 1 if((mouse01==1)&&(mouse02==0)) 291 1 { 292 2 mycode=set_config(1,1); C51 COMPILER V7.06 MOUSE 08/02/2005 13:30:01 PAGE 6 293 2 printf("\nSetting config of device 1 to config 1... %04X",mycode); 294 2 295 2 if(mycode==0) 296 2 { 297 3 play_mouse(1); 298 3 } 299 2 } 300 1 301 1 if((mouse02==1)&&(mouse01==0)) 302 1 { 303 2 mycode=set_config(2,1); 304 2 printf("\nSetting config of device 2 to config 2... %04X",mycode); 305 2 306 2 if(mycode==0) 307 2 { 308 3 play_mouse(2); 309 3 } 310 2 } 311 1 312 1 if((mouse02==1)&&(mouse01==1)) 313 1 { 314 2 printf("\nUSB Mouse detected at both ports, using mouse @Port1"); 315 2 316 2 printf("\nPress any key to confirm..."); 317 2 318 2 getch(); 319 2 320 2 mycode=set_config(1,1); 321 2 printf("\nSetting config of device 1 to config 1... %04X",mycode); 322 2 323 2 if(mycode==0) 324 2 { 325 3 play_mouse(1); 326 3 } 327 2 } 328 1 329 1 if((mouse02==0)&&(mouse01==0)) 330 1 { 331 2 printf("\nUSB Mouse NOT detected, press any keys to continue..."); 332 2 333 2 getch(); 334 2 } 335 1 } 336 C51 COMPILATION COMPLETE. 10 WARNING(S), 1 ERROR(S)