dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2403回复:15

那位大哥能给一个52+d12的固件的例子(asm51)的,我都快疯掉了

楼主#
更多 发布于:2002-11-20 10:51
就算是调试还有错误的也没关系,主要是有许多问题不知如何下手,想看看格式阿,有些数据啊,命令是怎么处理的!!

拜托拜托了!

happycw@eyou.com

最新喜欢:

changjtchangj...
lvwj
驱动老牛
驱动老牛
  • 注册日期2001-08-21
  • 最后登录2021-01-31
  • 粉丝0
  • 关注0
  • 积分13分
  • 威望181点
  • 贡献值0点
  • 好评度52点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2002-11-20 13:57
同志,斑竹早把资源公开了.
你到 zboard 论坛看看吧.
www.bjjcz.com
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-11-20 15:07
我要的是asm51的程序!!那个是c的呀。不过还是很感谢你的回答。
poplar
驱动牛犊
驱动牛犊
  • 注册日期2001-05-04
  • 最后登录2007-01-08
  • 粉丝0
  • 关注0
  • 积分20分
  • 威望2点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-11-24 02:20
不信吧,到www.intel.com上面去找找,我以前在上面下载过的,
要不www.lvr.com上也能找到。
大巧不工,重剑无锋.
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-11-25 08:34
谢谢你提供的网站.不过那些例子是for EZ-USB,而我是用52的.不知道在指令上有什么不同阿??我怎么把它改成52可以使用的呢?
xjLegend
驱动小牛
驱动小牛
  • 注册日期2002-11-04
  • 最后登录2005-06-08
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-11-26 14:18
我要的是asm51的程序!!那个是c的呀。不过还是很感谢你的回答。


编译时可以选择生成汇编源文件的呀!在此基础上,把有用的部分提取出来简单修改一下不就行了?
我想要点分,这样才有成就感嘛!
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2002-11-26 17:18
[quote]我要的是asm51的程序!!那个是c的呀。不过还是很感谢你的回答。


编译时可以选择生成汇编源文件的呀!在此基础上,把有用的部分提取出来简单修改一下不就行了? [/quote]

这个办法我也想过,不过可读性太差,..郁闷中.....
poplar
驱动牛犊
驱动牛犊
  • 注册日期2001-05-04
  • 最后登录2007-01-08
  • 粉丝0
  • 关注0
  • 积分20分
  • 威望2点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2002-11-26 20:48
兼容的啊,不过你的板不一样,还是要根据硬件改改的。
大巧不工,重剑无锋.
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2002-11-27 08:06
兼容的啊,不过你的板不一样,还是要根据硬件改改的。


请问你指的是什么兼容的阿?
poplar
驱动牛犊
驱动牛犊
  • 注册日期2001-05-04
  • 最后登录2007-01-08
  • 粉丝0
  • 关注0
  • 积分20分
  • 威望2点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2002-12-11 20:02
指令兼容啊。
大巧不工,重剑无锋.
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
10楼#
发布于:2002-12-12 08:24
谢谢你.不过因为不太熟悉,所以看的还不是很懂..不过通过参考很多地方的资源,现在正在做枚举,就差最后一步了.正在研究那...
nter0
驱动牛犊
驱动牛犊
  • 注册日期2002-12-10
  • 最后登录2008-11-17
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望2点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
11楼#
发布于:2002-12-14 00:39
a
附件名称/大小 下载次数 最后更新
2002-12-14_aa.asm (12KB)  10
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
12楼#
发布于:2002-12-14 08:05
a



太谢谢了..好人啊....我最近正碰到问题呢.....
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
13楼#
发布于:2002-12-14 08:07
可是分数以前已经给出去了..没法给了...你要么..我可以专门开个帖子给你分啊..要多少说话.只要我能做到的
majingsong
驱动牛犊
驱动牛犊
  • 注册日期2002-04-02
  • 最后登录2007-05-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
14楼#
发布于:2002-12-25 21:12
; /////////////初始化命令
USB_SET_ADD EQU 0D0H ; 设置地址/使能
USB_SET_EPN EQU 0D8H ; 设置端点使能
USB_SET_MOD EQU 0F3H ; 设置模式
USB_SET_DMA EQU 0FBH ; 设置DMA
; ////////////选择端点命令
SLT_EP0_OUT EQU 000H ; 端点0输出
SLT_EP0_INP EQU 001H ; 端点0输入
SLT_EP1_OUT EQU 002H ; 端点1输出
SLT_EP1_INP EQU 003H ; 端点1输入
SLT_EP2_OUT EQU 004H ; 端点2输出
SLT_EP2_INP EQU 005H ; 端点2输入
; ////////////读最后处理状态命令
RD_EP0_OUT EQU 040H ; 端点0输出
RD_EP0_INP EQU 041H ; 端点0输入
RD_EP1_OUT EQU 042H ; 端点1输出
RD_EP1_INP EQU 043H ; 端点1输入
RD_EP2_OUT EQU 044H ; 端点2输出
RD_EP2_INP EQU 045H ; 端点2输入
; ////////////设置端点状态命令
SET_EP0_OUT EQU 040H ; 端点0输出
SET_EP0_INP EQU 041H ; 端点0输入
SET_EP1_OUT EQU 042H ; 端点1输出
SET_EP1_INP EQU 043H ; 端点1输入
SET_EP2_OUT EQU 044H ; 端点2输出
SET_EP2_INP EQU 045H ; 端点2输入
; ////////////读缓冲区命令
USB_RD_TMP EQU 0F0H
; ////////////写缓冲区命令
USB_WR_TMP EQU 0F0H
; ////////////应答建立命令
USB_ACK_CMD EQU 0F1H
; ////////////清缓冲区命令
USB_CLR_TMP EQU 0F2H
; ////////////读中断寄存器命令
USB_RD_INT EQU 0F4H
; ////////////读当前接收帧数目命令
USB_RD_SUM EQU 0F5H
; ////////////挂起恢复命令
USB_SUP_WAK EQU 0F6H
; ////////////使缓冲区有效命令
USB_SET_TMP EQU 0FAH
; //////////// USB 常量
USB_ADD_MSK EQU 080H ; 地址使能掩码
USB_SYC_MSK EQU 001H ; 普通同步端点使能掩码
USB_LAZ_MSK EQU 002H ; LAZYCLOCK掩码
USB_CLK_MSK EQU 004H ; 时00000000钟运行掩码
USB_INT_MSK EQU 008H ; 中断模式掩码
USB_SCT_MSK EQU 010H ; SOFTCONNECT掩码
USB_SET_MD0 EQU 000H ; 模式0(非同步模式)掩码
USB_SET_MD1 EQU 040H ; 模式1(同步输出模式)掩码
USB_SET_MD2 EQU 080H ; 模式2(同步输入模式)掩码
USB_SET_MD3 EQU 0C0H ; 模式3(同步输入/输出模式)掩码
; ///////////// D12 中断寄存器掩码
INT_EP0_OUT EQU 001H ; 端点0输出中断
INT_EP0_INP EQU 002H ; 端点0输入中断
INT_EP1_OUT EQU 004H ; 端点1输出中断
INT_EP1_INP EQU 008H ; 端点1输入中断
INT_EP2_OUT EQU 010H ; 端点2输出中断
INT_EP2_INP EQU 020H ; 端点2输入中断
INT_BUS_RST EQU 040H ; 总线复位
INT_SUP_CHG EQU 080H ; 挂起改变
INT_DMA_EOT EQU 100H ; DMA操作结束
; ///////////// D12 命令地址,数据地址
USB_CMD_ADD EQU 8203H
USB_DATA_ADD EQU 8202H
;------------------------------------------
;-- USB SYSTEM --
; D12在ALE方式:奇地址写命令,偶地址读写数据
;------------------------------------------
USB_DISCON:
CLR USB_RST
LCALL LDELAY
LCALL LDELAY
SETB USB_RST

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_MOD
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV A, #02H
MOVX @DPTR, A
MOV A, #41H
MOVX @DPTR, A
RET

USB_CONECT:

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_MOD
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV A, #12H
MOVX @DPTR, A
MOV A, #41H
MOVX @DPTR, A

RET
;-----------------------------------------
USB_RECONECT:
LCALL USB_DISCON

MOV R0, #90H
USB_IJ1:
LCALL LDELAY
LCALL LDELAY
CLR DOG_CS
SETB DOG_CS
DJNZ R0, USB_IJ1

LCALL USB_CONECT

RET
;-----------------------------------+
;   USB controller interrupt        |
;-----------------------------------+
I_INT1: CLR EA
PUSH PSW
PUSH DPH
PUSH DPL
PUSH ACC

CLR RS1
SETB RS0

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_RD_INT
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR
PUSH ACC
MOVX A, @DPTR
; JNB ACC.0, INT1_J1
; LCALL DMA_EOT
INT1_J1:
POP ACC
JNB ACC.6, INT1_J2
PUSH ACC
SETB USB_BUSRST ; 总线复位
POP ACC
SJMP INT1_J3
INT1_J2:
JNB ACC.7, INT1_J3
PUSH ACC
; 挂起改变
SETB USB_SUSCHG
POP ACC
INT1_J3:
JNB ACC.1, INT1_J4
PUSH ACC
LCALL EP0_TXDONE ; 端点0发送中断
POP ACC
INT1_J4:
  JNB ACC.0, INT1_J5
PUSH ACC
LCALL EP0_RXDONE ; 端点0接收中断
POP ACC
INT1_J5:
JNB ACC.2, INT1_J6
PUSH ACC
LCALL EP1_RXDONE ; 端点1接收中断
POP ACC
INT1_J6:
JNB ACC.3, INT1_J7
PUSH ACC
LCALL EP1_TXDONE ; 端点1发送中断
POP ACC
INT1_J7:
JNB ACC.4, INT1_J8
PUSH ACC
LCALL EP2_RXDONE ; 端点2接收中断
POP ACC
INT1_J8:
JNB ACC.5, INT1_RET
LCALL EP2_TXDONE ; 端点2发送中断
INT1_RET:
SETB EX1
POP ACC
POP DPL
POP DPH
POP PSW
SETB EA
RETI
;-----------------------------------
; DMA 结束中断处理
;-----------------------------------
DMA_EOT:

RET
;-----------------------------------
; 端点0发送中断处理(控制输入)
;-----------------------------------
EP0_TXDONE:
MOV DPTR, #USB_CMD_ADD
MOV A, #RD_EP0_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR ; 清除中断标志

JB USB_TRANSMIT, EP0_WJ0
RET

EP0_WJ0:
MOV A, USB_TX_LEN ; 计算发送数据长度
JNZ EP0_J1 ; 长度=0发送一个空包结束

MOV DPTR, #USB_CMD_ADD ; 选择端点
MOV A, #SLT_EP0_INP
MOVX @DPTR, A
  MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR
MOV DPTR, #USB_CMD_ADD
MOV A, #USB_WR_TMP ; 写缓冲区命令
MOVX @DPTR, A

  MOV DPTR, #USB_DATA_ADD ; 写数据
MOV A, #00H
MOVX @DPTR, A
MOV A, #00H
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD ; 使缓冲区有效
MOV A, #USB_SET_TMP
MOVX @DPTR, A
MOV USB_TX_LEN, #00H
MOV USB_TX_HEAD, #00H
CLR USB_TRANSMIT
RET
EP0_J1:
MOV A, USB_TX_LEN
CLR C
SUBB A, #10H
JC EP0_WJ2
MOV USB_TX_LEN, A
SETB USB_TRANSMIT
MOV R0, #10H
SJMP EP0_WJ3
EP0_WJ2:
MOV R0, USB_TX_LEN
MOV USB_TX_LEN, #00H
EP0_WJ3:
MOV DPTR, #USB_CMD_ADD ; 选择端点0索引1
MOV A, #SLT_EP0_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_WR_TMP ; 写缓冲区命令
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 写数据
MOV A, #00H
MOVX @DPTR, A
MOV A, R0
MOVX @DPTR, A
MOV A, USB_TX_HEAD
ADD A, #USB_W_RAM
MOV R1, A
MOV A, USB_TX_HEAD
ADD A, #10H
MOV USB_TX_HEAD, A
EP0_WJ4:
MOV A, @R1
MOVX @DPTR, A
INC R1
DJNZ R0, EP0_WJ4

MOV DPTR, #USB_CMD_ADD ; 使缓冲区有效开始发送
MOV A, #USB_SET_TMP
MOVX @DPTR, A
RET
;-----------------------------------
; 端点0接收中断处理(控制输出)
;-----------------------------------
EP0_RXDONE:
MOV DPTR, #USB_CMD_ADD
MOV A, #RD_EP0_OUT
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR ; 清除中断标志
JB ACC.5, EP0_RJ0
LJMP EP0_REND
EP0_RJ0: ;  处理设置包
MOV A, #SLT_EP0_OUT
LCALL USB_RDFRAME
MOV A, USB_D12_LEN
CJNE A, #08H,EP0_RJ1
SJMP EP0_RJ2
EP0_RJ1: ; 接收数据长度错误
SETB USB_ENDP_STAT
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
MOV USB_RX_LEN, #00H
CLR USB_TRANSMIT
CLR USB_RECEIVE
RET
EP0_RJ2: ; 有效数据处理

MOV R0, #USB_R_RAM
MOV R1, #USB_REQTYPE
MOV R2, #08H
EP0_RJ2A:
MOV A, @R0
MOV @R1, A
INC R0
INC R1
DJNZ R2, EP0_RJ2A

MOV USB_RX_LEN, #00H
MOV USB_TX_LEN, #00H
MOV USB_TX_HEAD, #00H

MOV DPTR, #USB_CMD_ADD ; 选择端点0输出
MOV A, #SLT_EP0_OUT
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD ; 应答
MOV A, #USB_ACK_CMD
MOVX @DPTR, A
MOV DPTR, #USB_CMD_ADD
MOV A, #USB_CLR_TMP ; 清缓冲区
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD ; 选择端点0输入
MOV A, #SLT_EP0_INP
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD ; 应答
MOV A, #USB_ACK_CMD
MOVX @DPTR, A

MOV A, USB_REQTYPE
JNB ACC.7, EP0_RJ3
SETB USB_SETPACK ; DEVICE TO HOST
CLR USB_TRANSMIT
CLR USB_RECEIVE
RET
EP0_RJ3:
MOV A, USB_LENGH_H
JNZ EP0_RJ4
MOV A, USB_LENGH
JNZ EP0_RJ4
SETB USB_SETPACK
CLR USB_RECEIVE
CLR USB_TRANSMIT
RET
EP0_RJ4:
CLR C
MOV A, USB_LENGH
CJNE A, #08H, EP0_RJ5
SJMP EP0_RJ6
EP0_RJ5:
JC EP0_RJ6
SETB USB_ENDP_STAT
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
CLR USB_RECEIVE
CLR USB_TRANSMIT
RET
EP0_RJ6:
SETB USB_RECEIVE
RET
EP0_REND:
JB USB_RECEIVE, EP0_RJ7
CLR USB_RECEIVE
CLR USB_TRANSMIT
RET
EP0_RJ7:
MOV A, #SLT_EP0_OUT
LCALL USB_RDFRAME
MOV A, USB_RX_LEN
ADD A, USB_D12_LEN
MOV USB_RX_LEN, A
MOV A, USB_D12_LEN
CJNE A, #10H, EP0_RJ8
MOV A, USB_LENGH
DEC A
CLR C
SUBB A, USB_RX_LEN
JC EP0_RJ8
RET
EP0_RJ8:
SETB USB_SETPACK
CLR USB_RECEIVE
CLR USB_TRANSMIT
RET
;-----------------------------------
; 设备请求处理
;-----------------------------------
DEV_REQUEST:
MOV A, USB_REQTYPE
ANL A, #60H
CJNE A, #00H, DEV_J1
LJMP USB_STD_REQ
DEV_J1:CJNE A, #20H, DEV_J2
LJMP USB_CLASS_REQ
DEV_J2:CJNE A, #40H, DEV_J3
LJMP USB_VENDOR_REQ
DEV_J3:
SETB USB_ENDP_STAT
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET

USB_STD_REQ:
MOV A, USB_REQUEST
ANL A, #0FH
CJNE A, #00H, DEV_S_J1
LCALL GET_STATUS
RET
DEV_S_J1:
CJNE A, #01H, DEV_S_J2
LCALL CLEAR_FEATURE
RET
DEV_S_J2:
CJNE A, #02H, DEV_S_J3
LJMP DEV_S_J13 ; RESERVED
DEV_S_J3:
CJNE A, #03H, DEV_S_J4
LCALL SET_FEATURE
RET
DEV_S_J4:
CJNE A, #04H, DEV_S_J5
LJMP DEV_S_J13 ; RESERVED
DEV_S_J5:
CJNE A, #05H, DEV_S_J6
  LCALL SET_ADDRESS
RET
DEV_S_J6:
CJNE A, #06H, DEV_S_J7
LCALL GET_DESCRIPTOR
RET
DEV_S_J7:
CJNE A, #07H, DEV_S_J8
LJMP DEV_S_J13 ; RESERVED
DEV_S_J8:
CJNE A, #08H, DEV_S_J9
LCALL GET_CONFIGURATION
RET
DEV_S_J9:
CJNE A, #09H, DEV_S_J10
LCALL SET_CONFIGURATION
RET
DEV_S_J10:
CJNE A, #0AH, DEV_S_J11
LCALL GET_INTERFACE
RET
DEV_S_J11:
CJNE A, #0BH, DEV_S_J12
LCALL SET_INTERFACE
RET
DEV_S_J12:
CJNE A, #0CH, DEV_S_J13
LCALL SYNCH_FRAME
RET
DEV_S_J13:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
USB_CLASS_REQ:
RET
USB_VENDOR_REQ:
MOV A, USB_REQUEST
JB ACC.7, V_RRJ
LJMP V_WRJ
V_RRJ:
MOV A, USB_INDEX_H ; GET FIRMWARE VERSION
CJNE A, #04H, V_RRJ1 ; USB_wINDEX = 0472H
MOV A, USB_INDEX ; USB_wVALUE = 0
CJNE A, #72H, V_RRJ1 ; USB_wLENGH = 1
MOV A, USB_VALUE_H
JNZ V_RRJ1
MOV A, USB_VALUE
JNZ V_RRJ1
MOV A, USB_LENGH_H
JNZ V_RRJ1
MOV A, USB_LENGH
CJNE A, #01H, V_RRJ1
MOV USB_WRDAT, #01H
MOV USB_WRDAT+1, #30H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
V_RRJ1:
MOV A, USB_INDEX_H ; GET BUFFER SIZE
CJNE A, #04H, V_RRJ2 ; USB_wVALUE = 0474H
MOV A, USB_INDEX ; USB_wVALUE = 0
CJNE A, #74H, V_RRJ2 ; USB_wLENGH = 4
MOV A, USB_VALUE_H
JNZ V_RRJ2
MOV A, USB_VALUE
JNZ V_RRJ2
MOV A, USB_LENGH_H
JNZ V_RRJ2
MOV A, USB_LENGH
XRL A, #04H
JNZ V_RRJ2
MOV USB_WRDAT, #04H
MOV USB_WRDAT+1, #40H
MOV USB_WRDAT+2, #00H
MOV USB_WRDAT+3, #00H
MOV USB_WRDAT+4, #00H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
V_RRJ2:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
V_WRJ:
MOV A, USB_INDEX_H ; SET UP DMA REQUEST
CJNE A, #04H, V_WRJ1 ; USB_wINDEX = 0471H
MOV A, USB_INDEX_H ; USB_wVALUE = 0
CJNE A, #71H, V_WRJ1 ; USB_wLENGH = 6
MOV A, USB_VALUE_H
JNZ V_WRJ1
MOV A, USB_VALUE
JNZ V_WRJ1
MOV A, USB_LENGH_H
JNZ V_WRJ1
MOV A, USB_LENGH
CJNE A, #06H, V_WRJ1
RET
V_WRJ1:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
;--------------------------
GET_STATUS:
MOV A, USB_REQTYPE
ANL A, #1FH
CJNE A, #00H, GETS_J1
MOV A, #03H ; DEVICE
MOV C, USB_RMT_WAK
MOV ACC.1, C
MOV USB_WRDAT+1, A
MOV USB_WRDAT+2, #00H
LJMP GETS_END
GETS_J1:
CJNE A, #01H, GETS_J2
MOV USB_WRDAT+1, #00H ; INTERFACE
MOV USB_WRDAT+2, #00H
LJMP GETS_END
GETS_J2:
CJNE A, #02H, GETS_J3
MOV A, USB_INDEX ; ENDPOINT
ANL A, #03H
RL A
PUSH ACC
MOV A, USB_INDEX
ANL A, #80H
JZ GETS_J3A
POP ACC
ADD A, #01H
PUSH ACC
GETS_J3A:
POP ACC
LCALL SELECT_POINT
MOV USB_WRDAT+1, #00H
JNB ACC.1, GETS_J3B
MOV USB_WRDAT+1, #01H
GETS_J3B:
MOV USB_WRDAT+2, #00H
LJMP GETS_END
GETS_J3:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
GETS_END:
MOV USB_WRDAT, #02H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
;--------------------------
CLEAR_FEATURE:
MOV A, USB_REQTYPE
ANL A, #1FH
PUSH ACC

CJNE A, #00H, CLRF_J1
MOV A, USB_VALUE_H ; USB FEATURE REMOTE_WAKEUP = 0001H
JNZ CLRF_J1
MOV A, USB_VALUE
CJNE A, #01H, CLRF_J1
CLR USB_RMT_WAK
POP ACC
LJMP CLRF_END
CLRF_J1:
POP ACC
CJNE A, #02H, CLRF_J2
MOV A, USB_VALUE_H ; USB FEATURE ENDPOINT STALL = 0000H
JNZ CLRF_J2
MOV A, USB_VALUE
JNZ CLRF_J2
MOV A, USB_INDEX
ANL A, #03H
RL A
PUSH ACC
MOV A, USB_INDEX
ANL A, #80H
JZ CLRF_J1A
POP ACC
ADD A, #01H
PUSH ACC
CLRF_J1A:
POP ACC
CLR USB_ENDP_STAT
LCALL SET_ENDPNT_STAT
LJMP CLRF_END
CLRF_J2:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
CLRF_END:
MOV USB_WRDAT, #00H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
;--------------------------
SET_FEATURE:
MOV A, USB_REQTYPE
ANL A, #1FH
PUSH ACC

CJNE A, #00H, SETF_J1
MOV A, USB_VALUE_H ; USB FEATURE REMOTE_WAKEUP
JNZ SETF_J1
MOV A, USB_VALUE
CJNE A, #01H, SETF_J1
SETB USB_RMT_WAK
POP ACC
LJMP SETF_END
SETF_J1:
POP ACC
CJNE A, #02H, SETF_J2
MOV A, USB_VALUE_H ; USB FEATURE ENDPOINT STALL
JNZ SETF_J2
MOV A, USB_VALUE
JNZ SETF_J2
MOV A, USB_INDEX
ANL A, #03H
RL A
PUSH ACC
MOV A, USB_INDEX
ANL A, #80H
JZ SETF_J1A
POP ACC
ADD A, #01H
PUSH ACC
SETF_J1A:
POP ACC
SETB USB_ENDP_STAT
LCALL SET_ENDPNT_STAT
LJMP SETF_END
SETF_J2:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
SETF_END:
MOV USB_WRDAT, #00H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
;--------------------------
SET_ADDRESS:
MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_ADD
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV A, USB_VALUE
ORL A, #80H
MOVX @DPTR, A
SETB USB_SET_ADDR
MOV USB_WRDAT, #00H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
;--------------------------
GET_DESCRIPTOR:
CLR DOG_CS
SETB    DOG_CS

MOV A, USB_VALUE_H
CJNE A, #01H, GETD_J1
MOV A, USB_LENGH ;#40H ;12H
CJNE A, #40H, GETD_J1B
SJMP GETD_J1C
GETD_J1B:
JC GETD_J1C
MOV A, #40H
GETD_J1C:
MOV R0, A
MOV R1, #USB_W_RAM
MOV DPTR, #DEV_DESCPT
GETD_J1A:
CLR A
MOVC A, @A+DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R0, GETD_J1A

MOV A, USB_LENGH
CLR C
SUBB A, #10H
MOV USB_TX_LEN, A ;#30H ; USB DEVICE DESCRIPTOR
SETB USB_TRANSMIT
MOV USB_TX_HEAD, #10H
MOV A, #SLT_EP0_INP
LCALL USB_WRFRAME
RET
GETD_J1:
CJNE A, #02H, GETD_J2
MOV A, USB_LENGH_H
JZ GETD_J2D
SJMP GETD_J2BB
GETD_J2D:
MOV A, USB_LENGH
CLR C
CJNE A, #2EH, GETD_J2B
SJMP GETD_J2C
GETD_J2B:
JC GETD_J2C
GETD_J2BB:
MOV R0, #2EH
MOV R1, #USB_W_RAM
MOV DPTR, #CFG_DESCPT
LJMP GETD_J1A
GETD_J2C:
MOV R0, #09H
MOV R1, #USB_WRDAT ;USB_W_RAM
MOV USB_WRDAT, #09H
INC R1
MOV DPTR, #CFG_DESCPT
GETD_J2A:
CLR A
MOVC A, @A+DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R0, GETD_J2A
; USB CONFIGURATTION DESCRIPTOR
MOV USB_TX_LEN, #00H
MOV USB_TX_HEAD, #00H
SETB USB_TRANSMIT
LCALL EP0_S_TX
RET
GETD_J2:
CJNE A, #04H, GETD_J3
MOV R0, USB_LENGH ;#09H
MOV R1, #USB_WRDAT
MOV USB_WRDAT, #09H
INC R1
MOV DPTR, #INTFACE_DESCPT
GETD_J3A:
CLR A
MOVC A, @A+DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R0, GETD_J3A
; USB INTERFACE DESCRIPTOR
MOV USB_TX_LEN, #00H
SETB USB_TRANSMIT
LCALL EP0_S_TX
RET
GETD_J3:
CJNE A, #05H, GETD_J4
MOV R0, #1CH
MOV R1, #USB_W_RAM
MOV DPTR, #EP1TX_DESCPT
GETD_J4A:
CLR A
MOVC A, @A+DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R0, GETD_J4A
; USB ENDPOINT DESCRIPTOR
MOV USB_TX_LEN, #0CH
MOV USB_TX_HEAD, #10H
SETB USB_TRANSMIT
LCALL USB_WRFRAME
RET
GETD_J4:

SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
;--------------------------
GET_CONFIGURATION:
MOV USB_WRDAT, #01H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
MOV C, USB_CONFIG
CLR A
MOV ACC.0, C
MOV USB_WRDAT+1, A
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
;--------------------------
SET_CONFIGURATION:
SETB USB_SET_CFG
MOV A, USB_VALUE_H
JNZ SET_CON_J2
MOV A, USB_VALUE
JNZ SET_CON_J1

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_EPN
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV A, #00H
MOVX @DPTR, A

CLR USB_CONFIG
MOV USB_WRDAT, #00H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
LCALL EP0_S_TX
RET
SET_CON_J1:
CJNE A, #01H, SET_CON_J2
MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_EPN
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV A, #00H
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_EPN
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV A, #01H
MOVX @DPTR, A

SETB USB_CONFIG
MOV USB_WRDAT, #00H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
SET_CON_J2:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
;--------------------------
GET_INTERFACE:
MOV USB_WRDAT, #01H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
LCALL EP0_S_TX
RET
;--------------------------
SET_INTERFACE:
MOV A, USB_VALUE_H ; USB wVALUE = 0
JNZ SET_INTF_J1
MOV A, USB_VALUE
JNZ SET_INTF_J1

MOV A, USB_INDEX_H ; USB wINDEX = 0
JNZ SET_INTF_J1
MOV A, USB_INDEX
JNZ SET_INTF_J1

MOV USB_WRDAT, #00H
MOV USB_WRDAT+1, #00H
MOV USB_WRDAT+2, #00H
MOV USB_TX_LEN, #00H
LCALL EP0_S_TX
RET
SET_INTF_J1:
SETB USB_ENDP_STAT ; STALL EP0
MOV A, #00H
LCALL SET_ENDPNT_STAT
MOV A, #01H
LCALL SET_ENDPNT_STAT
RET
;--------------------------
SYNCH_FRAME:
RET
;---------------------------
EP0_S_TX:
MOV DPTR, #USB_CMD_ADD ; 选择端点
MOV A, #SLT_EP0_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_WR_TMP ; 写缓冲区命令
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD
MOV A, #00H
MOVX @DPTR, A
MOV A, USB_WRDAT
MOVX @DPTR, A
MOV R0, A
MOV R1, #USB_WRDAT
INC R1
JZ EP0_S_3
EP0_S_2:
MOV A, @R1
MOVX @DPTR, A
INC R1
DJNZ R0, EP0_S_2
EP0_S_3:
MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_TMP ; 使缓冲区有效
MOVX @DPTR, A
RET

;-----------------------------------
; 选择端点
;-----------------------------------
SELECT_POINT:
MOV DPTR, #USB_CMD_ADD
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR
RET
;-----------------------------------
; 设置端点状态
;-----------------------------------
SET_ENDPNT_STAT:
MOV DPTR, #USB_CMD_ADD
ADD A, #40H
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOV C, USB_ENDP_STAT
MOV ACC.0, C
MOVX @DPTR, A
RET
;-----------------------------------
; 端点1接收中断处理(输出)
;-----------------------------------
EP1_RXDONE:
MOV DPTR, #USB_CMD_ADD ; 选择
MOV A, #RD_EP1_OUT
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD ; 读最后处理状态清中断标志
MOVX A, @DPTR

JB ACC.0, EP1_RJ1 ; 端点缓冲区是否有数据
RET
EP1_RJ1:
MOV DPTR, #USB_CMD_ADD
MOV A, #SLT_EP1_OUT
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD ; 读缓冲区命令
MOV A, #USB_RD_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 读数据
MOV R1, #USB_EP1_RAM
MOVX A, @DPTR
MOVX A, @DPTR ; 接收数据长度 0 < x < 16
JNZ EP1_RJ1A
RET
EP1_RJ1A:
CJNE A, #10H, EP1_RJ1B
SJMP EP1_RJ2
EP1_RJ1B:
JC EP1_RJ2
MOV A, #10H
EP1_RJ2:
MOV R0, A
EP1_RJ2A:
MOVX A, @DPTR
MOV @R1, A
INC R1
DJNZ R0, EP1_RJ2A

MOV DPTR, #USB_CMD_ADD ; 清缓冲区
MOV A, #USB_CLR_TMP
MOVX @DPTR, A
EP1_RD_J1:
SETB USB_EP1_RX
RET
;-----------------------------------
; 端点1发送
;-----------------------------------
EP1_TX:
MOV DPTR, #USB_CMD_ADD ; 选择端点
MOV A, #SLT_EP1_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

JNB ACC.0, EP1_TJ1 ; 端点缓冲区是否空
SETB USB_REPEAT
RET
EP1_TJ1:
MOV DPTR, #USB_CMD_ADD ; 写缓冲区命令
MOV A, #USB_WR_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 写数据
MOV A, #00H
MOVX @DPTR, A
MOV A, #10H
MOVX @DPTR, A
MOV R0, #10H
MOV R1, #USB_W_RAM
EP1_TJ2:
MOV A, @R1
MOVX @DPTR, A
INC R1
DJNZ R0, EP1_TJ2

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_TMP ; 使缓冲区有效
MOVX @DPTR, A
RET
;-----------------------------------
; 端点1发送中断处理(输入)
;-----------------------------------
EP1_TXDONE:
MOV DPTR, #USB_CMD_ADD ; 选择
MOV A, #RD_EP1_INP
MOVX @DPTR, A ; 读最后处理状态清中断标志
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR
RET
;-----------------------------------
; 端点2接收中断处理(输出)
;-----------------------------------
EP2_RXDONE:
MOV DPTR, #USB_CMD_ADD ; 选择
MOV A, #RD_EP2_OUT
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD ; 读最后处理状态清中断标志
MOVX A, @DPTR

JB ACC.0, EP2_RJ1 ; 端点缓冲区是否有数据
RET
EP2_RJ1:
MOV DPTR, #USB_CMD_ADD
MOV A, #SLT_EP2_OUT
MOVX @DPTR, A

MOV DPTR, #USB_CMD_ADD ; 读缓冲区命令
MOV A, #USB_RD_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 读数据
MOVX A, @DPTR
MOVX A, @DPTR
JNZ EP2_RJ1A
RET
EP2_RJ1A:
CJNE A, #0FFH, EP2_RJ2
RET
EP2_RJ2:
CJNE A, #40H, EP2_RJ3 ; 缓冲区长度64字节
SJMP EP2_RJ4
EP2_RJ3:
JC EP2_RJ4
MOV A, #40H
EP2_RJ4:
MOV R2, A ; 接收的数据长度
MOV R3, #10H
MOV A, USB_QEUE
ANL A, #70H
ADD A, #USB_TEMP
SETB ACC.7
MOV R1, A
PUSH 8EH
MOV 8EH, #00H
EP2_RJ5:
MOVX A, @DPTR
MOVX @R1, A
INC R1
DJNZ R3, EP2_RJ5

MOV R3, #10H
MOV A, R2 ; 计算剩余长度
CLR C
SUBB A, #10H
JNC EP2_RJ6
MOV A, #00H
EP2_RJ6:
MOV R2, A
MOV A, USB_QEUE ; 计算接收队列头指针
ADD A, #10H
ANL A, #77H
MOV USB_QEUE, A
MOV A, R1 ; 计算接收缓冲区地址
SETB ACC.7
MOV R1, A
MOV A, USB_QEUE
SWAP A
CLR USB_FULL
CJNE A, USB_QEUE, EP2_RJ7
SETB USB_FULL
EP2_RJ7:
CJNE R2, #00H, EP2_RJ5
POP 8EH

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_CLR_TMP ; 清缓冲区
MOVX @DPTR, A

SETB USB_RX

LJMP EP2_RXDONE

RET
;-----------------------------------
; 端点2发送
;-----------------------------------
EP2_TX:
MOV DPTR, #USB_CMD_ADD ; 选择端点
MOV A, #SLT_EP2_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

JNB ACC.0, EP2_TJ1 ; 端点缓冲区是否空
SETB USB_REPEAT
RET
EP2_TJ1:
MOV DPTR, #USB_CMD_ADD ; 写缓冲区命令
MOV A, #USB_WR_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 写数据
MOV A, #00H
MOVX @DPTR, A
MOV A, EP2_TX_LEN
MOVX @DPTR, A
MOV R0, EP2_TX_LEN
MOV R1, #USB_W_RAM
EP2_TJ2:
MOV A, @R1
MOVX @DPTR, A
INC R1
DJNZ R0, EP2_TJ2

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_TMP ; 使缓冲区有效
MOVX @DPTR, A
RET

;-----------------------------------
; 端点2发送中断处理(输入)
;-----------------------------------
EP2_TXDONE:
MOV DPTR, #USB_CMD_ADD ; 选择
MOV A, #RD_EP2_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD ; 读最后处理状态清中断标志
MOVX A, @DPTR

RET
; --------------------
; 由主程序判断发送是否完成,EP2发送中断不处理数据
MOV A, USB_TX_LEN
JNZ EP2_WJ1
RET
EP2_WJ1:
MOV DPTR, #USB_CMD_ADD ; 选择端点
MOV A, #SLT_EP2_INP
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

JNB ACC.0, EP2_WJ2 ; 端点缓冲区是否空
RET
EP2_WJ2:
MOV A, USB_TX_LEN
PUSH ACC
CLR C
SUBB A, #41H
JC EP2_WJ2A
ADD A, #01H
MOV USB_TX_LEN, A
POP ACC
MOV A, #40H
PUSH ACC
EP2_WJ2A:
POP ACC
MOV R0, A
MOV DPTR, #USB_CMD_ADD ; 写缓冲区命令
MOV A, #USB_WR_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 写数据
MOV A, #00H
MOVX @DPTR, A
MOV A, R0
MOVX @DPTR, A
MOV R1, #USB_W_RAM
EP2_WJ3:
MOV A, @R1
MOVX @DPTR, A
INC R1
DJNZ R0, EP2_WJ3

MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SET_TMP ; 使缓冲区有效
MOVX @DPTR, A
RET
;-----------------------------------
; 挂起改变中断处理
;-----------------------------------
SUSP_CHG:
MOV DPTR, #USB_CMD_ADD
MOV A, #USB_SUP_WAK
MOVX @DPTR, A
RET
;------------------------------------------------
; 向主机发送一个数据包,A 端点索引1,3或5(输入)
;------------------------------------------------
USB_WRFRAME:
MOV DPTR, #USB_CMD_ADD ; 选择端点
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

SND_J1:
MOV DPTR, #USB_CMD_ADD ; 写缓冲区命令
MOV A, #USB_WR_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 写数据
MOV A, #00H
MOVX @DPTR, A
MOV A, #10H
MOVX @DPTR, A
MOV R0, #10H
MOV R1, #USB_W_RAM
SND_J2:
MOV A, @R1
MOVX @DPTR, A
INC R1
DJNZ R0, SND_J2

MOV DPTR, #USB_CMD_ADD ; 使缓冲区有效
MOV A, #USB_SET_TMP
MOVX @DPTR, A
RET

;-----------------------------------
; 接收一个数据包,A 端点索引0,2或4
;-----------------------------------
USB_RDFRAME:
MOV DPTR, #USB_CMD_ADD ; 选择端点
MOVX @DPTR, A
MOV DPTR, #USB_DATA_ADD
MOVX A, @DPTR

JB ACC.0, REC_J1 ; 端点缓冲区是否有数据
MOV USB_D12_LEN, #00H
RET
REC_J1:
MOV DPTR, #USB_CMD_ADD ; 读缓冲区命令
MOV A, #USB_RD_TMP
MOVX @DPTR, A

MOV DPTR, #USB_DATA_ADD ; 读数据
MOVX A, @DPTR
MOVX A, @DPTR
CJNE A, #40H, REC_J1A
SJMP REC_J1B
REC_J1A:
JC REC_J1B
MOV A, #40H
REC_J1B:
MOV USB_D12_LEN, A
MOV R0, A
MOV A, USB_RX_LEN
ADD A, #USB_R_RAM
MOV R1, A
MOV A, USB_D12_LEN
JNZ REC_J2
RET
REC_J2:
MOVX A, @DPTR
MOV @R1, A
INC R1
DJNZ R0, REC_J2
MOV A, USB_RX_LEN
MOV USB_RX_HEAD, A
ADD A, USB_D12_LEN
MOV USB_RX_LEN, A

MOV DPTR, #USB_CMD_ADD ; 清缓冲区
MOV A, #USB_CLR_TMP
MOVX @DPTR, A
RET
;-----------------------------------
DEV_DESCPT:
DB 012H,001H,000H,001H,0DCH,000H,000H,010H,071H
DB 004H,066H,006H,000H,001H,000H,000H,000H,019H
;-----------------------------------
; USB DEVICE DESCRIPTOR:
; unsigned char bLengh;
; unsigned char bDescriptorType;
; unsigned bcdUSB;
; unsigned char bDeviceClass;
; unsigned char bdeviceSubClass;
; unsigned char bDeviceProtocol;
; unsigned char bMaxPacketsize;
; unsigned idVendor;
; unsigned idProduct;
; unsigned bcdDevice;
; unsigned char iManufacture;
; unsigned char iProduct;
; unsigned char iSerialNumber;
; unsigned char bNumConfigurations;
;-----------------------------------
;code USB_DEVICE_DESCRIPTOR DeviceDescr =
;{
; sizeof(USB_DEVICE_DESCRIPTOR),
;    USB_DEVICE_DESCRIPTOR_TYPE,
;    SWAP(0x0100),
;    USB_CLASS_CODE_TEST_CLASS_DEVICE,
;    0,
;    0,
; EP0_PACKET_SIZE,
; SWAP(0x0471), //VID
; SWAP(0x0666), //PID
; SWAP(0x0100),
;    0, //Manufactory
;    0, //Product
;    0, //Serial Number
;    25 //Number of possible configurations
;};
;-----------------------------------
CFG_DESCPT:
DB 009H,002H,02EH,000H,001H,001H,000H,060H,0F0H
;-----------------------------------
INTFACE_DESCPT:
DB 009H,004H,000H,000H,004H,0DCH,0A0H,0B0H,000H
;-----------------------------------
EP1TX_DESCPT:
DB 007H,005H,081H,002H,010H,000H,005H
;-----------------------------------
EP1RX_DESCPT:
DB 007H,005H,001H,002H,010H,000H,005H
;-----------------------------------
EP2TX_DESCPT:
DB 007H,005H,082H,002H,040H,000H,00AH
;-----------------------------------
EP2RX_DESCPT:
DB 007H,005H,002H,002H,040H,000H,00AH
;-----------------------------------
;USB CONFIGURATION_DESCRIPTOR:
; unsigned char bLength;
; unsigned char bDescriptorType;
; unsigned wTotalLength;
; unsigned char bNumInterfaces;
; unsigned char bConfigurationValue;
; unsigned char iConfiguration;
; unsigned char bmAttributes;
; unsigned char MaxPower;
;-----------------------------------
;code USB_CONFIGURATION_DESCRIPTOR ConfigDescr =
;{
;    sizeof(USB_CONFIGURATION_DESCRIPTOR),
;    USB_CONFIGURATION_DESCRIPTOR_TYPE,
;    SWAP(CONFIG_DESCRIPTOR_LENGTH),
; 1,
; 1,
;    0,
; 0x60,
; 0xf0
; //0x1
;};
;-----------------------------------
;USB INTERFACE DESCRIPTOR
; unsigned char bLength;
; unsigned char bDescriptorType;
; unsigned char bInterfaceNumber;
; unsigned char bAlternateSetting;
; unsigned char bNumEndpoints;
; unsigned char bInterfaceClass;
; unsigned char bInterfaceSubClass;
; unsigned char bInterfaceProtocol;
; unsigned char iInterface;
;-----------------------------------
;code USB_INTERFACE_DESCRIPTOR InterfaceDescr =
;{
;    sizeof(USB_INTERFACE_DESCRIPTOR),
;    USB_INTERFACE_DESCRIPTOR_TYPE,
;    0,
;    0,
; NUM_ENDPOINTS,
; USB_CLASS_CODE_TEST_CLASS_DEVICE,
; USB_SUBCLASS_CODE_TEST_CLASS_D12,
; USB_PROTOCOL_CODE_TEST_CLASS_D12,
; 0
;};
;-----------------------------------
;USB ENDPOINT DESCRIPTOR:
; unsigned char bLength;
; unsigned char bDescriptorType;
; unsigned char bEndpointAddress;
; unsigned char bmAttributes;
; unsigned wMaxPacketSize;
; unsigned char bInterval;
;-----------------------------------
;code USB_ENDPOINT_DESCRIPTOR EP1_TXDescr =
;{
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x81,
; USB_ENDPOINT_TYPE_INTERRUPT,
; SWAP(EP1_PACKET_SIZE),
; 10
;};
;-----------------------------------
;code USB_ENDPOINT_DESCRIPTOR EP1_RXDescr =
;{
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x1,
; USB_ENDPOINT_TYPE_INTERRUPT,
; SWAP(EP1_PACKET_SIZE),
; 10
;};
;-----------------------------------
;code USB_ENDPOINT_DESCRIPTOR EP2_TXDescr =
;{
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x82,
; USB_ENDPOINT_TYPE_BULK,
; SWAP(EP2_PACKET_SIZE),
; 10
;};
;-----------------------------------
;code USB_ENDPOINT_DESCRIPTOR EP2_RXDescr =
;{
; sizeof(USB_ENDPOINT_DESCRIPTOR),
; USB_ENDPOINT_DESCRIPTOR_TYPE,
; 0x2,
; USB_ENDPOINT_TYPE_BULK,
; SWAP(EP2_PACKET_SIZE),
; 10
;};
;-----------------------------------
;USB STRING DESCRIPTOR
; unsigned char bLength;
; unsigned char bDescriptorType;
; unsigned char bString[1];
;-----------------------------------
;USB POWER DESCRIPTOR:
; unsigned char bLength;
; unsigned char bDescriptorType;
; unsigned char bCapabilitiesFlags;
; unsigned char EventNotification;
; unsigned D1LatencyTime;
; unsigned D2LatencyTime;
; unsigned D3LatencyTime;
; unsigned char PowerUnit;
; unsigned D0PowerConsumption;
; unsigned D1PowerConsumption;
; unsigned D2PowerConsumption;
;-----------------------------------
;USB COMMON DESCRIPTOR
; unsigned char bLength;
; unsigned char bDescriptorType;
;-----------------------------------
;USB HUB DESCRIPTOR
; unsigned char bDescriptorLength;      // Length of this descriptor
; unsigned char bDescriptorType;        // Hub configuration type
; unsigned char bNumberOfPorts;         // number of ports on this hub
; unsigned wHubCharacteristics;    // Hub Charateristics
; unsigned char bPowerOnToPowerGood;    // port power on till power good in 2ms
; unsigned char bHubControlCurrent;     // max current in mA
; unsigned char bRemoveAndPowerMask[64]; //room for 255 ports power control and removable bitmask
;-----------------------------------
dacongtou
驱动中牛
驱动中牛
  • 注册日期2002-11-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
15楼#
发布于:2002-12-26 08:15
十分感谢..!!!
游客

返回顶部