📄 mypcioin.lst
字号:
C51 COMPILER V7.50 MYPCIOIN 07/03/2006 21:21:35 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MYPCIOIN
OBJECT MODULE PLACED IN MYPCIOIN.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE MYPCIOIN.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: srcout_s.c
4 // Contents: Hooks required to implement USB peripheral function.
5 // Code written for EZUSB FX2 128-pin REVE...
6 // Firmware tested on EZUSB FX2 128-pin (CY3681 DK)
7 // Copyright (c) 2001 Cypress Semiconductor All rights reserved
8 //-----------------------------------------------------------------------------
9 #include "fx2.h"
10 #include "fx2regs.h"
11 #include "fx2sdly.h" // SYNCDELAY macro
12
13 extern BOOL GotSUD; // Received setup data flag
14 extern BOOL Sleep;
15 extern BOOL Rwuen;
16 extern BOOL Selfpwr;
17
18 BYTE Configuration; // Current configuration
19 BYTE AlternateSetting; // Alternate settings
20
21 // ...debug LEDs: accessed via movx reads only ( through CPLD )
22 xdata volatile const BYTE LED0_ON _at_ 0x8000;
23 xdata volatile const BYTE LED0_OFF _at_ 0x8100;
24 xdata volatile const BYTE LED1_ON _at_ 0x9000;
25 xdata volatile const BYTE LED1_OFF _at_ 0x9100;
26 xdata volatile const BYTE LED2_ON _at_ 0xA000;
27 xdata volatile const BYTE LED2_OFF _at_ 0xA100;
28 xdata volatile const BYTE LED3_ON _at_ 0xB000;
29 xdata volatile const BYTE LED3_OFF _at_ 0xB100;
30 // it may be worth noting here that the default monitor loads at 0xC000
31
32 // use this global variable when (de)asserting debug LEDs...
33 BYTE ledX_rdvar = 0x00;
34
35 BYTE xdata Digit[] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, 0x88, 0x83, 0xc6, 0xa1,
- 0x86, 0x8e };
36
37
38 #define BTN_ADDR 0x38
39 #define LED_ADDR 0x39
40
41 BYTE num = 0;
42 BYTE display = TRUE;
43
44
45 #define KEY_WAKEUP 0
46 #define KEY_F1 1
47 #define KEY_F2 2
48 #define KEY_F3 3
49
50 //-----------------------------------------------------------------------------
51 // Task Dispatcher hooks
52 // The following hooks are called by the task dispatcher.
53 //-----------------------------------------------------------------------------
54 void TD_Init( void )
C51 COMPILER V7.50 MYPCIOIN 07/03/2006 21:21:35 PAGE 2
55 { // Called once at startup
56 1
57 1 CPUCS = 0x10; // CLKSPD[1:0]=10, for 48MHz operation
58 1 // CLKOE=0, don't drive CLKOUT
59 1
60 1 IFCONFIG = 0xCB;
61 1 // IFCLKSRC=1 , FIFOs executes on internal clk source
62 1 // xMHz=1 , 48MHz internal clk rate
63 1 // IFCLKOE=0 , Don't drive IFCLK pin signal at 48MHz
64 1 // IFCLKPOL=0 , Don't invert IFCLK pin signal from internal clk
65 1 // ASYNC=1 , master samples asynchronous
66 1 // GSTATE=0 , Don't drive GPIF states out on PORTE[2:0], debug WF
67 1 // IFCFG[1:0]=11, FX2 in slave FIFO mode
68 1
69 1
70 1 // Registers which require a synchronization delay, see section 15.14
71 1 // FIFORESET FIFOPINPOLAR
72 1 // INPKTEND OUTPKTEND
73 1 // EPxBCH:L REVCTL
74 1 // GPIFTCB3 GPIFTCB2
75 1 // GPIFTCB1 GPIFTCB0
76 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
77 1 // EPxFIFOCFG EPxGPIFFLGSEL
78 1 // PINFLAGSxx EPxFIFOIRQ
79 1 // EPxFIFOIE GPIFIRQ
80 1 // GPIFIE GPIFADRH:L
81 1 // UDMACRCH:L EPxGPIFTRIG
82 1 // GPIFTRIG
83 1
84 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
85 1 // ...these have been replaced by GPIFTC[B3:B0] registers
86 1
87 1 SYNCDELAY; // see TRM section 15.14
88 1 REVCTL = 0x01; // use enhanced packet handling
89 1
90 1 // NOTE: when using "enhanced packet handling" feature (REVCTL.0=1)
91 1 // ...the core functions as follows:
92 1 // - OUTPKTEND is used to skip/commit OUT pkt.
93 1 // - INPKTEND is used to skip/commit IN pkt.
94 1 // - EPxBCH/L is used to
95 1 // - commit cpu sourced pkt.
96 1 // - modify length of an OUT pkt.
97 1 // - cpu can not source an OUT pkt in "AUTOOUT" mode
98 1 // - see cpu source out pkt method in BOOL DR_VendorCmnd(); ...
99 1
100 1 // EP2 512 BULK OUT 4x
101 1 SYNCDELAY; //
102 1 EP2CFG = 0xA0; // BUF[1:0]=00 for 4x buffering
103 1
104 1 // EP6 512 BULK IN 4x
105 1 SYNCDELAY; //
106 1 EP6CFG = 0xE0; // BUF[1:0]=00 for 4x buffering
107 1
108 1 // EP4 and EP8 are not used in this implementation...
109 1 SYNCDELAY; //
110 1 EP4CFG = 0x20; // clear valid bit
111 1 SYNCDELAY; //
112 1 EP8CFG = 0x60; // clear valid bit
113 1
114 1 SYNCDELAY; //
115 1 FIFORESET = 0x80; // activate NAK-ALL to avoid race conditions
116 1 SYNCDELAY; //
C51 COMPILER V7.50 MYPCIOIN 07/03/2006 21:21:35 PAGE 3
117 1 FIFORESET = 0x02; // reset, FIFO 2
118 1 SYNCDELAY; //
119 1 FIFORESET = 0x04; // reset, FIFO 4
120 1 SYNCDELAY; //
121 1 FIFORESET = 0x06; // reset, FIFO 6
122 1 SYNCDELAY; //
123 1 FIFORESET = 0x08; // reset, FIFO 8
124 1 SYNCDELAY; //
125 1 FIFORESET = 0x00; // deactivate NAK-ALL
126 1
127 1 // 8-bit bus (WORDWIDE=0)...
128 1
129 1 // use manual out mode...
130 1 SYNCDELAY; //
131 1 EP2FIFOCFG = 0x00; // AUTOOUT=0, WORDWIDE=0
132 1
133 1 SYNCDELAY; //
134 1 OUTPKTEND = 0x82; // arm first buffer
135 1 SYNCDELAY; //
136 1 OUTPKTEND = 0x82; // arm second buffer
137 1 SYNCDELAY; //
138 1 OUTPKTEND = 0x82; // arm third buffer
139 1 SYNCDELAY; //
140 1 OUTPKTEND = 0x82; // arm fourth buffer
141 1
142 1 // use auto in mode
143 1 SYNCDELAY; //
144 1 EP6FIFOCFG = 0x0C; // AUTOIN=1, ZEROLENIN=1, WORDWIDE=0
145 1 }
146
147 void TD_Poll( void )
148 { // Called repeatedly while the device is idle
149 1
150 1 // see BOOL DR_VendorCmnd( void );
151 1 // ...core "auto" commits pkts using EP6AUTOINLENH/L value
152 1 BYTE xdata buttons;
153 1 BYTE kstates = 0xff;
154 1 BYTE kdeltas;
155 1 BYTE key;
156 1
157 1 EZUSB_Delay (200);
158 1 EZUSB_ReadI2C(BTN_ADDR,0x01,&buttons); // Read button states
159 1
160 1 kdeltas = kstates ^ buttons; //
161 1 kstates = buttons;
162 1 key = 0;
163 1
164 1 while(kdeltas)
165 1 {
166 2 if(kdeltas & 0x01)
167 2 {
168 3 if(!((kstates >> key) & 0x01))
169 3 switch(key)
170 3 {
171 4 case KEY_F1:
172 4 if(--num > 0x0f)
173 4 num = 0x0f;
174 4 break;
175 4 case KEY_F2:
176 4 if(++num > 0x0f)
177 4 num = 0;
178 4 break;
C51 COMPILER V7.50 MYPCIOIN 07/03/2006 21:21:35 PAGE 4
179 4 case KEY_WAKEUP:
180 4 num = 0;
181 4 break;
182 4 case KEY_F3:
183 4 num = 0x0f;
184 4 }
185 3 display = TRUE;
186 3 }
187 2 kdeltas = kdeltas >> 1;
188 2 ++key;
189 2 }
190 1 if(display)
191 1 {
192 2 EZUSB_WriteI2C(LED_ADDR, 0x01, &(Digit[num]));
193 2 EZUSB_WaitForEEPROMWrite(LED_ADDR);
194 2 display = FALSE;
195 2 }
196 1
197 1 }
198
199 BOOL TD_Suspend( void )
200 { // Called before the device goes into suspend mode
201 1 return( TRUE );
202 1 }
203
204 BOOL TD_Resume( void )
205 { // Called after the device resumes
206 1 return( TRUE );
207 1 }
208
209 //-----------------------------------------------------------------------------
210 // Device Request hooks
211 // The following hooks are called by the end point 0 device request parser.
212 //-----------------------------------------------------------------------------
213 BOOL DR_GetDescriptor( void )
214 {
215 1 return( TRUE );
216 1 }
217
218 BOOL DR_SetConfiguration( void )
219 { // Called when a Set Configuration command is received
220 1
221 1 if( EZUSB_HIGHSPEED( ) )
222 1 { // ...FX2 in high speed mode
223 2 SYNCDELAY; //
224 2 EP6AUTOINLENH = 0x02; // set core AUTO commit len = 512 bytes
225 2 SYNCDELAY; //
226 2 EP6AUTOINLENL = 0x00;
227 2 SYNCDELAY; //
228 2 }
229 1 else
230 1 { // ...FX2 in full speed mode
231 2 SYNCDELAY; //
232 2 EP6AUTOINLENH = 0x00; // set core AUTO commit len = 64 bytes
233 2 SYNCDELAY; //
234 2 EP6AUTOINLENL = 0x40;
235 2 SYNCDELAY; //
236 2 }
237 1
238 1 Configuration = SETUPDAT[ 2 ];
239 1 return( TRUE ); // Handled by user code
240 1 }
C51 COMPILER V7.50 MYPCIOIN 07/03/2006 21:21:35 PAGE 5
241
242 BOOL DR_GetConfiguration( void )
243 { // Called when a Get Configuration command is received
244 1 EP0BUF[ 0 ] = Configuration;
245 1 EP0BCH = 0;
246 1 EP0BCL = 1;
247 1 return(TRUE); // Handled by user code
248 1 }
249
250 BOOL DR_SetInterface( void )
251 { // Called when a Set Interface command is received
252 1 AlternateSetting = SETUPDAT[ 2 ];
253 1 return( TRUE ); // Handled by user code
254 1 }
255
256 BOOL DR_GetInterface( void )
257 { // Called when a Set Interface command is received
258 1 EP0BUF[ 0 ] = AlternateSetting;
259 1 EP0BCH = 0;
260 1 EP0BCL = 1;
261 1 return( TRUE ); // Handled by user code
262 1 }
263
264 BOOL DR_GetStatus( void )
265 {
266 1 return( TRUE );
267 1 }
268
269 BOOL DR_ClearFeature( void )
270 {
271 1 return( TRUE );
272 1 }
273
274 BOOL DR_SetFeature( void )
275 {
276 1 return( TRUE );
277 1 }
278
279 #define VX_B2 0xB2 // turn ON debug LEDs...
280 #define VX_B3 0xB3 // turn OFF debug LEDs...
281
282 #define VX_B7 0xB7 // re-initialize, call TD_Init( );
283 #define VX_B8 0xB8 // do a "soft reset", vector to org 00h
284 #define VX_BA 0xBA // commit out pkt. new way
285 #define VX_BB 0xBB // commit in pkt. new way
286 #define VX_C2 0xC2 // source out pkt.
287
288
289 #define VX_BC 0xBC // turn OFF debug LEDs...
290 #define VX_BD 0xBD // turn OFF debug LEDs...
291 #define VX_BE 0xBE // turn OFF debug LEDs...
292 #define VX_BF 0xBF // turn OFF debug LEDs...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -