📄 counter.lst
字号:
00DA
00DA USBEventEP0SetupTargetDeviceIN:
00DA 16 80 [04] cmp a,USBRqstTargetDevice | USBRqstTypeDirection
00DC A1 18 [05] jz USBEventEP0SetupGetDescriptor ; Yes
00DE
00DE USBEventEP0SetupTargetInterfaceIN:
00DE 16 81 [04] cmp a,USBRqstTargetInterface | USBRqstTypeDirection
00E0 A0 B8 [05] jz USBEventEP0Stall ; Yes Oops! We don't have an interface.
00E2
00E2 USBEventEP0SetupTargetEndpointIN:
00E2 16 82 [04] cmp a,USBRqstTargetEndPoint | USBRqstTypeDirection
00E4 A0 B8 [05] jz USBEventEP0Stall ; Yes
00E6
00E6 ; Vendor specific commands
00E6 USBEventEP0SetupTargetVendorIN_OUT:
00E6 ; Check request (IN packet OK, OUT packet ERR)
00E6 1A 70 [06] mov a,[USBEndP0FIFO_0]
00E8 10 C2 [04] and a,USBRqstTypeVendor | USBRqstTargetEndPoint | USBRqstTypeDirection
00EA 16 C2 [04] cmp a,USBRqstTypeVendor | USBRqstTargetEndPoint | USBRqstTypeDirection
00EC A2 3C [05] jz USBEventEP0VendorRqst
00EE
00EE ; Unsupported request !!!
00EE 80 B8 [05] jmp USBEventEP0Stall ; Oops! We don't support whatever
00F0 ; request was made.
00F0
00F0 ;//$PAGE
00F0 ;********************************************************
00F0 ; USBEventEP0SetupIsSet()
00F0 ; @func End point event SETUP to set address.
00F0 ; @devnote Runs in interrupt enabled context.
00F0 ;********************************************************
00F0 USBEventEP0SetupIsSetAddress:
00F0
00F0 ; Set device address?
00F0 1A 71 [06] mov a,[USBRqstMessage]
00F2 16 05 [04] cmp a,USBRqstSetAddress
00F4 A0 FE [05] jz USBEventEP0SetupSetAddress ; Yes
00F6
00F6 ; Set device configuration?
00F6 1A 71 [06] mov a,[USBRqstMessage]
00F8 16 09 [04] cmp a,USBRqstSetConfiguration
00FA A1 08 [05] jz USBEventEP0SetupSetConfig ; Yes
00FC
00FC ; Unsupported set request !!!
00FC 80 B8 [05] jmp USBEventEP0Stall ; No. Stall
00FE
00FE ;********************************************************
00FE ; USBEventEP0SetupSetAddress()
00FE ; @func End point zero event SETUP to set address.
00FE ; @devnote Runs in interrupt enabled context.
00FE ; @comm
00FE ; The status token of the SetAddress is an IN. So, we send status manually.
00FE ;********************************************************
00FE USBEventEP0SetupSetAddress:
00FE
00FE ; Send ACK
00FE 20 [04] NOP
00FF 1F [04] XPAGE
0100 92 23 [10] call USBSendACK
0102 ; Now that we have been acknowleged, we actually set the address.
0102 ; This is different from all other commands which execute first
0102 ; and then acknowlege (_________________)
0102
0102 ; Set Address
0102 1A 72 [06] mov a,[USBRqstWordValueLo]
0104 2A 12 [05] iowr USBDeviceAddress
0106
0106 ; Done
0106 80 B4 [05] jmp USBEventEP0End
0108
0108 ;********************************************************
0108 ; USBEventEP0SetupSetConfig()
0108 ; @func End point zero event SETUP to Set Configuration.
0108 ; @devnote Runs in interrupt enabled context.
0108 ; 1
0108 ; set enumerated (gbSysEnumerated) state,
0108 ; enable GPIO (and EP1, if appropriate)
0108 ; Enable P0 and P1
0108 ; 0
0108 ; Reset enumerated (gbSysEnumerated) state,
0108 ; Turn off LED
0108 ; Reset variables
0108 ; Disable GPIO and EP1
0108 ; Disable dallas chip and P0 and P1
0108 ;********************************************************
0108 USBEventEP0SetupSetConfig:
0108
0108 ; Enumerated !
0108 ; Write a 0 to the LED on P13 to turn it on
0108 19 F7 [04] mov a,~(LED_ON)
010A 2A 01 [05] iowr SysPort1
010C
010C 19 10 [04] mov a,10h
010E 2A 11 [05] iowr USBEndP1TxConfig;NAK
0110
0110 ; enable all appropriate irq's
0110 19 5C [04] mov a,SysIntTimer1024us | SysIntGPIO | SysIntUSBEndP0 | SysIntUSBEndP1
0112 31 20 [05] mov [gbSysInterruptMask],a
0114
0114 ; Send ACK
0114 92 23 [10] call USBSendACK
0116 80 B4 [05] jmp USBEventEP0End
0118
0118 ;//$PAGE
0118 ;********************************************************
0118 ; USBEventEP0SetupGetDescriptor()
0118 ; @func End point zero event SETUP to Get Descriptor.
0118 ; @devnote Runs in interrupt enabled context.
0118 ;********************************************************
0118 USBEventEP0SetupGetDescriptor:
0118
0118 ; Get descriptor type
0118 1A 73 [06] mov a,[USBRqstWordValueHi]
011A
011A USBEventEP0SetupGetDescriptorDevice:
011A ; Device Descriptor?
011A 16 01 [04] cmp a,USBDescriptorTypeDevice
011C B1 2C [05] jnz USBEventEP0SetupGetDescriptorConfig ; No
011E
011E ;*********************************************
011E ; Get Device Descriptor Event
011E ;*********************************************
011E ; Descriptor pointer
011E 19 00 [04] mov a,(USBDeviceDescription -USBSendROMBufferBase)
0120 31 2A [05] mov [gbUSBSendBuffer],a
0122
0122 ; Descriptor size
0122 19 12 [04] mov a,12h ;[USBDeviceDescription]
0124 31 29 [05] mov [gbUSBSendBytes],a
0126
0126 ; Check request size field
0126 91 B6 [10] call USBSendDescriptorCheckLength
0128
0128 ; Send buffer
0128 91 C7 [10] call USBSendROMBuffer
012A 80 B4 [05] jmp USBEventEP0End
012C
012C USBEventEP0SetupGetDescriptorConfig:
012C ; Configuration Descriptor?
012C 16 02 [04] cmp a,USBDescriptorTypeConfig
012E B1 42 [05] jnz USBEventEP0SetupGetDescriptorString ; No
0130
0130 ;*********************************************
0130 ; Get Configuration Descriptor Event
0130 ;*********************************************
0130 ; Descriptor pointer
0130 19 12 [04] mov a,(USBConfigurationDescription -USBSendROMBufferBase)
0132 31 2A [05] mov [gbUSBSendBuffer],a
0134
0134 ; Descriptor size
0134 19 09 [04] mov a,09h ;[USBConfigurationDescription]
0136 01 09 [04] add a,09h ;[USBInterfaceDescription]
0138 01 07 [04] add a,07h ;[USBEndPointDescriptionInt]
013A 31 29 [05] mov [gbUSBSendBytes],a
013C
013C ; Check request size field
013C 91 B6 [10] call USBSendDescriptorCheckLength
013E
013E ; Send buffer
013E 91 C7 [10] call USBSendROMBuffer
0140 80 B4 [05] jmp USBEventEP0End
0142
0142 USBEventEP0SetupGetDescriptorString:
0142 ; Get String Descriptor?
0142 16 03 [04] cmp a,USBDescriptorTypeString
0144 B1 B4 [05] jnz USBEventEP0SetupGetDescriptorEnd ; No
0146
0146 ;*********************************************
0146 ; Get String Descriptor Event
0146 ;*********************************************
0146
0146 ; Get string descriptor index
0146 1A 72 [06] mov a,[USBRqstWordValueLo]
0148
0148 USBEventEP0SetupGetDescriptorString0:
0148 16 00 [04] cmp a,0h
014A B1 5A [05] jnz USBEventEP0SetupGetDescriptorString1 ; No
014C
014C ;*********************************************
014C ; Get String Language(s) Descriptor Event
014C ;*********************************************
014C ; Descriptor pointer
014C 19 2B [04] mov a,(USBStringLanguageDescription -USBSendROMBufferBase)
014E 31 2A [05] mov [gbUSBSendBuffer],a
0150
0150 ; Descriptor size
0150 19 04 [04] mov a,4h ;[USBStringLanguageDescription]
0152 31 29 [05] mov [gbUSBSendBytes],a
0154
0154 ; Check request size field
0154 91 B6 [10] call USBSendDescriptorCheckLength
0156
0156 ; Send buffer
0156 91 C7 [10] call USBSendROMBuffer
0158 80 B4 [05] jmp USBEventEP0End
015A
015A USBEventEP0SetupGetDescriptorString1:
015A 16 01 [04] cmp a,1
015C B1 6C [05] jnz USBEventEP0SetupGetDescriptorString2 ; No
015E
015E ;*********************************************
015E ; Get String 1 Descriptor Event
015E ;*********************************************
015E ; Descriptor pointer
015E 19 2F [04] mov a,(USBStringDescription1 -USBSendROMBufferBase)
0160 31 2A [05] mov [gbUSBSendBuffer],a
0162
0162 ; Descriptor size
0162 19 10 [04] mov a,10h ;[USBStringDescription1]
0164 31 29 [05] mov [gbUSBSendBytes],a
0166
0166 ; Check request size field
0166 91 B6 [10] call USBSendDescriptorCheckLength
0168
0168 ; Send buffer
0168 91 C7 [10] call USBSendROMBuffer
016A 80 B4 [05] jmp USBEventEP0End
016C
016C USBEventEP0SetupGetDescriptorString2:
016C 16 02 [04] cmp a,2
016E B1 7E [05] jnz USBEventEP0SetupGetDescriptorString3 ; No
0170
0170 ;*********************************************
0170 ; Get String 2 Descriptor Event
0170 ;*********************************************
0170 ; Descriptor pointer
0170 19 3F [04] mov a,(USBStringDescription2 -USBSendROMBufferBase)
0172 31 2A [05] mov [gbUSBSendBuffer],a
0174
0174 ; Descriptor size
0174 19 10 [04] mov a,10h ;[USBStringDescription2]
0176 31 29 [05] mov [gbUSBSendBytes],a
0178
0178 ; Check request size field
0178 91 B6 [10] call USBSendDescriptorCheckLength
017A
017A ; Send buffer
017A 91 C7 [10] call USBSendROMBuffer
017C 80 B4 [05] jmp USBEventEP0End
017E
017E USBEventEP0SetupGetDescriptorString3:
017E 16 03 [04] cmp a,3
0180 B1 90 [05] jnz USBEventEP0SetupGetDescriptorString4 ; No
0182
0182 ;*********************************************
0182 ; Get String 3 Descriptor Event
0182 ;*********************************************
0182 ; Descriptor pointer
0182 19 4F [04] mov a,(USBStringDescription3 -USBSendROMBufferBase)
0184 31 2A [05] mov [gbUSBSendBuffer],a
0186
0186 ; Descriptor size
0186 19 0A [04] mov a,0Ah ;[USBStringDescription3]
0188 31 29 [05] mov [gbUSBSendBytes],a
018A
018A ; Check request size field
018A 91 B6 [10] call USBSendDescriptorCheckLength
018C
018C ; Send buffer
018C 91 C7 [10] call USBSendROMBuffer
018E 80 B4 [05] jmp USBEventEP0End
0190
0190 USBEventEP0SetupGetDescriptorString4:
0190 16 04 [04] cmp a,4
0192 B1 A2 [05] jnz USBEventEP0SetupGetDescriptorString5 ; No
0194
0194 ;*********************************************
0194 ; Get String 4 Descriptor Event
0194 ;*********************************************
0194 ; Descriptor pointer
0194 19 59 [04] mov a,(USBStringDescription4 -USBSendROMBufferBase)
0196 31 2A [05] mov [gbUSBSendBuffer],a
0198
0198 ; Descriptor size
0198 19 28 [04] mov a,28h ;[USBStringDescription4]
019A 31 29 [05] mov [gbUSBSendBytes],a
019C
019C ; Check request size field
019C 91 B6 [10] call USBSendDescriptorCheckLength
019E
019E ; Send buffer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -