⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 82930ha.cod

📁 mcs51,2051,x86系列MCU
💻 COD
📖 第 1 页 / 共 5 页
字号:
$$IF$ (EPADDR13 == 131)  
$$IF$ (EPATT13 == 1)        
	mov     EPINDEX, #03
	call    TX3_ISO        
$$END$        
$$END$
$$END$
$$IF$ (BENCFG14 == 1)
$$IF$ (EPADDR14 == 131)  
$$IF$ (EPATT14 == 1)        
	mov     EPINDEX, #03
	call    TX3_ISO        
$$END$        
$$END$
$$END$
$$IF$ (BENCFG15 == 1)
$$IF$ (EPADDR15 == 131)  
$$IF$ (EPATT15 == 1)        
	mov     EPINDEX, #03
	call    TX3_ISO        
$$END$        
$$END$
$$END$
$$IF$ (BENCFG16 == 1)
$$IF$ (EPADDR16 == 131)  
$$IF$ (EPATT16 == 1)        
	mov     EPINDEX, #03
	call    TX3_ISO        
$$END$        
$$END$
$$END$
$$IF$ (BENCFG11 == 1)
$$IF$ (EPADDR11 == 3) 
$$IF$ (EPATT11 == 1)
	mov     EPINDEX, #03
	call    RX3_ISO
$$END$
$$END$
$$END$
$$IF$ (BENCFG12 == 1)
$$IF$ (EPADDR12 == 3) 
$$IF$ (EPATT12 == 1)
	mov     EPINDEX, #03
	call    RX3_ISO
$$END$
$$END$
$$END$
$$IF$ (BENCFG13 == 1)
$$IF$ (EPADDR13 == 3) 
$$IF$ (EPATT13 == 1)
	mov     EPINDEX, #03
	call    RX3_ISO
$$END$
$$END$
$$END$
$$IF$ (BENCFG14 == 1)
$$IF$ (EPADDR14 == 3) 
$$IF$ (EPATT14 == 1)
	mov     EPINDEX, #03
	call    RX3_ISO
$$END$
$$END$
$$END$
$$IF$ (BENCFG15 == 1)
$$IF$ (EPADDR15 == 3) 
$$IF$ (EPATT15 == 1)
	mov     EPINDEX, #03
	call    RX3_ISO
$$END$
$$END$
$$END$
$$IF$ (BENCFG16 == 1)
$$IF$ (EPADDR16 == 3) 
$$IF$ (EPATT16 == 1)
	mov     EPINDEX, #03
	call    RX3_ISO
$$END$
$$END$
$$END$
	pop     EPINDEX                                        
	clr     ASOF
	push    ACC
	mov     A,      P1
	anl     A,      #0F8h
	mov     P1,     A
	mov     A,      SOFH
	anl     A,      #07h
	orl     P1,     A
	pop     ACC
	
ExitSofIsr:

reti
$$END$        



COMMENT *------------------------------------------------------------
Function name     : ProcessOutToken
Brief Description : Services all OUTs on EP0.
		  : This routine checks to see if this is an OUT token or
		  : SETUP token.  If a SETUP token then the Control Command
		  : State machine is initialized to SETUP STAGE
Regs preserved    : No reg. is saved
--------------------------------------------------------------------*
SCOPE
ProcessOutToken:
	mov     A,     EPINDEX

; FUNCTION COMMAND                
	anl     FIFLG,  #EP0_RX_CLR               ; Clear the interrupt bit.
	jmp     ProcCommand

ProcCommand:
	mov     A,     RXSTAT
	jnb     ACC.6, CheckOutStatusPhase       ; Is this a setup packet?

	lCall   SetupReceived
	setb    RXFFRC                           ; Update receive FIFO state
	clr     RXSETUP
       
	jmp     ReturnProcessOutToken

CheckOutStatusPhase:
	mov     A,     gbSetupSeqRX
	cjne    A,     #STATUS_PHASE, CheckDataPhase    ; Is this the status 
						 ; phase of a "GET" command?

	setb    RXFFRC                           ; Update receive FIFO state
	setb    TXCLR                            ; Flush the Transmit FIFOS 
						 ;  in case a null packet is 
						 ;  still left.

	mov     A,      #SETUP_PHASE             ; Update the state machine-
						 ;  Expect a setup packet
	mov     gbSetupSeqRX, A
	mov     gbSetupSeqTX, A
	jmp     ReturnProcessOutToken

	    ;---------------------------------------------------------------
	    ; -   Control Write Data Stage
	    ;---------------------------------------------------------------            
	    
	      ; If this is a control write command then the routine will be 
	      ; called on all data stages of the control write.
	      ; This routine will parse the relevant parts of the code and 
	      ; then direct the call to the approprate recipient.  When the 
	      ; calling code recieves the last packet of data THE CALLING 
	      ; CODE MUST THEN CALL SetUpControlWriteStatusStage to allow
	      ; the status stage to continue.  The user must NOT do this 
	      ; themselves.
	      
CheckDataPhase:
	cjne    A,     #DATA_PHASE, ReturnProcessOutToken ; Are we processing 
							  ; a Control Write, 
							  ; i.e. Set Descr...
;        mov     A, bRequest
;        cjne    A, #EXPECTED_COMMAND_1, CheckCommand2
;        call    USERS_CODE
;        jmp     ReturnProcessOutToken
	
;USERS_CODE:
;        READ DATA FROM FIFO
;        RELASE FIFO by SETTING FFRC BIT
;        IF THIS WAS NOT THE LAST DATA STAGE THEN RETURN
;        ELSE IF THIS WAS THE LAST DATA STAGE AND WE ARE EXPECTING
;        THE STATUS STAGE THEN Call SetUpControlWriteStatusStage and RETURN

CheckCommand2:

ReturnProcessOutToken:
	Ret

COMMENT *------------------------------------------------------------
Function name     : SetupReceived
Brief Description : Service all Setup Tokens recd. on EP0
Regs preserved    : No reg. is saved
--------------------------------------------------------------------*
SCOPE
SetupReceived:
	mov     A,     RXCNT                    ; Get the no. of bytes
	clr     CY

	subb    A,     #SETUP_PACKET_LENGTH
	JNZ     ReturnSetup                      ; If less than 8 bytes recd.
						 ; Return

						 ; Since buffer will reside 
						 ; within the the first 255 
						 ; bytes, can use register 
						 ; indirect addressing
	; Move FIFO to command buffer.
	; Notice byte swapping of word fields
	; For Word Fields make USB Little Endian words->'251 Big Endian words
	clr      EDOVW
	mov      COMMAND_BUFFER,   RXDAT         ; bmRequestType 
	mov      COMMAND_BUFFER+1, RXDAT         ; bRequest
	mov      COMMAND_BUFFER+3, RXDAT         ; wValue LSB
	mov      COMMAND_BUFFER+2, RXDAT         ; wValue MSB
	mov      COMMAND_BUFFER+5, RXDAT         ; wIndex LSB
	mov      COMMAND_BUFFER+4, RXDAT         ; wIndex MSB
	mov      COMMAND_BUFFER+7, RXDAT         ; wLength LSB
	mov      COMMAND_BUFFER+6, RXDAT         ; wLength MSB

	push     DPX                             ; Processing the jump table 
						 ; will corrupt DPX.  Save it 
						 ; here
	lCall    ProcessSetup
	pop      DPX                             ; Restore DPX
ReturnSetup:
	Ret

COMMENT *------------------------------------------------------------
Function name     : ProcessSetup
Brief Description : Process a Setup token recd. on EP0.  
		  : The following simply prepares a byte of data for use in a 
		  : jump table.
		  : The code compresses the 8 byte bmRequestValue into 4 1/2
		  : bits by removing bits 2,3 & 4.  These bits are never used
		  : and it allows the jump table to be significantly smaller.
		  : By using this jump table, the code size reduces by several
		  : hundred bytes over the entire code.
		  : THIS FIRMWARE IS ASSUMES BITS 2,3 & 4 ARE ZERO.
		  : By compressing the byte down, we limit the size
		  : of the jump table.
Regs preserved    : No reg. is saved
--------------------------------------------------------------------*
SCOPE
ProcessSetup:

	; The First step is setting up the Stage tracing variable by examing the 
	; bmRequest value.  This will tell us if this is a control write
	; or control read command.  For right now we will assume that this
	; is a no data command and will therefore pre-initilize the data
	; byte counters used to send data back, to zero.

	mov     gbFControlBufferBytesLeft,     #00h
	mov     gbFControlBufferBytesLeft + 1, #00h
	mov     A,            bmRequestType
	jb      ACC.7,        SetupGetCommand

SetupSetCommand:
	mov     gbSetupSeqRX, #DATA_PHASE        ; Advance State Machine to 
						 ;  next state
	mov     gbSetupSeqTX, #STATUS_PHASE    
	
	jmp     DoJumpTable

SetupGetCommand:
	mov     gbSetupSeqRX, #STATUS_PHASE      ; Advance State Machine to 
						 ;  next state
	mov     gbSetupSeqTX, #DATA_PHASE    

DoJumpTable:
	; This table will jump to the correct subroutine
	; to handle the type of command contained in bmRequestType
	; The new jmp table will be compressed by shifting and rotating
	; out bits, 2,3 & 4. 
	; Place bmRequestType in the following order and then do the jump table
	; on it.
	; xx65107x
	; if bits 65 == 11, Reserved = Error
	
	
	mov     A,      bmRequestType       ; Get the value.
	
	anl     A,      #0E3h               ; Clear out bits 2,3,4 since 
					    ; we don't need these
					    ; Reg A now looks like 765xxx10
	RL      A                           ; Put bits 1,0,& 7 in new placement
	RL      A                           ; Leave LSB cleared so jump is the 
					    ; number of words.
					    ; xxxx1076
CheckBit6:                                  ; 6 is currently in bit 0 position, 
	jnb     ACC.0,  CheckBit5           ; Convert it to bit 5 position        
	setb    ACC.5                       ; xx6x107
 CheckBit5:                                 ; Bit 5 is currently at 7 position
	jnb     ACC.7,  CheckValidType      ; Convert it to bit 4 position        
	setb    ACC.4                       ; xx65107
	
CheckValidType:                              
	jnb     ACC.5,  GoodCommand         ; If this bit (6) is clear we know 
					    ; it's a valid value
	jb      ACC.4,  ReservedCommand     ; Bit (6) was set, if bit 5 is set 
					    ; it's a reserved command.
	jmp     GoodCommand

ReservedCommand:
	orl     EPCON, #0C0h               ; Stall EP0.
	ret

	
					    ; This code will branch to the 
					    ; correct jump statement in the 
					    ; bmRequestJumpTable below. 
GoodCommand:
	anl     A, #1Fh
	mov     DPTR,   #bmRequestJumpTable
	mov     DPXL,   #LOW HIGH16(GoodCommand)     ; Get Page of Jump Table. 
					    ; Low byte of the upper 16 bits 
					    ; of the 32 bit address of the
					    ; jump table.
					    ; Is this code in RAM or ROM
	jmp     @A+DPTR                     ; Used for RISM which places code 
					    ; in RAM

;---------------------------------------
;-- bmRequest Jump Table ---------------
;-- The order of these are based on the 
;-- compresion algorythm used above.
;-- Each of these instructions occupy two 
;-- bytes of ROM.  Do not change AJMP to 
;-- LJMP as the algorytm depends on the 
;-- 2 byte length of AJMP.  LJMP is 3 
;-- bytes long
;-- ------------------------------------
bmRequestJumpTable:
	AJMP    StandardSetDeviceCommand
	AJMP    StandardGetDeviceCommand        
	AJMP    StandardSetInterfaceCommand
	AJMP    StandardGetInterfaceCommand        
	AJMP    StandardSetEndpointCommand
	AJMP    StandardGetEndpointCommand        
	AJMP    StandardSetOtherCommand
	AJMP    StandardGetOtherCommand        

	AJMP    ClassSetDeviceCommand
	AJMP    ClassGetDeviceCommand        
	AJMP    ClassSetInterfaceCommand
	AJMP    ClassGetInterfaceCommand        
	AJMP    ClassSetEndpointCommand
	AJMP    ClassGetEndpointCommand        
	AJMP    ClassSetOtherCommand
	AJMP    ClassGetOtherCommand        

	AJMP    VendorSetDeviceCommand
	AJMP    VendorGetDeviceCommand        
	AJMP    VendorSetInterfaceCommand
	AJMP    VendorGetInterfaceCommand        
	AJMP    VendorSetEndpointCommand
	AJMP    VendorGetEndpointCommand        
	AJMP    VendorSetOtherCommand
	AJMP    VendorGetOtherCommand   

	

	
##82930H enum2#
;-----------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs
;S
;S          STANDARD TYPE COMMANDS FIRST
;S
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs
;-----------------------------------------------------------------

COMMENT *------------------------------------------------------------
Function name     : GetStandardDeviceCommand:        
Brief Description : Process a Get Standard Device Command Setup Token
		  : This can only be a Get (Device or Configuration) Descriptor,
		  : or Get Device Status, Get Configuration.  
Regs preserved    : No reg. is saved
--------------------------------------------------------------------*
SCOPE
StandardGetDeviceCommand:        
	mov     A,     bRequest
	cjne    A,     #GET_DESCRIPTOR, CheckGetConfiguration

	mov     A,     bDescriptorType
	cjne    A,     #DEVICE_DESCR, CheckConfigDescriptor              

	; ********************** GET DESCRIPTOR,  DEVICE *******************
	mov     gbFControlBufferLocation,   #LOW HIGH16(BEGIN_DEVICE_DESCRIPTOR)
	mov     gbFControlBufferLocation+1, #HIGH LOW16(BEGIN_DEVICE_DESCRIPTOR)        
	mov     gbFControlBufferLocation+2, #LOW  LOW16(BEGIN_DEVICE_DESCRIPTOR)        
	mov     A,  #12h
	mov     B,  #00h
	jmp     LoadBuffer

CheckConfigDescriptor:
	cjne    A,     #CONFIG_DESCR, CheckStringDescriptor

	; ********************** GET DESCRIPTOR,  CONFIGURATION ************
	mov     gbFControlBufferLocation,   #LOW HIGH16(BEGIN_CONFIG_DESCRIPTOR)
	mov     gbFControlBufferLocation+1, #HIGH LOW16(BEGIN_CONFIG_DESCRIPTOR)        
	mov     gbFControlBufferLocation+2, #LOW  LOW16(BEGIN_CONFIG_DESCRIPTOR)        
	mov     A,  #LOW  (END_CONFIG_DESCRIPTOR - BEGIN_CONFIG_DESCRIPTOR)
	mov     B,  #HIGH (END_CONFIG_DESCRIPTOR - BEGIN_CONFIG_DESCRIPTOR)        
	jmp     LoadBuffer

CheckStringDescriptor:
	cjne    A,     #STRING_DESCR, ReturnBADSTDGetDeviceCommand
	; ********************** GET DESCRIPTOR,  CONFIGURATION ************
	mov     gbFControlBufferLocation,   #LOW HIGH16(STRING_1)
	mov     gbFControlBufferLocation+1, #HIGH LOW16(STRING_1)
	mov     gbFControlBufferLocation+2, #LOW  LOW16(STRING_1)

	mov     A,     #LOW (STRING_2-STRING_1)
	mov     B,     #HIGH(STRING_2-STRING_1)        
	jmp     LoadBuffer



LoadBuffer:                                 ; Compare to see which is shorter.
					    ; The amount asked for or the amount 
					    ; availible.
	
	push    ACC
	push    B
	clr     CY                          ; A=Actual-wLength=AskedFor
	subb    A,  wLength+1
	mov     A,  B
	subb    A,  wLength
	jc      AskedFor_IsLarger

LengthsMatch:
wLengthIsSmaller:                           ; If Asked for is smaller, replace 
					    ; actual with asked for.
	pop     B
	pop     ACC
	mov     B,  wLength
	mov     A,  wLength+1
	jmp     LoadIt
	
AskedFor_IsLarger:
	pop     B
	pop     ACC
LoadIt:                                     ; From now on, wLength = bytes remaining.
	mov     gbFControlBufferBytesLeft,   B
	mov     gbFControlBufferBytesLeft+1, A
	Call    LoadControlTXFifo
	jmp     ReturnSTDGetDeviceCommand

	



CheckGetConfiguration:
	cjne    A,     #GET_CONFIGURATION, CheckGetStatus
		   ;------------------------------------------------
		   ;- GET CONFIGURATION
		   ;------------------------------------------------

	;------- TBD -------
	jmp     ReturnSTDGetDeviceCommand
CheckGetStatus:
	cjne    A,     #GET_STATUS, ReturnSTDGetDeviceCommand
		   ;------------------------------------------------
		   ;- GET DEVICE STATUS
		   ;------------------------------------------------

	;------- TBD -------        
	jmp     ReturnSTDGetDeviceCommand
ReturnBADSTDGetDeviceCommand:
	orl     EPCON, #0C0h                   ; Stall EP0

ReturnSTDGetDev

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -