DEFINE PROCESS_TEXT,space=code,align=01H SEGMENT PROCESS_TEXT FILE "C:\USB\930CODE\ISO_REC\PROCESS.C" MODE=BINARY ; 1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; 2 (C) Copyright Intel Corp., 1996 ; 3 ; 4 File: process.c ; 5 ; 6 Universal Serial Bus 930 Test firmware ; 7 ; 8 Revision History ; 9 --------------------------------------------- ; 10 0.1 05-27-96 Abdul Rahman Ismail ; 11 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ ; 12 ; 13 #include <8x930ax.h> ; 14 #include "defs.h" ; 15 ; 16 #include "process.h" ; 17 ; 18 #ifdef ALT_X_FACE ; 19 // external functions. - altxface.asm ; 20 // extern void FillEP1Fifo( void ); ; 21 // extern void FillEP2Fifo( void ); ; 22 extern void TestThing( void ); ; 23 extern void SOF_Init_FIFOs( void ); ; 24 #endif ; 25 ; 26 // External variables. - Assemdbly file ; 27 // #ifndef IR_DONGLE ; 28 // extern WORD EP1RxPtr; ; 29 // extern WORD EP1TxPtr; ; 30 // extern WORD EP1DataCount; ; 31 ; 32 // extern WORD EP2RxPtr; ; 33 // extern WORD EP2TxPtr; ; 34 // extern WORD EP2DataCount; ; 35 ; 36 // extern WORD EP3RxPtr; ; 37 // extern WORD EP3TxPtr; ; 38 // extern WORD EP3DataCount; ; 39 // #endif ; 40 ; 41 #ifdef ALT_X_FACE ; 42 // extern BYTE gbEP1Running; ; 43 // extern BYTE gbEP2Running; ; 44 extern BYTE gbMPSEndPoint1; ; 45 extern BYTE gbMPSEndPoint2; ; 46 #endif ; 47 ; 48 // Global function prototypes. ; 49 // reentrant void SetFeature( BYTE bRequestType, WORD wValue, WORD wIndex ); ; 50 // reentrant void StallEndPoint( WORD wEndPointAddress ); ; 51 ; 52 // reentrant void ClearFeature( BYTE bRequestType, WORD wValue, WORD wIndex ); ; 53 // reentrant void EnableEndPoint( WORD wEndPointAddress ); ; 54 ; 55 // reentrant WORD GetStatus( BYTE bRequestType, WORD wIndex ); ; 56 ; 57 #ifdef ALT_X_FACE ; 58 reentrant void SetInterface( WORD wAlternateSetting, WORD wInterfaceNo ); ; 59 reentrant void SetLEDs( BYTE val ); ; 60 #endif ; 61 ; 62 /*----------------------------------------------------------------------------- ; 63 Function name : StallEndPoint ; 64 Brief Description : Stalls the endpoint if valid endpoint recd. ; 65 -----------------------------------------------------------------------------*/ ; 66 ; 67 // reentrant void StallEndPoint( WORD wEndPointAddress ) ; 68 // { ; 69 // BYTE bStallEPMask; ; 70 ; 71 // if ((wEndPointAddress & GET_EP_DIRECTION) == HOST_2_DEV) ; 72 // bStallEPMask = STALL_RX; ; 73 // else ; 74 // bStallEPMask = STALL_TX; ; 75 ; 76 // wEndPointAddress &= GET_EP_NUMBER; ; 77 ; 78 // EPINDEX = (BYTE) wEndPointAddress; ; 79 ; 80 // switch (wEndPointAddress) ; 81 // { ; 82 // case 0: ; 83 // RXSTL = TRUE; ; 84 // TXSTL = TRUE; ; 85 // break; ; 86 ; 87 // case 1: ; 88 // case 2: ; 89 // case 3: ; 90 // EPCON |= bStallEPMask; ; 91 // break; ; 92 // } ; 93 // } ; 94 ; 95 // /*----------------------------------------------------------------------------- ; 96 // Function name : SetFeature ; 97 // Brief Description : Decodes the setup packet and performs the reqd. task. ; 98 // -----------------------------------------------------------------------------*/ ; 99 ; 100 // reentrant void SetFeature( BYTE bRequestType, WORD wValue, WORD wIndex ) ; 101 // { ; 102 // BYTE bRecipient; ; 103 ; 104 // bRecipient = bRequestType & GET_RECIPIENT; ; 105 ; 106 // if (bRecipient == RECEIPIENT_INTERFACE) ; 107 // return; ; 108 ; 109 // if (bRecipient == RECEIPIENT_DEVICE) ; 110 // { ; 111 // if (wValue == DEVICE_REMOTE_WAKEUP) ; 112 // ; // Do something.... ; 113 // } ; 114 // else ; 115 // { ; 116 // if (wValue == ENDPOINT_STALL) ; 117 // StallEndPoint( wIndex ); ; 118 // } ; 119 // } ; 120 ; 121 // /*----------------------------------------------------------------------------- ; 122 // Function name : EnableEndPoint ; 123 // Brief Description : Enables the endpoint if valid endpoint recd. ; 124 // -----------------------------------------------------------------------------*/ ; 125 ; 126 // reentrant void EnableEndPoint( WORD wEndPointAddress ) ; 127 // { ; 128 // BYTE bEnableEPTX; ; 129 ; 130 // if ((wEndPointAddress & GET_EP_DIRECTION) == HOST_2_DEV) ; 131 // bEnableEPTX = FALSE; ; 132 // else ; 133 // bEnableEPTX = TRUE; ; 134 ; 135 // wEndPointAddress &= GET_EP_NUMBER; ; 136 // EPINDEX = (BYTE) wEndPointAddress; ; 137 // switch (wEndPointAddress) ; 138 // { ; 139 // case 0: ; 140 // RXSTL = FALSE; ; 141 // TXSTL = FALSE; ; 142 // TXCLR = TRUE; ; 143 // RXCLR = TRUE; ; 144 // break; ; 145 ; 146 // case 1: ; 147 // if( bEnableEPTX == TRUE ) ; 148 // { ; 149 // TXSTL = FALSE; ; 150 // TXCLR = TRUE; ; 151 // } ; 152 // else ; 153 // { ; 154 // RXSTL = FALSE; ; 155 // RXCLR = TRUE; ; 156 // } ; 157 // #ifndef IR_DONGLE ; 158 // EP1TxPtr = 0; ; 159 // EP1RxPtr = 0; ; 160 // EP1DataCount = 0; ; 161 // #endif ; 162 // break; ; 163 ; 164 // case 2: ; 165 // if( bEnableEPTX == TRUE ) ; 166 // { ; 167 // TXSTL = FALSE; ; 168 // TXCLR = TRUE; ; 169 // } ; 170 // else ; 171 // { ; 172 // RXSTL = FALSE; ; 173 // RXCLR = TRUE; ; 174 // } ; 175 // #ifndef IR_DONGLE ; 176 // EP2TxPtr = 0; ; 177 // EP2RxPtr = 0; ; 178 // EP2DataCount = 0; ; 179 // #endif ; 180 // break; ; 181 ; 182 // case 3: ; 183 // if( bEnableEPTX == TRUE ) ; 184 // { ; 185 // TXSTL = FALSE; ; 186 // TXCLR = TRUE; ; 187 // } ; 188 // else ; 189 // { ; 190 // RXSTL = FALSE; ; 191 // RXCLR = TRUE; ; 192 // } ; 193 // #ifndef IR_DONGLE ; 194 // EP3TxPtr = 0; ; 195 // EP3RxPtr = 0; ; 196 // EP3DataCount = 0; ; 197 // #endif ; 198 // break; ; 199 // } ; 200 // } ; 201 ; 202 // /*----------------------------------------------------------------------------- ; 203 // Function name : ClearFeature ; 204 // Brief Description : Decodes the setup packet and performs the reqd. task. ; 205 // -----------------------------------------------------------------------------*/ ; 206 ; 207 // reentrant void ClearFeature( BYTE bRequestType, WORD wValue, WORD wIndex ) ; 208 // { ; 209 // BYTE bRecipient; ; 210 ; 211 // bRecipient = bRequestType & GET_RECIPIENT; ; 212 ; 213 // if (bRecipient == RECEIPIENT_INTERFACE) ; 214 // return; ; 215 ; 216 // if (bRecipient == RECEIPIENT_DEVICE) ; 217 // { ; 218 // if (wValue == DEVICE_REMOTE_WAKEUP) ; 219 // P1 = 0x55; ; 220 // ; // Do something.... ; 221 // } ; 222 // else ; 223 // { ; 224 // if (wValue == ENDPOINT_STALL) ; 225 // EnableEndPoint( wIndex ); ; 226 // } ; 227 // } ; 228 ; 229 // /*----------------------------------------------------------------------------- ; 230 // Function name : GetStatus ; 231 // Brief Description : Decodes the setup packet and performs the reqd. task. ; 232 // -----------------------------------------------------------------------------*/ ; 233 ; 234 // reentrant WORD GetStatus( BYTE bRequestType, WORD wIndex ) ; 235 // { ; 236 // BYTE bRecipient; ; 237 // WORD wStatus = 0; ; 238 // BYTE bDirection; ; 239 ; 240 // // Get the recipient bits so you know what to do ; 241 // bRecipient = bRequestType & GET_RECIPIENT; ; 242 ; 243 // switch (bRecipient) { ; 244 // case RECEIPIENT_DEVICE: ; 245 // /* TBD!!! In the future, look at the real descriptor ; 246 // data (config descr) and return based on that value */ ; 247 // wStatus = 1; /* Device not a remote wakeup source ; 248 // Device is self powered ; 249 // */ ; 250 // break; ; 251 ; 252 // case RECEIPIENT_INTERFACE: ; 253 // wStatus = 0; ; 254 // break; ; 255 ; 256 // case RECEIPIENT_ENDPOINT: ; 257 // if ((wIndex & GET_EP_DIRECTION) == HOST_2_DEV) ; 258 // bDirection = HOST_2_DEV; ; 259 // else ; 260 // bDirection = DEV_2_HOST; ; 261 ; 262 // wIndex &= GET_EP_NUMBER; ; 263 ; 264 // /* Endpoint number */ ; 265 // EPINDEX = (BYTE) wIndex; ; 266 ; 267 // switch (wIndex) { ; 268 // case 0: ; 269 // /* We always return OK for EP 0 (can never be stalled) */ ; 270 // break; ; 271 ; 272 // case 1: ; 273 // case 2: ; 274 // case 3: ; 275 // if (bDirection == HOST_2_DEV) { ; 276 // if (RXSTL == TRUE) ; 277 // wStatus = TRUE; ; 278 // } ; 279 // else { ; 280 // if (TXSTL == TRUE) ; 281 // wStatus = TRUE; ; 282 // } /*if-else*/ ; 283 ; 284 // break; ; 285 ; 286 // default: ; 287 // break; ; 288 ; 289 // } /* switch */ ; 290 ; 291 // break; ; 292 ; 293 // default: ; 294 // break; ; 295 ; 296 // } // switch ; 297 ; 298 // return (wStatus); ; 299 ; 300 // }/* GetStatus */ ; 301 ; 302 #ifdef ALT_X_FACE ; 303 /*----------------------------------------------------------------------------- ; 304 Function name : SetLEDs ; 305 Brief Description : Just does an out to P1 ; 306 -----------------------------------------------------------------------------*/ ; 307 reentrant void SetLEDs( BYTE val ) ; 308 { _SetLEDs: PUSH WR30 MOV DR28,SPX ; 309 // P1 = val; ; 310 TestThing(); LCALL _TestThing ; 311 } POP WR30 RET ; ;**************************** _SetLEDs *************************** ;Name Addr/Register Size Type ;_TestThing IMPORT ----- function ;val WR30-4 1 parameter ; ;Local Frame Size: 5 (bytes) ; .FRAME SetLEDs,_$_SetLEDs,pdata .FCALL TestThing SEGMENT PROCESS_TEXT ; 312 ; 313 /*----------------------------------------------------------------------------- ; 314 Function name : SetInterface ; 315 Brief Description : Decodes the setup packet and performs the reqd. task. ; 316 -----------------------------------------------------------------------------*/ ; 317 ; 318 reentrant void SetInterface( WORD wAlternateSetting, WORD wInterfaceNo ) ; 319 { _SetInterface: PUSH WR30 MOV DR28,SPX ; 320 if (wInterfaceNo != 0) MOV WR26,@WR30+-7 CMP WR26,#00H JMPNE L_10 ; 321 return; ; 322 ; 323 switch (wAlternateSetting) MOV WR14,@WR30+-5 CMP WR14,#05H JMPG L_9 MOV WR26,WR14 SLL WR26 ADD WR26,WR14 ADD WR26,#low16(L__5) LJMP @WR26 L__5: LJMP L_2 LJMP L_3 LJMP L_4 LJMP L_5 LJMP L_6 LJMP L_7 ; 324 { ; 325 case 0x00: L_2: ; 326 gbMPSEndPoint1 = MPS_EP1_AX0; MOV R15,#08H MOV 00:_gbMPSEndPoint1,R15 ; 327 gbMPSEndPoint2 = MPS_EP2_AX0; MOV R15,#08H MOV 00:_gbMPSEndPoint2,R15 ; 328 break; JMP L_9 ; 329 ; 330 case 0x01: L_3: ; 331 gbMPSEndPoint1 = MPS_EP1_AX1; MOV R15,#020H MOV 00:_gbMPSEndPoint1,R15 ; 332 gbMPSEndPoint2 = MPS_EP2_AX1; MOV R15,#04H MOV 00:_gbMPSEndPoint2,R15 ; 333 break; JMP L_9 ; 334 ; 335 case 0x02: L_4: ; 336 gbMPSEndPoint1 = MPS_EP1_AX2; MOV R15,#040H MOV 00:_gbMPSEndPoint1,R15 ; 337 gbMPSEndPoint2 = MPS_EP2_AX2; MOV R15,#02H MOV 00:_gbMPSEndPoint2,R15 ; 338 break; JMP L_9 ; 339 ; 340 case 0x03: L_5: ; 341 gbMPSEndPoint1 = MPS_EP1_AX3; MOV R15,#080H MOV 00:_gbMPSEndPoint1,R15 ; 342 gbMPSEndPoint2 = MPS_EP2_AX3; MOV R15,#01H MOV 00:_gbMPSEndPoint2,R15 ; 343 break; JMP L_9 ; 344 ; 345 case 0x04: L_6: ; 346 gbMPSEndPoint1 = MPS_EP1_AX4; MOV R15,#035H MOV 00:_gbMPSEndPoint1,R15 ; 347 gbMPSEndPoint2 = MPS_EP2_AX4; MOV R15,#03H MOV 00:_gbMPSEndPoint2,R15 ; 348 break; JMP L_9 ; 349 ; 350 case 0x05: L_7: ; 351 gbMPSEndPoint1 = MPS_EP1_AX5; MOV R15,#067H MOV 00:_gbMPSEndPoint1,R15 ; 352 gbMPSEndPoint2 = MPS_EP2_AX5; MOV R15,#07H MOV 00:_gbMPSEndPoint2,R15 ; 353 break; ; 354 } L_9: ; 355 ; 356 ; 357 SOF_Init_FIFOs(); LCALL _SOF_Init_FIFOs ; 358 } L_10: POP WR30 RET ; ;**************************** _SetInterface *************************** ;Name Addr/Register Size Type ;_SOF_Init_FIFOs IMPORT ----- function ;_gbMPSEndPoint2 IMPORT 1 variable ;_gbMPSEndPoint1 IMPORT 1 variable ;wInterfaceNo WR30-7 2 parameter ;wAlternateSetting WR30-5 2 parameter ; ;Local Frame Size: 8 (bytes) ; .FRAME SetInterface,_$_SetInterface,pdata .FCALL SOF_Init_FIFOs XREF _gbMPSEndPoint2:pdata XREF _gbMPSEndPoint1:pdata XREF _SOF_Init_FIFOs:code XREF _TestThing:code XDEF _SetInterface XDEF _SetLEDs END