📄 std.asm
字号:
;Standard--------------------------------------------------------------------
;Get device descriptor
readtable_withcheckindex:
SZ FIFO_wIndexL
JMP ToStallPipe0
readtable_withcheckHindex:
SZ FIFO_wIndexH
JMP ToStallPipe0
out_of_rd_table_sendcnf:
JMP ReadEntityAndSendCnf ;Read configuration table
;----------------------------------------------------------------------------------------------
GetDeviceDes:
MOV A,LOW DeviceD ;Set table pointer to device
MOV TBLP,A ; table
MOV A,Device_Length ;(Entity length not included
jmp readtable_withcheckindex
;----------------------------------------------------------------------------------------------
;(Configuration, interface & endpoint) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GetConfigurationDes:
MOV A,LOW ConfigurationD ;Set table pointer to
MOV TBLP,A ;configuration
MOV A,config_Length ;(Entity length not included
jmp readtable_withcheckindex
;Class-----------------------------------------------------------------------
GetHID:
MOV A,LOW HID_0 ;Set table pointer to
MOV TBLP,A ;HID
MOV A,HID_Length ;(Entity length not included
jmp out_of_rd_table_sendcnf
;----------------------------------------------------------------------------------------------
FIFO_Full:
SET bFIFO_Full ;Send Request
FIFO_NoFull:
CLR bSend_Continue ;clear continue send flag
SZ TableLength ;Finished read ?
JMP ReadAgain ;No, Read Next Byte
;----------------------------------------------------------------------------------------------
EndSend:
sz bFIFO_Full
set bSend_Continue ;if fifo_full & TableLength=0
;must send zero length data in next in token
sz bSend_Continue
jmp RequestResponse
set bwait_setup
SZ FIFO_SendLen
jmp RequestResponse
jmp SendHandshake ;send zero length
;----------------------------------------------------------------------------------------------
GetConfiguration:
clr FIFO_out1
sz bcfgvalue
set FIFO_OUT1.0 ;to FIFO
MOV A,01H ;Send length = 1
jmp SendFIFOOut
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetConfiguration:
mov a,1
sub a,FIFO_wValueL ;1 - FIFO_wValueL
snz c
jmp ToStallPipe0
clr baddr_state
snz z ;fifo_wvaluel=1
set baddr_state
CLR STALL ;Reset all stall to 0
MOV A,USB_STALL ;
MOV MP1,A ;
CLR R1 ;
sz FIFO_wvalueL
jmp set_cfg
clr bcfgvalue
JMP SendHandShake
set_cfg:
set bcfgvalue
set timer1_on
JMP SendHandShake
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GetDescriptor: ;No check bmRequestType D4..0
mov a,fifo_wlengthh
mov lengthh,a
mov a,fifo_wlengthl
mov lengthl,a
clr brd_h_table
MOV A,FIFO_Type ;only (device,interface & endpoint)
AND A,Setup_Rev
sz z
jmp StandardDst ;10000000
xor a,1
sz z
JMP ClassDst_Interface ;10000001Class (new)
JMP ToStallPipe0
;-----------------------------------------------------------------------------------------
;
; Read FIFO_SIZE bytes or until TableLength=0
;
;-----------------------------------------------------------------------------------------
GetTableBeg:
MOV A,OFFSET FIFO_OUT1 ;Let MP0 pointer to FIFO_OUT1
MOV MP0,A ;
CLR FIFO_SendLen ;Send data length = 0
;Check whether all data is written
GetTableLp:
sz tablelength ;check whether out of number to send
jmp read_data_again
ret
;----------------------------------------------------------------------------------------------
;
; Read one byte from table
;
;----------------------------------------------------------------------------------------------
read_data_again:
snz brd_h_table
jmp read_L_table_byte
;read_H_byte
clr brd_h_table
TABRDL R0
INC TBLP
mov a,tblh
and a,INVALID_CODE
xor a,INVALID_CODE
sz z
jmp read_data_again ;GetTableTag
mov a,tblh
and a,INVALID_CODE
mov R0,a
jmp read_next_table
read_L_table_byte:
set brd_h_table
TABRDL R0 ;Get table and write FIFO_OUTx
;-----------------------------------------------------------------------------------
read_next_table:
INC MP0 ;Update memory pointer 0
INC FIFO_SendLen ;Update send FIFO length
sz lengthl
jmp skip_check_lengthh
sz lengthH
jmp check_length_data
out_descript: ;out_of_number to send
jmp get_table_lp
skip_check_lengthh:
dec lengthl
get_table_lp:
SDZ TableLength ;end_of_Tablelength
JMP GetTableTag
RET
check_length_data:
set lengthl
dec lengthH
jmp get_table_lp
;Check whether FIFO_SIZE data has written
GetTableTag:
MOV A,FIFO_SendLen ;
XOR A,FIFO_SIZE ;
SNZ Z ;
JMP GetTableLp ;No
RET ;FIFO FULL
;----------------------------------------------------------------------------------------------
;
;
;----------------------------------------------------------------------------------------------
;stack 1
;!!!!! Must in same page with caller
ReadEntityAndSendCnf:
MOV TableLength,A ; in entity table)
SendCnf:
call gettablenolength
call GetTableBeg
JMP ReadNextXX
;----------------------------------------------------------------------------------------------
ReadAgain:
clr bFIFO_Full
SET bSend_Continue ;Set continue send flag
MOV A,TBLP ;Save TBLP
MOV FIFO_TBLP,A ;
JMP RequestResponse
;----------------------------------------------------------------------------------------------
;input point of the get next 8-byte table data
ReadNextCnf:
MOV A,FIFO_TBLP ;Restore TBLP
MOV TBLP,A ;
CALL GetTableBeg ;Read next 8 byte or until TableLength=0
;
;Check Whether FIFO data is FULL
;
ReadNextXX:
MOV A,FIFO_SendLen ;FIFO full ?
XOR A,FIFO_SIZE ;
SZ Z ;
JMP FIFO_Full ;Yes
JMP FIFO_NoFull ;NO
;---------------------------------------------------------------------------------------------
;stack 1
GetTableNoLength:
SZ LengthH ;Table length >= wLengthH ?
ret ;No
MOV A,TableLength ;Table length >= wLengthL ?
SUB A,LengthL ;
SNZ C ;
ret
set_tablelength:
MOV A,LengthL ;Yes
MOV TableLength,A ;Update Tablelength by FIFO_wLengthL
ret
;---------------------------------------------------------------------------------------------
ClassDst_Interface:
MOV A,FIFO_wIndexL
SUB A,INTERFACE_NO
SZ C
JMP ToStallPipe0
Skip_Check_Endpoint:
MOV A,FIFO_wValueH ;Descriptor
AND A,wValueH_Dst ; Stanard, Class & Vendor
MOV TEMP,A ;
SUB A,03H ;Over 4 iteM ?
SZ C ;
JMP ToStallPipe0 ;Yes
MOV A,TEMP
class_des_pcl_5:
ADDM A,PCL
JMP ToStallPipe0 ;Designator set no support
JMP GetHID ;Get HID descriptor
; JMP GetEntity ;Get entity descriptor
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GetEntity:
MOV a,FIFO_wIndexL ;
MOV TEMP,A
MOV A,LOW Entity_0 ;Set table pointer to
sz TEMP
mov a, LOW ENTITY_1
MOV TBLP,A ;Entity
MOV A,Entity_Length_0 ;(Entity length not included
sz TEMP
MOV A, Entity_Length_1
jmp readtable_withcheckHindex
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StandardDst:
MOV A,FIFO_wValueH ;Descriptor
AND A,wValueH_Dst ; Stanard, Class & Vendor
MOV TEMP,A ;
SUB A,04H ;Over 4 item ?
SZ C ;
JMP ToStallPipe0 ;Yes
MOV A,TEMP
std_device_pcl_5:
ADDM A,PCL
JMP ToStallPipe0 ;Reserve
JMP GetDeviceDes ;Get device descriptor
JMP GetConfigurationDes ;Get configuration descriptor
JMP GetStringDes ;Get string descriptor
;-------------------------------------------------------------------------------
PUBLIC StandardRequest
PUBLIC ReadNextCnf
public GetDeviceDes
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -