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

📄 nf.lst

📁 基于AT89C51SND1的MP3的程序设计(包括播放mp3和录音功能)
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE NF
OBJECT MODULE PLACED IN nf.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lib_mem\nf_1x_2kb\nf.c OPTIMIZE(7,SPEED) BROWSE INCDIR(.\modules\system;.\;
                    -.\;.\lib_refd) DEFINE(KEIL) DEBUG OBJECTEXTEND PRINT(.\nf.lst) OBJECT(nf.obj)

stmt level    source

   1          /*C**************************************************************************
   2          * NAME:         nf.c
   3          *----------------------------------------------------------------------------
   4          * Copyright (c) 2003 Atmel.
   5          *----------------------------------------------------------------------------
   6          * RELEASE:      snd1c-refd-nf-4_0_3      
   7          * REVISION:     1.11     
   8          *----------------------------------------------------------------------------
   9          * PURPOSE:
  10          * This file contains the high level NF with 2Kb page routines
  11          *****************************************************************************/
  12           
  13          /*_____ I N C L U D E S ____________________________________________________*/
  14          
  15          
  16          #include "config.h"                           /* system configuration */
  17          #include "board.h"                            /* board definition  */
  18          #include "lib_mcu\usb\usb_drv.h"              /* usb driver definition */
  19          #include "nf.h"                               /* NF definition */
  20          
  21          
  22          /*_____ M A C R O S ________________________________________________________*/
  23          
  24          #ifndef NF_CAPACITY_AUTO_DETECT
                #error  NF_CAPACITY_AUTO_DETECT must be defined in board.h
              #endif
  27          
  28          #if NF_CONFIG != NF_1X_2KB
                #error NF_CONFIG must be defined with NF_1X_2KB in config.h
              #endif
  31          
  32          #ifndef NF_FULL_CHIP_ERASE
                #error NF_FULL_CHIP_ERASE  must be set to TRUE or FALSE in config.h
              #endif
  35          
  36          #ifndef MEM_RESERVED_SIZE
                #error MEM_RESERVED_SIZE must be defined in config.h
              #endif
  39          
  40          
  41          /*_____ D E F I N I T I O N ________________________________________________*/
  42          
  43          xdata Byte nf_send_cmd At(NF_CMD_LATCH_ENABLE_ADD);   /* Command */
  44          xdata Byte nf_send_add At(NF_ADD_LATCH_ENABLE_ADD);   /* Address */
  45          xdata Byte volatile nf_data At(NF_ADDRESS_CMD_DATA);  /* Data    */
  46          
  47          /*_____ D E C L A R A T I O N ______________________________________________*/
  48          extern  data    Uint32  gl_ptr_mem;               /* memory data pointer                        */
  49          extern  pdata   Byte gl_buffer[];
  50          extern          bit reserved_disk_space;
  51          
  52          data  Uint32  nf_current_physical_sector_addr;   /* give the address of the current sector     */  
  53          data  Uint32  gl_address;                        /* general address variable                   */
  54          data  Uint16  nf_look_up_table_block;            /* look up table address (block)              */
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 2   

  55          data  Uint16  gl_cpt_page;                       /* internal page counter (byte access)        */
  56          data  Byte    nf_zone;                           /* current zone number                        */
  57          data  Byte    nf_gl_buf_idx;
  58          data  Byte    gl_buf_free_idx ;
  59          
  60          bdata bit nf_block_used = FALSE;                  /* Set when a block was used                  */
  61          bdata bit nf_busy = FALSE;                        /* indicate that nand flash is busy           */
  62          bdata bit nf_lut_modified = FALSE;                /* indicate that LUT have been modified       */
  63          bdata bit nf_wr_open = FALSE;                     /* indicate that a write command is required  */ 
  64          bdata bit nf_reserved_space = FALSE;
  65          
  66          idata Uint16  nf_logical_block;                   /* Current logical block value                */
  67          idata Byte    nf_gl_buf_idx_max;                  /* max index for updating LUT                 */
  68          
  69          xdata Uint16  nf_lut_block[NF_ZONE_MAX];          /* LUT address (block value)                  */
  70          xdata Uint16  nf_buf_free[24];                    /* contain free physical block address        */
  71          xdata Byte    nf_spare_block;                     /* number of free block                       */
  72          xdata Uint16  nf_block_to_be_deleted;             /* give the address of the next deleted block */
  73          xdata Uint16  nf_block_min;                       /* address of the first block in the buffer   */
  74          xdata Uint16  nf_block_max;                       /* address of the last block in the buffer    */
  75          xdata Union16 nf_buf[NF_BUFFER_SIZE];             /* Buffer for write operation                 */
  76          xdata Byte    nf_old_zone;                        /* for zone change                            */  
  77          xdata Byte    nf_lut_index[NF_ZONE_MAX];          /* give the index for updating LUT            */
  78          xdata Byte    nf_spare_block_number[NF_ZONE_MAX]; /* Number of free spare block in each zone    */
  79          
  80          
  81          
  82          
  83          xdata Uint32 nf_mem_size;
  84          xdata Uint32 nf_reserved_space_start;
  85          xdata Uint32 save_gl_ptr_mem;
  86          xdata Uint32 save_physical_sector;
  87          bit nf_write_advanced = FALSE;
  88          bit nf_close_write_session = FALSE;
  89          
  90          #if (NF_CAPACITY_AUTO_DETECT == TRUE)             /* If autodetect capacity nand flash is active  */
  91            xdata Byte    nf_zone_max;                      /* nf_zone_max definition                       */
  92            xdata Byte    nf_device_type;                   /* nf_device_type definition                    */
  93            bdata bit     nf_5_cycle_address;               /* nf_5_cycle_address definition                */
  94          #endif
  95          
  96          
  97          
  98          /**************************************************************************************
  99          manufacturer code :
 100                      0x98                Toshiba
 101                      0xEC                Samsung
 102          
 103          
 104          supported   |  device |  capacity |     |manufacturer | Copy back
 105          by this     |   code  |           |     |S : Samsung  | supported
 106          driver      |         |           |     |T : Toshiba  |
 107          ------------------------------------------------------------------------------------
 108            no        |   0x39  |    8MB    | 512 |S    (1,8V)  | no
 109            no        |   0xE6  |    8MB    | 512 |S - T(3,3V)  | no
 110            no        |   0x73  |   16MB    | 512 |S - T(3,3V)  | no
 111            no        |   0x33  |   16MB    | 512 |S    (1,8V)  | no
 112            no        |   0x75  |   32MB    | 512 |S    (3,3V)  | yes
 113            no        |   0x75  |   32MB    | 512 |T    (3,3V)  | no
 114            no        |   0x76  |   64MB    | 512 |S    (3,3V)  | yes
 115            no        |   0x76  |   64MB    | 512 |T    (3,3V)  | no
 116            no        |   0x79  |  128MB    | 512 |S    (3,3V)  | yes
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 3   

 117            no        |   0x79  |  128MB    | 512 |T    (3,3V)  | no
 118            yes       |   0xA1  |  128MB    |2048 |S    (1,8V)  | yes
 119            yes       |   0xF1  |  128MB    |2048 |S    (3,3V)  | yes
 120            yes       |   0xAA  |  256MB    |2048 |S    (1,8V)  | yes
 121            yes       |   0xDA  |  256MB    |2048 |S    (3,3V)  | yes
 122          **************************************************************************************/
 123          
 124          
 125          /*F**************************************************************************
 126          * NAME: nf_force_write_close
 127          *----------------------------------------------------------------------------
 128          * PARAMS:
 129          *
 130          * return:
 131          *----------------------------------------------------------------------------
 132          * PURPOSE:
 133          *   End of write close function.
 134          *----------------------------------------------------------------------------
 135          * EXAMPLE:
 136          *----------------------------------------------------------------------------
 137          * NOTE:
 138          *   Call to this function is mandatory after a write session.
 139          *   Flag nf_close_write_session must be set to 1 during the call to 
 140          *   nf_write_close() function.
 141          *   This flag must be reset after a call to nf_force_write_close().
 142          *----------------------------------------------------------------------------
 143          * REQUIREMENTS:
 144          *****************************************************************************/
 145          void nf_force_write_close(void)
 146          {
 147   1        /* Copy last part of a block if the block was assigned */
 148   1        Nf_CS_ON();
 149   1        if (nf_block_used)
 150   1        {
 151   2          if ( (((Byte*)&gl_ptr_mem)[3] & 0x3F) || (gl_cpt_page != 0) ) 
 152   2            nf_copy_block_tail();
 153   2          nf_block_erase((Uint32)(nf_block_to_be_deleted) << NF_SHIFT_SECTOR_BLOCK);    /* Erase old block */
 154   2          nf_block_used = FALSE;
 155   2        }
 156   1      }
 157          
 158          
 159          /*F**************************************************************************
 160          * NAME: nf_read_spare_byte
 161          *----------------------------------------------------------------------------
 162          * PARAMS:
 163          *
 164          * return:
 165          *   OK : LUT construction complete
 166          *   KO : pb for LUT
 167          *----------------------------------------------------------------------------
 168          * PURPOSE:
 169          *   read spare data byte and construct the look up table.
 170          *----------------------------------------------------------------------------
 171          * EXAMPLE:
 172          *----------------------------------------------------------------------------
 173          * NOTE:
 174          *----------------------------------------------------------------------------
 175          * REQUIREMENTS:
 176          *****************************************************************************/
 177          bit nf_read_spare_byte(void)
 178          {
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 4   

 179   1      Byte byte_5;
 180   1      Byte byte_6;
 181   1      Byte lut_is_present;
 182   1      Byte page;
 183   1      Uint16 block;
 184   1      Uint16 j;                       /* counter */
 185   1      Uint16 i;                       /* counter */
 186   1      Uint16 start;                   /* start value for the construction of the LUT */
 187   1      Uint16 end;                     /* final value */
 188   1      Uint16 free_bloc_pos;
 189   1      Union16 block2;
 190   1      bit   block_valid;
 191   1      xdata Uint16 last_physical_used_block[NF_ZONE_MAX]; /* Last physical block used */
 192   1      #define temp_address  gl_ptr_mem
 193   1      
 194   1        Nf_CS_ON();
 195   1      
 196   1        lut_is_present      = 0x00;         
 197   1        nf_close_write_session = FALSE;
 198   1        for (i = 0; i < NF_ZONE_MAX_CPT; i++)
 199   1        {
 200   2          nf_lut_index[i] = 0;                /* LUT index */
 201   2        }
 202   1      
 203   1        /***************************************************/
 204   1        /* For each zone, this following lines :           */
 205   1        /*   Search bad block                              */
 206   1        /*   Determine if a LUT is present                 */
 207   1        /*   Determine the last physical block             */ 
 208   1        /***************************************************/
 209   1        gl_address = 0;
 210   1        Nf_wait_busy();
 211   1                                            
 212   1        for (i = 0; i < NF_ZONE_MAX_CPT; i++)                               /* for each zone */
 213   1      
 214   1        {
 215   2          nf_spare_block_number[i] = 23;                                    /* initialize the spare block table 
             -*/
 216   2          last_physical_used_block[i] = (Uint16)(i) << NF_SHIFT_BLOCK_ZONE; /* initialize the last used physical
             - block value */
 217   2          for (j = NF_BLOCK_PER_ZONE; j != 0; j--)        
 218   2          {
 219   3            Nf_read_open_spare_area(gl_address, 0x05);
 220   3            if ( Nf_rd_byte() != 0xFF )                                     /* block status : valid/invalid */

⌨️ 快捷键说明

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