C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 1 C51 COMPILER V7.06, COMPILATION OF MODULE PTD OBJECT MODULE PLACED IN PTD.OBJ COMPILER INVOKED BY: d:\Keil777\C51\BIN\C51.EXE PTD.C BROWSE DEBUG OBJECTEXTEND stmt level source 1 #include "isp1362.h" 2 3 unsigned int port1speed=0; 4 unsigned int port2speed=0; 5 unsigned int port_speed=0; 6 7 unsigned int wait_time=20; 8 unsigned int retry=50000; 9 10 unsigned int c_ptd[4]; 11 12 void send_iso(unsigned int *a_ptr,unsigned int bytesize,unsigned int ptl,unsigned int addr) 13 { 14 1 random_write(a_ptr,addr,920); *** WARNING C206 IN LINE 14 OF PTD.C: 'random_write': missing function-prototype *** ERROR C267 IN LINE 14 OF PTD.C: 'random_write': requires ANSI-style prototype 15 1 } 16 17 unsigned int error_recorder(char mode,int ccode1, int ccode2) 18 { 19 1 static int cnt=0; 20 1 static int c1[2048]; 21 1 static int c2[2048]; 22 1 23 1 int data2return; 24 1 25 1 if(mode=='W') 26 1 { 27 2 c1[cnt]=ccode1; 28 2 c2[cnt]=ccode2; 29 2 cnt++; 30 2 31 2 if(cnt>2047) {cnt=2047;} 32 2 } 33 1 34 1 if(mode=='R') 35 1 { 36 2 data2return=c1[ccode1]; 37 2 data2return=data2return<<8; 38 2 data2return|=c2[ccode2]; 39 2 } 40 1 41 1 if(mode=='C') 42 1 { 43 2 data2return=cnt; 44 2 } 45 1 46 1 if(mode=='Z') 47 1 { 48 2 cnt=0; 49 2 } 50 1 51 1 return(data2return); 52 1 } 53 C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 2 54 unsigned int addr_info(int addr,int mode,int dtype,int para) 55 { 56 1 static unsigned int speed[8]; 57 1 static unsigned int maxpac[8]; 58 1 static unsigned int iman[8]; 59 1 static unsigned int ipro[8]; 60 1 61 1 unsigned int data2return; 62 1 63 1 //Displaying data 64 1 if(mode=='D') 65 1 { 66 2 printf("\nPort 1 : Speed[%2d] MPS[%4d] iMan[%2d] iPro[%2d]",speed[1],maxpac[1],iman[1],ipro[1]); 67 2 printf("\nPort 2 : Speed[%2d] MPS[%4d] iMan[%2d] iPro[%2d]",speed[2],maxpac[2],iman[2],ipro[2]); 68 2 } 69 1 70 1 //Writing data 71 1 if(mode=='W') 72 1 { 73 2 if(dtype=='S') 74 2 { 75 3 speed[addr]=para; 76 3 } 77 2 78 2 if(dtype=='M') 79 2 { 80 3 maxpac[addr]=para; 81 3 } 82 2 83 2 if(dtype=='O') //Manufaturer 84 2 { 85 3 iman[addr]=para; 86 3 } 87 2 88 2 if(dtype=='P') //Product 89 2 { 90 3 ipro[addr]=para; 91 3 } 92 2 } 93 1 94 1 //Reading data 95 1 if(mode=='R') 96 1 { 97 2 if(dtype=='S') 98 2 { 99 3 data2return=speed[addr]; 100 3 } 101 2 102 2 if(dtype=='M') 103 2 { 104 3 data2return=maxpac[addr]; 105 3 } 106 2 107 2 if(dtype=='O') 108 2 { 109 3 data2return=iman[addr]; 110 3 } 111 2 112 2 if(dtype=='P') 113 2 { 114 3 data2return=ipro[addr]; 115 3 } C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 3 116 2 } 117 1 118 1 return(data2return); 119 1 } 120 121 unsigned int get_port_speed(unsigned int port) 122 { 123 1 if(port==1) {return(port1speed);} 124 1 if(port==2) {return(port2speed);} 125 1 } 126 127 void set_port_speed(unsigned int port, unsigned int speed) 128 { 129 1 if(port==1) 130 1 { 131 2 port1speed=speed; 132 2 addr_info(1,'W','S',speed); 133 2 } 134 1 135 1 if(port==2) 136 1 { 137 2 port2speed=speed; 138 2 addr_info(2,'W','S',speed); 139 2 } 140 1 141 1 port_speed=speed; 142 1 } 143 144 145 146 void poll(unsigned int poll_len) 147 { 148 1 unsigned int temp=0; 149 1 150 1 do 151 1 { 152 2 temp++; 153 2 } 154 1 while(temp>12; 209 2 if(timeout==9) {ccode1=ccode;} 210 2 if(timeout==8) {ccode2=ccode;} 211 2 212 2 timeout--; 213 2 } 214 1 while( (ccode!=0) && (timeout!=0) ); 215 1 216 1 if(ccode1!=0 && ccode2!=0) 217 1 { 218 2 error_recorder('W',ccode1,ccode2); 219 2 } 220 1 return(cnt); 221 1 } 222 223 unsigned int send_int(unsigned int *a_ptr,unsigned int *r_ptr) 224 { 225 1 unsigned int cnt=retry; 226 1 unsigned int active_bit; 227 1 unsigned int abuf[128]; 228 1 unsigned int UpInt; 229 1 230 1 unsigned int far *dptr; 231 1 232 1 dptr=a_ptr; 233 1 234 1 write_int(a_ptr,8); //write 16 bytes 235 1 236 1 w16(HcUpInt,0x0080); 237 1 w16(HcBufStatus,0x04); 238 1 239 1 r32(HcIntDone); //read and clear done map, enables ATL interrupt C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 5 240 1 241 1 do 242 1 { 243 2 UpInt=r16(HcUpInt); 244 2 if( (UpInt&0x80)!=0) {active_bit=0;} 245 2 else {active_bit=1;} 246 2 247 2 poll(50); 248 2 cnt--; 249 2 } 250 1 while((cnt>0) && (active_bit!=0)); 251 1 252 1 w16(HcBufStatus,0x00); 253 1 254 1 read_int(r_ptr,72); 255 1 256 1 return(cnt); 257 1 } 258 259 void full_ptd(int *rptr,char token,char ep,int max,int total,char tog,char addr,char port) 260 { 261 1 ptd2send.c_code=0x0F; 262 1 ptd2send.active_bit=1; 263 1 ptd2send.toggle=tog; 264 1 ptd2send.actual_size=0; 265 1 ptd2send.endpoint=ep; 266 1 ptd2send.last_ptd=0; 267 1 268 1 ptd2send.speed=port_speed; 269 1 if(port==1) {ptd2send.speed=port1speed;} 270 1 if(port==2) {ptd2send.speed=port2speed;} 271 1 272 1 ptd2send.max_size=max; 273 1 ptd2send.total_size=total; 274 1 ptd2send.pid= token; 275 1 ptd2send.format=0; 276 1 ptd2send.fm=0; 277 1 ptd2send.func_addr=addr; 278 1 279 1 *(rptr+0)= (ptd2send.c_code &0x0000)<<12 280 1 |(ptd2send.active_bit &0x0001)<<11 281 1 |(ptd2send.toggle &0x0001)<<10 282 1 |(ptd2send.actual_size &0x03FF); 283 1 284 1 *(rptr+1)= (ptd2send.endpoint &0x000F)<<12 285 1 |(ptd2send.last_ptd &0x0001)<<11 286 1 |(ptd2send.speed &0x0001)<<10 287 1 |(ptd2send.max_size &0x03FF); 288 1 289 1 *(rptr+2)= (0x0000 &0x000F)<<12 290 1 |(ptd2send.pid &0x0003)<<10 291 1 |(ptd2send.total_size &0x03FF); 292 1 293 1 *(rptr+3)= (ptd2send.fm &0x00FF)<<8 294 1 |(ptd2send.format &0x0001)<<7 295 1 |(ptd2send.func_addr &0x007F); 296 1 } 297 298 void make_ptd(int *rptr,char token,char ep,int max,char tog,char addr,char port) 299 { 300 1 ptd2send.c_code=0x0F; 301 1 ptd2send.active_bit=1; C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 6 302 1 ptd2send.toggle=tog; 303 1 ptd2send.actual_size=0; 304 1 ptd2send.endpoint=ep; 305 1 ptd2send.last_ptd=0; 306 1 307 1 ptd2send.speed=port_speed; 308 1 if(port==1) {ptd2send.speed=port1speed;} 309 1 if(port==2) {ptd2send.speed=port2speed;} 310 1 311 1 ptd2send.max_size=max; 312 1 ptd2send.total_size=max; 313 1 ptd2send.pid= token; 314 1 ptd2send.format=0; 315 1 ptd2send.fm=0; 316 1 ptd2send.func_addr=addr; 317 1 318 1 *(rptr+0)= (ptd2send.c_code &0x0000)<<12 319 1 |(ptd2send.active_bit &0x0001)<<11 320 1 |(ptd2send.toggle &0x0001)<<10 321 1 |(ptd2send.actual_size &0x03FF); 322 1 323 1 *(rptr+1)= (ptd2send.endpoint &0x000F)<<12 324 1 |(ptd2send.last_ptd &0x0001)<<11 325 1 |(ptd2send.speed &0x0001)<<10 326 1 |(ptd2send.max_size &0x03FF); 327 1 328 1 *(rptr+2)= (0x0000 &0x000F)<<12 329 1 |(ptd2send.pid &0x0003)<<10 330 1 |(ptd2send.total_size &0x03FF); 331 1 332 1 *(rptr+3)= (ptd2send.fm &0x00FF)<<8 333 1 |(ptd2send.format &0x0001)<<7 334 1 |(ptd2send.func_addr &0x007F); 335 1 } 336 337 void new_make_ptd(int *rptr,char token,char ep,int max,char tog,char addr,char port, unsigned int total) 338 { 339 1 ptd2send.c_code=0x0F; 340 1 ptd2send.active_bit=1; 341 1 ptd2send.toggle=tog; 342 1 ptd2send.actual_size=0; 343 1 ptd2send.endpoint=ep; 344 1 ptd2send.last_ptd=0; 345 1 346 1 ptd2send.speed=port_speed; 347 1 if(port==1) {ptd2send.speed=port1speed;} 348 1 if(port==2) {ptd2send.speed=port2speed;} 349 1 350 1 ptd2send.max_size=max; 351 1 ptd2send.total_size=total; 352 1 ptd2send.pid= token; 353 1 ptd2send.format=0; 354 1 ptd2send.fm=0; 355 1 ptd2send.func_addr=addr; 356 1 357 1 *(rptr+0)= (ptd2send.c_code &0x0000)<<12 358 1 |(ptd2send.active_bit &0x0001)<<11 359 1 |(ptd2send.toggle &0x0001)<<10 360 1 |(ptd2send.actual_size &0x03FF); 361 1 362 1 *(rptr+1)= (ptd2send.endpoint &0x000F)<<12 363 1 |(ptd2send.last_ptd &0x0001)<<11 C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 7 364 1 |(ptd2send.speed &0x0001)<<10 365 1 |(ptd2send.max_size &0x03FF); 366 1 367 1 *(rptr+2)= (0x0000 &0x000F)<<12 368 1 |(ptd2send.pid &0x0003)<<10 369 1 |(ptd2send.total_size &0x03FF); 370 1 371 1 *(rptr+3)= (ptd2send.fm &0x00FF)<<8 372 1 |(ptd2send.format &0x0001)<<7 373 1 |(ptd2send.func_addr &0x007F); 374 1 } 375 376 377 378 void make_int_ptd(int *rptr,char token,char ep,int max,char tog,char addr,char port,int freq) 379 { 380 1 ptd2send.c_code=0x0F; 381 1 ptd2send.active_bit=1; 382 1 ptd2send.toggle=tog; 383 1 ptd2send.actual_size=0; 384 1 ptd2send.endpoint=ep; 385 1 ptd2send.last_ptd=0; 386 1 387 1 ptd2send.speed=port_speed; 388 1 if(port==1) {ptd2send.speed=port1speed;} 389 1 if(port==2) {ptd2send.speed=port2speed;} 390 1 391 1 ptd2send.max_size=max; 392 1 ptd2send.total_size=max; 393 1 ptd2send.pid= token; 394 1 ptd2send.format=0; 395 1 ptd2send.fm=freq; 396 1 ptd2send.func_addr=addr; 397 1 398 1 *(rptr+0)= (ptd2send.c_code &0x0000)<<12 399 1 |(ptd2send.active_bit &0x0001)<<11 400 1 |(ptd2send.toggle &0x0001)<<10 401 1 |(ptd2send.actual_size &0x03FF); 402 1 403 1 *(rptr+1)= (ptd2send.endpoint &0x000F)<<12 404 1 |(ptd2send.last_ptd &0x0001)<<11 405 1 |(ptd2send.speed &0x0001)<<10 406 1 |(ptd2send.max_size &0x03FF); 407 1 408 1 *(rptr+2)= (0x0000 &0x000F)<<12 409 1 |(ptd2send.pid &0x0003)<<10 410 1 |(ptd2send.total_size &0x03FF); 411 1 412 1 *(rptr+3)= (ptd2send.fm &0x00FF)<<8 413 1 |(ptd2send.format &0x0001)<<7 414 1 |(ptd2send.func_addr &0x007F); 415 1 } 416 417 418 //This PTD is used to simple bulk test to check the mechanism of Skip/Last 419 void make_xbulk(char ep,char addr,int *rptr) 420 { 421 1 unsigned int *ptd_ptr; 422 1 423 1 ptd2send.c_code=0x0F; 424 1 ptd2send.active_bit=1; 425 1 ptd2send.toggle=0; C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 8 426 1 ptd2send.actual_size=0; 427 1 ptd2send.endpoint=ep; 428 1 ptd2send.last_ptd=0; 429 1 ptd2send.speed=0; 430 1 ptd2send.max_size=128; 431 1 ptd2send.total_size=128; 432 1 ptd2send.pid= OUT; 433 1 ptd2send.format=0; 434 1 ptd2send.fm=0; 435 1 ptd2send.func_addr=addr; 436 1 437 1 *(rptr+0)= (ptd2send.c_code &0x0000)<<12 438 1 |(ptd2send.active_bit &0x0001)<<11 439 1 |(ptd2send.toggle &0x0001)<<10 440 1 |(ptd2send.actual_size &0x03FF); 441 1 442 1 *(rptr+1)= (ptd2send.endpoint &0x000F)<<12 443 1 |(ptd2send.last_ptd &0x0001)<<11 444 1 |(ptd2send.speed &0x0001)<<10 445 1 |(ptd2send.max_size &0x03FF); 446 1 447 1 *(rptr+2)= (0x0002 &0x000F)<<12 448 1 |(ptd2send.pid &0x0003)<<10 449 1 |(ptd2send.total_size &0x03FF); 450 1 451 1 *(rptr+3)= (ptd2send.fm &0x00FF)<<8 452 1 |(ptd2send.format &0x0001)<<7 453 1 |(ptd2send.func_addr &0x007F); 454 1 } 455 456 void send_ptl(unsigned int *a_ptr,unsigned int bytesize,unsigned int ptl,unsigned int addr) 457 { 458 1 unsigned int abuf[8]; 459 1 460 1 abuf[0]=*(a_ptr+0); 461 1 abuf[1]=*(a_ptr+1); 462 1 abuf[2]=*(a_ptr+2); 463 1 abuf[3]=*(a_ptr+3); 464 1 465 1 random_write(abuf,addr,176); 466 1 } 467 468 unsigned int ptl_ptd(char type_ptd,char last,char ep,unsigned int max,char tog,char addr,unsigned char fra -me_no) 469 { 470 1 unsigned int *ptd_ptr; 471 1 472 1 ptd2send.c_code=0x0F; 473 1 ptd2send.active_bit=1; 474 1 ptd2send.toggle=tog; 475 1 ptd2send.actual_size=0; 476 1 ptd2send.endpoint=ep; 477 1 ptd2send.last_ptd=last; 478 1 ptd2send.speed=port1speed; 479 1 ptd2send.max_size=max; 480 1 ptd2send.total_size=max; 481 1 ptd2send.pid= type_ptd; 482 1 ptd2send.format=1; 483 1 ptd2send.fm=frame_no; 484 1 ptd2send.func_addr=addr; 485 1 486 1 c_ptd[0]= (ptd2send.c_code &0x0000)<<12 C51 COMPILER V7.06 PTD 08/02/2005 13:30:02 PAGE 9 487 1 |(ptd2send.active_bit &0x0001)<<11 488 1 |(ptd2send.toggle &0x0001)<<10 489 1 |(ptd2send.actual_size &0x03FF); 490 1 491 1 c_ptd[1]= (ptd2send.endpoint &0x000F)<<12 492 1 |(ptd2send.last_ptd &0x0001)<<11 493 1 |(ptd2send.speed &0x0001)<<10 494 1 |(ptd2send.max_size &0x03FF); 495 1 496 1 c_ptd[2]= (0x0000 &0x000F)<<12 497 1 |(ptd2send.pid &0x0003)<<10 498 1 |(ptd2send.total_size &0x03FF); 499 1 500 1 c_ptd[3]= (ptd2send.fm &0x00FF)<<8 501 1 |(ptd2send.format &0x0001)<<7 502 1 |(ptd2send.func_addr &0x007F); 503 1 504 1 ptd_ptr=c_ptd; 505 1 506 1 return(ptd_ptr); 507 1 } 508 509 void iso_ptd(unsigned int *iso,char type_ptd,char last,char ep,unsigned int max,char tog,char addr,unsigne -d char frame_no) 510 { 511 1 ptd2send.c_code=0x0F; 512 1 ptd2send.active_bit=1; 513 1 ptd2send.toggle=tog; 514 1 ptd2send.actual_size=0; 515 1 ptd2send.endpoint=ep; 516 1 ptd2send.last_ptd=last; 517 1 ptd2send.speed=port1speed; 518 1 ptd2send.max_size=max; 519 1 ptd2send.total_size=max; 520 1 ptd2send.pid= type_ptd; 521 1 ptd2send.format=1; 522 1 ptd2send.fm=frame_no; 523 1 ptd2send.func_addr=addr; 524 1 525 1 *(iso+0)= (ptd2send.c_code &0x0000)<<12 526 1 |(ptd2send.active_bit &0x0001)<<11 527 1 |(ptd2send.toggle &0x0001)<<10 528 1 |(ptd2send.actual_size &0x03FF); 529 1 530 1 *(iso+1)= (ptd2send.endpoint &0x000F)<<12 531 1 |(ptd2send.last_ptd &0x0001)<<11 532 1 |(ptd2send.speed &0x0001)<<10 533 1 |(ptd2send.max_size &0x03FF); 534 1 535 1 *(iso+2)= (0x0000 &0x000F)<<12 536 1 |(ptd2send.pid &0x0003)<<10 537 1 |(ptd2send.total_size &0x03FF); 538 1 539 1 *(iso+3)= (ptd2send.fm &0x00FF)<<8 540 1 |(ptd2send.format &0x0001)<<7 541 1 |(ptd2send.func_addr &0x007F); 542 1 } 543 C51 COMPILATION COMPLETE. 1 WARNING(S), 1 ERROR(S)