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

📄 f34x_msd_msd.lst

📁 USB读写SD卡例程
💻 LST
📖 第 1 页 / 共 5 页
字号:
 278      =3  #define INTERRUPT_COMPARATOR0      12  // Comparator0
 279      =3  #define INTERRUPT_COMPARATOR1      13  // Comparator1
 280      =3  #define INTERRUPT_TIMER3           14  // Timer3 Overflow
 281      =3  #define INTERRUPT_VBUS_LEVEL       15  // VBUS level-triggered int
             -errupt
 282      =3  #define INTERRUPT_UART1            16  // Serial Port 1
 283      =3  
 284      =3  //----------------------------------------------------------------
             --------------
 285      =3  // Header File PreProcessor Directive
 286      =3  //----------------------------------------------------------------
             --------------
 287      =3  
 288      =3  #endif                                 // #define C8051F340_H
 289      =3  
 290      =3  //----------------------------------------------------------------
             --------------
 291      =3  // End Of File
 292      =3  //----------------------------------------------------------------
             --------------
  36      =2  #ifdef DEBUG_TIMEOUTS
  37      =2  sbit START_STOP_SPI = P3^0 ;
  38      =2  sbit START_STOP_READ_TO = P3^1;
  39      =2  sbit START_STOP_WRITE_TO = P3^2;
  40      =2  
  41      =2  #define START_SPI_TIMEOUT (START_STOP_SPI = 1)
  42      =2  #define STOP_SPI_TIME_OUT (START_STOP_SPI = 0)
  43      =2  #define START_READ_COPY (START_STOP_READ_TO = 1)
  44      =2  #define STOP_READ_COPY (START_STOP_READ_TO = 0)
  45      =2  #define START_WRITE_COPY (START_STOP_WRITE_TO = 1)
  46      =2  #define STOP_WRITE_COPY (START_STOP_WRITE_TO = 0)
  47      =2  #else
           =2 
           =2 #define START_SPI_TIMEOUT /\
           =2 /
           =2 #define STOP_SPI_TIME_OUT /\
           =2 /
           =2 #define START_READ_COPY /\
           =2 /
           =2 #define STOP_READ_COPY /\
           =2 /
           =2 #define START_WRITE_COPY /\
           =2 /
           =2 #define STOP_WRITE_COPY /\
           =2 /
           =2 
           =2 #endif
  63      =2  
  64      =2  #define ENDLINE         "\r\n"
  65      =2  #define ENDLINE_SGN '\r'
C51 COMPILER V7.50   F34X_MSD_MSD                  11/28/2006 10:54:20 PAGE 10  

  66      =2  
  67      =2  #endif
  37      =1  //#define _USB_LOW_SPEED_                      // Change this comm
             -ent to make Full/Low speed
  38      =1  
  39      =1  #define SYSCLK                   12000000    // SYSCLK frequency i
             -n Hz
  40      =1  
  41      =1  // USB clock selections (SFR CLKSEL)
  42      =1  #define USB_4X_CLOCK             0x00        // Select 4x clock mu
             -ltiplier, for USB Full Speed
  43      =1  #define USB_INT_OSC_DIV_2        0x10        // See Data Sheet sec
             -tion 13. Oscillators
  44      =1  #define USB_EXT_OSC              0x20
  45      =1  #define USB_EXT_OSC_DIV_2        0x30
  46      =1  #define USB_EXT_OSC_DIV_3        0x40
  47      =1  #define USB_EXT_OSC_DIV_4        0x50
  48      =1  
  49      =1  // System clock selections (SFR CLKSEL)
  50      =1  #define SYS_INT_OSC              0x00        // Select to use inte
             -rnal oscillator
  51      =1  #define SYS_4X_MUL               0x03        // Select to use inte
             -rnal oscillator
  52      =1  #define SYS_EXT_OSC              0x01        // Select to use an e
             -xternal oscillator
  53      =1  #define SYS_4X_DIV_2             0x02
  54      =1  
  55      =1  // BYTE type definition
  56      =1  #ifndef _BYTE_DEF_
  57      =1  #define _BYTE_DEF_
  58      =1  typedef unsigned char BYTE;
  59      =1  #endif   /* _BYTE_DEF_ */
  60      =1  
  61      =1  // WORD type definition, for KEIL Compiler
  62      =1  #ifndef _WORD_DEF_                           // Compiler Specific,
             - written for Little Endian
  63      =1  #define _WORD_DEF_
  64      =1  typedef union {unsigned int i; unsigned char c[2];} WORD;
  65      =1  #define LSB 1                                // All words sent to 
             -and received from the host are
  66      =1  #define MSB 0                                // little endian, thi
             -s is switched by software when
  67      =1                                               // neccessary.  These
             - sections of code have been marked
  68      =1                                                                                           // with "Compiler Specific" as above for easier modifi
             -cation
  69      =1  #endif   /* _WORD_DEF_ */
  70      =1  
  71      =1  // DWORD type definition
  72      =1  #ifndef _DWORD_DEF_
  73      =1  #define _DWORD_DEF_
  74      =1  typedef unsigned long DWORD;
  75      =1  #endif /* _DWORD_DEF_ */
  76      =1  
  77      =1  extern volatile DWORD xdata tickcount;
  78      =1  
  79      =1  // Define Endpoint Packet Sizes
  80      =1  #ifdef _USB_LOW_SPEED_
           =1 #define  EP0_PACKET_SIZE         0x40        // This value can be 
             -8,16,32,64 depending on device speed, see USB spec
           =1 #else
  83      =1  #define  EP0_PACKET_SIZE         0x40
C51 COMPILER V7.50   F34X_MSD_MSD                  11/28/2006 10:54:20 PAGE 11  

  84      =1  #endif /* _USB_LOW_SPEED_ */ 
  85      =1  
  86      =1  #define  EP1_PACKET_SIZE         0x0040      // Can range 0 - 1024
             - depending on data and transfer type  
  87      =1  #define  EP1_PACKET_SIZE_LE      0x4000      // IMPORTANT- this sh
             -ould be Little-Endian version of EP1_PACKET_SIZE
  88      =1  #define  EP2_PACKET_SIZE         0x0040      // Can range 0 - 1024
             - depending on data and transfer type
  89      =1  #define  EP2_PACKET_SIZE_LE      0x4000      // IMPORTANT- this sh
             -ould be Little-Endian version of EP2_PACKET_SIZE
  90      =1  
  91      =1  // Standard Descriptor Types
  92      =1  #define  DSC_DEVICE              0x01        // Device Descriptor
  93      =1  #define  DSC_CONFIG              0x02        // Configuration Desc
             -riptor
  94      =1  #define  DSC_STRING              0x03        // String Descriptor
  95      =1  #define  DSC_INTERFACE           0x04        // Interface Descript
             -or
  96      =1  #define  DSC_ENDPOINT            0x05        // Endpoint Descripto
             -r
  97      =1  
  98      =1  // HID Descriptor Types
  99      =1  #define DSC_HID                                 0x21            // HID Class Descriptor
 100      =1  #define DSC_HID_REPORT                  0x22            // HID Report Descriptor
 101      =1  
 102      =1  // Standard Request Codes
 103      =1  #define  GET_STATUS             0x00        // Code for Get Status
 104      =1  #define  CLEAR_FEATURE          0x01        // Code for Clear Feat
             -ure
 105      =1  #define  SET_FEATURE            0x03        // Code for Set Featur
             -e
 106      =1  #define  SET_ADDRESS            0x05        // Code for Set Addres
             -s
 107      =1  #define  GET_DESCRIPTOR         0x06        // Code for Get Descri
             -ptor
 108      =1  #define  SET_DESCRIPTOR         0x07        // Code for Set Descri
             -ptor(not used)
 109      =1  #define  GET_CONFIGURATION      0x08        // Code for Get Config
             -uration
 110      =1  #define  SET_CONFIGURATION      0x09        // Code for Set Config
             -uration
 111      =1  #define  GET_INTERFACE          0x0A        // Code for Get Interf
             -ace
 112      =1  #define  SET_INTERFACE          0x0B        // Code for Set Interf
             -ace
 113      =1  #define  SYNCH_FRAME            0x0C        // Code for Synch Fram
             -e(not used)
 114      =1  #define  MSD_RESET                              0xFF            // Mass-storage device Reset
 115      =1  #define  MSD_GET_MAX_LUN                0xFE            // Mass-storage device Get Max LU
             -N
 116      =1  
 117      =1  // HID Request Codes
 118      =1  #define GET_REPORT                              0x01            // Code for Get Report
 119      =1  #define GET_IDLE                                0x02            // Code for Get Idle
 120      =1  #define GET_PROTOCOL                    0x03            // Code for Get Protocol
 121      =1  #define SET_REPORT                              0x09            // Code for Set Report
 122      =1  #define SET_IDLE                                0x0A            // Code for Set Idle
 123      =1  #define SET_PROTOCOL                    0x0B            // Code for Set Protocol
 124      =1  
 125      =1  // Define device states
 126      =1  #define  DEV_ATTACHED            0x00        // Device is in Attac
             -hed State
C51 COMPILER V7.50   F34X_MSD_MSD                  11/28/2006 10:54:20 PAGE 12  

 127      =1  #define  DEV_POWERED             0x01        // Device is in Power
             -ed State
 128      =1  #define  DEV_DEFAULT             0x02        // Device is in Defau
             -lt State
 129      =1  #define  DEV_ADDRESS             0x03        // Device is in Addre
             -ssed State
 130      =1  #define  DEV_CONFIGURED          0x04        // Device is in Confi
             -gured State
 131      =1  #define  DEV_SUSPENDED           0x05        // Device is in Suspe
             -nded State
 132      =1  
 133      =1  // Define bmRequestType bitmaps
 134      =1  #define  IN_DEVICE               0x00        // Request made to de
             -vice, direction is IN 
 135      =1  #define  OUT_DEVICE              0x80        // Request made to de
             -vice, direction is OUT
 136      =1  #define  IN_INTERFACE            0x01        // Request made to in
             -terface, direction is IN
 137      =1  #define  OUT_INTERFACE           0x81        // Request made to in
             -terface, direction is OUT
 138      =1  #define  IN_ENDPOINT             0x02        // Request made to en
             -dpoint, direction is IN
 139      =1  #define  OUT_ENDPOINT            0x82        // Request made to en
             -dpoint, direction is OUT
 140      =1  
 141      =1  // Define wIndex bitmaps
 142      =1  #define  IN_EP1                  0x81        // Index values used 
             -by Set and Clear feature
 143      =1  #define  OUT_EP1                 0x01        // commands for Endpo
             -int_Halt
 144      =1  #define  IN_EP2                  0x82
 145      =1  #ifdef __F326_VER__
           =1 #define  OUT_EP2                                 0x01           
           =1 #else
 148      =1  #define  OUT_EP2                                 0x01           
 149      =1  #endif
 150      =1  
 151      =1  // Define wValue bitmaps for Standard Feature Selectors
 152      =1  #define  DEVICE_REMOTE_WAKEUP    0x01        // Remote wakeup feat
             -ure(not used)
 153      =1  #define  ENDPOINT_HALT           0x00        // Endpoint_Halt feat
             -ure selector
 154      =1  
 155      =1  // Define Endpoint States
 156      =1  #define  EP_IDLE                 0x00        // This signifies End
             -point Idle State
 157      =1  #define  EP_TX                   0x01        // Endpoint Transmit 
             -State
 158      =1  #define  EP_RX                   0x02        // Endpoint Receive S
             -tate
 159      =1  #define  EP_HALT                 0x03        // Endpoint Halt Stat
             -e (return stalls)
 160      =1  #define  EP_STALL                0x04        // Endpoint Stall (se
             -nd procedural stall next status phase)
 161      =1  #define  EP_ADDRESS              0x05        // Endpoint Address (
             -change FADDR during next status phase)
 162      =1  
 163      =1  // Function prototypes
 164      =1  // USB Routines
 165      =1  void USB_Resume(void);                       // This routine resum
             -es USB operation
 166      =1  void USB_Reset(void);                        // Called after USB b
C51 COMPILER V7.50   F34X_MSD_MSD                  11/28/2006 10:54:20 PAGE 13  

             -us reset
 167      =1  void Handle_Setup(void);                     // Handle setup packe
             -t on Endpoint 0
 168      =1  void Handle_In1(BYTE* ptr_buf);                       // Handle in
             - packet on Endpoint 1
 169      =1  void Handle_Out2(void);                      // Handle out packet 
             -on Endpoint 2
 170      =1  void USB_Suspend(void);                      // This routine calle
             -d when suspend signalling on bus
 171      =1  void Out2_Get_Data(BYTE* ptr_buf);                               // Copies from FIFO to ptr_
             -buf, clears FIFO-full flag.
 172      =1  void Out2_Done(void);                                            // Call this when finished with the d
             -ata
 173      =1  
 174      =1  // Standard Requests
 175      =1  void Get_Status(void);                       // These are called f
             -or each specific standard request
 176      =1  void Clear_Feature(void);
 177      =1  void Set_Feature(void);

⌨️ 快捷键说明

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