📄 fwhid.lst
字号:
195 3
196 3 */
197 3
198 3 if(dscr_ptr = (void *)EZUSB_GetConfigDscr(SETUPDAT[2]))
199 3 {
200 4 SUDPTRH = MSB(dscr_ptr);
201 4 SUDPTRL = LSB(dscr_ptr);
202 4 }
203 3 else
204 3 EZUSB_STALL_EP0(); // Stall End Point 0
205 3 break;
206 3 case GD_STRING: // String
207 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
208 3 {
209 4 // Workaround for rev D errata number 8
210 4 // If you're certain that you will never run on rev D,
211 4 // you can just do this:
212 4 // SUDPTRH = MSB(dscr_ptr);
213 4 // SUDPTRL = LSB(dscr_ptr);
214 4 STRINGDSCR *sdp;
215 4 BYTE len;
216 4
217 4 sdp = dscr_ptr;
218 4
219 4 len = sdp->length;
220 4 if (len > SETUPDAT[6])
221 4 len = SETUPDAT[6]; //limit to the requested length
222 4
223 4 while (len)
224 4 {
225 5 for(i=0; i<min(len,64); i++)
226 5 *(IN0BUF+i) = *((BYTE xdata *)sdp+i);
227 5
228 5 //set length and arm Endpoint
229 5 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(len,64));
230 5 len -= min(len,64);
231 5
232 5 // Wait for it to go out (Rev C and above)
233 5 while(EP0CS & 0x04)
234 5 ;
235 5 }
236 4
237 4 // Arm a 0 length packet just in case. There was some reflector traffic about
238 4 // Apple hosts asking for too much data. This will keep them happy and will
239 4 // not hurt valid hosts because the next SETUP will clear this.
C51 COMPILER V6.14 FWHID 04/03/2003 11:25:17 PAGE 5
240 4 EZUSB_SET_EP_BYTES(IN0BUF_ID,0);
241 4 // Clear the HS-nak bit
242 4 EP0CS = bmHS;
243 4 }
244 3 else
245 3 EZUSB_STALL_EP0(); // Stall End Point 0
246 3 break;
247 3
248 3 case GD_REPORT:
249 3
250 3 {
251 4 //rdp holds the address of a REPORTDSCR structure.
252 4 REPORTDSCR *rdp;
253 4 //dscr_ptr is the address of the report descriptor
254 4 dscr_ptr = (REPORTDSCR xdata *) pReportDscr;
255 4 rdp = dscr_ptr;
256 4
257 4 //Get the report descriptor's length
258 4 reportlen = sizeof(REPORTDSCR);
259 4 // If the descriptor is longer than the requested amount,
260 4 // limit the data returned to the requested amount.
261 4 if (reportlen > SETUPDAT[6])
262 4 reportlen = SETUPDAT[6];
263 4 // If the host requests more bytes than the descriptor contains,
264 4 // the device will send the descriptor only.
265 4
266 4 while (reportlen)
267 4 {
268 5 //Copy the data to send into Endpoint 0's IN buffer.
269 5 //In each transaction, send the entire descriptor or 64 bytes, whichever is less.
270 5 //The data to send begins at the address pointed to by *rdp.
271 5 for(i=0; i<min(reportlen,64); i++)
272 5 *(IN0BUF+i) = *((BYTE xdata *)rdp+i);
273 5
274 5 //Set the amount of data to send and arm the endpoint
275 5 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(reportlen,64));
276 5 // If reportlen <= 64, all bytes have been copied, so set reportlen =0.
277 5 // Else, set reportlen = number of bytes remaining to send.
278 5 reportlen -= min(reportlen,64);
279 5
280 5 // Wait for the data to go out (Rev C and above)
281 5 while(EP0CS & 0x04);
282 5 }
283 4
284 4 }
285 3 //else
286 3 // EZUSB_STALL_EP0(); // Stall End Point 0
287 3
288 3 break;
289 3
290 3
291 3 default: // Invalid request
292 3 EZUSB_STALL_EP0(); // Stall End Point 0
293 3 }
294 2 break;
295 2 case SC_GET_INTERFACE: // *** Get Interface
296 2 DR_GetInterface();
297 2 break;
298 2 case SC_SET_INTERFACE: // *** Set Interface
299 2 DR_SetInterface();
300 2 break;
301 2 case SC_SET_CONFIGURATION: // *** Set Configuration
C51 COMPILER V6.14 FWHID 04/03/2003 11:25:17 PAGE 6
302 2 DR_SetConfiguration();
303 2 break;
304 2 case SC_GET_CONFIGURATION: // *** Get Configuration
305 2 DR_GetConfiguration();
306 2 break;
307 2 case SC_GET_STATUS: // *** Get Status
308 2 if(DR_GetStatus())
309 2 switch(SETUPDAT[0])
310 2 {
311 3 case GS_DEVICE: // Device
312 3 IN0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
313 3 IN0BUF[1] = 0;
314 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
315 3 break;
316 3 case GS_INTERFACE: // Interface
317 3 IN0BUF[0] = 0;
318 3 IN0BUF[1] = 0;
319 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
320 3 break;
321 3 case GS_ENDPOINT: // End Point
322 3 IN0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
323 3 IN0BUF[1] = 0;
324 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
325 3 break;
326 3 default: // Invalid Command
327 3 EZUSB_STALL_EP0(); // Stall End Point 0
328 3 }
329 2 break;
330 2 case SC_CLEAR_FEATURE: // *** Clear Feature
331 2 if(DR_ClearFeature())
332 2 switch(SETUPDAT[0])
333 2 {
334 3 case FT_DEVICE: // Device
335 3 if(SETUPDAT[2] == 1)
336 3 Rwuen = FALSE; // Disable Remote Wakeup
337 3 else
338 3 EZUSB_STALL_EP0(); // Stall End Point 0
339 3 break;
340 3 case FT_ENDPOINT: // End Point
341 3 if(SETUPDAT[2] == 0)
342 3 {
343 4 EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
344 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
345 4 }
346 3 else
347 3 EZUSB_STALL_EP0(); // Stall End Point 0
348 3 break;
349 3 }
350 2 break;
351 2 case SC_SET_FEATURE: // *** Set Feature
352 2 if(DR_SetFeature())
353 2 switch(SETUPDAT[0])
354 2 {
355 3 case FT_DEVICE: // Device
356 3 if(SETUPDAT[2] == 1)
357 3 Rwuen = TRUE; // Enable Remote Wakeup
358 3 else
359 3 EZUSB_STALL_EP0(); // Stall End Point 0
360 3 break;
361 3 case FT_ENDPOINT: // End Point
362 3 if(SETUPDAT[2] == 0)
363 3 EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
C51 COMPILER V6.14 FWHID 04/03/2003 11:25:17 PAGE 7
364 3 else
365 3 EZUSB_STALL_EP0(); // Stall End Point 0
366 3 break;
367 3 }
368 2 break;
369 2 default: // *** Invalid Command
370 2 if(DR_VendorCmnd())
371 2 EZUSB_STALL_EP0(); // Stall End Point 0
372 2 }
373 1
374 1 // Acknowledge handshake phase of device request
375 1 // Required for rev C does not effect rev B
376 1 EP0CS |= bmBIT1;
377 1 }
378
379 // Wake-up interrupt handler
380 void resume_isr(void) interrupt WKUP_VECT
381 {
382 1 EZUSB_CLEAR_RSMIRQ();
383 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1365 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 9 27
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -