usb_specific_request.c File Reference

#include "config.h"
#include "conf_usb.h"
#include "lib_mcu/usb/usb_drv.h"
#include "usb_descriptors.h"
#include "modules/usb/device_chap9/usb_standard_request.h"
#include "usb_specific_request.h"
#include "modules/control_access/ctrl_access.h"
#include "lib_mcu/flash/flash_drv.h"

Include dependency graph for usb_specific_request.c:

Go to the source code of this file.

Functions

Bool usb_user_read_request (U8 type, U8 request)
 This function checks the specific request and if known then processes it
void usb_user_endpoint_init (U8 conf_nb)
U8 usb_user_interface_get (U16 wInterface)
void usb_user_interface_reset (U16 wInterface, U8 alternate_setting)
Bool usb_user_get_descriptor (U8 type, U8 string)
 This function fills the global descriptor.

Variables

bit ms_multiple_drive
U8 code * pbuffer
U8 data_to_transfer


Detailed Description

user call-back functions This file contains the user call-back functions corresponding to the application: - Compiler: IAR EWAVR and GNU GCC for AVR

Definition in file usb_specific_request.c.


Function Documentation

Bool usb_user_read_request ( U8  type,
U8  request 
)

This function checks the specific request and if known then processes it

Parameters:
type corresponding at bmRequestType (see USB specification)
request corresponding at bRequest (see USB specification)
Returns:
TRUE, when the request is processed

FALSE, if the request is'nt know (STALL handshake is managed by the main standard request function).

Definition at line 83 of file usb_specific_request.c.

Referenced by usb_process_request().

00084 {
00085    U16   wInterface;
00086    U8    wValue_msb;
00087    U8    wValue_lsb;
00088 
00089    // Read wValue
00090    wValue_lsb = Usb_read_byte();
00091    wValue_msb = Usb_read_byte();
00092 
00093    //** Specific request from Class MassStorage
00094    if( USB_SETUP_SET_CLASS_INTER == type )
00095    {
00096       switch( request )
00097       {
00098          case SETUP_MASS_STORAGE_RESET:
00099          // wValue must be 0
00100          // wIndex = Interface
00101          if( (0!=wValue_lsb) || (0!=wValue_msb) )
00102             break;
00103          LSB(wInterface)=Usb_read_byte();
00104          MSB(wInterface)=Usb_read_byte();
00105          if( INTERFACE_NB != wInterface )
00106             break;
00107          Usb_ack_receive_setup();
00108          Usb_send_control_in();
00109          while(!Is_usb_in_ready());
00110          return TRUE;
00111          break;
00112       }
00113    }
00114    if( USB_SETUP_GET_CLASS_INTER == type )
00115    {
00116       switch( request )
00117       {
00118          case SETUP_MASS_STORAGE_GET_MAX_LUN:
00119          // wValue must be 0
00120          // wIndex = Interface
00121          if( (0!=wValue_lsb) || (0!=wValue_msb) )
00122             break;
00123          LSB(wInterface)=Usb_read_byte();
00124          MSB(wInterface)=Usb_read_byte();
00125          if( INTERFACE_NB != wInterface )
00126             break;
00127          Usb_ack_receive_setup();
00128          Usb_write_byte( (get_nb_lun()-1) );
00129          Usb_send_control_in();
00130          while(!Is_usb_in_ready());
00131          while( !Is_usb_receive_out() );
00132          Usb_ack_receive_out();
00133          ms_multiple_drive = 1;
00134          return TRUE;
00135          break;
00136       }
00137    }
00138    
00139    return FALSE;  // No supported request
00140 }

Here is the caller graph for this function:

void usb_user_endpoint_init ( U8  conf_nb  ) 

This function configures the endpoints

Parameters:
conf_nb configuration number choosed by USB host

Definition at line 147 of file usb_specific_request.c.

Referenced by usb_set_configuration().

00148 {
00149    usb_configure_endpoint(EP_MS_IN,      \
00150                           TYPE_BULK,     \
00151                           DIRECTION_IN,  \
00152                           SIZE_64,       \
00153                           TWO_BANKS,     \
00154                           NYET_ENABLED);
00155    usb_configure_endpoint(EP_MS_OUT,     \
00156                           TYPE_BULK,     \
00157                           DIRECTION_OUT, \
00158                           SIZE_64,       \
00159                           TWO_BANKS,     \
00160                           NYET_ENABLED);
00161 }

Here is the caller graph for this function:

U8 usb_user_interface_get ( U16  wInterface  ) 

This function returns the interface alternate setting

Parameters:
wInterface Interface selected
Returns:
alternate setting configurated

Definition at line 170 of file usb_specific_request.c.

Referenced by usb_get_interface().

00171 {
00172    return 0;  // Only one alternate setting possible for all interface
00173 }

Here is the caller graph for this function:

void usb_user_interface_reset ( U16  wInterface,
U8  alternate_setting 
)

This function selects (and resets) the interface alternate setting

Parameters:
wInterface Interface selected
alternate_setting alternate setting selected

Definition at line 181 of file usb_specific_request.c.

Referenced by usb_set_interface().

00182 {  
00183    // default setting selected = reset data toggle
00184    if( INTERFACE_NB == wInterface )
00185    {
00186       // Interface Mass Storage
00187       Usb_select_endpoint(EP_MS_IN);
00188       Usb_disable_stall_handshake();
00189       Usb_reset_endpoint(EP_MS_IN);
00190       Usb_reset_data_toggle();
00191       Usb_select_endpoint(EP_MS_OUT);
00192       Usb_disable_stall_handshake();
00193       Usb_reset_endpoint(EP_MS_OUT);
00194       Usb_reset_data_toggle();
00195    }
00196 }

Here is the caller graph for this function:

Bool usb_user_get_descriptor ( U8  type,
U8  string 
)

This function fills the global descriptor.

Parameters:
type corresponding at MSB of wValue (see USB specification)
string corresponding at LSB of wValue (see USB specification)
Returns:
FALSE, if the global descriptor no filled

Definition at line 206 of file usb_specific_request.c.

Referenced by usb_get_descriptor().

00207 {
00208    switch(type)
00209    {
00210       case DESCRIPTOR_STRING:
00211       switch (string)
00212       {
00213          case LANG_ID:
00214          data_to_transfer = sizeof (usb_user_language_id);
00215          pbuffer = &(usb_user_language_id.bLength);
00216          return TRUE;
00217          break;
00218         
00219          case MAN_INDEX:
00220          data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
00221          pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
00222          return TRUE;
00223          break;
00224         
00225          case PROD_INDEX:
00226          data_to_transfer = sizeof (usb_user_product_string_descriptor);
00227          pbuffer = &(usb_user_product_string_descriptor.bLength);
00228          return TRUE;
00229          break;
00230            
00231 #if (USB_DEVICE_SN_USE==ENABLE)              
00232          case SN_INDEX:
00233          data_to_transfer = sizeof (usb_user_serial_number);
00234          pbuffer = &(usb_user_serial_number.bLength);
00235 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00236          f_get_serial_string=TRUE;
00237          data_to_transfer += (SN_LENGTH*4);
00238 #endif
00239          return TRUE;
00240          break;
00241 #endif
00242       }
00243       break;
00244    }
00245    return FALSE;
00246 }

Here is the caller graph for this function:


Variable Documentation

bit ms_multiple_drive

Definition at line 63 of file usb_specific_request.c.

U8 code* pbuffer

Definition at line 94 of file usb_standard_request.c.

Referenced by usb_get_descriptor(), and usb_user_get_descriptor().

U8 data_to_transfer

Definition at line 99 of file usb_standard_request.c.

Referenced by usb_get_descriptor(), and usb_user_get_descriptor().


Generated on Wed Sep 23 09:17:16 2009 for ATMEL by  doxygen 1.5.3