📄 csb.lst
字号:
C51 COMPILER V6.10 CSB 06/04/2008 20:29:43 PAGE 1
C51 COMPILER V6.10, COMPILATION OF MODULE CSB
OBJECT MODULE PLACED IN .\CSB.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\CSB.c DEBUG OBJECTEXTEND
stmt level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: periph.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // Copyright (c) 1997 AnchorChips, Inc. All rights reserved
7 //-----------------------------------------------------------------------------
8 #include "fx2.h"
9 #include "fx2regs.h"
10 #include "fx2sdly.h" // SYNCDELAY macro
11
12 extern BOOL GotSUD; // Received setup data flag
13 extern BOOL Sleep;
14 extern BOOL Rwuen;
15 extern BOOL Selfpwr;
16 extern void GpifInit( void ); //GPIF.C中有该函数
17 BYTE Configuration; // Current configuration
18 BYTE AlternateSetting; // Alternate settings
19 static WORD enum_pkt_size = 0x0000;
20 //-----------------------------------------------------------------------------
21 // Task Dispatcher hooks
22 // The following hooks are called by the task dispatcher.
23 //-----------------------------------------------------------------------------
24 void TD_Init(void) // Called once at startup
25 {
26 1 CPUCS = 0x02; //12MHz 不反转 驱动CLKOUT管脚 0000 0010
27 1 GpifInit (); // initialize GPIF registers 使用外部时钟,不反转,同步,GPIF方式等等
28 1 SYNCDELAY;
29 1 BREAKPT &= ~bmBPEN; // to see BKPT LED go out TGE
30 1 Rwuen = TRUE; // Enable remote-wakeup
31 1 SYNCDELAY;
32 1 //REVCTL.1=0: 当芯片在AutoOut模式(AUTOOUT=1)和ManualOut模式(AUTOOUT=0)之间转换时,固件必须复位端点(有可能丢
-包)
33 1 //REVCTL.1=1: 可以通过CPU进行上述两种模式之间的转换,同时固件不必再复位端点(因此也不会丢数据)
34 1 //REVCTL.0=0: CPU可以跳过或者提交OUT数据包,也可以提交或者编辑/产生IN数据包
35 1 //REVCTL.0=1: CPU可以跳过/提交或者编辑/产生 OUT和IN数据包
36 1 REVCTL = 0x03; // MUST set REVCTL.0 and REVCTL.1 to 1动态输出特性
37 1 SYNCDELAY;
38 1 ///*------EPxCFG-----*///
39 1 //B7=(1 Valid) B6=(1 In / 0 Out) B5&B4:(00 Invalid / 01 ISO/ 10 BLK/ 11 INT)
40 1 //B3:(0 512 / 1 1024(2&6 only)) B2(只读位) B1&B0(缓冲数:00单缓冲 01不可用 10双缓冲 11三缓冲)
41 1 EP2CFG = 0xE8; // EP2 is DIR=IN, TYPE=BLK 4*1024 1110 1010 方向为输入,2*1024k的缓冲区
42 1 SYNCDELAY;
43 1 EP4CFG = 0x00; // EP4 not valid
44 1 SYNCDELAY;
45 1 EP6CFG = 0xAA; // EP6 is DIR=Out,TYPE=BLK 2*1024 (1010 1010)=0xAA
46 1 SYNCDELAY;
47 1 EP8CFG = 0x00; // EP8 not valid
48 1 SYNCDELAY;
49 1
50 1 FIFORESET = 0x80; // set NAKALL bit to NAK all transfers from host
51 1 SYNCDELAY;
52 1 FIFORESET = 0x02; // reset EP2 FIFO
53 1 SYNCDELAY;
54 1 FIFORESET = 0x04; // reset, FIFO 4
C51 COMPILER V6.10 CSB 06/04/2008 20:29:43 PAGE 2
55 1 SYNCDELAY;
56 1 FIFORESET = 0x06; // reset, FIFO 6
57 1 SYNCDELAY;
58 1 FIFORESET = 0x08; // reset, FIFO 8
59 1 SYNCDELAY;
60 1 FIFORESET = 0x00; // clear NAKALL bit to resume normal operation
61 1 SYNCDELAY;
62 1
63 1 ///*------EPxFIFOCFG-----*///
64 1 //B7(只读=0) B6(仅用于输入端口的ISO传输模式 =1则提前一个样本的时间提交数据)
65 1 //B5(仅用于输出端口的ISO传输模式 =1则提前一个样本的时间提交数据) B4(AutoOut =1则启动)
66 1 //B3(AutoIn =1则启动) B2(ZeroInLen=1 则在数据包的末尾添加一个0长度的包) B1(只读=0) B0(字宽(仅当IFCONFIG.10
-=11 10时起作用) =1 16位)
67 1 EP2FIFOCFG = 0x0D; // EP2 is AUTOOUT=0, AUTOIN=1, ZEROLEN=1, WORDWIDE=1 自动输入,字宽16位
68 1 SYNCDELAY;
69 1 EP2AUTOINLENH = 0x04; // if AUTOIN=1, auto commit 1024 byte packets 自动提交1024个字节的数据
70 1 SYNCDELAY;
71 1 EP2AUTOINLENL = 0x00; //
72 1 SYNCDELAY;
73 1 /// EP2GPIFFLGSEL = 0x02; // For EP2IN, GPIF uses FF flag
74 1 /// SYNCDELAY;
75 1
76 1 EP6FIFOCFG = 0x15; // (0001 0101)=0x15
77 1 SYNCDELAY; // EP6 is AUTOOUT=1, AUTOIN=0, ZEROLEN=1, WORDWIDE=1 自动输入,字宽16位
78 1 EP6AUTOINLENH = 0x04; // if AUTOIN=1, auto commit 1024 byte packets 自动提交1024个字节的数据
79 1 SYNCDELAY;
80 1 EP6AUTOINLENL = 0x00; //(0x0400=1024)
81 1 SYNCDELAY;
82 1 /// EP6GPIFFLGSEL = 0x02; // For EP6 OUT, GPIF uses FF flag
83 1 /// SYNCDELAY;
84 1
85 1 }
86
87 #define GPIFTRIGRD 4 //TD_Poll需要用到的宏
88 #define GPIF_EP2 0
89 void TD_Poll(void) // Called repeatedly while the device is idle
90 {
91 1 // static WORD xFIFOTC_IN = 0x0000; //长传输模式的最大值
92 1 // Handle IN data...对IN请求进行处理
93 1 // NOTE: We aren't doing IN data transfers for this example...
94 1 // is the peripheral interface idle...
95 1 // if( GPIFTRIG & 0x80 ) // check if peripheral "not empty"...测试数据线是否非空
96 1 // {
97 1 // if( ! ( EP24FIFOFLGS & 0x01 ) )
98 1 // {
99 1 // EP2FF=0, when fifo "不是满的时候", buffer available...
100 1
101 1 // NOTE: we're using EPxGPIFTCH/L registers here to show backwards
102 1 // ...compatibility. New implementations should use the new
103 1 // ...unified GPIFTCB3, GPIFTCB2, GPIFTCB1, GPIFTCB0 registers
104 1 // ...these registers maintain a live update which the cpu can read
105 1 // ...at anytime to determine the status of a long transfer...
106 1
107 1 // setup GPIF transaction count传输计数
108 1 //SYNCDELAY;
109 1 EP2GPIFTCH = 0x08;//0xFF;
110 1 // SYNCDELAY;
111 1 EP2GPIFTCL = 0x00;
112 1
113 1 // trigger FIFO read transaction(s), using SFR
114 1 // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)
115 1 // SYNCDELAY;
C51 COMPILER V6.10 CSB 06/04/2008 20:29:43 PAGE 3
116 1 GPIFTRIG = GPIFTRIGRD | GPIF_EP2; //触发Ep2的GPIF波形
117 1 // NOTE: 512 bytes transfers in ~75usec on 8-bit async bus
118 1 // NOTE: 64 bytes transfers in ~10usec on 8-bit async bus
119 1
120 1 // wait for the transaction to terminate naturally..等待GPIF波形自然完成.
121 1 // SYNCDELAY; // 把这一延时去掉会如何?
122 1 // }
123 1 // }
124 1 }
125
126 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
127 {
128 1 return(TRUE);
129 1 }
130
131 BOOL TD_Resume(void) // Called after the device resumes
132 {
133 1 return(TRUE);
134 1 }
135
136 //-----------------------------------------------------------------------------
137 // Device Request hooks
138 // The following hooks are called by the end point 0 device request parser.
139 //-----------------------------------------------------------------------------
140
141 BOOL DR_GetDescriptor(void)
142 {
143 1 return(TRUE);
144 1 }
145
146 BOOL DR_SetConfiguration( void )
147 { // Called when a Set Configuration command is received
148 1 if( EZUSB_HIGHSPEED( ) )
149 1 { // ...FX2 in high speed mode
150 2 SYNCDELAY; //
151 2 EP6AUTOINLENH = 0x02; // set core AUTO commit len = 512 bytes
152 2 SYNCDELAY; //
153 2 EP6AUTOINLENL = 0x00;
154 2 SYNCDELAY; //
155 2 enum_pkt_size = 512; // max. pkt. size = 512 bytes
156 2 }
157 1 else
158 1 { // ...FX2 in full speed mode
159 2 SYNCDELAY; //
160 2 EP6AUTOINLENH = 0x00; // set core AUTO commit len = 64 bytes
161 2 SYNCDELAY; //
162 2 EP6AUTOINLENL = 0x40;
163 2 SYNCDELAY; //
164 2 enum_pkt_size = 64; // max. pkt. size = 64 bytes
165 2 }
166 1
167 1 Configuration = SETUPDAT[ 2 ];
168 1 return( TRUE ); // Handled by user code
169 1 }
170
171 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
172 {
173 1 EP0BUF[0] = Configuration;
174 1 EP0BCH = 0;
175 1 EP0BCL = 1;
176 1 return(TRUE); // Handled by user code
177 1 }
C51 COMPILER V6.10 CSB 06/04/2008 20:29:43 PAGE 4
178
179 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
180 {
181 1 AlternateSetting = SETUPDAT[2];
182 1 return(TRUE); // Handled by user code
183 1 }
184
185 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
186 {
187 1 EP0BUF[0] = AlternateSetting;
188 1 EP0BCH = 0;
189 1 EP0BCL = 1;
190 1 return(TRUE); // Handled by user code
191 1 }
192
193 BOOL DR_GetStatus(void)
194 {
195 1 return(TRUE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -