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 "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

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

Referenced by usb_process_request().

00081 {
00082    U8  wValue_msb;
00083    U8  wValue_lsb;
00084 
00085    // Read wValue
00086    wValue_lsb = Usb_read_byte();
00087    wValue_msb = Usb_read_byte();
00088 
00089    //** Specific request from Class
00090    if( USB_SETUP_GET_STAND_INTERFACE == type )
00091    {
00092       switch( request )
00093       {
00094          case SETUP_GET_DESCRIPTOR:
00095          switch( wValue_msb ) // Descriptor ID
00096          {
00097             default:
00098             // TODO
00099             break;
00100          }
00101          break;
00102       }
00103    }
00104    if( USB_SETUP_SET_CLASS_INTER == type )
00105    {
00106       switch( request )
00107       {
00108          default:
00109          break;
00110       }
00111    }
00112    if( USB_SETUP_GET_CLASS_INTER == type )
00113    {
00114       switch( request )
00115       {
00116          default:
00117          break;
00118       }
00119    }
00120    return FALSE;  // No supported request
00121 }

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

Referenced by usb_set_configuration().

00129 {
00130    usb_configure_endpoint(EP_TEMP_IN,    \
00131                           TYPE_BULK,     \
00132                           DIRECTION_IN,  \
00133                           SIZE_64,       \
00134                           ONE_BANK,      \
00135                           NYET_ENABLED);
00136    usb_configure_endpoint(EP_TEMP_OUT,   \
00137                           TYPE_BULK,     \
00138                           DIRECTION_OUT, \
00139                           SIZE_64,       \
00140                           ONE_BANK,      \
00141                           NYET_ENABLED);
00142    usb_configure_endpoint(EP_TEMP_INT_IN,\
00143                           TYPE_BULK,     \
00144                           TYPE_INTERRUPT,\
00145                           SIZE_64,       \
00146                           ONE_BANK,      \
00147                           NYET_ENABLED);
00148 }

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

Referenced by usb_get_interface().

00158 {
00159    return 0;  // Only one alternate setting possible for all interface
00160 }

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

Referenced by usb_set_interface().

00169 {  
00170    // default setting selected = reset data toggle
00171    if( INTERFACE_NB_TEMP == wInterface )
00172    {
00173       // Interface reset
00174       Usb_select_endpoint(EP_TEMP_IN);
00175       Usb_disable_stall_handshake();
00176       Usb_reset_endpoint(EP_TEMP_IN);
00177       Usb_reset_data_toggle();
00178       Usb_select_endpoint(EP_TEMP_OUT);
00179       Usb_disable_stall_handshake();
00180       Usb_reset_endpoint(EP_TEMP_OUT);
00181       Usb_reset_data_toggle();
00182    }
00183    if( INTERFACE_NB_SECOND_TEMP == wInterface )
00184    {
00185       // Interface reset
00186       Usb_select_endpoint(EP_TEMP_INT_IN);
00187       Usb_disable_stall_handshake();
00188       Usb_reset_endpoint(EP_TEMP_INT_IN);
00189       Usb_reset_data_toggle();
00190    }
00191 }

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

Referenced by usb_get_descriptor().

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

Here is the caller graph for this function:


Variable Documentation

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 Mon Sep 14 13:24:12 2009 for ATMEL by  doxygen 1.5.3