?? et44_usb_lib.inc
字號:
JMP UNDEFINE_COMMAND
endif
check_fc_ep80:
MOV A,#EP0RXCSR
check_fc_end:
MOV IAP0,A
MOV A,#0x02
MOV EP0TXCTR,A
N_NOP
CLR wLengthL
CLR wLengthH
MOV A,#0x01
JBS IAC0,SESTALL,ep1_susp
MOV A,#0x00
ep1_susp:
MOV EP0TXDAR,A
N_NOP
MOV A,#0x00
MOV EP0TXDAR,A
N_NOP
RET
SetInterface:
if _USB_HUB == _ENABLE
JBS USB_STATUS,HorF,FcSetInterface
RET
endif
FcSetInterface:
MOV A,IAC0 ;wValueL
MOV A_INTERFACE,A
RET
GetInterface:
if _USB_HUB == _ENABLE
JBS USB_STATUS,HorF,GetFcInterface
MOV A,#1
MOV HEP0TXCTR,A
N_NOP
CLR HwLengthL
CLR HwLengthH
MOV A,#0x00
MOV HEP0TXDAR,A
N_NOP
RET
endif
GetFcInterface:
MOV A,#1
MOV EP0TXCTR,A
N_NOP
CLR wLengthL
CLR wLengthH
MOV A,A_INTERFACE
MOV EP0TXDAR,A
N_NOP
RET
//Hub
GetHubDescriptor:
if _USB_HUB == _ENABLE
MOV A,#High(Hub_class_desc_table<<1)
MOV TBHPTR,A
MOV A,#Low(Hub_class_desc_table<<1)
MOV TBLPTR,A
JMP H_TABLE_READ
else
JMP UNKNOWN_wValueL
endif
ClearHubFeature:
if _USB_HUB == _ENABLE
MOV A,#c_hub_local_power
XOR A,HwValueL
JBS STATUS,Z,ClearLocalPowerChange
MOV A,#c_hub_over_current
XOR A,HwValueL
JBS STATUS,Z,ClearOverCurrentChange
JMP UNKNOWN_wValueL
ClearLocalPowerChange:
BC HSR,LPSC
JMP ClearHubFeature_1
ClearOverCurrentChange:
BC HSR,OVIC
ClearHubFeature_1:
BC STATUS_BUF,HSTSC
N_NOP
RET
else
JMP UNKNOWN_wValueL
endif
SetHubFeature:
if _USB_HUB == _ENABLE
//?????????????
RET
else
JMP UNKNOWN_wValueL
endif
ClearPortFeature:
if _USB_HUB == _ENABLE
//check port number = 1~4 ?
DECA HwIndexL
AND A,#0b11111100
JBC STTS,Z,UNKNOWN_wIndex
MOV A,#port_enable
XOR A,HwValueL
JBS STATUS,Z,ClearPort_ENABLE
MOV A,#port_suspend
XOR A,HwValueL
JBS STATUS,Z,ClearPortSuspend
MOV A,#port_power
XOR A,HwValueL
JBS STATUS,Z,ClearPortPower
MOV A,#1
XOR A,HwIndexL
JBC STATUS,Z,$+3
BC STATUS_BUF,HSTSCP1
MOV A,#2
XOR A,HwIndexL
JBC STATUS,Z,$+3
BC STATUS_BUF,HSTSCP2
MOV A,#3
XOR A,HwIndexL
JBC STATUS,Z,$+3
BC STATUS_BUF,HSTSCP3
MOV A,#4
XOR A,HwIndexL
JBC STATUS,Z,$+3
BC STATUS_BUF,HSTSCP4
MOV A,STATUS_BUF
AND A,#0b00011110
;ZCHK STATUS_BUF
JBC STATUS,Z,ClearPortFeature_change
BS HUB_STATUS,HTX1_INDEX
ClearPortFeature_change:
MOV A,#c_port_connection
XOR A,HwValueL
JBS STATUS,Z,ClearPortConnectionChange
MOV A,#c_port_enable
XOR A,HwValueL
JBS STATUS,Z,ClearPort_ENABLEChange
MOV A,#c_port_suspend
XOR A,HwValueL
JBS STATUS,Z,ClearPortSuspendChange
MOV A,#c_port_over_current
XOR A,HwValueL
JBS STATUS,Z,ClearPortOverCurrentChange
MOV A,#c_port_reset
XOR A,HwValueL
JBS STATUS,Z,ClearPortResetChange
JMP UNKNOWN_wValueL
ClearPort_ENABLE:
MOV A,#0b10011000
ADD A,HwIndexL
MOV HPCONR,A
N_NOP
RET
ClearPortSuspend:
MOV A,#0b10100000
ADD A,HwIndexL
MOV HPCONR,A
N_NOP
RET
ClearPortPower:
MOV A,#0b10101000
ADD A,HwIndexL
MOV HPCONR,A
N_NOP
; RET ;for pass USB check.
ClearPortConnectionChange:
CALL SEARCH_CHANGE_PORT
BC IAC0,PCSTSC
N_NOP
RET
SEARCH_CHANGE_PORT:
MOV A,#HPSR4
ADD A,HwIndexL
MOV IAP0,A
RET
ClearPort_ENABLEChange:
CALL SEARCH_CHANGE_PORT
BC IAC0,PENSTSC
N_NOP
RET
ClearPortSuspendChange:
CALL SEARCH_CHANGE_PORT
BC IAC0,PSUSSTSC
N_NOP
RET
ClearPortOverCurrentChange:
CALL SEARCH_CHANGE_PORT
BC IAC0,POCIC
N_NOP
RET
ClearPortResetChange:
CALL SEARCH_CHANGE_PORT
BC IAC0,PRTSTSC
N_NOP
RET
else
JMP UNKNOWN_wValueL
endif
SetPortFeature:
if _USB_HUB == _ENABLE
//check port number = 1~4 ?
DECA HwIndexL
AND A,#0b11111100
JBC STTS,Z,UNKNOWN_wIndex
MOV A,#port_reset
XOR A,HwValueL
JBS STATUS,Z,SetPortReset
MOV A,#port_power
XOR A,HwValueL
JBS STATUS,Z,SetPortPower
MOV A,#port_suspend
XOR A,HwValueL
JBS STATUS,Z,SetPortSuspend
RET
SetPortSuspend:
DECA HwIndexL
JBC STATUS,Z,not_port1_susp
; BC GCNTR,FUNEN
N_NOP
not_port1_susp:
MOV A,#0b10000000
ADD A,HwIndexL
MOV HPCONR,A
N_NOP
RET
SetPortReset:
MOV A,#0b10001000
ADD A,HwIndexL
MOV HPCONR,A
N_NOP
//Embedded port?
DECA HwIndexL
JBC STTS,Z,SPR_NOT_EMBEDDED_F
BS GCNTR,FUNRST
N_NOP
CLR FAR ;SOTA FIXED OK 010924
N_NOP ;DON'T CLEAR HERE FOR AVOIDE TO GET ADDR0 (CLEAR IN CLEAR_PORT_RESET)
CLR ADDRESS_BUFf
; BC HINTE,SOFINT
; N_NOP
SPR_NOT_EMBEDDED_F:
RET
SetPortPower:
MOV A,#0b10010000
ADD A,HwIndexL
MOV HPCONR,A
N_NOP
RET
else
JMP UNKNOWN_wValueL
endif
GetBusState:
if _USB_HUB == _ENABLE
MOV A,#1
MOV HEP0TXCTR,A
N_NOP
CLR HwLengthL
CLR HwLengthH
DECA HwIndexL
AND A,#0b11111100
JBC STTS,Z,UNKNOWN_wIndex
MOV A,HwIndexL
TBL
JMP Port1State
JMP Port2State
JMP Port3State
Port4State:
RLCA HPSTAR1,3
JMP put_data
Port1State:
MOV A,HPSTAR1
JMP PUT_DATA
Port3State:
SHRA HPSTAR1,4
JMP PUT_DATA
Port2State:
SHRA HPSTAR1,2
put_data:
AND a,#0b00000011
JBC STATUS,Z,Dm_Dp_newData
FILLIN_HEP0TXDAR:
MOV HEP0TXDAR,A
N_NOP
RET
Dm_Dp_newData:
xor A,#0b00000011
JMP FILLIN_HEP0TXDAR
else
JMP UNKNOWN_wValueL
endif
GetHubStatus:
if _USB_HUB == _ENABLE
MOV A,#4
MOV HEP0TXCTR,A
N_NOP
CLR HwLengthL
CLR HwLengthH
MOV A,HSR
AND A,#0b00000011
MOV HEP0TXDAR,A
N_NOP
MOV A,#0x00
MOV HEP0TXDAR,A
N_NOP
MOV A,HSR
SHRA HSR,2
AND A,#0b00000011
MOV HEP0TXDAR,A
N_NOP
MOV A,#0x00
MOV HEP0TXDAR,A
N_NOP
RET
else
JMP UNKNOWN_wValueL
endif
GetPortStatus:
if _USB_HUB == _ENABLE
//check port number = 1~4 ?
DECA HwIndexL
AND A,#0b11111100
JBC STTS,Z,UNKNOWN_wIndex
MOV A,#4
MOV HEP0TXCTR,A
N_NOP
CLR HwLengthL
CLR HwLengthH
MOV A,#HSR
ADD A,HwIndexL
MOV IAP0,A
NOP
MOV A,IAC0
DEC IAP0
AND A,#0b00011111
MOV HEP0TXDAR,A
N_NOP
RLCA IAC0,4
AND A,#0b00000011
MOV HEP0TXDAR,A
N_NOP
MOV A,#HPSR4-HSR-1
ADD IAP0,A
NOP
MOV A,IAC0
AND A,#0b00011111
MOV HEP0TXDAR,A
N_NOP
MOV A,#0b00000000
MOV HEP0TXDAR,A
N_NOP
RET
else
JMP UNKNOWN_wValueL
endif
GetReport:
BS FC_STATUS,TBorREG_INDEX
_ADD_USB_GET_REPORT_SUB
RET
SetReport:
BS FC_STATUS,DATA_OUT
RET
SetIdleReport:
MOV A,wValueH
MOV IDLE_TIMER,A
CLR EP0TXCTR
N_NOP
RET
GetIdleReport:
MOV A,#1
MOV EP0TXCTR,A
N_NOP
MOV A,IDLE_TIMER
MOV EP0TXDAR,A
N_NOP
RET
SetProtocolReport:
MOV A,wValueL
MOV PROTOCOL,A
CLR EP0TXCTR
N_NOP
RET
GetProtocolReport:
MOV A,#1
MOV EP0TXCTR,A
N_NOP
MOV A,PROTOCOL
MOV EP0TXDAR,A
N_NOP
RET
STRING_COMMAND:
MOV A,wValueL
JBS STATUS,Z,String_langid
if _USB_HD_iManufacture != 0
MOV A,#_USB_HD_iManufacture
XOR A,wValueL
JBS STATUS,Z,String_index_HManufacture
endif
if _USB_HD_iProduct != 0
MOV A,#_USB_HD_iProduct
XOR A,wValueL
JBS STATUS,Z,String_index_HProduct
endif
if _USB_HD_iSerialNumber != 0
MOV A,#_USB_HD_iSerialNumber
XOR A,wValueL
JBS STATUS,Z,String_index_HSerialNumber
endif
if _USB_HC_iConfiguration != 0
MOV A,#_USB_HC_iConfiguration
XOR A,wValueL
JBS STATUS,Z,String_index_HConfiguration
endif
if _USB_HI_iInterface != 0
MOV A,#_USB_HI_iInterface
XOR A,wValueL
JBS STATUS,Z,String_index_HInterface
endif
if _USB_DD_iManufacture != 0
MOV A,#_USB_DD_iManufacture
XOR A,wValueL
JBS STATUS,Z,String_index_DManufacture
endif
if _USB_DD_iProduct != 0
MOV A,#_USB_DD_iProduct
XOR A,wValueL
JBS STATUS,Z,String_index_DProduct
endif
if _USB_DD_iSerialNumber != 0
MOV A,#_USB_DD_iSerialNumber
XOR A,wValueL
JBS STATUS,Z,String_index_DSerialNumber
endif
if _USB_CD_iConfiguration != 0
MOV A,#_USB_CD_iConfiguration
XOR A,wValueL
JBS STATUS,Z,String_index_DConfiguration
endif
; if _USB_ID_iInterface0 != 0 ;
; MOV A,#_USB_ID_iInterface0
; XOR A,wValueL
; JBS STATUS,Z,String_index_DInterface
; endif
//else
JMP UNKNOWN_wValueL
//only for HID report descriptor
HID_report_descriptor:
if _RT0X81_R0X06_Value2100 == _ENABLE
MOV A,#HID
XOR A,wValueH
JBS STATUS,Z,Descriptor_type_21
endif
if _RT0X81_R0X06_Value2200 == _ENABLE
MOV A,#REPORT
XOR A,wValueH
JBS STATUS,Z,Descriptor_type_22
endif
if _RT0X81_R0X06_Value2300 == _ENABLE
MOV A,#PHYSCIAL
XOR A,wValueH
JBS STATUS,Z,Descriptor_type_23
endif
//else
JMP UNKNOWN_wValueL
Descriptor_type_21:
MOV A,#0x00
XOR A,wIndexL
JBS STATUS,Z,Descriptor_type_21_index00
if _USB_CD_bNumInterface == 2
MOV A,#0x01
XOR A,wIndexL
JBS STATUS,Z,Descriptor_type_21_index01
endif
//else
JMP UNKNOWN_wValueL
Descriptor_type_21_index00:
_ADD_USB_HID_DESCRIPTION_SUB
if _USB_CD_bNumInterface == 2
Descriptor_type_21_index01:
_ADD_USB_HID_DESCRIPTION_SUB1
endif
Descriptor_type_22:
MOV A,#0x00
XOR A,wIndexL
JBS STATUS,Z,Descriptor_type_22_index00
if _USB_CD_bNumInterface == 2
MOV A,#0x01
XOR A,wIndexL
JBS STATUS,Z,Descriptor_type_22_index01
endif
//else
JMP UNKNOWN_wValueL
Descriptor_type_22_index00:
_ADD_USB_HID_REPORT_SUB1
Descriptor_type_22_index01:
if _USB_CD_bNumInterface == 2
_ADD_USB_HID_REPORT_SUB2
endif
Descriptor_type_23:
_ADD_USB_HID_PHYSCIAL_SUB
String_langid:
MOV A,#High(String_langid_table<<1)
MOV TBHPTR,A
MOV A,#Low(String_langid_table<<1)
MOV TBLPTR,A
JMP F_TABLE_READ
String_index_HManufacture:
_ADD_USB_STRING_INDEX_HM
String_index_HProduct:
_ADD_USB_STRING_INDEX_HP
String_index_HSerialNumber:
_ADD_USB_STRING_INDEX_HS
String_index_HConfiguration:
_ADD_USB_STRING_INDEX_HC
String_index_HInterface:
_ADD_USB_STRING_INDEX_HI
String_index_DManufacture:
_ADD_USB_STRING_INDEX_HM
String_index_DProduct:
_ADD_USB_STRING_INDEX_HP
String_index_DSerialNumber:
_ADD_USB_STRING_INDEX_HS
String_index_DConfiguration:
_ADD_USB_STRING_INDEX_HC
String_index_DInterface:
_ADD_USB_STRING_INDEX_HI
//*********************************************************
// DESCRIPTION TABLE FOR HUB
//*********************************************************
Hub_device_desc_table:
DB _USB_HD_bLength,_USB_HD_bDescriptorType
DW _USB_HD_bcdUSB
DB _USB_HD_bDeviceClass,_USB_HD_bDeviceSubClass
DB _USB_HD_bDeviceProtocol,_USB_HD_bMaxPacketSize0
DW _USB_HD_idVender
DW _USB_HD_idProduct
DW _USB_HD_bcdDevice
DB _USB_HD_iManufacture,_USB_HD_iProduct
DB _USB_HD_iSerialNumber,_USB_HD_bNumConfiguration
Hub_config_desc_table:
DB _USB_HC_bLength,_USB_HC_bDescriptorType
DW _USB_HC_wTotalLength
DB _USB_HC_bNumInterface,_USB_HC_bConfigurationValue
DB _USB_HC_iConfiguration,_USB_HC_bmAttributes
DB _USB_HC_MaxPower,_USB_HI_bLength
DB _USB_HI_bDescriptorType,_USB_HI_bInterfaceNumber
DB _USB_HI_bAlternateSetting,_USB_HI_bNumEndpoints
DB _USB_HI_bInterfaceClass,_USB_HI_bInterfaceSubClass
DB _USB_HI_bInterfaceProtocol,_USB_HI_iInterface
DB _USB_HE_bLength1,_USB_HE_bDescriptorType1
DB _USB_HE_bEndpointAddress1,_USB_HE_bmAttributes1
DW _USB_HE_wMaxPacketSize1
DB _USB_HE_bInterval1
Hub_class_desc_table:
DB _USB_HU_bDescLength,_USB_HU_bDescriptorType
DB _USB_HU_bNbrPorts,_USB_HU_bHubCharacteristics%256
DB _USB_HU_bHubCharacteristics/256,_USB_HU_bPwrOn2PwrGood
DB _USB_HU_bHubContrCurrent,_USB_HU_DeviceRemovable
DB _USB_HU_PortPwrCtrlMask
//=========================================================
// Descriptor table for DEVICE
//=========================================================
Fc_device_desc_table:
DB _USB_DD_bLength,_USB_DD_bDescriptorType
DW _USB_DD_bcdUSB
DB _USB_DD_bDeviceClass,_USB_DD_bDeviceSubClass
DB _USB_DD_bDeviceProtocol,_USB_DD_bMaxPacketSize0
DW _USB_DD_idVender
DW _USB_DD_idProduct
DW _USB_DD_bcdDevice
DB _USB_DD_iManufacture,_USB_DD_iProduct
DB _USB_DD_iSerialNumber,_USB_DD_bNumConfiguration
String_langid_table:
DB 0x04,string
DW _USB_String_LANGUAGE_ID
;============================================================
;Copyright c 2004 by ETOMS Electronics Corp. All right reserved.
;No part of this computer program may be reproduced, stored in a retrieval system, or
;transmitted in any form or by any means, electronic, mechanical, photocopying,
;recording, scanning or otherwise, except as permitted under ETOMS authorization.
;セ筿福祘Αぇ帝
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -