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

📄 f34x_msd_file_system.lst

📁 USB读写SD卡例程
💻 LST
📖 第 1 页 / 共 5 页
字号:
 125      =2  // Define device states
 126      =2  #define  DEV_ATTACHED            0x00        // Device is in Attac
             -hed State
 127      =2  #define  DEV_POWERED             0x01        // Device is in Power
             -ed State
 128      =2  #define  DEV_DEFAULT             0x02        // Device is in Defau
             -lt State
 129      =2  #define  DEV_ADDRESS             0x03        // Device is in Addre
             -ssed State
 130      =2  #define  DEV_CONFIGURED          0x04        // Device is in Confi
             -gured State
 131      =2  #define  DEV_SUSPENDED           0x05        // Device is in Suspe
             -nded State
 132      =2  
 133      =2  // Define bmRequestType bitmaps
 134      =2  #define  IN_DEVICE               0x00        // Request made to de
             -vice, direction is IN 
 135      =2  #define  OUT_DEVICE              0x80        // Request made to de
             -vice, direction is OUT
 136      =2  #define  IN_INTERFACE            0x01        // Request made to in
             -terface, direction is IN
 137      =2  #define  OUT_INTERFACE           0x81        // Request made to in
             -terface, direction is OUT
 138      =2  #define  IN_ENDPOINT             0x02        // Request made to en
             -dpoint, direction is IN
C51 COMPILER V7.50   F34X_MSD_FILE_SYSTEM          11/28/2006 10:54:06 PAGE 14  

 139      =2  #define  OUT_ENDPOINT            0x82        // Request made to en
             -dpoint, direction is OUT
 140      =2  
 141      =2  // Define wIndex bitmaps
 142      =2  #define  IN_EP1                  0x81        // Index values used 
             -by Set and Clear feature
 143      =2  #define  OUT_EP1                 0x01        // commands for Endpo
             -int_Halt
 144      =2  #define  IN_EP2                  0x82
 145      =2  #ifdef __F326_VER__
           =2 #define  OUT_EP2                                 0x01           
           =2 #else
 148      =2  #define  OUT_EP2                                 0x01           
 149      =2  #endif
 150      =2  
 151      =2  // Define wValue bitmaps for Standard Feature Selectors
 152      =2  #define  DEVICE_REMOTE_WAKEUP    0x01        // Remote wakeup feat
             -ure(not used)
 153      =2  #define  ENDPOINT_HALT           0x00        // Endpoint_Halt feat
             -ure selector
 154      =2  
 155      =2  // Define Endpoint States
 156      =2  #define  EP_IDLE                 0x00        // This signifies End
             -point Idle State
 157      =2  #define  EP_TX                   0x01        // Endpoint Transmit 
             -State
 158      =2  #define  EP_RX                   0x02        // Endpoint Receive S
             -tate
 159      =2  #define  EP_HALT                 0x03        // Endpoint Halt Stat
             -e (return stalls)
 160      =2  #define  EP_STALL                0x04        // Endpoint Stall (se
             -nd procedural stall next status phase)
 161      =2  #define  EP_ADDRESS              0x05        // Endpoint Address (
             -change FADDR during next status phase)
 162      =2  
 163      =2  // Function prototypes
 164      =2  // USB Routines
 165      =2  void USB_Resume(void);                       // This routine resum
             -es USB operation
 166      =2  void USB_Reset(void);                        // Called after USB b
             -us reset
 167      =2  void Handle_Setup(void);                     // Handle setup packe
             -t on Endpoint 0
 168      =2  void Handle_In1(BYTE* ptr_buf);                       // Handle in
             - packet on Endpoint 1
 169      =2  void Handle_Out2(void);                      // Handle out packet 
             -on Endpoint 2
 170      =2  void USB_Suspend(void);                      // This routine calle
             -d when suspend signalling on bus
 171      =2  void Out2_Get_Data(BYTE* ptr_buf);                               // Copies from FIFO to ptr_
             -buf, clears FIFO-full flag.
 172      =2  void Out2_Done(void);                                            // Call this when finished with the d
             -ata
 173      =2  
 174      =2  // Standard Requests
 175      =2  void Get_Status(void);                       // These are called f
             -or each specific standard request
 176      =2  void Clear_Feature(void);
 177      =2  void Set_Feature(void);
 178      =2  void Set_Address(void);
 179      =2  void Get_Descriptor(void);
 180      =2  void Get_Configuration(void);
C51 COMPILER V7.50   F34X_MSD_FILE_SYSTEM          11/28/2006 10:54:06 PAGE 15  

 181      =2  void Set_Configuration(void);
 182      =2  void Get_Interface(void);
 183      =2  void Set_Interface(void);
 184      =2  
 185      =2  // MSD Specific Requests
 186      =2  // void Reset_Msd(void);
 187      =2  // void Get_MaxLUN(void);
 188      =2  
 189      =2  // Initialization Routines
 190      =2  void Sys_Clk_Init(void);                      // Initialize the sy
             -stem clock(depends on Full/Low speed)
 191      =2  void Port_Init(void);                        // Configure ports fo
             -r this specific application
 192      =2  void USB0_Init(void);                        // Configure USB core
             - for either Full/Low speed
 193      =2  void Timer_Init(void);                       // Start timer 2 for 
             -use by ADC and to check switches
 194      =2  void Adc_Init(void);                         // Configure ADC for 
             -continuous conversion, low-power mode
 195      =2  
 196      =2  // Other Routines
 197      =2  void Timer2_ISR(void);                       // Called when Timer 
             -2 overflows, see if switches are pressed
 198      =2  void Adc_ConvComple_ISR(void);               // When a conversion 
             -completes, switch ADC multiplexor
 199      =2  void USB_ISR(void);                          // Called to determin
             -e type of USB interrupt
 200      =2  void Fifo_ReadC(BYTE, unsigned int, BYTE *) ;
 201      =2  extern void Fifo_Read (BYTE, unsigned int, BYTE *) ; // Used for m
             -ultiple byte reads of Endpoint fifos
 202      =2  extern void Fifo_Write (BYTE, unsigned int, BYTE *) reentrant;// U
             -sed for multiple byte writes of Endpoint fifos
 203      =2  void Force_Stall(void);                      // Forces a procedura
             -l stall on Endpoint 0
 204      =2  void Delay(void);                            // Approximately 80 u
             -s/1 ms on Full/Low Speed
 205      =2  
 206      =2  void USB_In(BYTE* ptr_buf,unsigned count);
 207      =2  
 208      =2  void USB_Bulk_Init(void);
 209      =2  
 210      =2  extern unsigned xdata Out_Count;
 211      =2  extern BYTE xdata Out_Packet[EP2_PACKET_SIZE];
 212      =2  extern BYTE xdata In_count;
 213      =2  extern BYTE xdata In_Packet[EP1_PACKET_SIZE];
 214      =2  //extern BYTE xdata In_Overrun;
 215      =2  
 216      =2  #endif      /* _USB_MAIN_H_ */
 217      =2  
  35      =1  
  36      =1  //----------------------------------------------------------------
             --------------
  37      =1  // Structure Prototypes
  38      =1  //----------------------------------------------------------------
             --------------
  39      =1  
  40      =1  typedef struct {
  41      =1          unsigned cluster_start;
  42      =1          unsigned long sector_current;
  43      =1          unsigned sector_direntry;
  44      =1          unsigned offset_direntry;
  45      =1          BYTE attrib;
C51 COMPILER V7.50   F34X_MSD_FILE_SYSTEM          11/28/2006 10:54:06 PAGE 16  

  46      =1          DWORD pos;
  47      =1          DWORD size;
  48      =1          BYTE isopen;
  49      =1  } FILE;
  50      =1  
  51      =1  typedef WORD UNI; // Unicode character type
  52      =1  
  53      =1  typedef union {
  54      =1  
  55      =1  struct {
  56      =1          BYTE seq_nr; // Bit 0..4 = seqnr, ascending, start with 1. Bit 6:
             - final part of name
  57      =1          UNI unicode1_5[5]; // Little endian
  58      =1          BYTE attrib; // 0x0F
  59      =1          BYTE type; // 0x00
  60      =1          BYTE checksum; // int i;BYTE sum=0;for(i=0;i<11;i++) { sum=(sum>>
             -1)+((sum&1)<<7);sum+=name[i]; }
  61      =1          UNI unicode6_11[6];
  62      =1          unsigned starting_cluster; // 0x0000
  63      =1          UNI unicode12_13[2];
  64      =1  } lfn;
  65      =1  
  66      =1  struct {
  67      =1          char name[11];
  68      =1          BYTE attrib;
  69      =1          BYTE reserved[10];
  70      =1          WORD time; // 5/6/5 bits for h/m/2*sec
  71      =1          WORD date; // 7/4/5 bits for y-1980/m/d
  72      =1          unsigned starting_cluster; // 0 for empty file
  73      =1          DWORD filesize;
  74      =1  } sfn;
  75      =1  
  76      =1  } dir_entry;
  77      =1  
  78      =1  typedef struct {
  79      =1          unsigned long block;
  80      =1          unsigned offset;
  81      =1          BYTE findempty;
  82      =1          dir_entry* direntry;
  83      =1  } find_info;
  84      =1  
  85      =1  
  86      =1  
  87      =1  #define ATTRIB_READ_ONLY        0x01
  88      =1  #define ATTRIB_HIDDEN           0x02
  89      =1  #define ATTRIB_SYSTEM           0x04
  90      =1  #define ATTRIB_LABEL            0x08
  91      =1  #define ATTRIB_SUBDIR           0x10
  92      =1  #define ATTRIB_ARCHIVE          0x20
  93      =1  
  94      =1  #define SEEK_CUR 0
  95      =1  #define SEEK_END 1
  96      =1  #define SEEK_SET 2
  97      =1  
  98      =1  //----------------------------------------------------------------
             --------------
  99      =1  // Function Prototypes
 100      =1  //----------------------------------------------------------------
             --------------
 101      =1  
 102      =1  int fopen(FILE* f,char* filename,char* mode);
 103      =1  int fseek(FILE* f,long offset,int origin);
C51 COMPILER V7.50   F34X_MSD_FILE_SYSTEM          11/28/2006 10:54:06 PAGE 17  

 104      =1  DWORD ftell(FILE* f);
 105      =1  int feof(FILE* f);
 106      =1  unsigned fread(FILE* f,BYTE* buffer,unsigned count);
 107      =1  unsigned fwrite(FILE* f,BYTE* buffer,unsigned count);
 108      =1  void fclose(FILE* f);
 109      =1  int fexists(char* filename);
 110      =1  int fdelete(char* filename);
 111      =1  BYTE findfirst(find_info* findinfo,BYTE empty);
 112      =1  BYTE findnext(find_info* findinfo);
 113      =1  
 114      =1  
 115      =1  //----------------------------------------------------------------
             ----------------
 116      =1  // Functions only for F340 device
 117      =1  //----------------------------------------------------------------
             ----------------
 118      =1  
 119      =1  #ifdef __F340_VER__
 120      =1  
 121      =1  #define DIRECTORY_EXISTS                1
 122      =1  #define NO_PLACE_FOR_DIRECTORY  2
 123      =1  #define DIRNAME_LENGTH_ERROR    3
 124      =1  
 125      =1  //----------------------------------------------------------------
             --------------
 126      =1  // Function Prototypes
 127      =1  //----------------------------------------------------------------
             --------------
 128      =1  
 129      =1  void FileSys_Init();
 130      =1  BYTE chngdir(char* dirname);
 131      =1  BYTE mkdir(char* dir_name);
 132      =1  BYTE rmdir(char* dir_name) ;
 133      =1  void write_current_dir();
 134      =1  
 135      =1  //----------------------------------------------------------------
             --------------
 136      =1  // Structure Prototypes
 137      =1  //----------------------------------------------------------------
             --------------
 138      =1  
 139      =1  typedef struct 
 140      =1  { 
 141      =1          unsigned long block;
 142      =1          unsigned offset;
 143      =1  }
 144      =1  PREV_SEARCH;
 145      =1  
 146      =1  
 147      =1  #endif

⌨️ 快捷键说明

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