?? myusb_std.asm
字號(hào):
;-----------------------------------------------------------------------------
;
; 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_dev_06 & USB_UM_SUPPLIED)
export myUSB_CB_d2h_std_dev_06
myUSB_CB_d2h_std_dev_06:
;-----------------------------------------------------------------------------
; Dispatch to the proper handler
;-----------------------------------------------------------------------------
MOV A, REG[myUSB_EP0DATA+wValueHi] ; Get the descrptor type
ASL A ; Make it into a offset
CMP A, GET_DESCR_DISPATCH_SIZE ; Validity check
JNC myUSB_Not_Supported
JACC GET_DESCR_DISPATCH
GET_DESCR_DISPATCH:
JMP myUSB_Not_Supported ; Invalid
JMP myUSB_SendDeviceDescr ; Device Descriptor
JMP myUSB_SendConfigDescr ; Configuration Descriptor
IF myUSB_bNumStringDescrs ; Number of String Descriptor defined with the Wizard
JMP myUSB_SendStringDescr ; String Descriptor
ELSE
JMP myUSB_Not_Supported ; Not supported if we don't have
; any String Descriptor
ENDIF
GET_DESCR_DISPATCH_END:
GET_DESCR_DISPATCH_SIZE: EQU (GET_DESCR_DISPATCH_END - GET_DESCR_DISPATCH)
;-----------------------------------------------------------------------------
; Configuration Descriptor Handler
;-----------------------------------------------------------------------------
myUSB_SendConfigDescr:
CALL myUSB_GET_DEVICE_TABLE_ENTRY
SWAP A, X
ADD A, 2 ; We want the pointer to the descriptor table (second entry)
SWAP A, X
ADC A, 0 ; Don't forget the carry
MOV [myUSB_t2], myUSB_t1 ; Set up the destination
CALL myUSB_GETWORD ; Get the pointer
MOV A, [myUSB_t1] ; Pointer MSB
MOV X, [myUSB_t1+1] ; Pointer LSB
PUSH A ; Save the MSB
MOV A, REG[myUSB_EP0DATA+wValueLo] ; Get the descrptor index
MOV [myUSB_t2], A ; Use the UM temp var--Selector
POP A ; Need the MSB for the range check
PUSH A ; Save the MSB for after the range check
ROMX ; First entry is the table size (only a byte)
CMP A, [myUSB_t2] ; Range check
JNC .range_ok
POP A ; Fix the stack
JMP myUSB_Not_Supported
.range_ok:
POP A ; Get the MSB back
JMP myUSB_GetTableEntry_Local_Std
;-----------------------------------------------------------------------------
; Device Descriptor Handler
;-----------------------------------------------------------------------------
myUSB_SendDeviceDescr:
MOV [myUSB_t2], [myUSB_bCurrentDevice] ; Use the UM temp var--Selector
MOV A,>myUSB_DEVICE_DESCR_TABLE ; Get the ROM Address MSB
MOV X,<myUSB_DEVICE_DESCR_TABLE ; Get the ROM Address LSB
ROMX ; First entry is the table size (only a byte)
CMP A, [myUSB_t2] ; Range check
JC myUSB_Not_Supported
MOV A,>myUSB_DEVICE_DESCR_TABLE ; Get the ROM Address MSB
JMP myUSB_GetTableEntry_Local_Std
;-----------------------------------------------------------------------------
; String Descriptor Handler
;-----------------------------------------------------------------------------
IF myUSB_bNumStringDescrs ; Not needed if we don't have any String Descriptors
myUSB_SendStringDescr:
MOV A, REG[myUSB_EP0DATA+wValueLo] ; Get the descrptor index
MOV [myUSB_t2], A ; Use the UM temp var--Selector
MOV A,>myUSB_StringTable ; Get the ROM Address MSB
MOV X,<myUSB_StringTable ; Get the ROM Address LSB
ROMX ; First entry is the table size (only a byte)
CMP A, [myUSB_t2] ; Range check
JC myUSB_Not_Supported
MOV A,>myUSB_StringTable ; Get the ROM Address MSB
JMP myUSB_GetTableEntry_Local_Std
ENDIF
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_d2h_std_dev_08
;
; DESCRIPTION: Get Device Configuration
;
;****************************************************************
; STANDARD DEVICE IN REQUEST: Get_Device_Configuration
;****************************************************************
;
; bmRequestType : (IN | STANDARD | DEVICE) = 80h
; bRequest : GET_CONFIGURATION = 08h
; wValue : RESERVED = 0000h
; wIndex : RESERVED = 0000h
; wLength : SIZEOF_DEVICE_CONFIGURATION = 0001h
;
; The GET_DEVICE_CONFIGURATION request returns the currently
; selected device configuration number.
;
; request_value and request_index contain 0000h. request_length
; contains 0001h and the one-byte configuration number is returned
; in a separate data transfer.
;
;-----------------------------------------------------------------------------
;
; 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_dev_08 & USB_UM_SUPPLIED)
.LITERAL
GetConfigTransferDescrTable:
TD_START_TABLE 1 ; One entry
TD_ENTRY USB_DS_RAM, 1, myUSB_Configuration, NULL_PTR ; Current configuration
.ENDLITERAL
export myUSB_CB_d2h_std_dev_08
myUSB_CB_d2h_std_dev_08:
MOV [myUSB_t2], 0 ; Use the UM temp var--Selector
MOV A,>GetConfigTransferDescrTable ; Get the ROM Address MSB
MOV X,<GetConfigTransferDescrTable ; Get the ROM Address LSB
JMP myUSB_GetTableEntry_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_h2d_std_dev_01
;
; DESCRIPTION: Clear Device Feature
;
;****************************************************************
; STANDARD DEVICE OUT REQUEST: Clear_Device_Feature
;****************************************************************
;
; bmRequestType : (OUT | STANDARD | DEVICE) = 00h
; bRequest : CLEAR_FEATURE = 01h
; wValue : FEATURE_SELECTOR = --xxh
; wIndex : RESERVED = 0000h
; wLength : RESERVED = 0000h
;
; The CLEAR_DEVICE_FEATURE request disables a particular feature
; for a device. The only feature supported for a device is the
; REMOTE_WAKEUP 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_dev_01 & USB_UM_SUPPLIED)
export myUSB_CB_h2d_std_dev_01
myUSB_CB_h2d_std_dev_01:
MOV A, REG[myUSB_EP0DATA+wValueLo] ; Get the Feature Selector
; Check against valid features
; for device receipient
CMP A, USB_DEVICE_REMOTE_WAKEUP ; Only remote wakeup is defined for clear
JNZ myUSB_Not_Supported ;
AND [myUSB_DeviceStatus], ~USB_DEVICE_STATUS_REMOTE_WAKEUP
JMP myUSB_NoDataStageControlTransfer_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_h2d_std_dev_03
;
; DESCRIPTION: Set Device Featue
;
;****************************************************************
; STANDARD DEVICE OUT REQUEST: Set_Device_Feature
;****************************************************************
;
; bmRequestType : (OUT | STANDARD | DEVICE) = 00h
; bRequest : SET_FEATURE = 03h
; wValue : FEATURE_SELECTOR = --xxh
; wIndex : RESERVED = 0000h
; wLength : RESERVED = 0000h
;
; The SET_DEVICE_FEATURE request enables a particular feature
; on a device. The only feature supported for a device is the
; REMOTE_WAKEUP 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_dev_03 & USB_UM_SUPPLIED)
export myUSB_CB_h2d_std_dev_03
myUSB_CB_h2d_std_dev_03:
MOV A, REG[myUSB_EP0DATA+wValueLo] ; Get the Feature Selector
; Check against valid features
; for device receipient
CMP A, USB_DEVICE_REMOTE_WAKEUP ; Remote wakeup?
JZ .remote_wakeup
CMP A, USB_TEST_MODE ; Test Mode
JZ .test_mode
; Flow here for any other selector is invalid for device receipient
JMP myUSB_Not_Supported
; Jump here to enable remote wake up
.remote_wakeup:
OR [myUSB_DeviceStatus], USB_DEVICE_STATUS_REMOTE_WAKEUP
JMP .finish
; Jump here to enable test mode
.test_mode:
JMP myUSB_Not_Supported
.finish:
JMP myUSB_NoDataStageControlTransfer_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_h2d_std_dev_05
;
; DESCRIPTION: Set Device Address
;
;****************************************************************
; STANDARD DEVICE OUT REQUEST: Set_Device_Address
;****************************************************************
;
; bmRequestType : (OUT | STANDARD | DEVICE) = 00h
; bRequest : SET_ADDRESS = 05h
; wValue : DEVICE_ADDRESS = 00xxh
; wIndex : RESERVED = 0000h
; wLength : RESERVED = 0000h
;
; The SET_DEVICE_ADDRESS request sets the USB device address
; for all future USB accesses.
;
;****************************************************************
;
;-----------------------------------------------------------------------------
;
; 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_05 & USB_UM_SUPPLIED)
export myUSB_CB_h2d_std_dev_05
myUSB_CB_h2d_std_dev_05:
MOV [myUSB_fDataPending], USB_ADDRESS_CHANGE_PENDING
MOV A, REG[myUSB_EP0DATA+wValueLo]
MOV [myUSB_TransferBuffer],A
JMP myUSB_NoDataStageControlTransfer_Local_Std
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: myUSB_CB_h2d_std_dev_09
;
; DESCRIPTION: Set Configuration
;
;****************************************************************
; STANDARD DEVICE OUT REQUEST: Set_Device_Configuration
;****************************************************************
;
; bmRequestType : (OUT | STANDARD | DEVICE) = 00h
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -