📄 rb.lst
字号:
=1 185 ; The example use only used Endpoints 0 and 1 and also SOF for timing
0118 =1 186 Reserved:
0118 =1 187 INT0_ISR:
0118 =1 188 Timer0_ISR:
0118 =1 189 INT1_ISR:
A51 MACRO ASSEMBLER RB 23/07/99 16:57:48 PAGE 4
0118 =1 190 Timer1_ISR:
0118 =1 191 UART0_ISR:
0118 =1 192 Timer2_ISR:
0118 =1 193 UART1_ISR:
0118 =1 194 I2C_ISR:
0118 =1 195 INT4_ISR:
0118 =1 196 INT5_ISR:
0118 =1 197 INT6_ISR:
0118 =1 198 SUTOK_ISR:
0118 =1 199 EP0In_ISR:
0118 =1 200 EP0Out_ISR:
0118 =1 201 EP1In_ISR:
0118 =1 202 EP1Out_ISR:
0118 =1 203 EP2In_ISR:
0118 =1 204 EP2Out_ISR:
0118 =1 205 EP3In_ISR:
0118 =1 206 EP3Out_ISR:
0118 =1 207 EP4In_ISR:
0118 =1 208 EP4Out_ISR:
0118 =1 209 EP5In_ISR:
0118 =1 210 EP5Out_ISR:
0118 =1 211 EP6In_ISR:
0118 =1 212 EP6Out_ISR:
0118 =1 213 EP7In_ISR :
0118 =1 214 EP7Out_ISR:
0118 =1 215 Not_Used: ; Should not get any of these
0118 32 =1 216 RETI
=1 217
0119 =1 218 ClearINT2: ; Tell the hardware that we're done
0119 E591 =1 219 MOV A, EXIF
011B C2E4 =1 220 CLR ACC.4 ; Clear the Interrupt 2 bit
011D F591 =1 221 MOV EXIF, A
011F 22 =1 222 RET
=1 223
0120 =1 224 USBReset_ISR: ; Bus has been Reset, move to DEFAULT state
0120 C0E0 =1 225 PUSH ACC
0122 C200 =1 226 CLR Configured
0124 3119 =1 227 CALL ClearINT2
=1 228 ; No need to clear source of interrupt
0126 D0E0 =1 229 POP ACC
0128 32 =1 230 RETI
=1 231
0129 =1 232 Suspend_ISR: ; SIE detected an Idle bus
0129 C0E0 =1 233 PUSH ACC
012B E587 =1 234 MOV A, PCON
012D 4401 =1 235 ORL A, #1
012F F587 =1 236 MOV PCON, A ; Go to sleep!
0131 00 =1 237 NOP
0132 00 =1 238 NOP ; Wake up here due to a USBResume
0133 00 =1 239 NOP
0134 3119 =1 240 CALL ClearINT2
0136 D0E0 =1 241 POP ACC
0138 32 =1 242 RETI
=1 243
0139 =1 244 WakeUp_ISR: ; Not using external WAKEUP in these examples
=1 245 ; So this must be due to a USBResume
0139 C2DC =1 246 CLR EICON.4 ; Clear the wakeup interrupt source
013B 32 =1 247 RETI
=1 248
013C =1 249 SUDAV_ISR: ; A Setup packet has been received
013C C0D0 =1 250 PUSH PSW ; Save Registers before the service routine
013E C0E0 =1 251 PUSH ACC
0140 C082 =1 252 PUSH DPL
0142 C083 =1 253 PUSH DPH
0144 120169 =1 254 CALL ServiceSetupPacket
0147 3119 =1 255 CALL ClearINT2
A51 MACRO ASSEMBLER RB 23/07/99 16:57:48 PAGE 5
=1 256 ; Clear the source of the interrupt
0149 7401 =1 257 MOV A, #00000001b
014B 907FAB =1 258 ExitISR:MOV DPTR, #USBIRQ
014E F0 =1 259 MOVX @DPTR, A
014F D083 =1 260 POP DPH ; Restore Registers
0151 D082 =1 261 POP DPL
0153 D0E0 =1 262 POP ACC
0155 D0D0 =1 263 POP PSW
0157 32 =1 264 RETI
=1 265
0158 =1 266 SOF_ISR: ; A Start-Of-Frame packet has been received
0158 C0D0 =1 267 PUSH PSW ; Save Registers before the service routine
015A C0E0 =1 268 PUSH ACC
015C C082 =1 269 PUSH DPL
015E C083 =1 270 PUSH DPH
0160 1205FA =1 271 CALL ServiceTimerRoutine
0163 3119 =1 272 CALL ClearINT2
=1 273 ; Clear the source of the interrupt
0165 7402 =1 274 MOV A, #00000010b
0167 80E2 =1 275 JMP ExitISR
=1 276
=1 277
278 $INCLUDE(../USB_INT.A51)
=1 279 ; This module is common to all of the examples.
=1 280 ; It services USB Requests from the SIE.
=1 281 ; Interpretation of the Output Reports is handled by MAIN
=1 282 ;
---- =1 283 CSEG
0169 =1 284 ServiceSetupPacket:
0169 907FE8 =1 285 MOV DPTR, #SETUPDAT ; Point to Setup Packet data
016C E0 =1 286 MOVX A, @DPTR ; Get the RequestType
016D A2E7 =1 287 MOV C, ACC.7 ; Bit 7 = 1 means IO device needs to send data to P
C Host
016F 9202 =1 288 MOV SendData, C
0171 545C =1 289 ANL A, #01011100b ; IF RequestType[6.4.3.2] = 1 THEN goto BadRequest
0173 7051 =1 290 JNZ BadRequest
0175 E0 =1 291 MOVX A, @DPTR ; IF RequestType[1&0] = 1 THEN goto BadRequest
0176 A2E0 =1 292 MOV C, ACC.0
0178 82E1 =1 293 ANL C, ACC.1
017A 404A =1 294 JC BadRequest
017C 30E502 =1 295 JNB ACC.5, NotB5 ; IF RequestType[5] = 1 THEN RequestType[1,0] = [1,
1]
017F 7403 =1 296 MOV A, #00000011b
0181 5403 =1 297 NotB5: ANL A, #00000011b ; Set CommandIndex[5,4] = RequestType[1,0]
0183 C4 =1 298 SWAP A
0184 F540 =1 299 MOV Temp, A ; Save HI nibble of CommandIndex
=1 300 ; Set CommandIndex[3,0] = Request[3,0]
0186 A3 =1 301 INC DPTR ; Point to Request
0187 E0 =1 302 MOVX A, @DPTR
0188 540F =1 303 ANL A, #00001111b ; Only 13 are defined today, handle in table
018A 4540 =1 304 ORL A, Temp
018C 1201D5 =1 305 CALL CorrectSubroutine ; goto CommandTable(CommandIndex)
=1 306 ; Returns STALL=1 if a stall is required
018F 200134 =1 307 JB STALL, BadRequest
0192 300218 =1 308 JNB SendData, HandShake
0195 200320 =1 309 JB IsDescriptor, LoadSUDPTR; EZ-USB has a short cut for descriptors
=1 310 ; Send data in ReplyBuffer
0198 907F02 =1 311 MOV DPTR, #EP0InBuffer+2
019B 7846 =1 312 MOV R0, #ReplyBuffer+3
019D 754003 =1 313 MOV Temp, #3 ; Copy maximum byte count
01A0 E6 =1 314 CopyRB: MOV A, @R0
01A1 F0 =1 315 MOVX @DPTR, A
01A2 1582 =1 316 DEC DPL
01A4 18 =1 317 DEC R0
01A5 D540F8 =1 318 DJNZ Temp, CopyRB
01A8 E6 =1 319 MOV A, @R0 ; Get real byte count
A51 MACRO ASSEMBLER RB 23/07/99 16:57:48 PAGE 6
01A9 =1 320 SendEP0InBuffer:
01A9 907FB5 =1 321 MOV DPTR, #In0ByteCount
01AC =1 322 StartXfer:
01AC F0 =1 323 MOVX @DPTR, A ; This write initiates the transfer
01AD =1 324 HandShake: ; Handshake with host
01AD 754002 =1 325 MOV Temp, #00000010b ; Set HSNAK to tell the SIE that we're done
01B0 =1 326 SetEP0Control:
01B0 907FB4 =1 327 MOV DPTR, #EP0Control
01B3 E0 =1 328 MOVX A, @DPTR
01B4 4540 =1 329 ORL A, Temp
01B6 F0 =1 330 MOVX @DPTR, A
01B7 22 =1 331 RET
01B8 =1 332 LoadSUDPTR: ; Send the data pointed to by DPTR
01B8 858240 =1 333 MOV Temp, DPL
01BB E583 =1 334 MOV A, DPH
01BD 907FD4 =1 335 MOV DPTR, #SUDPTR
01C0 F0 =1 336 MOVX @DPTR, A
01C1 E540 =1 337 MOV A, Temp
01C3 A3 =1 338 INC DPTR
01C4 80E6 =1 339 JMP StartXfer
01C6 =1 340 BadRequest: ; Invalid Request was received
01C6 754003 =1 341 MOV Temp, #00000011b ; Set EP0STALL and HSNAK
01C9 80E5 =1 342 JMP SetEP0Control
=1 343
01CB =1 344 NextDPTR: ; Returns (DPTR + byte DPTR is pointing to)
01CB E0 =1 345 MOVX A, @DPTR
01CC =1 346 BumpDPTR: ; Returns (DPTR + ACC)
01CC 2582 =1 347 ADD A, DPL
01CE F582 =1 348 MOV DPL, A
01D0 5002 =1 349 JNC Skip
01D2 0583 =1 350 INC DPH ; Need 16 bit arithmetic here
01D4 22 =1 351 Skip: RET
=1 352
01D5 =1 353 CorrectSubroutine: ; Jump to the subroutine that DPTR is pointing to
01D5 9001FA =1 354 MOV DPTR, #CommandTable
01D8 31CC =1 355 CALL BumpDPTR ; Point to entry
01DA E0 =1 356 MOVX A, @DPTR ; Get the offset
01DB 9001FA =1 357 MOV DPTR, #CommandTable
01DE 31CC =1 358 CALL BumpDPTR ; Get the routine address
01E0 C082 =1 359 PUSH DPL ; Create a RETURN address on stack
01E2 C083 =1 360 PUSH DPH ; Note: JMP @A+DPTR not used since A, DPTR needed
01E4 7845 =1 361 MOV R0, #ReplyBuffer+2
01E6 E4 =1 362 CLR A
01E7 F6 =1 363 MOV @R0, A ; Clear ReplyBuffer
01E8 18 =1 364 DEC R0
01E9 F6 =1 365 MOV @R0, A
01EA 18 =1 366 DEC R0
01EB 7601 =1 367 MOV @R0, #1 ; Default non-descriptor reply
01ED 907FEA =1 368 MOV DPTR, #SETUPDAT+2 ; Point to LOW(wValue)
01F0 E0 =1 369 MOVX A, @DPTR ; Many of the routines need these
01F1 F5F0 =1 370 MOV B, A ; LOW(wValue) in B
01F3 A3 =1 371 INC DPTR
01F4 E0 =1 372 MOVX A, @DPTR ; HIGH(wValue) in A
01F5 C201 =1 373 CLR STALL
01F7 C203 =1 374 CLR IsDescriptor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -