📄 periph.lst
字号:
C51 COMPILER V7.06 PERIPH 02/13/2008 21:37:10 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE PERIPH
OBJECT MODULE PLACED IN periph.OBJ
COMPILER INVOKED BY: C:\Keil\c51\bin\c51.exe periph.c DB OE CODE MODDP2 NOIV DF(FX2LP) DF(FX2LP_NEW)
stmt level source
1 /******************************************************************************
2 * File: periph.c
3 *
4 * Contents: Implementation of functions for supporting USB peripheral
5 * device functionality for l123456 devices, based on the
6 * Cypress FX2LP (CY7C68013A) development board.
7 * The functions' implementation was derived from the specific
8 * device configuration defined with the DriverWizard.
9 *
10 * Code was generated by DriverWizard v8.02 - http://www.jungo.com
11 * Copyright (c) 2008 Jungo Ltd. http://www.jungo.com
12 *******************************************************************************/
13
14 #pragma NOIV // Do not generate interrupt vectors
15
16 #include "wdf_cypress_lib.h"
17
18 #define NUM_OF_INTERFACES 1
19 extern BOOL GotSUD; // Received setup data flag
20 extern BOOL Sleep;
21 extern BOOL Rwuen;
22 extern BOOL Selfpwr;
23
24 BYTE Configuration; // Current configuration
25 BYTE AlternateSettings[NUM_OF_INTERFACES]; // Alternate settings
26
27 BYTE xdata myBuffer[1024];
28 #define MIN(a,b) ((a) < (b) ? (a) : (b))
29 static int CalcMaxPacketSize(int high_speed_max_packet, EP_TYPE type)
30 {
31 1 if (EZUSB_HIGHSPEED())
32 1 return high_speed_max_packet;
33 1
34 1 if (type == ISOCHRONOUS)
35 1 return MIN(high_speed_max_packet, 1023);
36 1
37 1 return MIN(high_speed_max_packet, 64);
38 1 }
39
40 //-----------------------------------------------------------------------------
41 // Task Dispatcher hooks
42 // The following hooks are called by the task dispatcher.
43 //-----------------------------------------------------------------------------
44
45 void WDF_InitInterface(BYTE ifc)
46 {
47 1 int i;
48 1
49 1 switch (ifc)
50 1 {
51 2 case 0:
52 2 switch (AlternateSettings[ifc])
53 2 {
54 3 case 0:
55 3 WDF_EP1OUTConfig(BULK);
C51 COMPILER V7.06 PERIPH 02/13/2008 21:37:10 PAGE 2
56 3 for (i = 0; i < 1; i++)
57 3 WDF_SkipOutPacket(0x1);
58 3
59 3 break;
60 3 }
61 2
62 2 default:
63 2 break;
64 2 }
65 1 }
66
67 void WDF_Init(void)
68 {
69 1 BREAKPT &= ~bmBPEN; // to see BKPT LED go out TGE
70 1 Rwuen = FALSE; // Disable remote wakeup
71 1 Selfpwr = FALSE; // Disable self powered
72 1
73 1 // set the CPU clock to 48MHz
74 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
75 1
76 1 // set the slave FIFO interface to 48MHz
77 1 IFCONFIG |= 0x40;
78 1
79 1 // enable dual autopointer feature
80 1 AUTOPTRSETUP |= 0x01;
81 1
82 1 WDF_InitInterface(0);
83 1 }
84
85 void WDF_Poll(void)
86 {
87 1 switch (AlternateSettings[0])
88 1 {
89 2 case 0:
90 2 if (!WDF_FIFOEmpty(0x1))
91 2 {
92 3 // Read the size of ready data in the FIFO
93 3 WORD bytesCount = WDF_GetEPByteCount(0x1);
94 3 // There is data in endpoint buffer - ignore it
95 3 WDF_SkipOutPacket(0x1);
96 3 }
97 2 break;
98 2 }
99 1
100 1 }
101
102 //-----------------------------------------------------------------------------
103 // Device Request hooks
104 // The following hooks are called by the end point 0 device request parser.
105 //-----------------------------------------------------------------------------
106
107 BOOL WDF_GetDescriptor(void)
108 {
109 1 return(TRUE);
110 1 }
111
112 // Called when a Set Configuration command is received
113 BOOL WDF_SetConfiguration(BYTE config)
114 {
115 1 Configuration = config;
116 1 return(TRUE); // Handled by user code
117 1 }
C51 COMPILER V7.06 PERIPH 02/13/2008 21:37:10 PAGE 3
118
119 // Called when a Get Configuration command is received
120 BOOL WDF_GetConfiguration(void)
121 {
122 1 EP0BUF[0] = Configuration;
123 1 EP0BCH = 0;
124 1 EP0BCL = 1;
125 1 return(TRUE); // Handled by user code
126 1 }
127
128 // Called when a Set Interface command is received
129 BOOL WDF_SetInterface(BYTE ifc, BYTE alt_set)
130 {
131 1 AlternateSettings[ifc] = alt_set;
132 1 WDF_InitInterface(ifc);
133 1 return(TRUE); // Handled by user code
134 1 }
135
136 // Called when a Get Interface command is received
137 BOOL WDF_GetInterface(BYTE ifc)
138 {
139 1 EP0BUF[0] = AlternateSettings[ifc];
140 1 EP0BCH = 0;
141 1 EP0BCL = 1;
142 1 return(TRUE); // Handled by user code
143 1 }
144
145 BOOL WDF_GetStatus(void)
146 {
147 1 return(TRUE);
148 1 }
149
150 BOOL WDF_ClearFeature(void)
151 {
152 1 return(TRUE);
153 1 }
154
155 BOOL WDF_SetFeature(void)
156 {
157 1 return(TRUE);
158 1 }
159
160 BOOL WDF_VendorCmnd(void)
161 {
162 1 if (!(SETUPDAT[0] & SETUP_VENDOR_REQUEST))
163 1 return FALSE;
164 1
165 1 switch (SETUPDAT[1])
166 1 {
167 2 /* Add here code for handling your specific vendor requests */
168 2 default:
169 2 return FALSE;
170 2 break;
171 2 }
172 1 return TRUE;
173 1 }
174
175 // Called before the device goes into suspend mode
176 BOOL WDF_Suspend(void)
177 {
178 1 return(TRUE);
179 1 }
C51 COMPILER V7.06 PERIPH 02/13/2008 21:37:10 PAGE 4
180
181 // Called after the device resumes
182 BOOL WDF_Resume(void)
183 {
184 1 return(TRUE);
185 1 }
186 //-----------------------------------------------------------------------------
187 // USB Interrupt Handlers
188 // The following functions are called by the USB interrupt jump table.
189 //-----------------------------------------------------------------------------
190
191 // Setup Data Available Interrupt Handler
192 void ISR_Sudav(void) interrupt 0
193 {
194 1 GotSUD = TRUE; // Set flag
195 1 EZUSB_IRQ_CLEAR();
196 1 USBIRQ = bmSUDAV; // Clear SUDAV IRQ
197 1 }
198
199 // Setup Token Interrupt Handler
200 void ISR_Sutok(void) interrupt 0
201 {
202 1 EZUSB_IRQ_CLEAR();
203 1 USBIRQ = bmSUTOK; // Clear SUTOK IRQ
204 1 }
205
206 void ISR_Sof(void) interrupt 0
207 {
208 1 EZUSB_IRQ_CLEAR();
209 1 USBIRQ = bmSOF; // Clear SOF IRQ
210 1 }
211
212 void ISR_Ures(void) interrupt 0
213 {
214 1 // whenever we get a USB reset, we should revert to full speed mode
215 1 pConfigDscr = pFullSpeedConfigDscr;
216 1 ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR_TYPE;
217 1 pOtherConfigDscr = pHighSpeedConfigDscr;
218 1 ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR_TYPE;
219 1
220 1 EZUSB_IRQ_CLEAR();
221 1 USBIRQ = bmURES; // Clear URES IRQ
222 1 }
223
224 void ISR_Susp(void) interrupt 0
225 {
226 1 Sleep = TRUE;
227 1 EZUSB_IRQ_CLEAR();
228 1 USBIRQ = bmSUSP;
229 1 }
230
231 void ISR_Highspeed(void) interrupt 0
232 {
233 1 if (EZUSB_HIGHSPEED())
234 1 {
235 2 pConfigDscr = pHighSpeedConfigDscr;
236 2 ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR_TYPE;
237 2 pOtherConfigDscr = pFullSpeedConfigDscr;
238 2 ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR_TYPE;
239 2 }
240 1
241 1 EZUSB_IRQ_CLEAR();
C51 COMPILER V7.06 PERIPH 02/13/2008 21:37:10 PAGE 5
242 1 USBIRQ = bmHSGRANT;
243 1 }
244 void ISR_Ep0ack(void) interrupt 0
245 {
246 1 }
247 void ISR_Stub(void) interrupt 0
248 {
249 1 }
250 void ISR_Ep0in(void) interrupt 0
251 {
252 1 }
253 void ISR_Ep0out(void) interrupt 0
254 {
255 1 }
256 void ISR_Ep1in(void) interrupt 0
257 {
258 1 }
259 void ISR_Ep1out(void) interrupt 0
260 {
261 1 }
262 void ISR_Ep2inout(void) interrupt 0
263 {
264 1 }
265 void ISR_Ep4inout(void) interrupt 0
266 {
267 1 }
268 void ISR_Ep6inout(void) interrupt 0
269 {
270 1 }
271 void ISR_Ep8inout(void) interrupt 0
272 {
273 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -