📄 f3xx_usb0_standard_requests.lst
字号:
240 //-----------------------------------------------------------------------------
241 //
242 // Return Value - None
243 // Parameters - None
244 //
245 // Standard request that should not change in custom HID designs.
246 //
247 //-----------------------------------------------------------------------------
248 void Set_Feature (void) // This routine will set the EP Halt
249 { // feature for endpoint 1
250 1
251 1 // Make sure device is configured, SETUP data
252 1 if ((USB0_STATE != DEV_CONFIGURED) ||
253 1 // is all valid and that request is directed at an endpoint
254 1 (SETUP.bmRequestType == IN_DEVICE) ||
255 1 (SETUP.bmRequestType == IN_INTERFACE) ||
256 1 SETUP.wValue.c[MSB] || SETUP.wIndex.c[MSB] ||
257 1 SETUP.wLength.c[MSB] || SETUP.wLength.c[LSB])
258 1 {
259 2 Force_Stall (); // Otherwise send stall to host
260 2 }
261 1
262 1 else
263 1 {
264 2 // Make sure endpoint exists and that halt
265 2 if ( (SETUP.bmRequestType == IN_ENDPOINT)&&
266 2 // endpoint feature is selected
267 2 (SETUP.wValue.c[LSB] == ENDPOINT_HALT) &&
268 2 ((SETUP.wIndex.c[LSB] == IN_EP1) ||
269 2 (SETUP.wIndex.c[LSB] == OUT_EP2) ) )
270 2 {
271 3 if (SETUP.wIndex.c[LSB] == IN_EP1)
272 3 {
273 4 POLL_WRITE_BYTE (INDEX, 1);// Set feature endpoint 1 halt
*** ERROR C202 IN LINE 273 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 273 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 273 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
274 4 POLL_WRITE_BYTE (EINCSR1, rbInSDSTL);
*** ERROR C202 IN LINE 274 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 274 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 274 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
275 4 EP_STATUS[1] = EP_HALT;
276 4 }
277 3 }
278 2 else
279 2 {
280 3 Force_Stall (); // Send procedural stall
281 3 }
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 6
282 2 }
283 1 POLL_WRITE_BYTE (INDEX, 0);
*** ERROR C202 IN LINE 283 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 283 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 283 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
284 1 if (EP_STATUS[0] != EP_STALL)
285 1 {
286 2 POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
*** ERROR C202 IN LINE 286 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 286 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 286 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
287 2 // Indicate SETUP packet has been
288 2 // serviced
289 2 }
290 1 }
291
292 //-----------------------------------------------------------------------------
293 // Set_Address
294 //-----------------------------------------------------------------------------
295 //
296 // Return Value - None
297 // Parameters - None
298 //
299 // Standard request that should not change in custom HID designs.
300 //
301 //-----------------------------------------------------------------------------
302 void Set_Address (void) // Set new function address
303 {
304 1 // Request must be directed to device
305 1 if ((SETUP.bmRequestType != IN_DEVICE) ||
306 1 // with index and length set to zero.
307 1 SETUP.wIndex.c[MSB] || SETUP.wIndex.c[LSB]||
308 1 SETUP.wLength.c[MSB] || SETUP.wLength.c[LSB]||
309 1 SETUP.wValue.c[MSB] || (SETUP.wValue.c[LSB] & 0x80))
310 1 {
311 2 Force_Stall (); // Send stall if SETUP data invalid
312 2 }
313 1
314 1 EP_STATUS[0] = EP_ADDRESS; // Set endpoint zero to update
315 1 // address next status phase
316 1 if (SETUP.wValue.c[LSB] != 0)
317 1 {
318 2 USB0_STATE = DEV_ADDRESS; // Indicate that device state is now
319 2 // address
320 2 }
321 1 else
322 1 {
323 2 USB0_STATE = DEV_DEFAULT; // If new address was 0x00, return
324 2 } // device to default state
325 1 if (EP_STATUS[0] != EP_STALL)
326 1 {
327 2 POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
*** ERROR C202 IN LINE 327 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 327 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 327 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
328 2 // Indicate SETUP packet has
329 2 // been serviced
330 2 }
331 1 }
332
333 //-----------------------------------------------------------------------------
334 // Get_Descriptor
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 7
335 //-----------------------------------------------------------------------------
336 //
337 // Return Value - None
338 // Parameters - None
339 //
340 // Standard request that should not change in custom HID designs.
341 //
342 //-----------------------------------------------------------------------------
343 void Get_Descriptor (void) // This routine sets the data pointer
344 { // and size to correct descriptor and
345 1 // sets the endpoint status to transmit
346 1
347 1 switch(SETUP.wValue.c[MSB]) // Determine which type of descriptor
348 1 { // was requested, and set data ptr and
349 2 case DSC_DEVICE: // size accordingly
350 2 DATAPTR = (unsigned char*) &DEVICEDESC;
351 2 DATASIZE = DEVICEDESC.bLength;
352 2 break;
353 2
354 2 case DSC_CONFIG:
355 2 DATAPTR = (unsigned char*) &ConfigDesc;
356 2 // Compiler Specific - The next statement
357 2 // reverses the bytes in the configuration
358 2 // descriptor for the compiler
359 2 DATASIZE = ConfigDesc.wTotalLength.c[MSB] +
360 2 256*ConfigDesc.wTotalLength.c[LSB];
361 2 break;
362 2
363 2 case DSC_STRING:
364 2 DATAPTR = STRINGDESCTABLE[SETUP.wValue.c[LSB]];
365 2 // Can have a maximum of 255 strings
366 2 DATASIZE = *DATAPTR;
367 2 break;
368 2
369 2 case DSC_INTERFACE:
370 2 DATAPTR = (unsigned char*) &InterfaceDesc;
371 2 DATASIZE = InterfaceDesc.bLength;
372 2 break;
373 2
374 2 case DSC_ENDPOINT:
375 2 if ( (SETUP.wValue.c[LSB] == IN_EP1) )
376 2 {
377 3 if (SETUP.wValue.c[LSB] == IN_EP1)
378 3 {
379 4 DATAPTR = (unsigned char*) &Endpoint1Desc;
380 4 DATASIZE = Endpoint1Desc.bLength;
381 4 }
382 3 else
383 3 {
384 4 DATAPTR = (unsigned char*) &Endpoint2Desc;
385 4 DATASIZE = Endpoint2Desc.bLength;
386 4 }
387 3 }
388 2 else
389 2 {
390 3 Force_Stall();
391 3 }
392 2 break;
393 2
394 2 case DSC_HID: // HID Specific (HID class descriptor)
395 2 DATAPTR = (unsigned char*)&HidDesc;
396 2 DATASIZE = HidDesc.bLength;
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 8
397 2 break;
398 2
399 2 case DSC_HID_REPORT: // HID Specific (HID report descriptor)
400 2 DATAPTR = (unsigned char*)&HIDREPORTDESC;
401 2 DATASIZE = HID_REPORT_DESCRIPTOR_SIZE;
402 2 break;
403 2
404 2 default:
405 2 Force_Stall (); // Send Stall if unsupported request
406 2 break;
407 2 }
408 1
409 1 // Verify that the requested descriptor is valid
410 1 if (SETUP.wValue.c[MSB] == DSC_DEVICE ||
411 1 SETUP.wValue.c[MSB] == DSC_CONFIG ||
412 1 SETUP.wValue.c[MSB] == DSC_STRING ||
413 1 SETUP.wValue.c[MSB] == DSC_INTERFACE ||
414 1 SETUP.wValue.c[MSB] == DSC_ENDPOINT)
415 1 {
416 2 if ((SETUP.wLength.c[LSB] < DATASIZE) &&
417 2 (SETUP.wLength.c[MSB] == 0))
418 2 {
419 3 DATASIZE = SETUP.wLength.i; // Send only requested amount of data
420 3 }
421 2 }
422 1 if (EP_STATUS[0] != EP_STALL) // Make sure endpoint not in stall mode
423 1 {
424 2 POLL_WRITE_BYTE (E0CSR, rbSOPRDY);// Service SETUP Packet
*** ERROR C202 IN LINE 424 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 424 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 424 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
425 2 EP_STATUS[0] = EP_TX; // Put endpoint in transmit mode
426 2 DATASENT = 0; // Reset Data Sent counter
427 2 }
428 1 }
429
430 //-----------------------------------------------------------------------------
431 // Get_Configuration
432 //-----------------------------------------------------------------------------
433 //
434 // Return Value - None
435 // Parameters - None
436 //
437 // Standard request that should not change in custom HID designs.
438 //
439 //-----------------------------------------------------------------------------
440 void Get_Configuration (void) // This routine returns current
441 { // configuration value
442 1 // This request must be directed to the device
443 1 if ( (SETUP.bmRequestType != OUT_DEVICE) ||
444 1 // with value word set to zero
445 1 SETUP.wValue.c[MSB] || SETUP.wValue.c[LSB]||
446 1 // and index set to zero
447 1 SETUP.wIndex.c[MSB] || SETUP.wIndex.c[LSB]||
448 1 // and SETUP length set to one
449 1 SETUP.wLength.c[MSB] || (SETUP.wLength.c[LSB] != 1) )
450 1 {
451 2 Force_Stall (); // Otherwise send a stall to host
452 2 }
453 1
454 1 else
455 1 {
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 9
456 2 if (USB0_STATE == DEV_CONFIGURED)// If the device is configured, then
457 2 { // return value 0x01 since this software
458 3 // only supports one configuration
459 3 DATAPTR = (unsigned char*)&ONES_PACKET;
460 3 DATASIZE = 1;
461 3 }
462 2 if (USB0_STATE == DEV_ADDRESS) // If the device is in address state, it
463 2 { // is not configured, so return 0x00
464 3 DATAPTR = (unsigned char*)&ZERO_PACKET;
465 3 DATASIZE = 1;
466 3 }
467 2 }
468 1 if (EP_STATUS[0] != EP_STALL)
469 1 {
470 2 // Set Serviced Out Packet bit
471 2 POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
*** ERROR C202 IN LINE 471 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 471 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 471 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
472 2 EP_STATUS[0] = EP_TX; // Put endpoint into transmit mode
473 2 DATASENT = 0; // Reset Data Sent counter to zero
474 2 }
475 1 }
476
477 //-----------------------------------------------------------------------------
478 // Set_Configuration
479 //-----------------------------------------------------------------------------
480 //
481 // Return Value - None
482 // Parameters - None
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -