USB device specific requests


Functions

void usb_user_endpoint_init (U8)
 This function configures the endpoints of the device application.
Bool usb_user_get_descriptor (U8, U8)
 This function returns the size and the pointer on a user information structure.
Bool usb_user_read_request (U8, U8)
 This function is called by the standard USB read request function when the USB request is not supported.


Function Documentation

void usb_user_endpoint_init ( U8  conf_nb  ) 

This function configures the endpoints of the device application.

This function is called when the set configuration request has been received.

The core of this function should be correctly rewritten depending on the USB device application characteristics (the USB device application has specific endpoint configuration).

This function is called when the set configuration request has been received.

Definition at line 79 of file usb_specific_request.c.

00080 {
00081 }

Bool usb_user_get_descriptor ( U8  ,
U8   
)

This function returns the size and the pointer on a user information structure.

Definition at line 148 of file usb_specific_request.c.

References data_to_transfer, LANG_ID, MAN_INDEX, pbuffer, PROD_INDEX, SN_INDEX, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.

00149 {
00150   pbuffer = NULL;
00151 
00152   switch (type)
00153   {
00154   case STRING_DESCRIPTOR:
00155     switch (string)
00156     {
00157     case LANG_ID:
00158       data_to_transfer = sizeof(usb_user_language_id);
00159       pbuffer = &usb_user_language_id;
00160       break;
00161 
00162     case MAN_INDEX:
00163       data_to_transfer = sizeof(usb_user_manufacturer_string_descriptor);
00164       pbuffer = &usb_user_manufacturer_string_descriptor;
00165       break;
00166 
00167     case PROD_INDEX:
00168       data_to_transfer = sizeof(usb_user_product_string_descriptor);
00169       pbuffer = &usb_user_product_string_descriptor;
00170       break;
00171 
00172 #if defined(SN_INDEX)
00173 #if SN_INDEX != 0
00174     case SN_INDEX:
00175       data_to_transfer = sizeof(usb_user_serial_number);
00176       pbuffer = &usb_user_serial_number;
00177       break;
00178 #endif
00179 #endif
00180 
00181     default:
00182       break;
00183     }
00184     break;
00185 
00186   default:
00187     break;
00188   }
00189 
00190   return pbuffer != NULL;
00191 }

Bool usb_user_read_request ( U8  type,
U8  request 
)

This function is called by the standard USB read request function when the USB request is not supported.

This function returns TRUE when the request is processed. This function returns FALSE if the request is not supported. In this case, a STALL handshake will be automatically sent by the standard USB read request function.

Definition at line 90 of file usb_specific_request.c.

References DFU_ABORT, DFU_CLRSTATUS, DFU_DETACH, DFU_DNLOAD, DFU_GETSTATE, DFU_GETSTATUS, DFU_UPLOAD, STATE_dfuERROR, STATE_dfuIDLE, STATUS_errSTALLEDPKT, STATUS_OK, usb_dfu_dnload(), usb_dfu_state, usb_dfu_status, and usb_dfu_upload().

00091 {
00092   if ((type & 0x7F) == 0x21)  // Type: Class; Recipient: Interface
00093   {
00094     switch (request)
00095     {
00096     case DFU_DETACH:
00097       break;
00098 
00099     case DFU_DNLOAD:
00100       return usb_dfu_dnload();
00101 
00102     case DFU_UPLOAD:
00103       return usb_dfu_upload();
00104 
00105     case DFU_GETSTATUS:
00106       Usb_ack_setup_received_free();
00107       Usb_reset_endpoint_fifo_access(EP_CONTROL);
00108       Usb_write_endpoint_data(EP_CONTROL, 8, usb_dfu_status); // bStatus
00109       Usb_write_endpoint_data(EP_CONTROL, 8, 0);  // bwPollTimeout
00110       Usb_write_endpoint_data(EP_CONTROL, 8, 0);
00111       Usb_write_endpoint_data(EP_CONTROL, 8, 0);
00112       Usb_write_endpoint_data(EP_CONTROL, 8, usb_dfu_state);  // bState
00113       Usb_write_endpoint_data(EP_CONTROL, 8, 0);  // iString
00114       Usb_ack_control_in_ready_send();
00115       while (!Is_usb_control_out_received());
00116       Usb_ack_control_out_received_free();
00117       return TRUE;
00118 
00119     case DFU_GETSTATE:
00120       Usb_ack_setup_received_free();
00121       Usb_reset_endpoint_fifo_access(EP_CONTROL);
00122       Usb_write_endpoint_data(EP_CONTROL, 8, usb_dfu_state);  // bState
00123       Usb_ack_control_in_ready_send();
00124       while (!Is_usb_control_out_received());
00125       Usb_ack_control_out_received_free();
00126       return TRUE;
00127 
00128     case DFU_CLRSTATUS:
00129     case DFU_ABORT:
00130       Usb_ack_setup_received_free();
00131       usb_dfu_status = STATUS_OK;
00132       usb_dfu_state = STATE_dfuIDLE;
00133       Usb_ack_control_in_ready_send();
00134       while (!Is_usb_control_in_ready());
00135       return TRUE;
00136     }
00137   }
00138 
00139   usb_dfu_status = STATUS_errSTALLEDPKT;
00140   usb_dfu_state = STATE_dfuERROR;
00141   return FALSE;
00142 }


Generated on Fri Feb 19 02:32:46 2010 for AVR32 - USB DFU Example: ISP by  doxygen 1.5.5