usb_standard_request.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00002 /*! \file *********************************************************************
00003  *
00004  * \brief
00005  *      This file contains the USB endpoint 0 management routines corresponding to
00006  *      the standard enumeration process (refer to chapter 9 of the USB
00007  *      specification.
00008  *      This file calls routines of the usb_specific_request.c file for non-standard
00009  *      request management.
00010  *      The enumeration parameters (descriptor tables) are contained in the
00011  *      usb_descriptors.c file.
00012  *
00013  * \addtogroup usbdriver
00014  *
00015  * \author
00016  *      Atmel Corporation: http://www.atmel.com \n
00017  *      Support email: avr@atmel.com
00018  *
00019  ******************************************************************************/
00020 /* Copyright (c) 2008  ATMEL Corporation
00021    All rights reserved.
00022 
00023    Redistribution and use in source and binary forms, with or without
00024    modification, are permitted provided that the following conditions are met:
00025 
00026    * Redistributions of source code must retain the above copyright
00027      notice, this list of conditions and the following disclaimer.
00028    * Redistributions in binary form must reproduce the above copyright
00029      notice, this list of conditions and the following disclaimer in
00030      the documentation and/or other materials provided with the
00031      distribution.
00032    * Neither the name of the copyright holders nor the names of
00033      contributors may be used to endorse or promote products derived
00034      from this software without specific prior written permission.
00035 
00036   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00037   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00039   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00040   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00041   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00042   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00043   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00044   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00045   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00046   POSSIBILITY OF SUCH DAMAGE.
00047 */
00048 
00049 //_____ I N C L U D E S ____________________________________________________
00050 
00051 #include "config.h"
00052 #include "usb_drv.h"
00053 #include "usb_descriptors.h"
00054 #include "usb_specific_request.h"
00055 #include <string.h>
00056 
00057 //_____ M A C R O S ________________________________________________________
00058 
00059 
00060 //_____ D E F I N I T I O N ________________________________________________
00061 #define PRINTF printf
00062 #define PRINTF_P printf_P
00063 
00064 //_____ P R I V A T E   D E C L A R A T I O N ______________________________
00065 
00066 static  void    usb_get_descriptor(   void);
00067 static  void    usb_set_address(      void);
00068 static  void    usb_set_configuration(void);
00069 static  void    usb_clear_feature(    void);
00070 static  void    usb_set_feature(      void);
00071 static  void    usb_get_status(       void);
00072 static  void    usb_get_configuration(void);
00073 static  void    usb_get_interface (void);
00074 static  void    usb_set_interface (void);
00075 
00076 
00077 //_____ D E C L A R A T I O N ______________________________________________
00078 
00079 static  bit  zlp;
00080 static  U8   endpoint_status[NB_ENDPOINTS];
00081 
00082 #ifdef AVRGCC
00083         PGM_VOID_P pbuffer;
00084 #else
00085         U8   FLASH *pbuffer;
00086 #endif
00087         U8   data_to_transfer;
00088 
00089         U16  wInterface;
00090 
00091 static  U8   bmRequestType;
00092 
00093         U8   usb_configuration_nb;
00094 
00095                 usb_mode_t usb_mode = rndis_debug;
00096 
00097 extern  bit     usb_connected;
00098 extern  FLASH    S_usb_device_descriptor             usb_user_device_descriptor_network;
00099 extern  FLASH    S_usb_user_configuration_descriptor_network usb_user_configuration_descriptor_network;
00100 extern  FLASH    S_usb_device_descriptor             usb_user_device_descriptor_composite;
00101 extern  FLASH    S_usb_user_configuration_descriptor_composite usb_user_configuration_descriptor_composite;
00102 
00103 //! usb_process_request.
00104 //!
00105 //! @brief This function reads the SETUP request sent to the default control endpoint
00106 //! and calls the appropriate function. When exiting of the usb_read_request
00107 //! function, the device is ready to manage the next request.
00108 //!
00109 //! @note list of supported requests:
00110 //! GET_DESCRIPTOR
00111 //! GET_CONFIGURATION
00112 //! SET_ADDRESS
00113 //! SET_CONFIGURATION
00114 //! CLEAR_FEATURE
00115 //! SET_FEATURE
00116 //! GET_STATUS
00117 //!
00118 void usb_process_request(void)
00119 {
00120    U8  bmRequest;
00121 
00122    bmRequestType = Usb_read_byte();
00123    bmRequest     = Usb_read_byte();
00124 
00125    switch (bmRequest)
00126    {
00127     case GET_DESCRIPTOR:
00128          if (0x80 == bmRequestType) { usb_get_descriptor(); }
00129          else goto user_read;
00130          break;
00131 
00132     case GET_CONFIGURATION:
00133          if (0x80 == bmRequestType) { usb_get_configuration(); }
00134          else goto user_read;
00135          break;
00136 
00137     case SET_ADDRESS:
00138          if (0x00 == bmRequestType) { usb_set_address(); }
00139          else goto user_read;
00140          break;
00141 
00142     case SET_CONFIGURATION:
00143          if (0x00 == bmRequestType) { usb_set_configuration(); }
00144          else goto user_read;
00145          break;
00146 
00147     case CLEAR_FEATURE:
00148          if (0x02 >= bmRequestType) { usb_clear_feature(); }
00149          else goto user_read;
00150          break;
00151 
00152     case SET_FEATURE:
00153          if (0x02 >= bmRequestType) { usb_set_feature(); }
00154          else goto user_read;
00155          break;
00156 
00157     case GET_STATUS:
00158          if ((0x7F < bmRequestType) & (0x82 >= bmRequestType))
00159                                     { usb_get_status(); }
00160          else goto user_read;
00161          break;
00162 
00163     case GET_INTERFACE:
00164           if (bmRequestType == 0x81) { usb_get_interface(); }
00165                   else goto user_read;
00166           break;
00167 
00168 
00169     case SET_INTERFACE:
00170       if (bmRequestType == 0x01) {usb_set_interface();}
00171       break;
00172 
00173     case SET_DESCRIPTOR:
00174     case SYNCH_FRAME:
00175     default: //!< un-supported request => call to user read request
00176         user_read:
00177          usb_user_read_request(bmRequestType, bmRequest);
00178          break;
00179   }
00180         
00181         Usb_select_endpoint(EP_CONTROL);
00182 
00183         // If the receive setup flag hasn't been cleared
00184         // by this point then we can assume that we didn't
00185         // support this request and should stall.
00186         if(Is_usb_receive_setup())
00187                 Usb_enable_stall_handshake();
00188         
00189         // Clear some flags.
00190         Usb_ack_receive_setup();
00191         Usb_ack_receive_out();
00192         Usb_ack_in_ready();
00193 }
00194 
00195 //! usb_set_address.
00196 //!
00197 //! This function manages the SET ADDRESS request. When complete, the device
00198 //! will filter the requests using the new address.
00199 //!
00200 //! @warning Code:xx bytes (function code length)
00201 //!
00202 void usb_set_address(void)
00203 {
00204    Usb_configure_address(Usb_read_byte());
00205 
00206    Usb_ack_receive_setup();
00207 
00208    Usb_send_control_in();                    //!< send a ZLP for STATUS phase
00209    while(!Is_usb_in_ready());                //!< waits for status phase done
00210                                              //!< before using the new address
00211    Usb_enable_address();
00212 }
00213 
00214 //! usb_set_configuration.
00215 //!
00216 //! This function manages the SET CONFIGURATION request. If the selected
00217 //! configuration is valid, this function call the usb_user_endpoint_init()
00218 //! function that will configure the endpoints following the configuration
00219 //! number.
00220 //!
00221 //! @warning Code:xx bytes (function code length)
00222 //!
00223 void usb_set_configuration( void )
00224 {
00225 U8 configuration_number;
00226 
00227    configuration_number = Usb_read_byte();
00228 
00229    // TODO: Verify configuration_number!
00230    Usb_ack_receive_setup();
00231    usb_configuration_nb = configuration_number;
00232 
00233    Usb_send_control_in();                    //!< send a ZLP for STATUS phase
00234    while(!Is_usb_in_ready());
00235 
00236    usb_user_endpoint_init(usb_configuration_nb);  //!< endpoint configuration
00237    Usb_set_configuration_action();
00238 }
00239 
00240 
00241 
00242 
00243 
00244 void usb_get_string_descriptor_sram(U8  string_type) {
00245         U16 requested_length;
00246         U8  dummy;
00247         const char* user_str;
00248 
00249         user_str = usb_user_get_string_sram(string_type);
00250         
00251         dummy = Usb_read_byte();                     //!< don't care of wIndex field
00252         dummy = Usb_read_byte();
00253         requested_length = Usb_read_byte();              //!< read wLength
00254         requested_length |= Usb_read_byte()<<8;
00255         
00256         if(!user_str)
00257                 return;
00258         
00259         const U8 actual_descriptor_size = 2+strlen(user_str)*2;
00260 
00261         if (requested_length > actual_descriptor_size) {
00262                 zlp = ((actual_descriptor_size % EP_CONTROL_LENGTH) == 0);
00263                 requested_length = actual_descriptor_size;
00264         }
00265         
00266         Usb_ack_receive_setup() ;                  //!< clear the receive setup flag
00267 
00268         if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00269                 Usb_enable_stall_handshake();
00270                 return;
00271         }
00272 
00273         // Output the length
00274         Usb_write_byte(actual_descriptor_size);
00275         
00276         // Output the type
00277         Usb_write_byte(STRING_DESCRIPTOR);
00278 
00279         requested_length -= 2;
00280         U8  nb_byte = 2;
00281 
00282         if(!requested_length) {
00283                 Usb_send_control_in();
00284         }
00285                 
00286    while((requested_length != 0) && (!Is_usb_receive_out()))
00287    {
00288                 if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00289                         Usb_enable_stall_handshake();
00290                         break;
00291                 }
00292 
00293       while(requested_length != 0)        //!< Send data until necessary
00294       {
00295          if(nb_byte==EP_CONTROL_LENGTH) //!< Check endpoint 0 size
00296          {
00297             nb_byte=0;
00298             break;
00299          }
00300 
00301          Usb_write_byte(*user_str);
00302          Usb_write_byte(0);
00303                  user_str++;
00304          requested_length -=2;
00305                  nb_byte+=2;
00306       }
00307       Usb_send_control_in();
00308    }
00309 
00310 //bail:
00311         if(Is_usb_receive_out()) {
00312                 //! abort from Host
00313                 Usb_ack_receive_out();
00314                 return;
00315         } 
00316 
00317         if(zlp == TRUE) {
00318                 if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00319                         Usb_enable_stall_handshake();
00320                         return;
00321                 }
00322                 Usb_send_control_in();
00323         }
00324 
00325         usb_endpoint_wait_for_receive_out();
00326         Usb_ack_receive_out();
00327 }
00328 
00329 
00330 void usb_get_string_descriptor(U8  string_type) {
00331         U16 requested_length;
00332         U8  dummy;
00333         PGM_P user_str;
00334 
00335         user_str = usb_user_get_string(string_type);
00336 
00337         if(!user_str) {
00338                 usb_get_string_descriptor_sram(string_type);
00339                 return;
00340         }
00341         
00342         dummy = Usb_read_byte();                     //!< don't care of wIndex field
00343         dummy = Usb_read_byte();
00344         requested_length = Usb_read_byte();              //!< read wLength
00345         requested_length |= Usb_read_byte()<<8;
00346         
00347         
00348         const U8 actual_descriptor_size = 2+strlen_P(user_str)*2;
00349 
00350         if (requested_length > actual_descriptor_size) {
00351                 zlp = ((actual_descriptor_size % EP_CONTROL_LENGTH) == 0);
00352                 requested_length = actual_descriptor_size;
00353         }
00354         
00355         Usb_ack_receive_setup() ;                  //!< clear the receive setup flag
00356 
00357         if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00358                 Usb_enable_stall_handshake();
00359                 return;
00360         }
00361         U8  nb_byte = 0;
00362 
00363         // Output the length
00364         if(requested_length) {
00365                 Usb_write_byte(actual_descriptor_size);
00366                 requested_length--;
00367                 nb_byte++;
00368         }
00369         
00370         // Output the type
00371         if(requested_length) {
00372                 Usb_write_byte(STRING_DESCRIPTOR);
00373                 requested_length--;
00374                 nb_byte++;
00375         }
00376         
00377         if(!requested_length) {
00378                 Usb_send_control_in();
00379         }
00380                 
00381         while((requested_length != 0) && (!Is_usb_receive_out()))
00382         {
00383                 if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00384                         Usb_enable_stall_handshake();
00385                         break;
00386                 }
00387 
00388                 while(requested_length != 0)        //!< Send data until necessary
00389                 {
00390                         if(nb_byte==EP_CONTROL_LENGTH) { //!< Check endpoint 0 size
00391                                 nb_byte=0;
00392                                 break;
00393                         }
00394 
00395                         Usb_write_byte(pgm_read_byte_near((unsigned int)user_str++));
00396                         requested_length--;
00397                         nb_byte++;
00398                         if(requested_length) {
00399                                 Usb_write_byte(0);
00400                                 requested_length--;
00401                                 nb_byte++;
00402                         }
00403                 }
00404                 Usb_send_control_in();
00405         }
00406 
00407 //bail:
00408 
00409         if(Is_usb_receive_out()) {
00410                 //! abort from Host
00411                 Usb_ack_receive_out();
00412                 return;
00413         } 
00414 
00415         if(zlp == TRUE) {
00416                 if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00417                         Usb_enable_stall_handshake();
00418                         return;
00419                 }
00420                 Usb_send_control_in();
00421         }
00422 
00423         usb_endpoint_wait_for_receive_out();
00424         Usb_ack_receive_out();
00425 }
00426 
00427 
00428 //! usb_get_descriptor.
00429 //!
00430 //! This function manages the GET DESCRIPTOR request. The device descriptor,
00431 //! the configuration descriptor and the device qualifier are supported. All
00432 //! other descriptors must be supported by the usb_user_get_descriptor
00433 //! function.
00434 //! Only 1 configuration is supported.
00435 //!
00436 //! @warning Code:xx bytes (function code length)
00437 //!
00438 void usb_get_descriptor(void)
00439 {
00440         U8  LSBwLength, MSBwLength;
00441         U8  descriptor_type ;
00442         U8  string_type     ;
00443         U8  dummy;
00444         U8  byteswereread;
00445 
00446         zlp             = FALSE;                  /* no zero length packet */
00447         string_type     = Usb_read_byte();        /* read LSB of wValue    */
00448         descriptor_type = Usb_read_byte();        /* read MSB of wValue    */
00449         byteswereread   = 0;
00450 
00451         switch (descriptor_type)
00452         {
00453         case DEVICE_DESCRIPTOR:
00454           data_to_transfer = Usb_get_dev_desc_length(); //!< sizeof (usb_user_device_descriptor);
00455           pbuffer          = Usb_get_dev_desc_pointer();
00456           break;
00457         case CONFIGURATION_DESCRIPTOR:
00458                 data_to_transfer = Usb_get_conf_desc_length(string_type); //!< sizeof (usb_user_configuration_descriptor);
00459                 pbuffer          = Usb_get_conf_desc_pointer(string_type);
00460           break;
00461 #if 1 
00462         case STRING_DESCRIPTOR:
00463           if(string_type!=LANG_ID) {
00464                 usb_get_string_descriptor(string_type);
00465                 return;
00466           }
00467 #endif
00468         default:
00469                 dummy = Usb_read_byte();
00470                 dummy = Usb_read_byte();
00471                 LSBwLength = Usb_read_byte();
00472                 MSBwLength = Usb_read_byte();
00473                 byteswereread=1;
00474                 if( usb_user_get_descriptor(descriptor_type, string_type)==FALSE ) {
00475                     Usb_enable_stall_handshake(); //TODO:is this necessary, Win7 flaky without?
00476                         Usb_ack_receive_setup();
00477                         return;
00478                 }
00479           break;
00480         }
00481         if (byteswereread==0) {
00482                 dummy = Usb_read_byte();                     //!< don't care of wIndex field
00483                 dummy = Usb_read_byte();
00484                 LSBwLength = Usb_read_byte();              //!< read wLength
00485                 MSBwLength = Usb_read_byte();
00486         }
00487 
00488         Usb_ack_receive_setup() ;                  //!< clear the receive setup flag
00489 
00490         if ((LSBwLength > data_to_transfer) || (MSBwLength)) {
00491                 if ((data_to_transfer % EP_CONTROL_LENGTH) == 0) { zlp = TRUE; }
00492                 else { zlp = FALSE; }                   //!< no need of zero length packet
00493 
00494                 LSBwLength = data_to_transfer;
00495                 MSBwLength = 0x00;
00496         } else {
00497                 data_to_transfer = LSBwLength;         //!< send only requested number of data
00498         }
00499         
00500         while((data_to_transfer != 0) && (!Is_usb_receive_out())) {
00501                 U8  nb_byte = 0;
00502                 if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00503                         Usb_enable_stall_handshake();
00504                         break;
00505                 }
00506 
00507         //! Send data until necessary
00508                 while(data_to_transfer != 0) {
00509 //                      if(Is_usb_write_enabled()) //!< Check endpoint 0 size
00510                         if(nb_byte++==EP_CONTROL_LENGTH) //!< Check endpoint 0 size
00511                                 break;
00512 
00513                         Usb_write_byte(pgm_read_byte_near((unsigned int)pbuffer++));
00514                         data_to_transfer --;
00515 
00516                 }
00517                 Usb_send_control_in();
00518         }
00519 
00520         if(Is_usb_receive_out()) {
00521                 //! abort from Host
00522                 Usb_ack_receive_out();
00523                 return;
00524         }
00525         
00526         if(zlp == TRUE) {
00527                 if(usb_endpoint_wait_for_read_control_enabled()!=0) {
00528                         Usb_enable_stall_handshake();
00529                         return;
00530                 }
00531                 Usb_send_control_in();
00532         }
00533 
00534         usb_endpoint_wait_for_receive_out();
00535         Usb_ack_receive_out();
00536 }
00537 
00538 //! usb_get_configuration.
00539 //!
00540 //! This function manages the GET CONFIGURATION request. The current
00541 //! configuration number is returned.
00542 //!
00543 //! @warning Code:xx bytes (function code length)
00544 //!
00545 void usb_get_configuration(void)
00546 {
00547    Usb_ack_receive_setup();
00548 
00549    Usb_write_byte(usb_configuration_nb);
00550    Usb_send_control_in();
00551 
00552    usb_endpoint_wait_for_receive_out();
00553    Usb_ack_receive_out();
00554 }
00555 
00556 //! usb_get_status.
00557 //!
00558 //! This function manages the GET STATUS request. The device, interface or
00559 //! endpoint status is returned.
00560 //!
00561 //! @warning Code:xx bytes (function code length)
00562 //!
00563 void usb_get_status(void)
00564 {
00565 U8 wIndex;
00566 U8 dummy;
00567 
00568    dummy    = Usb_read_byte();                 //!< dummy read
00569    dummy    = Usb_read_byte();                 //!< dummy read
00570    wIndex = Usb_read_byte();
00571 
00572    switch(bmRequestType)
00573    {
00574     case REQUEST_DEVICE_STATUS:    Usb_ack_receive_setup();
00575                                    Usb_write_byte(DEVICE_STATUS);
00576                                    break;
00577 
00578     case REQUEST_INTERFACE_STATUS: Usb_ack_receive_setup();
00579                                    Usb_write_byte(INTERFACE_STATUS);
00580                                    break;
00581 
00582     case REQUEST_ENDPOINT_STATUS:  Usb_ack_receive_setup();
00583                                    wIndex = wIndex & MSK_EP_DIR;
00584                                    Usb_write_byte(endpoint_status[wIndex]);
00585                                    break;
00586     default:
00587                                    Usb_enable_stall_handshake();
00588                                    Usb_ack_receive_setup();
00589                                    return;
00590    }
00591 
00592    Usb_write_byte(0x00);
00593    Usb_send_control_in();
00594 
00595    usb_endpoint_wait_for_receive_out();
00596    Usb_ack_receive_out();
00597 }
00598 
00599 //! usb_set_feature.
00600 //!
00601 //! This function manages the SET FEATURE request. The USB test modes are
00602 //! supported by this function.
00603 //!
00604 //! @warning Code:xx bytes (function code length)
00605 //!
00606 void usb_set_feature(void)
00607 {
00608 U8 wValue;
00609 U8 wIndex;
00610 U8 dummy;
00611 
00612    if (bmRequestType == INTERFACE_TYPE)
00613    {
00614       return;
00615    }
00616    else if (bmRequestType == ENDPOINT_TYPE)
00617    {
00618       wValue = Usb_read_byte();
00619       dummy    = Usb_read_byte();                //!< dummy read
00620 
00621       if (wValue == FEATURE_ENDPOINT_HALT)
00622       {
00623          wIndex = (Usb_read_byte() & MSK_EP_DIR);
00624 
00625          if (wIndex == EP_CONTROL)
00626          {
00627             return;
00628          }
00629 
00630          Usb_select_endpoint(wIndex);
00631          if(Is_usb_endpoint_enabled())
00632          {
00633             Usb_enable_stall_handshake();
00634             Usb_select_endpoint(EP_CONTROL);
00635             endpoint_status[wIndex] = 0x01;
00636             Usb_ack_receive_setup();
00637             Usb_send_control_in();
00638          }
00639          else
00640          {
00641             Usb_select_endpoint(EP_CONTROL);
00642             return;
00643          }
00644       }
00645       else
00646       {
00647          return;
00648       }
00649    }
00650 }
00651 
00652 //! usb_clear_feature.
00653 //!
00654 //! This function manages the SET FEATURE request.
00655 //!
00656 //! @warning Code:xx bytes (function code length)
00657 //!
00658 void usb_clear_feature(void)
00659 {
00660 U8 wValue;
00661 U8 wIndex;
00662 U8 dummy;
00663 
00664    if (bmRequestType == ZERO_TYPE)
00665    {
00666       return;
00667    }
00668    else if (bmRequestType == INTERFACE_TYPE)
00669    {
00670       return;
00671    }
00672    else if (bmRequestType == ENDPOINT_TYPE)
00673    {
00674       wValue = Usb_read_byte();
00675       dummy  = Usb_read_byte();                //!< dummy read
00676 
00677       if (wValue == FEATURE_ENDPOINT_HALT)
00678       {
00679          wIndex = (Usb_read_byte() & MSK_EP_DIR);
00680 
00681          Usb_select_endpoint(wIndex);
00682          if(Is_usb_endpoint_enabled())
00683          {
00684             if(wIndex != EP_CONTROL)
00685             {
00686                Usb_disable_stall_handshake();
00687                Usb_reset_endpoint(wIndex);
00688                Usb_reset_data_toggle();
00689             }
00690             Usb_select_endpoint(EP_CONTROL);
00691             endpoint_status[wIndex] = 0x00;
00692             Usb_ack_receive_setup();
00693             Usb_send_control_in();
00694 
00695          }
00696          else
00697          {
00698             return;
00699          }
00700       }
00701       else
00702       {
00703          return;
00704       }
00705    }
00706 }
00707 
00708 //! usb_get_interface.
00709 //!
00710 //! TThis function manages the GET_INTERFACE request.
00711 //!
00712 //! @warning Code:xx bytes (function code length)
00713 //!
00714 void usb_get_interface (void)
00715 {
00716         // Not yet implemented.
00717 }
00718 
00719 //! usb_set_interface.
00720 //!
00721 //! TThis function manages the SET_INTERFACE request.
00722 //!
00723 //! @warning Code:xx bytes (function code length)
00724 //!
00725 void usb_set_interface (void)
00726 {
00727         U8 alt_setting;
00728         U8 dummy;
00729         U8 interface;
00730         
00731         alt_setting = Usb_read_byte();
00732         dummy    = Usb_read_byte();
00733         interface = Usb_read_byte();
00734         
00735         if(usb_user_set_alt_interface(interface, alt_setting)) {
00736                 Usb_ack_receive_setup();
00737                 Usb_send_control_in();                    //!< send a ZLP for STATUS phase
00738                 while(!Is_usb_in_ready());
00739 
00740                 usb_endpoint_wait_for_receive_out();
00741                 Usb_ack_receive_out();
00742         }
00743 
00744 }

Generated on Mon Apr 11 14:23:36 2011 for Contiki 2.5 by  doxygen 1.6.1