?? myusb_std.asm
字號:
; bRequest : SET_CONFIGURATION = 09h
; wValue : CONFIGURATION_VALUE = --xxh
; wIndex : RESERVED = 0000h
; wLength : RESERVED = 0000h
;
; The SET_DEVICE_CONFIGURATION request selects a device
; configuration to be activated as the current configuration.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_h2d_std_dev_09 & USB_UM_SUPPLIED)
export myUSB_CB_h2d_std_dev_09
myUSB_CB_h2d_std_dev_09:
CALL myUSB_GET_DEVICE_TABLE_ENTRY ; Get the selected device
MOV [myUSB_t2],myUSB_t1 ; Set the GETWORD destination
CALL myUSB_GETWORD ; Get the pointer to the CONFIG_LOOKUP table
; ITempW has the address
MOV A, REG[myUSB_EP0DATA+wValueLo] ; Get the configuration number
MOV [myUSB_t2],A ; Save it
MOV A, [myUSB_t1] ; Get the CONFIG_LOOKUP ROM Address MSB
MOV X, [myUSB_t1+1] ; Get the CONFIG_LOOKUP ROM Address LSB
ROMX ; First entry is the table size (only a byte)
CMP A, [myUSB_t2] ; Range check
JC myUSB_Not_Supported
; Refactored from the two loops below
MOV [myUSB_Configuration],[myUSB_t2] ; Save the config number
CMP [myUSB_t2], 0 ; Unconfigure?
JZ .unconfigure
; Flow here to configure the endpoints
MOV A, [myUSB_t1] ; Get the CONFIG_LOOKUP ROM Address MSB
MOV X, [myUSB_t1+1] ; Get the CONFIG_LOOKUP ROM Address LSB
INC X ; Point to the first table entry
ADC A, 0 ;
MOV [myUSB_t2], myUSB_t1 ; Set up the destination
CALL myUSB_GETWORD ; Get the pointer to the CONFIG_LOOKUP table
; ITempW has the address
MOV X, 0 ; Start the index at 0, but we INC first
.configure_next:
INC X ; Do the next one
PUSH X ; Save the endpoint number
MOV A, [myUSB_t1] ; Get the CONFIG_LOOKUP ROM Address MSB
MOV X, [myUSB_t1+1] ; Get the CONFIG_LOOKUP ROM Address LSB
ROMX
INC [myUSB_t1+1] ; Point to the next
ADC [myUSB_t1], 0 ;
POP X
CALL ConfigureEP ; X contains the EP number
; A contains the EP Direction
MOV A, X ;
CMP A, USB_MAX_EP_NUMBER ; Configure each of the endpoints
JNZ .configure_next ; Do another one?
; Flow here when we are done
JMP .done
; Jump here to unconfigure the endpoints
.unconfigure:
MOV X, USB_MAX_EP_NUMBER ; Configure each of the endpoints
.unconfigure_next:
MOV [X+myUSB_EndpointAPIStatus], NO_EVENT_ALLOWED ; For the API
MOV REG[X+EP0MODE], USB_MODE_DISABLE ; Disable the endpoint
DEC X ; One more down
JNZ .unconfigure_next ; Don't unconfigure EP0
.done:
JMP myUSB_NoDataStageControlTransfer_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_d2h_std_ifc_00
;
; DESCRIPTION: Get Interface Status
;
;****************************************************************
; STANDARD INTERFACE IN REQUEST: Get_Interface_Status
;****************************************************************
;
; bmRequestType : (IN | STANDARD | INTERFACE) = 81h
; bRequest : GET_STATUS = 00h
; wValue : RESERVED = 0000h
; wIndex : INTERFACE = --xxh
; wLength : SIZEOF_INTERFACE_STATUS = 0002h
;
; The GET_INTERFACE_STATUS request returns status for the
; specified interface.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_d2h_std_ifc_00 & USB_UM_SUPPLIED)
.LITERAL
GetInterfaceStatusTransferDescrTable:
TD_START_TABLE 1 ; One entry
TD_ENTRY USB_DS_RAM, 2, myUSB_TransferBuffer, NULL_PTR ; Reuse the transfer buffer
.ENDLITERAL
export myUSB_CB_d2h_std_ifc_00
myUSB_CB_d2h_std_ifc_00:
MOV [myUSB_TransferBuffer], 0 ; Zero the transfer buffer
MOV [myUSB_TransferBuffer+1], 0 ;
MOV [myUSB_t2], 0 ; Use the UM temp var--Selector
MOV A,>GetInterfaceStatusTransferDescrTable ; Get the ROM Address MSB
MOV X,<GetInterfaceStatusTransferDescrTable ; Get the ROM Address LSB
JMP myUSB_GetTableEntry_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_d2h_std_ifc_10
;
; DESCRIPTION: Get Interface
;
;****************************************************************
; STANDARD INTERFACE IN REQUEST: Get_Interface
;****************************************************************
;
; bmRequestType : (IN | STANDARD | INTERFACE) = 81h
; bRequest : GET_INTERFACE = 0Ah
; wValue : RESERVED = 0000h
; wIndex : INTERFACE = xxxxh
; wLength : SIZEOF_GET_INTERFACE = 0001h
;
; The GET_INTERFACE request returns the selected alternate
; setting for the specified interface.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_d2h_std_ifc_10 & USB_UM_SUPPLIED)
.LITERAL
GetInterfaceTransferDescrTable:
TD_START_TABLE 1 ; One entry
TD_ENTRY USB_DS_RAM, 1, myUSB_TransferBuffer, NULL_PTR ; Reuse the transfer buffer
.ENDLITERAL
export myUSB_CB_d2h_std_ifc_10
myUSB_CB_d2h_std_ifc_10:
MOV A, REG[myUSB_EP0DATA+wIndexLo] ; Get the interface number
CMP A, 2 ; Valid interface number? (UM Parameter: NumInterfaces)
JNC myUSB_Not_Supported
MOV X, A ; The interface number is the index into alternates settings table
MOV A, [X + myUSB_InterfaceSetting] ; Save the current interface setting
MOV [myUSB_TransferBuffer], A ; into the transfer buffer
MOV [myUSB_t2], 0 ; Use the UM temp var--Selector
MOV A,>GetInterfaceTransferDescrTable ; Get the ROM Address MSB
MOV X,<GetInterfaceTransferDescrTable ; Get the ROM Address LSB
JMP myUSB_GetTableEntry_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_d2h_std_ep_00
;
; DESCRIPTION: Get Endpoint Status
;
;****************************************************************
; STANDARD ENDPOINT IN REQUEST: Get_Endpoint_Status
;****************************************************************
;
; bmRequestType : (IN | STANDARD | ENDPOINT) = 82h
; bRequest : GET_STATUS = 00h
; wValue : RESERVED = 0000h
; wIndex : ENDPOINT = 00xxh
; wLength : SIZEOF_ENDPOINT_STATUS = 0002h
;
; The GET_ENDPOINT_STATUS request returns status for the specified
; endpoint.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_d2h_std_ep_00 & USB_UM_SUPPLIED)
export myUSB_CB_d2h_std_ep_00
myUSB_CB_d2h_std_ep_00:
MOV A, REG[myUSB_EP0DATA+wIndexLo] ; Get the endpoint number
AND A, ~USB_DIR_IN ; Strip off the direction bit
CMP A, USB_NUM_ENDPOINTS ; Range check
JNC myUSB_Not_Supported
MOV X, A ; The endpoint number is the index
MOV [myUSB_t2], 0 ; Use the UM temp var--Selector
MOV [myUSB_TransferBuffer + 1], 0 ; Use the UM Transfer Buffer
MOV A, [X + myUSB_EndpointStatus] ; Get the status
MOV [myUSB_TransferBuffer], A ; Save it in the report
MOV A,>GetStatusTransferDescrTable ; Get the ROM Address MSB
MOV X,<GetStatusTransferDescrTable ; Get the ROM Address LSB
JMP myUSB_GetTableEntry_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_h2d_std_ep_01
;
; DESCRIPTION: Clear Endpoint Feature
;
;****************************************************************
; STANDARD ENDPOINT OUT REQUEST: Clear_Endpoint_Feature
;****************************************************************
;
; bmRequestType : (OUT | STANDARD | ENDPOINT) = 02h
; bRequest : CLEAR_FEATURE = 01h
; wValue : FEATURE_SELECTOR = --xxh
; wIndex : ENDPOINT = 00xxh
; wLength : RESERVED = 0000h
;
; The CLEAR_ENDPOINT_FEATURE request disables a particular
; feature for an endpoint.
;
; The only feature supported for an endpoint is the EP_HALT
; feature.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_h2d_std_ep_01 & USB_UM_SUPPLIED)
export myUSB_CB_h2d_std_ep_01
myUSB_CB_h2d_std_ep_01:
MOV A, REG[myUSB_EP0DATA+wValueLo] ; Get the feature selector
CMP A, USB_ENDPOINT_HALT ; Halt is the only selector defined for endpoints
JNZ myUSB_Not_Supported
MOV A, REG[myUSB_EP0DATA+wIndexLo] ; Get the Endpoint number
AND A, ~USB_DIR_IN ; Strip off the direction bit
CMP A, 0 ; Since we can't halt the Control Endpoint
JZ .done
CMP A, USB_NUM_ENDPOINTS ; Range check
JNC myUSB_Not_Supported
MOV X, A ; Endpoint number is the index
AND [X+myUSB_EndpointStatus], ~USB_ENDPOINT_STATUS_HALT ; Clear the endpoint halt
TST REG[myUSB_EP0DATA+wIndexLo], USB_DIR_IN ; IN or OUT endpoint?
JNZ .in
MOV REG[X + myUSB_EP0MODE], USB_MODE_NAK_OUT ; NAK the endpoint
JMP .done
.in:
MOV REG[X + myUSB_EP0MODE], USB_MODE_NAK_IN ; NAK the endpoint
.done:
JMP myUSB_NoDataStageControlTransfer_Local_Std
ENDIF
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -