⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_specific_request.c

📁 基于at90usb1287的数据存储器例子
💻 C
字号:
//! @file usb_specific_request.c,v
//!
//! Copyright (c) 2006 Atmel.
//!
//! Use of this program is subject to Atmel's End User License Agreement.
//! Please read file license.txt for copyright notice.
//!
//! @brief Specific enumeration process requests
//!
//! This file contains the specific request decoding for enumearion process
//!
//! @version 1.1 at90usb128-usbkey-demo-storage-df-1_0_4 $Id: usb_specific_request.c,v 1.1 2006/03/13 12:53:54 rletendu Exp $
//!
//! @todo
//! @bug


//_____ I N C L U D E S ____________________________________________________

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

//_____ M A C R O S ________________________________________________________

//_____ D E F I N I T I O N ________________________________________________
       bit  ms_multiple_drive;
//_____ P R I V A T E   D E C L A R A T I O N ______________________________

#ifdef AVRGCC
extern PGM_VOID_P pbuffer;
#else
extern U8   code *pbuffer;
#endif
extern U8   data_to_transfer;
extern U16  wInterface;


//_____ D E C L A R A T I O N ______________________________________________

//! usb_user_read_request(type, request);
//!
//! @brief 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.
//!
//! @param none
//!
//! @return none
//!
Bool usb_user_read_request(U8 type, U8 request)
{
U8  descriptor_type ;
U8  string_type     ;

   string_type     = Usb_read_byte();
   descriptor_type = Usb_read_byte();
   switch(request)
   {
      case GET_DESCRIPTOR:

         switch (descriptor_type)
         {

            default:
               return FALSE;
               break;
         }
         break;
      case SET_CONFIGURATION:
         switch (descriptor_type)
         {


            default:
               return FALSE;
               break;
         }
         break;

    case MASS_STORAGE_RESET:
         Usb_ack_receive_setup();
         Usb_send_control_in();
         return TRUE;
         break;

    case GET_MAX_LUN:
         Usb_ack_receive_setup();
         Usb_write_byte( (get_nb_lun()-1) );
         Usb_send_control_in();
         ms_multiple_drive = 1;
         return TRUE;
         break;

      default:
         return FALSE;
         break;

   }
   return FALSE;
}



//! usb_user_endpoint_init.
//!
//! @brief This function configures the endpoints of the device application
//! This function is called when the set configuration request has been received.
//!
//! @param none
//!
//! @return none
//!
void usb_user_endpoint_init(U8 conf_nb)
{
 usb_configure_endpoint(EP_MS_IN,      \
                         TYPE_BULK,     \
                         DIRECTION_IN,  \
                         ep_size,       \
                         TWO_BANKS,     \
                         NYET_ENABLED);
  usb_configure_endpoint(EP_MS_OUT,     \
                         TYPE_BULK,     \
                         DIRECTION_OUT, \
                         ep_size,       \
                         TWO_BANKS,     \
                         NYET_ENABLED);

}


//! usb_user_get_descriptor.
//!
//! This function returns the size and the pointer on a user information
//! structure
//!
//! @param none
//!
//! @return none
//!
Bool usb_user_get_descriptor(U8 type, U8 string)
{
   switch(type)
   {
      case STRING_DESCRIPTOR:
         switch (string)
         {
            case LANG_ID:
               data_to_transfer = sizeof (usb_user_language_id);
               pbuffer = &(usb_user_language_id.bLength);
               return TRUE;
               break;
            case MAN_INDEX:
               data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
               pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
               return TRUE;
               break;
            case PROD_INDEX:
               data_to_transfer = sizeof (usb_user_product_string_descriptor);
               pbuffer = &(usb_user_product_string_descriptor.bLength);
               return TRUE;
               break;
            case SN_INDEX:
               data_to_transfer = sizeof (usb_user_serial_number);
               pbuffer = &(usb_user_serial_number.bLength);
               return TRUE;
               break;
            default:
               return FALSE;
         }
      default:
         return FALSE;
   }

   return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -