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

📄 fmcdev.c

📁 <B>SMSC USB2.0 Flash硬盘驱动源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
/*============================================================================
  ____________________________________________________________________________
                                ______________________________________________
   SSSS  M   M          CCCC          Standard Microsystems Corporation
  S      MM MM   SSSS  C                    Austin Design Center
   SSS   M M M  S      C                 11000 N. Mopac Expressway
      S  M   M   SSS   C                Stonelake Bldg. 6, Suite 500
  SSSS   M   M      S   CCCC                Austin, Texas 78759
                SSSS            ______________________________________________
  ____________________________________________________________________________
  
  Copyright(C) 1999, Standard Microsystems Corporation
  All Rights Reserved.

  This program code listing is proprietary to SMSC and may not be copied,
  distributed, or used without a license to do so.  Such license may have
  Limited or Restricted Rights. Please refer to the license for further
  clarification.
  ____________________________________________________________________________
                                                                    
  Notice: The program contained in this listing is a proprietary trade
  secret of SMSC, Hauppauge, New York, and is copyrighted
  under the United States Copyright Act of 1976 as an unpublished work,
  pursuant to Section 104 and Section 408 of Title XVII of the United
  States code. Unauthorized copying, adaption, distribution, use, or
  display is prohibited by this law.
  ____________________________________________________________________________

  Use, duplication, or disclosure by the Government is subject to
  restrictions as set forth in subparagraph(c)(1)(ii) of the Rights
  in Technical Data and Computer Software clause at DFARS 52.227-7013.
  Contractor/Manufacturer is Standard Microsystems Corporation,
  80 Arkay Drive, Hauppauge, New York, 1178-8847.
  ____________________________________________________________________________
  ____________________________________________________________________________

  <module name> - <module description>
  ____________________________________________________________________________

  comments tbd
  ____________________________________________________________________________

  Revision History
  Date      Who  Comment
  ________  ___  _____________________________________________________________
  05/31/00  tbh  initial version

============================================================================*/

////////////////////////////////////////////////////////////////////////////////
//
// USER DEVICE MODULE 
//
// atapi
//
// please try very hard to make this mcu independent...
// yes, there are some #ifdefs.  but this hasta run on the 102 sooner or later.
//
////////////////////////////////////////////////////////////////////////////////
#define __fmcdev_dot_c__
#include "fmc.h"

//------------------------------------------------------------------------------
// specify the product version number
//------------------------------------------------------------------------------
#include "version.inc"

#define _hi_digit(b) ((uint8) (((uint8)(b>>4)&0x0f) + (uint8)'0')),0
#define _lo_digit(b) ((uint8) (((uint8)(b   )&0x0f) + (uint8)'0')),0

//------------------------------------------------------------------------------
// vendor id and product id (SMSC -> 0106 dec = 0424 hex)
//------------------------------------------------------------------------------
#define k_vendorhi         0x04  // vendor id hi 
#define k_vendorlo         0x24  // vendor id lo
#define k_dev_producthi    0x10  // product id hi 
#define k_dev_productlo    0xCD  // product id lo 
//------------------------------------------------------------------------------
// version descriptor (not a usb thing, its used by the smsc romset utility)
// $$$ note that romset as is wont work on this because there are now multiple
// device and configuration descriptors.  romset needs to be updated.
//------------------------------------------------------------------------------
uint8 code g_version[] = {k_vendorhi, k_vendorlo, k_dev_producthi, k_dev_productlo, kbcd_dev_version_major, kbcd_dev_version_minor};
//------------------------------------------------------------------------------
// globals - keep your grubby mitts off these!  they are for "kernel" use only!
//------------------------------------------------------------------------------
#if defined(k_mcu_97FDC) || defined(k_mcu_97102)
uint8 g_usb_dev_addr;  // pending usb address, cleared by isr
uint8 g_usb_dev_cfg;   // active configuration
uint8 g_usb_dev_stat;  // device status
#endif




void        fmc_init() reentrant ;
static void fmc_dump_registers() reentrant ;
static void fmc_debug_12kb_ram() reentrant ;


//------------------------------------------------------------------------------
// globals - you hafta change the initializers for these to serve your needs.
//------------------------------------------------------------------------------
// string descriptors (in a form that the smsc romset utility can use)
// endian: lil big
// addrhi: msb lsb
// addrlo: lsb msb
//------------------------------------------------------------------------------
uint8 code g_str_lng[4] = {4, 3, 0x09, 0x04};  // (English lo 0x09, hi 0x04) 
uint8 code g_str_mfg[17][2] = {10, 3, "S", "M", "S", "C"};
uint8 code g_str_prd[35][2] = 
{
    34, 3,         
    "F", "M", "C", " ",
#if (kbcd_dev_version_major>0x10)
    _hi_digit(kbcd_dev_version_major), 
#endif
    _lo_digit(kbcd_dev_version_major), ".",
    
#if (kbcd_dev_version_minor>0x10)
    _hi_digit(kbcd_dev_version_minor), 
#endif
    _lo_digit(kbcd_dev_version_minor), ".",

#if (kbcd_dev_version_external_change>0x10)
    _hi_digit(kbcd_dev_version_external_change), 
#endif
    _lo_digit(kbcd_dev_version_external_change), ".",

#if (kbcd_dev_version_internal_change>0x10)
    _hi_digit(kbcd_dev_version_internal_change),
#endif
    _lo_digit(kbcd_dev_version_internal_change)
};


uint8 code g_str_ser[41][2] = {40, 3, "N", "o", "n", "e"};
uint8 code *code g_str_dscr[k_dev_max_string] = {g_str_lng, g_str_mfg, g_str_prd, g_str_ser};

//------------------------------------------------------------------------------
// string descriptor indicies
//------------------------------------------------------------------------------
#define k_dev_idx_str_dscr_lng 0
#define k_dev_idx_str_dscr_mfg 1
#define k_dev_idx_str_dscr_prd 2
#define k_dev_idx_str_dscr_ser 3



//------------------------------------------------------------------------------
// device descriptor 
//------------------------------------------------------------------------------
// full speed device descriptor 
uint8 code g_fs_dev_dscr[] =
{
    k_usb_devdscrsz,              // length of descriptor in bytes 
    k_usb_dscr_typ_device,        // descriptor type: device 
    0x10,                         // usb version lo 
    0x01,                         // usb version hi 
    0x00,                         // device class: see interfaces 
    0x00,                         // subclass:  see interfaces
    0x00,                         // protocol:  see interfaces
    k_maxpktsz,                   // ndp 0 max packet size (8,16,32,64) 
    k_vendorlo,                   // vendor lo 
    k_vendorhi,                   // vendor hi 
    k_dev_productlo,              // product lo 
    k_dev_producthi,              // product hi 
    kbcd_dev_version_minor,          // device release lo 
    kbcd_dev_version_major,          // device release hi 
    k_dev_idx_str_dscr_mfg,       // manufacturer string index 
    k_dev_idx_str_dscr_prd,       // product string index 
    0,                            // serial string index 
    k_dev_max_configuration       // number of configurations 
};
// full speed device descriptor with serial number - cds
uint8 code g_fs_dev_dscr_w_ser[] =
{
    k_usb_devdscrsz,              // length of descriptor in bytes 
    k_usb_dscr_typ_device,        // descriptor type: device 
    0x10,                         // usb version lo 
    0x01,                         // usb version hi 
    0x00,                         // device class: see interfaces 
    0x00,                         // subclass:  see interfaces
    0x00,                         // protocol:  see interfaces
    k_maxpktsz,                   // ndp 0 max packet size (8,16,32,64) 
    k_vendorlo,                   // vendor lo 
    k_vendorhi,                   // vendor hi 
    k_dev_productlo,              // product lo 
    k_dev_producthi,              // product hi 
    kbcd_dev_version_minor,          // device release lo 
    kbcd_dev_version_major,          // device release hi 
    k_dev_idx_str_dscr_mfg,       // manufacturer string index 
    k_dev_idx_str_dscr_prd,       // product string index 
    k_dev_idx_str_dscr_ser,       // cds - serial string index 
    k_dev_max_configuration       // number of configurations 
};
//------------------------------------------------------------------------------
// high speed device descriptor 
uint8 code g_hs_dev_dscr[] =
{
    k_usb_devdscrsz,              // length of descriptor in bytes 
    k_usb_dscr_typ_device,        // descriptor type: device 
    0x00,                         // usb version lo 
    0x02,                         // usb version hi 
    0x00,                         // device class: see interfaces 
    0x00,                         // subclass:  see interfaces
    0x00,                         // protocol:  see interfaces
    k_maxpktsz,                   // ndp 0 max packet size (8,16,32,64) 
    k_vendorlo,                   // vendor lo 
    k_vendorhi,                   // vendor hi 
    k_dev_productlo,              // product lo 
    k_dev_producthi,              // product hi 
    kbcd_dev_version_minor,          // device release lo 
    kbcd_dev_version_major,          // device release hi 
    k_dev_idx_str_dscr_mfg,       // manufacturer string index 
    k_dev_idx_str_dscr_prd,       // product string index 
    0,                            // serial string index 
    k_dev_max_configuration       // number of configurations 
};
// high speed device descriptor with serial number - cds
uint8 code g_hs_dev_dscr_w_ser[] =
{
    k_usb_devdscrsz,              // length of descriptor in bytes 
    k_usb_dscr_typ_device,        // descriptor type: device 
    0x00,                         // usb version lo 
    0x02,                         // usb version hi 
    0x00,                         // device class: see interfaces 
    0x00,                         // subclass:  see interfaces
    0x00,                         // protocol:  see interfaces
    k_maxpktsz,                   // ndp 0 max packet size (8,16,32,64) 
    k_vendorlo,                   // vendor lo 
    k_vendorhi,                   // vendor hi 
    k_dev_productlo,              // product lo 
    k_dev_producthi,              // product hi 
    kbcd_dev_version_minor,          // device release lo 
    kbcd_dev_version_major,          // device release hi 
    k_dev_idx_str_dscr_mfg,       // manufacturer string index 
    k_dev_idx_str_dscr_prd,       // product string index 
    k_dev_idx_str_dscr_ser,       // cds - serial string index 
    k_dev_max_configuration       // number of configurations 
};

//------------------------------------------------------------------------------
// device qualifier descriptor 
//------------------------------------------------------------------------------
// full speed device qualifier descriptor 
uint8 code g_fs_devqual_dscr[] =
{
    k_usb_devqualdscrsz,          // length of descriptor in bytes 
    k_usb_dscr_typ_devqual,       // descriptor type: device qualifier
    0x00,                         // usb version lo 
    0x02,                         // usb version hi 
    0x00,                         // device class: see interfaces 
    0x00,                         // subclass:  see interfaces
    0x00,                         // protocol:  see interfaces
    k_maxpktsz,                   // ndp 0 max packet size, other speed 
    k_dev_max_configuration,      // number of other speed configurations
    0                             // reserved
};
//------------------------------------------------------------------------------
// high speed device qualifier descriptor 
uint8 code g_hs_devqual_dscr[] =
{
    k_usb_devqualdscrsz,          // length of descriptor in bytes 
    k_usb_dscr_typ_devqual,       // descriptor type: device qualifier
    0x00,                         // usb version lo 
    0x02,                         // usb version hi 
    0x00,                         // device class: see interfaces 
    0x00,                         // subclass:  see interfaces
    0x00,                         // protocol:  see interfaces
    k_maxpktsz,                   // ndp 0 max packet size, other speed 
    k_dev_max_configuration,      // number of other speed configurations
    0                             // reserved
};



//------------------------------------------------------------------------------
// configuration descriptor
//------------------------------------------------------------------------------

#define k_usb_cfundscsz			0x07
#define k_usb_fundsctyp			0x21
// full speed configuration descriptor
#ifdef DFU
uint8 code g_fs_cfg_dscr[] =
{
    k_usb_cfgdscrsz,              // length of descriptor in bytes 
    k_usb_dscr_typ_config,        // descriptor type: configuration 
    k_usb_cfgdscrsz +
    k_usb_ifcdscrsz +
    k_usb_ifcdscrsz +             
    k_usb_ndpdscrsz +             
    k_usb_ndpdscrsz,              // total length lo
    0,                            // total length hi 
    2,                            // number of interfaces   2 to accomodate the DFU
    0x01,                         // configuration value 
    0x00,                         // index of string descriptor 
    0xC0,                         // attributes: bus powered, no remote wakeup 
    0xFA,                         // _max power: 500ma 
    // interface descriptor: BOT mass storage
    k_usb_ifcdscrsz,              // length of descriptor in bytes 

⌨️ 快捷键说明

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