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