📄 i2c.lst
字号:
0203 74 =1 377 DB Set_Configuration - CommandTable
0204 40 =1 378 DB Invalid - CommandTable
0205 40 =1 379 DB Invalid - CommandTable
0206 40 =1 380 DB Invalid - CommandTable
0207 40 =1 381 DB Invalid - CommandTable
0208 40 =1 382 DB Invalid - CommandTable
0209 40 =1 383 DB Invalid - CommandTable
=1 384 ; Next 16 commands are for the Interface
020A 71 =1 385 DB Interface_Get_Status - CommandTable
A51 MACRO ASSEMBLER I2C 22/07/99 12:36:44 PAGE 7
020B 40 =1 386 DB Interface_Clear_Feature - CommandTable
020C 40 =1 387 DB Invalid - CommandTable
020D 40 =1 388 DB Interface_Set_Feature - CommandTable
020E 40 =1 389 DB Invalid - CommandTable
020F 40 =1 390 DB Invalid - CommandTable
0210 A5 =1 391 DB Get_Class_Descriptor - CommandTable
0211 40 =1 392 DB Set_Class_Descriptor - CommandTable
0212 40 =1 393 DB Invalid - CommandTable
0213 40 =1 394 DB Invalid - CommandTable
0214 40 =1 395 DB Get_Interface - CommandTable
0215 40 =1 396 DB Set_Interface - CommandTable
0216 40 =1 397 DB Invalid - CommandTable
0217 40 =1 398 DB Invalid - CommandTable
0218 40 =1 399 DB Invalid - CommandTable
0219 40 =1 400 DB Invalid - CommandTable
=1 401 ; Next 16 commands are for the Endpoint
021A 71 =1 402 DB Endpoint_Get_Status - CommandTable
021B 42 =1 403 DB Endpoint_Clear_Feature - CommandTable
021C 40 =1 404 DB Invalid - CommandTable
021D 40 =1 405 DB Endpoint_Set_Feature - CommandTable
021E 40 =1 406 DB Invalid - CommandTable
021F 40 =1 407 DB Invalid - CommandTable
0220 40 =1 408 DB Invalid - CommandTable
0221 40 =1 409 DB Invalid - CommandTable
0222 40 =1 410 DB Invalid - CommandTable
0223 40 =1 411 DB Invalid - CommandTable
0224 40 =1 412 DB Invalid - CommandTable
0225 40 =1 413 DB Invalid - CommandTable
0226 40 =1 414 DB Endpoint_Sync_Frame - CommandTable
0227 40 =1 415 DB Invalid - CommandTable
0228 40 =1 416 DB Invalid - CommandTable
0229 40 =1 417 DB Invalid - CommandTable
=1 418 ; Next 16 commands are Class Requests
022A 40 =1 419 DB Invalid - CommandTable
022B 56 =1 420 DB Get_Report - CommandTable
022C 63 =1 421 DB Get_Idle - CommandTable
022D 40 =1 422 DB Get_Protocol - CommandTable
022E 40 =1 423 DB Invalid - CommandTable
022F 40 =1 424 DB Invalid - CommandTable
0230 40 =1 425 DB Invalid - CommandTable
0231 40 =1 426 DB Invalid - CommandTable
0232 40 =1 427 DB Invalid - CommandTable
0233 43 =1 428 DB Set_Report - CommandTable
0234 5D =1 429 DB Set_Idle - CommandTable
0235 40 =1 430 DB Set_Protocol - CommandTable
0236 40 =1 431 DB Invalid - CommandTable
0237 40 =1 432 DB Invalid - CommandTable
0238 40 =1 433 DB Invalid - CommandTable
0239 40 =1 434 DB Invalid - CommandTable
=1 435 ;
=1 436 ; Many requests are INVALID for this example
023A =1 437 Get_Protocol: ; We are not a Boot device
023A =1 438 Set_Protocol: ; We are not a Boot device
023A =1 439 Set_Descriptor: ; Our Descriptors are static
023A =1 440 Set_Class_Descriptor: ; Our Descriptors are static
023A =1 441 Set_Interface: ; We only have one Interface
023A =1 442 Get_Interface: ; We do not have an Alternate setting
023A =1 443 Device_Set_Feature: ; We have no features that can be set or cleared
023A =1 444 Interface_Set_Feature: ; We have no features that can be set or cleared
023A =1 445 Endpoint_Set_Feature: ; We have no features that can be set or cleared
023A =1 446 Device_Clear_Feature: ; We have no features that can be set or cleared
023A =1 447 Interface_Clear_Feature: ; We have no features that can be set or cleared
023A =1 448 Endpoint_Sync_Frame: ; We are not an Isonchronous device
=1 449
023A =1 450 Invalid: ; Invalid Request made, STALL the Endpoint
023A D201 =1 451 SETB STALL
A51 MACRO ASSEMBLER I2C 22/07/99 12:36:44 PAGE 8
=1 452 ;
023C =1 453 Endpoint_Clear_Feature: ; We have no features that can be set or cleared
=1 454 ;
023C 22 =1 455 Reply: RET
=1 456
023D =1 457 Set_Report: ; Host wants to sent us a Report.
=1 458 ; The ONLY case in this example where host sends data to us
023D 3000FA =1 459 JNB Configured, Invalid ; Need to be Configured to do this command
0240 907FC5 =1 460 MOV DPTR, #Out0ByteCount ; Enable EP0OutBuffer to receive data
0243 F0 =1 461 MOVX @DPTR, A ; Any value will do
0244 907FAA =1 462 MOV DPTR, #OUT07IRQ ; Wait for valid data in EP0OutBuffer
0247 E0 =1 463 Wait4D: MOVX A, @DPTR
0248 5401 =1 464 ANL A, #00000001b
024A 60FB =1 465 JZ Wait4D
024C F0 =1 466 MOVX @DPTR, A ; Clear the interrupt
024D 0203B3 =1 467 JMP ProcessOutputReport ; RETurn via this subroutine
0250 =1 468 Get_Report: ; Host wants a Report
0250 3000E7 =1 469 JNB Configured, Invalid ; Need to be Configured to do this command
0253 08 =1 470 INC R0 ; Point to ReplyBuffer(1)
0254 7618 =1 471 MOV @R0, #18H ; Reply with a recognizable (arbitary) value
0256 22 =1 472 RET
0257 =1 473 Set_Idle: ; Host wants to tell us how often we should talk
0257 3000E0 =1 474 JNB Configured, Invalid ; Need to be Configured to do this command
025A F541 =1 475 MOV Idle_Time, A
025C 22 =1 476 RET ; Handshake with host
025D =1 477 Get_Idle: ; Host must have forgotten what he told us to do
025D 3000DA =1 478 JNB Configured, Invalid ; Need to be Configured to do this command
0260 08 =1 479 INC R0 ; Point to ReplyBuffer(1)
0261 A641 =1 480 MOV @R0, Idle_Time
0263 22 =1 481 RET
0264 =1 482 Get_Configuration:
0264 3000D5 =1 483 JNB Configured, Reply
=1 484 ; If configured return a 1 (via Device_Get_Status)
0267 =1 485 Device_Get_Status: ; Only two bits of Device Status are defined
0267 08 =1 486 INC R0 ; Point to ReplyBuffer(1)
0268 7601 =1 487 MOV @R0, #1 ; Bit 1=Remote Wakeup(=0), Bit 0=Self Powered(=1)
026A 22 =1 488 RET
=1 489
026B =1 490 Interface_Get_Status: ; Interface Status is currently defined as 0
026B =1 491 Endpoint_Get_Status:
026B 7602 =1 492 MOV @R0, #2
026D 22 =1 493 RET
026E =1 494 Set_Configuration: ; Valid values are 0 and 1
026E E5F0 =1 495 MOV A, B ; Get LOW(wValue)
0270 6006 =1 496 JZ Deconfigured
0272 14 =1 497 DEC A
0273 70C5 =1 498 JNZ Invalid
0275 D200 =1 499 SETB Configured
0277 22 =1 500 RET
0278 =1 501 Deconfigured:
0278 C200 =1 502 CLR Configured
027A 22 =1 503 RET
027B =1 504 Get_Descriptor: ; Host wants to know who/what we are
027B D203 =1 505 SETB IsDescriptor
027D 14 =1 506 DEC A ; Valid Values are 1, 2 and 3
027E 9002C5 =1 507 MOV DPTR, #DeviceDescriptor
0281 60B9 =1 508 JZ Reply
0283 14 =1 509 DEC A
0284 9002D7 =1 510 MOV DPTR, #ConfigurationDescriptor
0287 60B3 =1 511 JZ Reply
0289 14 =1 512 DEC A
028A 70AE =1 513 JNZ Invalid
=1 514 ; Request is for a String Descriptor
028C 900318 =1 515 MOV DPTR, #String0 ; Point to String 0
028F E5F0 =1 516 MOV A, B ; Get String Index
0291 =1 517 NextString:
A51 MACRO ASSEMBLER I2C 22/07/99 12:36:44 PAGE 9
0291 601E =1 518 JZ FixUpthenReply
0293 F540 =1 519 MOV Temp, A ; Save String Index
0295 31CB =1 520 CALL NextDPTR
0297 E0 =1 521 MOVX A, @DPTR ; Get the String Length (= 0 means we're at Backsto
p)
0298 60A0 =1 522 JZ Invalid ; Asked for a string I don't have
029A E540 =1 523 MOV A, Temp
029C 14 =1 524 DEC A
029D 80F2 =1 525 JMP NextString ; Check if we are there yet
029F =1 526 Get_Class_Descriptor: ; Valid values are 21H, 22H, 23H for Class Request
029F D203 =1 527 SETB IsDescriptor
02A1 C3 =1 528 CLR C
02A2 9421 =1 529 SUBB A, #21H
02A4 9002E9 =1 530 MOV DPTR, #HIDDescriptor
02A7 6093 =1 531 JZ Reply
02A9 14 =1 532 DEC A
02AA 9002F9 =1 533 MOV DPTR, #ReportDescriptor
02AD 608D =1 534 JZ Reply
=1 535 ; DEC A ; This example does not use Physical Descriptors
=1 536 ; JZ Send_Physical_Descriptor
02AF 8089 =1 537 JMP Invalid
=1 538 ;
=1 539 ; Error check: this MUST be on within a page of CommandTable
00B7 =1 540 WithinSamePage EQU $ - CommandTable
=1 541 ;
02B1 =1 542 FixUpthenReply: ; EZ-USB Rev D has a String Descriptor bug
=1 543 ; Need to fill the IN0BUF (@ 7F00H) myself
02B1 E0 =1 544 MOVX A, @DPTR ; Get the string length
02B2 FF =1 545 MOV R7, A ; Save counter
02B3 F5F0 =1 546 MOV B, A
02B5 7800 =1 547 MOV R0, #LOW(EP0InBuffer) ; PageReg = 7FH = HIGH(EP0InBuffer)
02B7 F2 =1 548 CopySD: MOVX @R0, A
02B8 08 =1 549 INC R0
02B9 A3 =1 550 INC DPTR
02BA E0 =1 551 MOVX A, @DPTR
02BB DFFA =1 552 DJNZ R7, CopySD
=1 553 ; Fixup complete, get back to the program flow
02BD D0E0 =1 554 POP ACC ; Get rid of the return address
02BF D0E0 =1 555 POP ACC
02C1 E5F0 =1 556 MOV A, B ; Retrieve byte count
02C3 21A9 =1 557 JMP SendEP0InBuffer
558 $INCLUDE(DTables.A51)
=1 559 ; This module declares the descriptors
=1 560 ;
=1 561 ; This example has one Device Descriptor with:
=1 562 ; One Configuration - single IN port and single OUT port
=1 563 ; One Interface - there is only one method of accessing the ports
=1 564 ; One HID Descriptor - to make PC host software simpler
=1 565 ; One Endpoint Descriptor - for HID Input Reports
=1 566 ; One Report Descriptor - one byte IN and one byte OUT reports
=1 567 ; Multiple Sting Descriptors - to aid the user
=1 568 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -