📄 periph.lst
字号:
C51 COMPILER V7.06 PERIPH 02/20/2008 11:23:22 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 hid_001 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(INTERRUPT);
C51 COMPILER V7.06 PERIPH 02/20/2008 11:23:22 PAGE 2
56 3 for (i = 0; i < 1; i++)
57 3 WDF_SkipOutPacket(0x1);
58 3
59 3 WDF_EP1INConfig(INTERRUPT);
60 3 for (i = 0; i < 1; i++)
61 3 {
62 4 // Load EP fifo
63 4 WDF_FIFOWrite(0x81, myBuffer, CalcMaxPacketSize(64, INTERRUPT));
64 4 WDF_SetEPByteCount(0x81, CalcMaxPacketSize(64, INTERRUPT));
65 4 }
66 3
67 3 break;
68 3 }
69 2
70 2 default:
71 2 break;
72 2 }
73 1 }
74
75 void WDF_Init(void)
76 {
77 1 BREAKPT &= ~bmBPEN; // to see BKPT LED go out TGE
78 1 Rwuen = TRUE; // Enable remote wakeup
79 1 Selfpwr = FALSE; // Disable self powered
80 1
81 1 // set the CPU clock to 48MHz
82 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
83 1
84 1 // set the slave FIFO interface to 48MHz
85 1 IFCONFIG |= 0x40;
86 1
87 1 // enable dual autopointer feature
88 1 AUTOPTRSETUP |= 0x01;
89 1
90 1 WDF_InitInterface(0);
91 1 }
92
93 void WDF_Poll(void)
94 {
95 1 switch (AlternateSettings[0])
96 1 {
97 2 case 0:
98 2 if (!WDF_FIFOEmpty(0x1))
99 2 {
100 3 // Read the size of ready data in the FIFO
101 3 WORD bytesCount = WDF_GetEPByteCount(0x1);
102 3 // There is data in endpoint buffer - ignore it
103 3 WDF_SkipOutPacket(0x1);
104 3 }
105 2 if (!WDF_FIFOFull(0x81))
106 2 {
107 3 // Arm EP (with the initial data)
108 3 WDF_SetEPByteCount(0x81, CalcMaxPacketSize(64, INTERRUPT));
109 3 }
110 2 break;
111 2 }
112 1
113 1 }
114
115 //-----------------------------------------------------------------------------
116 // Device Request hooks
117 // The following hooks are called by the end point 0 device request parser.
C51 COMPILER V7.06 PERIPH 02/20/2008 11:23:22 PAGE 3
118 //-----------------------------------------------------------------------------
119
120 BOOL WDF_GetDescriptor(void)
121 {
122 1 return(TRUE);
123 1 }
124
125 // Called when a Set Configuration command is received
126 BOOL WDF_SetConfiguration(BYTE config)
127 {
128 1 Configuration = config;
129 1 return(TRUE); // Handled by user code
130 1 }
131
132 // Called when a Get Configuration command is received
133 BOOL WDF_GetConfiguration(void)
134 {
135 1 EP0BUF[0] = Configuration;
136 1 EP0BCH = 0;
137 1 EP0BCL = 1;
138 1 return(TRUE); // Handled by user code
139 1 }
140
141 // Called when a Set Interface command is received
142 BOOL WDF_SetInterface(BYTE ifc, BYTE alt_set)
143 {
144 1 AlternateSettings[ifc] = alt_set;
145 1 WDF_InitInterface(ifc);
146 1 return(TRUE); // Handled by user code
147 1 }
148
149 // Called when a Get Interface command is received
150 BOOL WDF_GetInterface(BYTE ifc)
151 {
152 1 EP0BUF[0] = AlternateSettings[ifc];
153 1 EP0BCH = 0;
154 1 EP0BCL = 1;
155 1 return(TRUE); // Handled by user code
156 1 }
157
158 BOOL WDF_GetStatus(void)
159 {
160 1 return(TRUE);
161 1 }
162
163 BOOL WDF_ClearFeature(void)
164 {
165 1 return(TRUE);
166 1 }
167
168 BOOL WDF_SetFeature(void)
169 {
170 1 return(TRUE);
171 1 }
172
173 BOOL WDF_VendorCmnd(void)
174 {
175 1 if (!(SETUPDAT[0] & SETUP_VENDOR_REQUEST))
176 1 return FALSE;
177 1
178 1 switch (SETUPDAT[1])
179 1 {
C51 COMPILER V7.06 PERIPH 02/20/2008 11:23:22 PAGE 4
180 2 /* Add here code for handling your specific vendor requests */
181 2 default:
182 2 return FALSE;
183 2 break;
184 2 }
185 1 return TRUE;
186 1 }
187
188 // Called before the device goes into suspend mode
189 BOOL WDF_Suspend(void)
190 {
191 1 return(TRUE);
192 1 }
193
194 // Called after the device resumes
195 BOOL WDF_Resume(void)
196 {
197 1 return(TRUE);
198 1 }
199 //-----------------------------------------------------------------------------
200 // USB Interrupt Handlers
201 // The following functions are called by the USB interrupt jump table.
202 //-----------------------------------------------------------------------------
203
204 // Setup Data Available Interrupt Handler
205 void ISR_Sudav(void) interrupt 0
206 {
207 1 GotSUD = TRUE; // Set flag
208 1 EZUSB_IRQ_CLEAR();
209 1 USBIRQ = bmSUDAV; // Clear SUDAV IRQ
210 1 }
211
212 // Setup Token Interrupt Handler
213 void ISR_Sutok(void) interrupt 0
214 {
215 1 EZUSB_IRQ_CLEAR();
216 1 USBIRQ = bmSUTOK; // Clear SUTOK IRQ
217 1 }
218
219 void ISR_Sof(void) interrupt 0
220 {
221 1 EZUSB_IRQ_CLEAR();
222 1 USBIRQ = bmSOF; // Clear SOF IRQ
223 1 }
224
225 void ISR_Ures(void) interrupt 0
226 {
227 1 // whenever we get a USB reset, we should revert to full speed mode
228 1 pConfigDscr = pFullSpeedConfigDscr;
229 1 ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR_TYPE;
230 1 pOtherConfigDscr = pHighSpeedConfigDscr;
231 1 ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR_TYPE;
232 1
233 1 EZUSB_IRQ_CLEAR();
234 1 USBIRQ = bmURES; // Clear URES IRQ
235 1 }
236
237 void ISR_Susp(void) interrupt 0
238 {
239 1 Sleep = TRUE;
240 1 EZUSB_IRQ_CLEAR();
241 1 USBIRQ = bmSUSP;
C51 COMPILER V7.06 PERIPH 02/20/2008 11:23:22 PAGE 5
242 1 }
243
244 void ISR_Highspeed(void) interrupt 0
245 {
246 1 if (EZUSB_HIGHSPEED())
247 1 {
248 2 pConfigDscr = pHighSpeedConfigDscr;
249 2 ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR_TYPE;
250 2 pOtherConfigDscr = pFullSpeedConfigDscr;
251 2 ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR_TYPE;
252 2 }
253 1
254 1 EZUSB_IRQ_CLEAR();
255 1 USBIRQ = bmHSGRANT;
256 1 }
257 void ISR_Ep0ack(void) interrupt 0
258 {
259 1 }
260 void ISR_Stub(void) interrupt 0
261 {
262 1 }
263 void ISR_Ep0in(void) interrupt 0
264 {
265 1 }
266 void ISR_Ep0out(void) interrupt 0
267 {
268 1 }
269 void ISR_Ep1in(void) interrupt 0
270 {
271 1 }
272 void ISR_Ep1out(void) interrupt 0
273 {
274 1 }
275 void ISR_Ep2inout(void) interrupt 0
276 {
277 1 }
278 void ISR_Ep4inout(void) interrupt 0
279 {
280 1 }
281 void ISR_Ep6inout(void) interrupt 0
282 {
283 1 }
284 void ISR_Ep8inout(void) interrupt 0
285 {
286 1 }
287 void ISR_Ibn(void) interrupt 0
288 {
289 1 }
290 void ISR_Ep0pingnak(void) interrupt 0
291 {
292 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -