PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 1 PC Machine Code I Line File: A 1 DEFINE PROCESS_TEXT,space=code,align=01H A 2 SEGMENT PROCESS_TEXT A 3 FILE "C:\USB\930CODE\COMMON1\PROCESS.C" A 4 MODE=BINARY A 5 ; 1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A 6 ; 2 (C) Copyright Intel Corp., 1996 A 7 ; 3 A 8 ; 4 File: process.c A 9 ; 5 A 10 ; 6 Universal Serial Bus 930 Test firmware A 11 ; 7 A 12 ; 8 Revision History A 13 ; 9 --------------------------------------------- A 14 ; 10 0.1 05-27-96 Abdul Rahman Ismail A 15 ; 11 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ A 16 ; 12 A 17 ; 13 #include <8x930ax.h> A 18 ; 14 #include "defs.h" A 19 ; 15 A 20 ; 16 #include "process.h" A 21 ; 17 A 22 ; 18 #ifdef ALT_X_FACE A 23 ; 19 // external functions. - altxface.asm A 24 ; 20 // extern void FillEP1Fifo( void ); A 25 ; 21 // extern void FillEP2Fifo( void ); A 26 ; 22 extern void TestThing( void ); A 27 ; 23 extern void SOF_Init_FIFOs( void ); A 28 ; 24 #endif A 29 ; 25 A 30 ; 26 // External variables. - Assemdbly file A 31 ; 27 // #ifndef IR_DONGLE A 32 ; 28 // extern WORD EP1RxPtr; A 33 ; 29 // extern WORD EP1TxPtr; A 34 ; 30 // extern WORD EP1DataCount; A 35 ; 31 A 36 ; 32 // extern WORD EP2RxPtr; A 37 ; 33 // extern WORD EP2TxPtr; A 38 ; 34 // extern WORD EP2DataCount; A 39 ; 35 A 40 ; 36 // extern WORD EP3RxPtr; A 41 ; 37 // extern WORD EP3TxPtr; A 42 ; 38 // extern WORD EP3DataCount; A 43 ; 39 // #endif A 44 ; 40 A 45 ; 41 #ifdef ALT_X_FACE A 46 ; 42 // extern BYTE gbEP1Running; A 47 ; 43 // extern BYTE gbEP2Running; A 48 ; 44 extern BYTE gbMPSEndPoint1; A 49 ; 45 extern BYTE gbMPSEndPoint2; A 50 ; 46 #endif A 51 ; 47 A 52 ; 48 // Global function prototypes. PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 2 PC Machine Code I Line File: c:\usb\930code\common1\process.src A 53 ; 49 // reentrant void SetFeature( BYTE bRequestType, WORD wValue, WORD wIndex ); A 54 ; 50 // reentrant void StallEndPoint( WORD wEndPointAddress ); A 55 ; 51 A 56 ; 52 // reentrant void ClearFeature( BYTE bRequestType, WORD wValue, WORD wIndex ); A 57 ; 53 // reentrant void EnableEndPoint( WORD wEndPointAddress ); A 58 ; 54 A 59 ; 55 // reentrant WORD GetStatus( BYTE bRequestType, WORD wIndex ); A 60 ; 56 A 61 ; 57 #ifdef ALT_X_FACE A 62 ; 58 reentrant void SetInterface( WORD wAlternateSetting, WORD wInterfaceNo ); A 63 ; 59 reentrant void SetLEDs( BYTE val ); A 64 ; 60 #endif A 65 ; 61 A 66 ; 62 /*----------------------------------------------------------------------------- A 67 ; 63 Function name : StallEndPoint A 68 ; 64 Brief Description : Stalls the endpoint if valid endpoint recd. A 69 ; 65 -----------------------------------------------------------------------------*/ A 70 ; 66 A 71 ; 67 // reentrant void StallEndPoint( WORD wEndPointAddress ) A 72 ; 68 // { A 73 ; 69 // BYTE bStallEPMask; A 74 ; 70 A 75 ; 71 // if ((wEndPointAddress & GET_EP_DIRECTION) == HOST_2_DEV) A 76 ; 72 // bStallEPMask = STALL_RX; A 77 ; 73 // else A 78 ; 74 // bStallEPMask = STALL_TX; A 79 ; 75 A 80 ; 76 // wEndPointAddress &= GET_EP_NUMBER; A 81 ; 77 A 82 ; 78 // EPINDEX = (BYTE) wEndPointAddress; A 83 ; 79 A 84 ; 80 // switch (wEndPointAddress) A 85 ; 81 // { A 86 ; 82 // case 0: A 87 ; 83 // RXSTL = TRUE; A 88 ; 84 // TXSTL = TRUE; A 89 ; 85 // break; A 90 ; 86 A 91 ; 87 // case 1: A 92 ; 88 // case 2: A 93 ; 89 // case 3: A 94 ; 90 // EPCON |= bStallEPMask; A 95 ; 91 // break; A 96 ; 92 // } A 97 ; 93 // } A 98 ; 94 A 99 ; 95 // /*----------------------------------------------------------------------------- A 100 ; 96 // Function name : SetFeature A 101 ; 97 // Brief Description : Decodes the setup packet and performs the reqd. task. A 102 ; 98 // -----------------------------------------------------------------------------*/ A 103 ; 99 A 104 ; 100 // reentrant void SetFeature( BYTE bRequestType, WORD wValue, WORD wIndex ) PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 3 PC Machine Code I Line File: c:\usb\930code\common1\process.src A 105 ; 101 // { A 106 ; 102 // BYTE bRecipient; A 107 ; 103 A 108 ; 104 // bRecipient = bRequestType & GET_RECIPIENT; A 109 ; 105 A 110 ; 106 // if (bRecipient == RECEIPIENT_INTERFACE) A 111 ; 107 // return; A 112 ; 108 A 113 ; 109 // if (bRecipient == RECEIPIENT_DEVICE) A 114 ; 110 // { A 115 ; 111 // if (wValue == DEVICE_REMOTE_WAKEUP) A 116 ; 112 // ; // Do something.... A 117 ; 113 // } A 118 ; 114 // else A 119 ; 115 // { A 120 ; 116 // if (wValue == ENDPOINT_STALL) A 121 ; 117 // StallEndPoint( wIndex ); A 122 ; 118 // } A 123 ; 119 // } A 124 ; 120 A 125 ; 121 // /*----------------------------------------------------------------------------- A 126 ; 122 // Function name : EnableEndPoint A 127 ; 123 // Brief Description : Enables the endpoint if valid endpoint recd. A 128 ; 124 // -----------------------------------------------------------------------------*/ A 129 ; 125 A 130 ; 126 // reentrant void EnableEndPoint( WORD wEndPointAddress ) A 131 ; 127 // { A 132 ; 128 // BYTE bEnableEPTX; A 133 ; 129 A 134 ; 130 // if ((wEndPointAddress & GET_EP_DIRECTION) == HOST_2_DEV) A 135 ; 131 // bEnableEPTX = FALSE; A 136 ; 132 // else A 137 ; 133 // bEnableEPTX = TRUE; A 138 ; 134 A 139 ; 135 // wEndPointAddress &= GET_EP_NUMBER; A 140 ; 136 // EPINDEX = (BYTE) wEndPointAddress; A 141 ; 137 // switch (wEndPointAddress) A 142 ; 138 // { A 143 ; 139 // case 0: A 144 ; 140 // RXSTL = FALSE; A 145 ; 141 // TXSTL = FALSE; A 146 ; 142 // TXCLR = TRUE; A 147 ; 143 // RXCLR = TRUE; A 148 ; 144 // break; A 149 ; 145 A 150 ; 146 // case 1: A 151 ; 147 // if( bEnableEPTX == TRUE ) A 152 ; 148 // { A 153 ; 149 // TXSTL = FALSE; A 154 ; 150 // TXCLR = TRUE; A 155 ; 151 // } A 156 ; 152 // else PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 4 PC Machine Code I Line File: c:\usb\930code\common1\process.src A 157 ; 153 // { A 158 ; 154 // RXSTL = FALSE; A 159 ; 155 // RXCLR = TRUE; A 160 ; 156 // } A 161 ; 157 // #ifndef IR_DONGLE A 162 ; 158 // EP1TxPtr = 0; A 163 ; 159 // EP1RxPtr = 0; A 164 ; 160 // EP1DataCount = 0; A 165 ; 161 // #endif A 166 ; 162 // break; A 167 ; 163 A 168 ; 164 // case 2: A 169 ; 165 // if( bEnableEPTX == TRUE ) A 170 ; 166 // { A 171 ; 167 // TXSTL = FALSE; A 172 ; 168 // TXCLR = TRUE; A 173 ; 169 // } A 174 ; 170 // else A 175 ; 171 // { A 176 ; 172 // RXSTL = FALSE; A 177 ; 173 // RXCLR = TRUE; A 178 ; 174 // } A 179 ; 175 // #ifndef IR_DONGLE A 180 ; 176 // EP2TxPtr = 0; A 181 ; 177 // EP2RxPtr = 0; A 182 ; 178 // EP2DataCount = 0; A 183 ; 179 // #endif A 184 ; 180 // break; A 185 ; 181 A 186 ; 182 // case 3: A 187 ; 183 // if( bEnableEPTX == TRUE ) A 188 ; 184 // { A 189 ; 185 // TXSTL = FALSE; A 190 ; 186 // TXCLR = TRUE; A 191 ; 187 // } A 192 ; 188 // else A 193 ; 189 // { A 194 ; 190 // RXSTL = FALSE; A 195 ; 191 // RXCLR = TRUE; A 196 ; 192 // } A 197 ; 193 // #ifndef IR_DONGLE A 198 ; 194 // EP3TxPtr = 0; A 199 ; 195 // EP3RxPtr = 0; A 200 ; 196 // EP3DataCount = 0; A 201 ; 197 // #endif A 202 ; 198 // break; A 203 ; 199 // } A 204 ; 200 // } A 205 ; 201 A 206 ; 202 // /*----------------------------------------------------------------------------- A 207 ; 203 // Function name : ClearFeature A 208 ; 204 // Brief Description : Decodes the setup packet and performs the reqd. task. PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 5 PC Machine Code I Line File: c:\usb\930code\common1\process.src A 209 ; 205 // -----------------------------------------------------------------------------*/ A 210 ; 206 A 211 ; 207 // reentrant void ClearFeature( BYTE bRequestType, WORD wValue, WORD wIndex ) A 212 ; 208 // { A 213 ; 209 // BYTE bRecipient; A 214 ; 210 A 215 ; 211 // bRecipient = bRequestType & GET_RECIPIENT; A 216 ; 212 A 217 ; 213 // if (bRecipient == RECEIPIENT_INTERFACE) A 218 ; 214 // return; A 219 ; 215 A 220 ; 216 // if (bRecipient == RECEIPIENT_DEVICE) A 221 ; 217 // { A 222 ; 218 // if (wValue == DEVICE_REMOTE_WAKEUP) A 223 ; 219 // P1 = 0x55; A 224 ; 220 // ; // Do something.... A 225 ; 221 // } A 226 ; 222 // else A 227 ; 223 // { A 228 ; 224 // if (wValue == ENDPOINT_STALL) A 229 ; 225 // EnableEndPoint( wIndex ); A 230 ; 226 // } A 231 ; 227 // } A 232 ; 228 A 233 ; 229 // /*----------------------------------------------------------------------------- A 234 ; 230 // Function name : GetStatus A 235 ; 231 // Brief Description : Decodes the setup packet and performs the reqd. task. A 236 ; 232 // -----------------------------------------------------------------------------*/ A 237 ; 233 A 238 ; 234 // reentrant WORD GetStatus( BYTE bRequestType, WORD wIndex ) A 239 ; 235 // { A 240 ; 236 // BYTE bRecipient; A 241 ; 237 // WORD wStatus = 0; A 242 ; 238 // BYTE bDirection; A 243 ; 239 A 244 ; 240 // // Get the recipient bits so you know what to do A 245 ; 241 // bRecipient = bRequestType & GET_RECIPIENT; A 246 ; 242 A 247 ; 243 // switch (bRecipient) { A 248 ; 244 // case RECEIPIENT_DEVICE: A 249 ; 245 // /* TBD!!! In the future, look at the real descriptor A 250 ; 246 // data (config descr) and return based on that value */ A 251 ; 247 // wStatus = 1; /* Device not a remote wakeup source A 252 ; 248 // Device is self powered A 253 ; 249 // */ A 254 ; 250 // break; A 255 ; 251 A 256 ; 252 // case RECEIPIENT_INTERFACE: A 257 ; 253 // wStatus = 0; A 258 ; 254 // break; A 259 ; 255 A 260 ; 256 // case RECEIPIENT_ENDPOINT: PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 6 PC Machine Code I Line File: c:\usb\930code\common1\process.src A 261 ; 257 // if ((wIndex & GET_EP_DIRECTION) == HOST_2_DEV) A 262 ; 258 // bDirection = HOST_2_DEV; A 263 ; 259 // else A 264 ; 260 // bDirection = DEV_2_HOST; A 265 ; 261 A 266 ; 262 // wIndex &= GET_EP_NUMBER; A 267 ; 263 A 268 ; 264 // /* Endpoint number */ A 269 ; 265 // EPINDEX = (BYTE) wIndex; A 270 ; 266 A 271 ; 267 // switch (wIndex) { A 272 ; 268 // case 0: A 273 ; 269 // /* We always return OK for EP 0 (can never be stalled) */ A 274 ; 270 // break; A 275 ; 271 A 276 ; 272 // case 1: A 277 ; 273 // case 2: A 278 ; 274 // case 3: A 279 ; 275 // if (bDirection == HOST_2_DEV) { A 280 ; 276 // if (RXSTL == TRUE) A 281 ; 277 // wStatus = TRUE; A 282 ; 278 // } A 283 ; 279 // else { A 284 ; 280 // if (TXSTL == TRUE) A 285 ; 281 // wStatus = TRUE; A 286 ; 282 // } /*if-else*/ A 287 ; 283 A 288 ; 284 // break; A 289 ; 285 A 290 ; 286 // default: A 291 ; 287 // break; A 292 ; 288 A 293 ; 289 // } /* switch */ A 294 ; 290 A 295 ; 291 // break; A 296 ; 292 A 297 ; 293 // default: A 298 ; 294 // break; A 299 ; 295 A 300 ; 296 // } // switch A 301 ; 297 A 302 ; 298 // return (wStatus); A 303 ; 299 A 304 ; 300 // }/* GetStatus */ A 305 ; 301 A 306 ; 302 #ifdef ALT_X_FACE A 307 ; 303 /*----------------------------------------------------------------------------- A 308 ; 304 Function name : SetLEDs A 309 ; 305 Brief Description : Just does an out to P1 A 310 ; 306 -----------------------------------------------------------------------------*/ A 311 ; 307 reentrant void SetLEDs( BYTE val ) A 312 ; 308 { PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 7 PC Machine Code I Line File: c:\usb\930code\common1\process.src 00000000 A 313 _SetLEDs: 00000000 A5CAF9 A 314 PUSH WR30 00000003 A57F7F A 315 MOV DR28,SPX A 316 ; 309 // P1 = val; A 317 ; 310 TestThing(); 00000006 12 0000 A 318 LCALL _TestThing A 319 ; 311 } 00000009 A5DAF9 A 320 POP WR30 0000000C 22 A 321 RET A 322 ; A 323 A 324 ;**************************** _SetLEDs *************************** A 325 A 326 ;Name Addr/Register Size Type A 327 A 328 ;_TestThing IMPORT ----- function A 329 ;val WR30-4 1 parameter A 330 ; A 331 A 332 ;Local Frame Size: 5 (bytes) A 333 ; A 334 A 335 .FRAME SetLEDs,_$_SetLEDs,pdata A 336 .FCALL TestThing A 337 SEGMENT PROCESS_TEXT A 338 ; 312 A 339 ; 313 /*----------------------------------------------------------------------------- A 340 ; 314 Function name : SetInterface A 341 ; 315 Brief Description : Decodes the setup packet and performs the reqd. task. A 342 ; 316 -----------------------------------------------------------------------------*/ A 343 ; 317 A 344 ; 318 reentrant void SetInterface( WORD wAlternateSetting, WORD wInterfaceNo ) A 345 ; 319 { 0000000D A 346 _SetInterface: 0000000D A5CAF9 A 347 PUSH WR30 00000010 A57F7F A 348 MOV DR28,SPX A 349 ; 320 if (wInterfaceNo != 0) 00000013 A549DF FFF9 A 350 MOV WR26,@WR30+-7 00000018 A5BED4 0000 A 351 CMP WR26,#00H 0000001D A5680302 00CF A 352 JMPNE L_10 A 353 ; 321 return; A 354 ; 322 A 355 ; 323 switch (wAlternateSetting) 00000023 A5497F FFFB A 356 MOV WR14,@WR30+-5 00000028 A5BE74 0005 A 357 CMP WR14,#05H 0000002D A5280302 00CC A 358 JMPG L_9 00000033 A57DD7 A 359 MOV WR26,WR14 00000036 A53ED4 A 360 SLL WR26 00000039 A52DD7 A 361 ADD WR26,WR14 0000003C A52ED4 0044 A 362 ADD WR26,#low16(L__5) 00000041 A589D4 A 363 LJMP @WR26 00000044 A 364 L__5: PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 8 PC Machine Code I Line File: c:\usb\930code\common1\process.src 00000044 02 0056 A 365 LJMP L_2 00000047 02 006A A 366 LJMP L_3 0000004A 02 007E A 367 LJMP L_4 0000004D 02 0092 A 368 LJMP L_5 00000050 02 00A6 A 369 LJMP L_6 00000053 02 00BA A 370 LJMP L_7 A 371 ; 324 { A 372 ; 325 case 0x00: 00000056 A 373 L_2: A 374 ; 326 gbMPSEndPoint1 = MPS_EP1_AX0; 00000056 A57EF008 A 375 MOV R15,#08H 0000005A A57AF3 0000 A 376 MOV 00:_gbMPSEndPoint1,R15 A 377 ; 327 gbMPSEndPoint2 = MPS_EP2_AX0; 0000005F A57EF008 A 378 MOV R15,#08H 00000063 A57AF3 0000 A 379 MOV 00:_gbMPSEndPoint2,R15 A 380 ; 328 break; 00000068 80 62 A 381 JMP L_9 A 382 ; 329 A 383 ; 330 case 0x01: 0000006A A 384 L_3: A 385 ; 331 gbMPSEndPoint1 = MPS_EP1_AX1; 0000006A A57EF020 A 386 MOV R15,#020H 0000006E A57AF3 0000 A 387 MOV 00:_gbMPSEndPoint1,R15 A 388 ; 332 gbMPSEndPoint2 = MPS_EP2_AX1; 00000073 A57EF004 A 389 MOV R15,#04H 00000077 A57AF3 0000 A 390 MOV 00:_gbMPSEndPoint2,R15 A 391 ; 333 break; 0000007C 80 4E A 392 JMP L_9 A 393 ; 334 A 394 ; 335 case 0x02: 0000007E A 395 L_4: A 396 ; 336 gbMPSEndPoint1 = MPS_EP1_AX2; 0000007E A57EF040 A 397 MOV R15,#040H 00000082 A57AF3 0000 A 398 MOV 00:_gbMPSEndPoint1,R15 A 399 ; 337 gbMPSEndPoint2 = MPS_EP2_AX2; 00000087 A57EF002 A 400 MOV R15,#02H 0000008B A57AF3 0000 A 401 MOV 00:_gbMPSEndPoint2,R15 A 402 ; 338 break; 00000090 80 3A A 403 JMP L_9 A 404 ; 339 A 405 ; 340 case 0x03: 00000092 A 406 L_5: A 407 ; 341 gbMPSEndPoint1 = MPS_EP1_AX3; 00000092 A57EF080 A 408 MOV R15,#080H 00000096 A57AF3 0000 A 409 MOV 00:_gbMPSEndPoint1,R15 A 410 ; 342 gbMPSEndPoint2 = MPS_EP2_AX3; 0000009B A57EF001 A 411 MOV R15,#01H 0000009F A57AF3 0000 A 412 MOV 00:_gbMPSEndPoint2,R15 A 413 ; 343 break; 000000A4 80 26 A 414 JMP L_9 A 415 ; 344 A 416 ; 345 case 0x04: PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 9 PC Machine Code I Line File: c:\usb\930code\common1\process.src 000000A6 A 417 L_6: A 418 ; 346 gbMPSEndPoint1 = MPS_EP1_AX4; 000000A6 A57EF035 A 419 MOV R15,#035H 000000AA A57AF3 0000 A 420 MOV 00:_gbMPSEndPoint1,R15 A 421 ; 347 gbMPSEndPoint2 = MPS_EP2_AX4; 000000AF A57EF003 A 422 MOV R15,#03H 000000B3 A57AF3 0000 A 423 MOV 00:_gbMPSEndPoint2,R15 A 424 ; 348 break; 000000B8 80 12 A 425 JMP L_9 A 426 ; 349 A 427 ; 350 case 0x05: 000000BA A 428 L_7: A 429 ; 351 gbMPSEndPoint1 = MPS_EP1_AX5; 000000BA A57EF067 A 430 MOV R15,#067H 000000BE A57AF3 0000 A 431 MOV 00:_gbMPSEndPoint1,R15 A 432 ; 352 gbMPSEndPoint2 = MPS_EP2_AX5; 000000C3 A57EF007 A 433 MOV R15,#07H 000000C7 A57AF3 0000 A 434 MOV 00:_gbMPSEndPoint2,R15 A 435 ; 353 break; A 436 ; 354 } 000000CC A 437 L_9: A 438 ; 355 A 439 ; 356 A 440 ; 357 SOF_Init_FIFOs(); 000000CC 12 0000 A 441 LCALL _SOF_Init_FIFOs A 442 ; 358 } 000000CF A 443 L_10: 000000CF A5DAF9 A 444 POP WR30 000000D2 22 A 445 RET A 446 ; A 447 A 448 ;**************************** _SetInterface *************************** A 449 A 450 ;Name Addr/Register Size Type A 451 A 452 ;_SOF_Init_FIFOs IMPORT ----- function A 453 ;_gbMPSEndPoint2 IMPORT 1 variable A 454 ;_gbMPSEndPoint1 IMPORT 1 variable A 455 ;wInterfaceNo WR30-7 2 parameter A 456 ;wAlternateSetting WR30-5 2 parameter A 457 ; A 458 A 459 ;Local Frame Size: 8 (bytes) A 460 ; A 461 A 462 .FRAME SetInterface,_$_SetInterface,pdata A 463 .FCALL SOF_Init_FIFOs A 464 XREF _gbMPSEndPoint2:pdata A 465 XREF _gbMPSEndPoint1:pdata A 466 XREF _SOF_Init_FIFOs:code A 467 XREF _TestThing:code A 468 XDEF _SetInterface PLC 80251 Macro Assembler, Version 2.10 11-Oct-96 13:12:12 page: 10 PC Machine Code I Line File: c:\usb\930code\common1\process.src A 469 XDEF _SetLEDs A 470 END Errors: 0 Warnings: 0 Lines Assembled: 471