USB device specific requests


Data Structures

struct  S_line_coding

Functions

void cdc_get_line_coding (void)
 This function manages reception of line coding parameters (baudrate.
void cdc_set_control_line_state (void)
 This function manages the SET_CONTROL_LINE_LINE_STATE CDC request.
void cdc_set_line_coding (void)
 This function manages reception of line coding parameters (baudrate.
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 cdc_get_line_coding ( void   ) 

This function manages reception of line coding parameters (baudrate.

..).

Definition at line 205 of file usb_specific_request.c.

References S_line_coding::bCharFormat, S_line_coding::bDataBits, S_line_coding::bParityType, and S_line_coding::dwDTERate.

Referenced by usb_user_read_request().

00206 {
00207    Usb_ack_setup_received_free();
00208 
00209    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00210    Usb_write_endpoint_data(EP_CONTROL, 8, LSB0(line_coding.dwDTERate));
00211    Usb_write_endpoint_data(EP_CONTROL, 8, LSB1(line_coding.dwDTERate));
00212    Usb_write_endpoint_data(EP_CONTROL, 8, LSB2(line_coding.dwDTERate));
00213    Usb_write_endpoint_data(EP_CONTROL, 8, LSB3(line_coding.dwDTERate));
00214    Usb_write_endpoint_data(EP_CONTROL, 8, line_coding.bCharFormat);
00215    Usb_write_endpoint_data(EP_CONTROL, 8, line_coding.bParityType);
00216    Usb_write_endpoint_data(EP_CONTROL, 8, line_coding.bDataBits  );
00217 
00218    Usb_ack_control_in_ready_send();
00219    while (!Is_usb_control_in_ready());
00220 
00221    while(!Is_usb_control_out_received());
00222    Usb_ack_control_out_received_free();
00223 }

void cdc_set_control_line_state ( void   ) 

This function manages the SET_CONTROL_LINE_LINE_STATE CDC request.

Todo:
Manages here hardware flow control...

Definition at line 271 of file usb_specific_request.c.

Referenced by usb_user_read_request().

00272 {
00273    Usb_ack_setup_received_free();
00274    Usb_ack_control_in_ready_send();
00275    while (!Is_usb_control_in_ready());
00276 }

void cdc_set_line_coding ( void   ) 

This function manages reception of line coding parameters (baudrate.

..).

Definition at line 225 of file usb_specific_request.c.

References S_line_coding::bCharFormat, S_line_coding::bDataBits, S_line_coding::bParityType, S_line_coding::dwDTERate, and pcl_freq_param.

Referenced by usb_user_read_request().

00226 {
00227    Usb_ack_setup_received_free();
00228 
00229    while(!Is_usb_control_out_received());
00230    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00231 
00232    LSB0(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8);
00233    LSB1(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8);
00234    LSB2(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8);
00235    LSB3(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8);
00236    line_coding.bCharFormat = Usb_read_endpoint_data(EP_CONTROL, 8);
00237    line_coding.bParityType = Usb_read_endpoint_data(EP_CONTROL, 8);
00238    line_coding.bDataBits = Usb_read_endpoint_data(EP_CONTROL, 8);
00239    Usb_ack_control_out_received_free();
00240 
00241    Usb_ack_control_in_ready_send();
00242    while (!Is_usb_control_in_ready());
00243 
00244    // Set the baudrate of the USART
00245    {
00246       static usart_options_t dbg_usart_options;
00247       U32 stopbits, parity;
00248 
00249       if     ( line_coding.bCharFormat==0 )   stopbits = USART_1_STOPBIT;
00250       else if( line_coding.bCharFormat==1 )   stopbits = USART_1_5_STOPBITS;
00251       else                                    stopbits = USART_2_STOPBITS;
00252 
00253       if     ( line_coding.bParityType==0 )   parity = USART_NO_PARITY;
00254       else if( line_coding.bParityType==1 )   parity = USART_ODD_PARITY;
00255       else if( line_coding.bParityType==2 )   parity = USART_EVEN_PARITY;
00256       else if( line_coding.bParityType==3 )   parity = USART_MARK_PARITY;
00257       else                                    parity = USART_SPACE_PARITY;
00258 
00259       // Options for debug USART.
00260       dbg_usart_options.baudrate    = line_coding.dwDTERate;
00261       dbg_usart_options.charlength  = line_coding.bDataBits;
00262       dbg_usart_options.paritytype  = parity;
00263       dbg_usart_options.stopbits    = stopbits;
00264       dbg_usart_options.channelmode = USART_NORMAL_CHMODE;
00265 
00266       // Initialize it in RS232 mode.
00267       usart_init_rs232(DBG_USART, &dbg_usart_options, pcl_freq_param.pba_f);
00268    }
00269 }

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 81 of file usb_specific_request.c.

References EP_ATTRIBUTES_1, EP_ATTRIBUTES_2, EP_ATTRIBUTES_3, EP_SIZE_1_FS, EP_SIZE_1_HS, EP_SIZE_2_FS, EP_SIZE_2_HS, EP_SIZE_3, INT_EP, RX_EP, and TX_EP.

00082 {
00083 #if (USB_HIGH_SPEED_SUPPORT==ENABLED)
00084    if( !Is_usb_full_speed_mode() )
00085    {
00086       (void)Usb_configure_endpoint(INT_EP,
00087                              EP_ATTRIBUTES_3,
00088                              DIRECTION_IN,
00089                              EP_SIZE_3,
00090                              SINGLE_BANK);
00091     
00092       (void)Usb_configure_endpoint(TX_EP,
00093                              EP_ATTRIBUTES_1,
00094                              DIRECTION_IN,
00095                              EP_SIZE_1_HS,
00096                              DOUBLE_BANK);
00097     
00098       (void)Usb_configure_endpoint(RX_EP,
00099                              EP_ATTRIBUTES_2,
00100                              DIRECTION_OUT,
00101                              EP_SIZE_2_HS,
00102                              DOUBLE_BANK);
00103       return;
00104    }
00105 #endif
00106   (void)Usb_configure_endpoint(INT_EP,
00107                          EP_ATTRIBUTES_3,
00108                          DIRECTION_IN,
00109                          EP_SIZE_3,
00110                          SINGLE_BANK);
00111 
00112   (void)Usb_configure_endpoint(TX_EP,
00113                          EP_ATTRIBUTES_1,
00114                          DIRECTION_IN,
00115                          EP_SIZE_1_FS,
00116                          DOUBLE_BANK);
00117 
00118   (void)Usb_configure_endpoint(RX_EP,
00119                          EP_ATTRIBUTES_2,
00120                          DIRECTION_OUT,
00121                          EP_SIZE_2_FS,
00122                          DOUBLE_BANK);
00123 }

Bool usb_user_get_descriptor ( U8  ,
U8   
)

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

Definition at line 161 of file usb_specific_request.c.

00162 {
00163   /*
00164   pbuffer = NULL;
00165 
00166   switch (type)
00167   {
00168   case STRING_DESCRIPTOR:
00169     switch (string)
00170     {
00171     case LANG_ID:
00172       data_to_transfer = sizeof(usb_user_language_id);
00173       pbuffer = &usb_user_language_id;
00174       break;
00175 
00176     case MAN_INDEX:
00177       data_to_transfer = sizeof(usb_user_manufacturer_string_descriptor);
00178       pbuffer = &usb_user_manufacturer_string_descriptor;
00179       break;
00180 
00181     case PROD_INDEX:
00182       data_to_transfer = sizeof(usb_user_product_string_descriptor);
00183       pbuffer = &usb_user_product_string_descriptor;
00184       break;
00185 
00186     case SN_INDEX:
00187       data_to_transfer = sizeof(usb_user_serial_number);
00188       pbuffer = &usb_user_serial_number;
00189       break;
00190 
00191     default:
00192       break;
00193     }
00194     break;
00195 
00196   default:
00197     break;
00198   }
00199 
00200   return pbuffer != NULL;
00201   */
00202   return FALSE;
00203 }

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 132 of file usb_specific_request.c.

References cdc_get_line_coding(), cdc_set_control_line_state(), cdc_set_line_coding(), GET_LINE_CODING, SET_CONTROL_LINE_STATE, and SET_LINE_CODING.

00133 {
00134   switch (request)
00135   {
00136     case GET_LINE_CODING:
00137       cdc_get_line_coding();
00138       return TRUE;
00139       // No need to break here !
00140 
00141     case SET_LINE_CODING:
00142       cdc_set_line_coding();
00143       return TRUE;
00144       // No need to break here !
00145 
00146     case SET_CONTROL_LINE_STATE:
00147       cdc_set_control_line_state();
00148       return TRUE;
00149       // No need to break here !
00150 
00151     default:
00152       return FALSE;
00153       // No need to break here !
00154   }
00155 }


Generated on Fri Feb 19 02:32:34 2010 for AVR32 - USB CDC Stand-alone Example by  doxygen 1.5.5