C51 COMPILER V7.06 PORT 08/02/2005 13:30:02 PAGE 1 C51 COMPILER V7.06, COMPILATION OF MODULE PORT OBJECT MODULE PLACED IN PORT.OBJ COMPILER INVOKED BY: d:\Keil777\C51\BIN\C51.EXE PORT.C BROWSE DEBUG OBJECTEXTEND stmt level source 1 #include 2 #include *** WARNING C318 IN LINE 2 OF PORT.C: can't open file 'conio.h' 3 #include *** WARNING C318 IN LINE 3 OF PORT.C: can't open file 'dos.h' 4 #include 5 #include *** WARNING C318 IN LINE 5 OF PORT.C: can't open file 'bios.h' 6 #include *** WARNING C318 IN LINE 6 OF PORT.C: can't open file 'mem.h' 7 #include *** WARNING C318 IN LINE 7 OF PORT.C: can't open file 'graphics.h' 8 #include 9 #include *** WARNING C318 IN LINE 9 OF PORT.C: can't open file 'io.h' 10 #include *** WARNING C318 IN LINE 10 OF PORT.C: can't open file 'fcntl.h' 11 12 #include "isp1362.h" 13 #include "isa290.h" 14 #include "reg.h" 15 #include "cheeyu.h" 16 17 void enable_port(void) 18 { 19 1 unsigned long dat32; 20 1 21 1 w32(HcRhP1,0x00000102); 22 1 w32(HcRhP2,0x00000102); 23 1 w32(HcRhStatus,0x00010000); //set Global Power 24 1 25 1 w32(HcRhA,0x20000102); 26 1 w32(HcRhB,0x00000000); 27 1 28 1 dat32=r32(HcRhP2); 29 1 if((dat32&0x00000001)==1) 30 1 { 31 2 set_port_speed(2,0); *** WARNING C206 IN LINE 31 OF PORT.C: 'set_port_speed': missing function-prototype *** ERROR C267 IN LINE 31 OF PORT.C: 'set_port_speed': requires ANSI-style prototype 32 2 if(((dat32)&(0x00000200))!=0) 33 2 { 34 3 set_port_speed(2,1); 35 3 } 36 2 } 37 1 38 1 dat32=r32(HcRhP1); 39 1 if((dat32&0x00000001)==1) 40 1 { 41 2 set_port_speed(1,0); 42 2 if(((dat32)&(0x00000200))!=0) 43 2 { 44 3 set_port_speed(1,1); 45 3 } 46 2 } C51 COMPILER V7.06 PORT 08/02/2005 13:30:02 PAGE 2 47 1 } 48 49 void reset_usb(void) 50 { 51 1 if (g_is_PCI == TRUE) w16(HcHWCfg , 0x3429 ); // set INT1 to Active LOW, Level Triggered 52 1 else w16(HcHWCfg , 0x342D ); 53 1 w32(HcFmItv , 0x25002EDF); 54 1 w32(HcControl , 0x00000600); 55 1 } 56 57 void set_operational(void) 58 { 59 1 if (g_is_PCI == TRUE) w16(HcHWCfg , 0x3429 ); // set INT1 to Active LOW, Level Triggered 60 1 else w16(HcHWCfg , 0x342D ); 61 1 w32(HcFmItv , 0x25002EDF); 62 1 w32(HcControl , 0x00000680); 63 1 } 64 65 66 void port_monitor(void) 67 { 68 1 unsigned long control,irq_status,status1,status2; 69 1 unsigned int start_y=10; 70 1 unsigned int user_in; 71 1 72 1 clrscr(); 73 1 74 1 set_operational(); 75 1 76 1 w32(HcRhP1,0x00000102); 77 1 w32(HcRhP2,0x00000102); 78 1 w32(HcRhA,0x20000002); 79 1 w32(HcRhB,0x00000000); 80 1 w32(HcRhStatus,0x00010000); //set Global Power 81 1 82 1 do 83 1 { 84 2 control =r32(HcControl); 85 2 irq_status=r32(HcIntStatus); 86 2 status1 =r32(HcRhP1); 87 2 status2 =r32(HcRhP2); 88 2 89 2 if((status1&0x00000001)==1) 90 2 { 91 3 gotoxy(20,start_y+6); 92 3 w32(HcRhP1,0x00000102); 93 3 if((status1&0x00000200)!=0) 94 3 { 95 4 printf("LS Device connected to Port 1"); 96 4 set_port_speed(1); 97 4 } 98 3 else 99 3 { 100 4 printf("FS Device connected to Port 1"); 101 4 set_port_speed(0); 102 4 } 103 3 } 104 2 105 2 else 106 2 { 107 3 gotoxy(20,start_y+6); 108 3 printf(" "); C51 COMPILER V7.06 PORT 08/02/2005 13:30:02 PAGE 3 109 3 } 110 2 111 2 if((status2&0x00000001)==1) 112 2 { 113 3 gotoxy(20,start_y+7); 114 3 w32(HcRhP2,0x00000102); 115 3 if((status2&0x00000200)!=0) 116 3 { 117 4 printf("LS Device connected to Port 2"); 118 4 set_port_speed(1); 119 4 } 120 3 else 121 3 { 122 4 printf("FS Device connected to Port 2"); 123 4 set_port_speed(0); 124 4 } 125 3 } 126 2 127 2 else 128 2 { 129 3 gotoxy(20,start_y+7); 130 3 printf(" "); 131 3 } 132 2 133 2 gotoxy(20,start_y); 134 2 printf("Port Status Monitor"); 135 2 gotoxy(20,start_y-1); 136 2 printf("OTGStatus Register = %8X.",r16(0x67)); 137 2 gotoxy(20,start_y+1); 138 2 printf("OTGControl Register = %8X.",r16(0x62)); 139 2 gotoxy(20,start_y+2); 140 2 printf("Control Register = %8lX.",control); 141 2 gotoxy(20,start_y+3); 142 2 printf("Int Status Register = %8lX.",irq_status); 143 2 gotoxy(20,start_y+4); 144 2 printf("P1 Status Register = %8lX.",status1); 145 2 gotoxy(20,start_y+5); 146 2 printf("P2 Status Register = %8lX.",status2); 147 2 gotoxy(20,start_y+8); 148 2 printf("Press '1' to go back to main menu"); 149 2 150 2 user_in=read_key(0); 151 2 } 152 1 while(user_in!='1'); 153 1 } 154 155 void check_ports(void) 156 { 157 1 unsigned long control,irq_status,status1,status2; 158 1 159 1 control =r32(HcControl); 160 1 irq_status=r32(HcIntStatus); 161 1 status1 =r32(HcRhP1); 162 1 status2 =r32(HcRhP2); 163 1 164 1 if((status1&0x00000001)==1) 165 1 { 166 2 w32(HcRhP1,0x00000102); 167 2 if((status1&0x00000200)!=0) 168 2 { 169 3 printf("\nLS Device connected to Port 1 "); 170 3 set_port_speed(1); C51 COMPILER V7.06 PORT 08/02/2005 13:30:02 PAGE 4 171 3 } 172 2 else 173 2 { 174 3 printf("\nFS Device connected to Port 1 "); 175 3 set_port_speed(0); 176 3 } 177 2 } 178 1 179 1 if((status2&0x00000001)==1) 180 1 { 181 2 w32(HcRhP2,0x00000102); 182 2 if((status2&0x00000200)!=0) 183 2 { 184 3 printf("\nLS Device connected to Port 2 "); 185 3 set_port_speed(1); 186 3 } 187 2 else 188 2 { 189 3 printf("\nFS Device connected to Port 2 "); 190 3 set_port_speed(0); 191 3 } 192 2 } 193 1 194 1 printf("\nControl Register = %8lX.",control); 195 1 printf("\nInt Status Register = %8lX.",irq_status); 196 1 printf("\nP1 Status Register = %8lX.",status1); 197 1 printf("\nP2 Status Register = %8lX.",status2); 198 1 } 199 200 unsigned int assign_address(unsigned int addr1, unsigned int addr2, int mode) 201 { 202 1 unsigned long rhp1,rhp2; 203 1 unsigned int status; 204 1 unsigned int ccode=0; 205 1 206 1 rhp1=r32(HcRhP1); 207 1 rhp2=r32(HcRhP2); 208 1 209 1 enable_port(); 210 1 211 1 gotoxy(1,5); 212 1 213 1 if(mode==1) 214 1 { 215 2 printf("\nRhP1 = %8lX RhP2 = %8lX",rhp1,rhp2); 216 2 printf("\nPort1Speed = %2d",get_port_speed(1)); 217 2 printf("\nPort2Speed = %2d",get_port_speed(2)); 218 2 } 219 1 220 1 if( ((rhp1&0x01)==1) && ((rhp2&0x01)==1) ) 221 1 { 222 2 if(mode==1)printf("\nBoth ports has USB device connected."); 223 2 224 2 w32(HcRhP1,0x00000010); //Resets port 1 225 2 delay(500); 226 2 w32(HcRhP2,0x00000010); //Resets port 2 227 2 228 2 ccode=set_address(0,1,1); 229 2 status=0x0100|(ccode<<12); 230 2 231 2 enable_port(); 232 2 C51 COMPILER V7.06 PORT 08/02/2005 13:30:02 PAGE 5 233 2 delay(200); 234 2 ccode=set_address(0,2,2); 235 2 236 2 status=0x0001|(ccode<<4); 237 2 } 238 1 239 1 else if( ((rhp1&0x01)==1) && ((rhp2&0x01)==0) ) 240 1 { 241 2 if(mode==1)printf("\nPort 1 has USB device connected, assigning address 1..."); 242 2 ccode=set_address(0,1,1); 243 2 244 2 status=0x0100|(ccode<<12); 245 2 } 246 1 247 1 else if( ((rhp1&0x01)==0) && ((rhp2&0x01)==1) ) 248 1 { 249 2 if(mode==1)printf("\nPort 2 has USB device connected, assigning address 2..."); 250 2 ccode=set_address(0,2,2); 251 2 252 2 status=0x0001|(ccode<<4); 253 2 } 254 1 255 1 else 256 1 { 257 2 if(mode==1)printf("\nNo device connected to ISP1362, aborting enumeration..."); 258 2 259 2 status=0x0000; 260 2 } 261 1 262 1 return(status); 263 1 } C51 COMPILATION COMPLETE. 8 WARNING(S), 1 ERROR(S)