📄 hx_all.asm
字号:
anl A, #020h ; Mask off all but stall bit.
jz NotStalled1
mov A, #01h
sjmp DoneWithCommand1
NotStalled1:
mov A, #00h
DoneWithCommand1:
anl EPINDEX,#80h ; Point the index back to EP0
mov TXDAT, A
mov TXDAT, #00h
mov TXCNTL, #02
ret
ReturnBadSTDGetEPCommand1:
orl EPCON, #0C0h ; Stall EP0
ReturnSTDGetEPCommand1:
Ret
;COMMENT *------------------------------------------------------------
;Function name : SetUpSinglePacketControlReadStatusStage
;Brief Description : Sets the status in the IN buffer and initilizes all the
; : registers needed to do a single packet control read.
; : This needs to be done so the IN token is processed correctly.
; :
;Regs preserved : No reg. is saved
;--------------------------------------------------------------------*
;SCOPE
SetUpSinglePacketControlReadStatusStage1:
mov wLength1, #00
mov wLength1+1, #00
mov gbSetupSeqRX1, #STATUS_PHASE ; Advance State Machine to next state
mov gbSetupSeqTX1, #DATA_PHASE
setb TXOE ; Enable data transmit
Ret
;COMMENT *------------------------------------------------------------
;Function name : StandardSetEndpointCommand:
;Brief Description : Process a Standard Set Endpoint Command Setup Token
; : This can only be a Set,Clear Feature - Endpoint Stall
; :
;Regs preserved : No reg. is saved
;--------------------------------------------------------------------*
;SCOPE
StandardSetEndpointCommand1:
push EPINDEX
mov A, wIndex1+1 ; Get the endpoint of the stall to clear
anl A, #0Fh ; Find out if this is an EP0 CLear Stall Command.
orl EPINDEX,A ; Setup the EPINDEX to point at correct index.
; Check to make sure this is an Endpoint Stall.
; If it is not then it's a wrong command plus you
; save a few bytes doing it in this order.
mov A, wValue1+1
cjne A, #ENDPOINT_STALL, ReturnBadSTDSetEPCommand1
mov A, bRequest1
cjne A, #CLEAR_FEATURE, CheckSetEndpointFeature1
ClearEndpointFeature1:
;------------------------------------------------
;- CLEAR ENDPOINT STALL
;------------------------------------------------
ClearEndpointStall1:
mov A, wIndex1+1 ; Get the endpoint of the stall to clear
anl A, #0Fh ; Find out if this is an EP0 CLear Stall Command.
JNZ ClearNonEP0Stall1
anl EPCON, #03Fh ; For EP0 Clear both TX & RX stall bits
ljmp ReturnSTDSetEPCommand1
ClearNonEP0Stall1: ; Must be EP1 Clear Stall command.
mov A, wIndex1+1 ; Get the endpoint of the stall to clear
JB ACC.7, ClearInStall1 ; For Non EP0, examing the direction bit as well.
ClearOutStall1:
anl HSTAT, #5Ah ; Clear the stall on Hub EP1
ljmp ReturnSTDSetEPCommand1
ClearInStall1:
anl HSTAT, #5Ah ; Clear the stall on Hub EP1
ljmp ReturnSTDSetEPCommand1
CheckSetEndpointFeature1:
cjne A, #SET_FEATURE, ReturnBadSTDSetEPCommand1
SetEndpointFeature1:
;------------------------------------------------
;- SET ENDPOINT STALL
;------------------------------------------------
SetEndpointStall1:
mov A, wIndex1+1 ; Get the endpoint to stall
JB ACC.7, SetInStall1
SetOutStall1:
orl HSTAT, #20h
ljmp ReturnSTDSetEPCommand1
SetInStall1:
orl HSTAT, #20h
ljmp ReturnSTDSetEPCommand1
ReturnBadSTDSetEPCommand1:
push EPINDEX
mov EPINDEX, #01
mov TXDAT, #14h
mov TXCNTL, #01h
pop EPINDEX
orl EPCON, #0C0h ;Stall EP0
ReturnSTDSetEPCommand1:
pop EPINDEX
ljmp SetUpControlWriteStatusStage1
;COMMENT *------------------------------------------------------------
;Function name : StandardSetDeviceCommand:
;Brief Description : Process a Standard Set Device Command Setup Token
; : The only valid commands are Set Address,
; : Set Configuration. Other commands which have this
; : field but are un-defined are
; : ClearDeviceFeature, SetDescriptor, SetDeviceFeature.
; :
;Regs preserved : No reg. is saved
;--------------------------------------------------------------------*
;SCOPE
StandardSetDeviceCommand1:
mov A, bRequest1
cjne A, #SET_CONFIGURATION, CheckSetDeviceAddress1
SetDeviceConfiguration1:
;------------------------------------------------
;- SET DEVICE CONFIGURATION
;------------------------------------------------
mov A, wValue1+1
CheckConfig0_1:
cjne A, #0, CheckConfig1_1
mov CurrentConfiguration1, R11 ; Set up the variables
mov EPINDEX, #80h
clr HSTAT.4 ; Disbale EP1
ljmp ReturnSTDSetDevice1
CheckConfig1_1:
cjne A, #1, ReturnBadSetDeviceCommand1
mov CurrentConfiguration1, R11 ; Set up the variables
mov EPINDEX, #80h ; Select Hub EP1
setb HSTAT.4 ; Enable EP1 (kls) normally done on SetConfiguration
ljmp ReturnSTDSetDevice1
CheckConfig2_1:
cjne A, #2, ReturnBadSetDeviceCommand1
sjmp ReturnSTDSetDevice1
;------- TBD -------
; Call SetConfiguration
sjmp ReturnSTDSetDevice1
CheckSetDeviceAddress1:
cjne A, #SET_ADDRESS, CheckSetDeviceRWU1
;------------------------------------------------
;- SET DEVICE ADDRESS
;------------------------------------------------
; Set Address should just return. The command will be executed following
; the status stage
sjmp ReturnSTDSetDevice1
CheckSetDeviceRWU1:
cjne A, #SET_FEATURE, CheckClearDeviceRWU1
mov A, wValue1+1
cjne A, #DEVICE_REMOTE_WAKEUP, ReturnBadSetDeviceCommand1
setb HRWUPE ; Enable the hub to respnd to RWU.
sjmp ReturnSTDSetDevice1
CheckClearDeviceRWU1:
cjne A, #CLEAR_FEATURE, ReturnBadSetDeviceCommand1
mov A, wValue1+1
cjne A, #DEVICE_REMOTE_WAKEUP, ReturnBadSetDeviceCommand1
clr HRWUPE ; Disable the hub to respnd to RWU.
sjmp ReturnSTDSetDevice1
ReturnSTDSetDevice1:
ljmp SetUpControlWriteStatusStage1
StandardSetInterfaceCommand1:
mov A, bRequest1
cjne A, #SET_INTERFACE, ReturnBadSetDeviceCommand1
mov A, wValue1+1
orl A, wIndex1+1
jnz ReturnBadSetDeviceCommand1
mov CurrentConfig1Interface1, R11
sjmp ReturnSTDSetDevice1
StandardGetInterfaceCommand1:
mov A, bRequest1
cjne A, #GET_INTERFACE, ReturnBadSetDeviceCommand1
mov A, wValue1+1
jnz ReturnBadSetDeviceCommand1
mov R11, CurrentConfig1Interface1
mov TXDAT, A
mov TXCNTL, #01
ret
StandardSetOtherCommand1:
StandardGetOtherCommand1:
;------------------------------------------
; - Unknown Standard Command -- STALL ENDPOINT
;------------------------------------------
ReturnBadSetDeviceCommand1:
orl EPCON, #0C0h ; Stall Endpoint
ret
;-----------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs
;S
;S END OF STANDARD TYPE COMMANDS
;S
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs
;-----------------------------------------------------------------
;-----------------------------------------------------------------
;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
;C
;C START OF CLASS COMMANDS
;C
;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
;-----------------------------------------------------------------
ClassGetDeviceCommand1:
lcall GetClassDeviceCommand
ret
ClassGetOtherCommand1:
lcall GetClassOtherCommand
ret
ClassSetDeviceCommand1:
lcall SetClassDeviceCommand
lcall SetUpControlWriteStatusStage1 ; We know this will was a single packet only
ret ; command so go ahead and prepare/arm the status stage
ClassSetEndpointCommand1:
ClassSetOtherCommand1:
lcall SetClassOtherCommand
lcall SetUpControlWriteStatusStage1 ; We know this will was a single packet only
; command so go ahead and prepare/arm the status stage
ret
ClassSetInterfaceCommand1:
ClassGetInterfaceCommand1:
ClassGetEndpointCommand1:
;------------------------------------------
; - Unknown Class Command -- STALL ENDPOINT
;------------------------------------------
orl EPCON, #0C0h ;Stall Endpoint
ret
;-----------------------------------------------------------------
;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
;C
;C END OF CLASS COMMANDS
;C
;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
;-----------------------------------------------------------------
;-----------------------------------------------------------------
;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
;V
;V START OF VENDOR COMMANDS
;V
;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
;-----------------------------------------------------------------
VendorSetDeviceCommand1:
VendorGetDeviceCommand1:
ret
VendorSetInterfaceCommand1:
VendorGetInterfaceCommand1:
VendorSetEndpointCommand1:
VendorGetEndpointCommand1:
VendorSetOtherCommand1:
VendorGetOtherCommand1:
;------------------------------------------
; - UnknownVendorCommand -- STALL ENDPOINT
;------------------------------------------
orl EPCON, #0C0h ;Stall Endpoint
ret
;-----------------------------------------------------------------
;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
;V
;V END OF VENDOR COMMANDS
;V
;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
;-----------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -