?? portcstb.lst
字號:
C51 COMPILER V6.10 PORTCSTB 01/12/2009 17:09:31 PAGE 1
C51 COMPILER V6.10, COMPILATION OF MODULE PORTCSTB
OBJECT MODULE PLACED IN .\portcstb.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\portcstb.c OPTIMIZE(6,SPEED) DEBU
-G OBJECTEXTEND CODE SYMBOLS PAGEWIDTH(80)
stmt level source
1 #pragma NOIV // Do not generate interrupt vecto
-rs
2 //----------------------------------------------------------------
--------------
3 // File: portcstb.c
4 // Contents: Hooks required to implement USB peripheral functio
-n.
5 // Code written for FX2 100-pin REVD...
6 // This firmware is used to demonstrate the PORTC STR
-OBE FEATURE
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 // EZUSB FX2 PORTA i/o...
22 sbit LATRIGWR = IOA ^ 0; // alt. func., INT0#
23 sbit LATRIGRD = IOA ^ 1; // alt. func., INT1#
24 sbit PA2 = IOA ^ 2;
25 sbit PA3 = IOA ^ 3; // alt. func., WU2
26 sbit PA4 = IOA ^ 4;
27 sbit PA5 = IOA ^ 5;
28 sbit PA6 = IOA ^ 6;
29 sbit PA7 = IOA ^ 7;
30
31 // EZUSB FX2 PORTE is not bit-addressable...
32
33 // ...debug LEDs: accessed via movx reads only ( through CPLD )
34 xdata volatile const BYTE LED0_ON _at_ 0x8000;
35 xdata volatile const BYTE LED0_OFF _at_ 0x8100;
36 xdata volatile const BYTE LED1_ON _at_ 0x9000;
37 xdata volatile const BYTE LED1_OFF _at_ 0x9100;
38 xdata volatile const BYTE LED2_ON _at_ 0xA000;
39 xdata volatile const BYTE LED2_OFF _at_ 0xA100;
40 xdata volatile const BYTE LED3_ON _at_ 0xB000;
41 xdata volatile const BYTE LED3_OFF _at_ 0xB100;
42 // it may be worth noting here that the default monitor loads at 0
-xC000
43
44 // use this global variable when (de)asserting debug LEDs...
45 BYTE ledX_rdvar = 0x00;
46
47 //----------------------------------------------------------------
--------------
C51 COMPILER V6.10 PORTCSTB 01/12/2009 17:09:31 PAGE 2
48 // Task Dispatcher hooks
49 // The following hooks are called by the task dispatcher.
50 //----------------------------------------------------------------
--------------
51
52 void TD_Init( void )
53 { // Called once at startup
54 1 CPUCS = 0x10; // CLKSPD[1:0]=10, for 48MHz opera
-tion
55 1
56 1 IFCONFIG = 0xC0; // set peripheral interface to por
-ts mode
57 1
58 1 CPUCS |= 0x26; // enable portc strobe feature, an
-d inv CLKOUT
59 1
60 1 // Registers which require a synchronization delay, see section
-15.14
61 1 // FIFORESET FIFOPINPOLAR
62 1 // INPKTEND OUTPKTEND
63 1 // EPxBCH:L REVCTL
64 1 // GPIFTCB3 GPIFTCB2
65 1 // GPIFTCB1 GPIFTCB0
66 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
67 1 // EPxFIFOCFG EPxGPIFFLGSEL
68 1 // PINFLAGSxx EPxFIFOIRQ
69 1 // EPxFIFOIE GPIFIRQ
70 1 // GPIFIE GPIFADRH:L
71 1 // UDMACRCH:L EPxGPIFTRIG
72 1 // GPIFTRIG
73 1
74 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as wel
-l...
75 1 // ...these have been replaced by GPIFTC[B3:B0] registers
76 1
77 1 SYNCDELAY; // see TRM section 15.14
78 1 EP1OUTCFG = 0xA0; // ep1out is valid BULK OUT 64
79 1 SYNCDELAY; // see TRM section 15.14
80 1 EP2CFG = 0xE2; // ep1out is valid BULK OUT 64
81 1 SYNCDELAY;
82 1 EP2BCH = 0x00;
83 1 // see TRM section 15.14
84 1 EP2BCL = 0x00;
85 1 EP2BCL = 0x00;
86 1 SYNCDELAY;
87 1
88 1 PORTACFG = 0x00; // PORTA as i/o pins...
89 1 OEA = 0xFF; // and as outputs...
90 1 IOA = 0x00;
91 1
92 1 PORTCCFG = 0x00; // PORTC as i/o pins...
93 1
94 1 BREAKPT &= ~bmBPEN; // to see BKPT LED go out TGE
95 1 Rwuen = TRUE; // Enable remote-wakeup
96 1
97 1 // turn debug LED[3:0] off...
98 1 ledX_rdvar = LED0_OFF;
99 1 ledX_rdvar = LED1_OFF;
100 1 ledX_rdvar = LED2_OFF;
101 1 ledX_rdvar = LED3_OFF;
102 1 }
103
C51 COMPILER V6.10 PORTCSTB 01/12/2009 17:09:31 PAGE 3
104 void TD_Poll( void )
105 { // Called repeatedly while the device is idle
106 1
107 1
108 1 if( !( EP1OUTCS & 0x02 ) )
109 1 { // BUSY=0, after host sent pkt.
110 2
111 2 if( EP1OUTBC )
112 2 {
113 3 LATRIGWR = 1; // PA0, just to give the LA a nice
- trigger
114 3 LATRIGWR = 0; // PA0, just to give the LA a nice
- trigger
115 3 LATRIGWR = 1; // PA0, just to give the LA a nice
- trigger
116 3
117 3 OEA = 0xFF; // PORTC[7:0] as outputs...
118 3
119 3
120 3 IOA = EP1OUTBUF[ 0 ]; // Write next byte to PortA, strob
-e WR#
121 3
122 3 }
123 2 else
124 2 { // host sent a zerolenpkt, or greater than 64 byte pkt.
125 3
126 3 }
127 2 EP1OUTBC = 0x00; // (re) arm endp buffer
128 2 }
129 1 else
130 1 {
131 2
132 2 }
133 1
134 1 OEA = 0x00;
135 1 // PORTC[7:0] as inputs
136 1 EP2FIFOBUF[ 0 ] = IOA; // Read next byte from PortC,
-strobe RD#
137 1 EP2BCL = 1;
138 1 // EP2BCL = 0x40;
139 1 // EP2BCL = 0x40;
140 1 SYNCDELAY;
141 1
142 1
143 1
144 1
145 1
146 1 }
147
148 BOOL TD_Suspend(void) // Called before the device goes in
-to suspend mode
149 {
150 1 return(TRUE);
151 1 }
152
153 BOOL TD_Resume(void) // Called after the device resumes
154 {
155 1 return(TRUE);
156 1 }
157
158 //----------------------------------------------------------------
--------------
C51 COMPILER V6.10 PORTCSTB 01/12/2009 17:09:31 PAGE 4
159 // Device Request hooks
160 // The following hooks are called by the end point 0 device requ
-est parser.
161 //----------------------------------------------------------------
--------------
162
163 BOOL DR_GetDescriptor(void)
164 {
165 1 return(TRUE);
166 1 }
167
168 BOOL DR_SetConfiguration(void) // Called when a Set Configuratio
-n command is received
169 {
170 1 Configuration = SETUPDAT[2];
171 1 return(TRUE); // Handled by user code
172 1 }
173
174 BOOL DR_GetConfiguration(void) // Called when a Get Configuratio
-n command is received
175 {
176 1 EP0BUF[0] = Configuration;
177 1 EP0BCH = 0;
178 1 EP0BCL = 1;
179 1 return(TRUE); // Handled by user code
180 1 }
181
182 BOOL DR_SetInterface(void) // Called when a Set Interface co
-mmand is received
183 {
184 1 AlternateSetting = SETUPDAT[2];
185 1 return(TRUE); // Handled by user code
186 1 }
187
188 BOOL DR_GetInterface(void) // Called when a Set Interface co
-mmand is received
189 {
190 1 EP0BUF[0] = AlternateSetting;
191 1 EP0BCH = 0;
192 1 EP0BCL = 1;
193 1 return(TRUE); // Handled by user code
194 1 }
195
196 BOOL DR_GetStatus(void)
197 {
198 1 return(TRUE);
199 1 }
200
201 BOOL DR_ClearFeature(void)
202 {
203 1 return(TRUE);
204 1 }
205
206 BOOL DR_SetFeature(void)
207 {
208 1 return(TRUE);
209 1 }
210
211 #define VX_B2 0xB2 // (re)arm endp 1 out
212
213 BOOL DR_VendorCmnd( void )
214 {
C51 COMPILER V6.10 PORTCSTB 01/12/2009 17:09:31 PAGE 5
215 1
216 1 switch( SETUPDAT[ 1 ] )
217 1 {
218 2 case VX_B2:
219 2 { // (re)arm endp1 out
220 3 ledX_rdvar = LED3_OFF; // visual
221 3 *EP0BUF = EP1OUTBC;
222 3 EP1OUTBC = 0x00; // (re)arm endp1out
223 3 EP0BCH = 0;
224 3 EP0BCL = 1; // Arm endpoint with # bytes to tr
-ansfer
225 3 EP0CS |= bmHSNAK; // Acknowledge handshake phase of
-device request
226 3 break;
227 3 }
228 2 default:
229 2 {
230 3 break;
231 3 }
232 2 }
233 1
234 1 return( FALSE ); // no error; command handled OK
235 1 }
236
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -