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

📄 nf.lst

📁 基于AT89C51SND1的MP3的程序设计(包括播放mp3和录音功能)
💻 LST
📖 第 1 页 / 共 5 页
字号:
 221   3            {
 222   4              nf_spare_block_number[i]--;                                   /* Defect block  */
 223   4              if (nf_spare_block_number[i] < 4)
 224   4                return KO;
 225   4            }
 226   3            else                                                            /* Block is valid */
 227   3            {
 228   4              byte_6 = Nf_rd_byte();                                        /* Determine is the block is a speci
             -fic block */
 229   4              if (  (byte_6 == 0x00) ||                                     /* 0x00 = specific block */
 230   4                    ( (byte_6 != 0xFF) && ( (byte_6 & 0xF8) != 0x10 ) &&    /* Value in redundant spare area not
             - correct */
 231   4                      (byte_6 != 0xE8) )                                    /* Don't care about LUT block */
 232   4                 )
 233   4              { 
 234   5                nf_spare_block_number[i]--;                                 /* specific or invalid block */
 235   5                if (nf_spare_block_number[i] < 4)
 236   5                  return KO;
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 5   

 237   5      
 238   5              }
 239   4              else
 240   4              {
 241   5                if (byte_6 == 0xE8)                                         /* look up table ? */
 242   5                {
 243   6                    lut_is_present |= (0x01) << i;
 244   6                    nf_lut_block[i] = gl_address >> NF_SHIFT_SECTOR_BLOCK;
 245   6                }
 246   5      
 247   5                if ( (byte_6 & 0xF8) == 0x10)                               /* Determine the last physical used 
             -block */
 248   5                {
 249   6                  last_physical_used_block[i] = gl_address >> NF_SHIFT_SECTOR_BLOCK;
 250   6                }
 251   5              }
 252   4      
 253   4            }
 254   3            gl_address += NF_PAGE_PER_BLOCK;
 255   3          }
 256   2        }
 257   1      
 258   1        for (i = 0; i < NF_ZONE_MAX_CPT; i++)
 259   1        { /* Determine the index for each correct lut */
 260   2          if ((lut_is_present & (0x01 << i)))
 261   2          {
 262   3            gl_address = (Uint32)(nf_lut_block[i]) << NF_SHIFT_SECTOR_BLOCK;
 263   3            do
 264   3            {
 265   4              Nf_read_open_spare_area(gl_address, 0x06);
 266   4              nf_lut_index[i]++;
 267   4              gl_address++;
 268   4              byte_6 = Nf_rd_byte();
 269   4            }
 270   3            while ((byte_6 == 0xE8) && ((gl_address & 0x3F) != 0)); 
 271   3            if ((byte_6 == 0xE8) && ((gl_address & 0x3F) == 0))
 272   3            {
 273   4              nf_lut_index[i]--;
 274   4              gl_address--;
 275   4            }
 276   3            else
 277   3            {
 278   4              nf_lut_index[i]-=2;
 279   4              gl_address-=2;
 280   4            }      
 281   3      
 282   3            Nf_read_open_spare_area(gl_address, 0x00);
 283   3            if (Nf_rd_byte() != 0xFF)                       /* LUT have been modified */
 284   3            {
 285   4              nf_block_erase(gl_address);
 286   4              lut_is_present &= ~((0x01) << i);             /* Reset bit */
 287   4              nf_lut_index[i] = 0;
 288   4              Nf_wait_busy();
 289   4            }
 290   3      
 291   3          }
 292   2        }
 293   1        /*****************************************************************/
 294   1        /*          Find free physical block for LUT for each zone       */
 295   1        /*****************************************************************/
 296   1        for (i = 0; i < NF_ZONE_MAX_CPT; i++)
 297   1        {
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 6   

 298   2          if (!(lut_is_present & (0x01 << i)))
 299   2          {
 300   3            block = last_physical_used_block[i];
 301   3            start = (Uint16)(i) << NF_SHIFT_BLOCK_ZONE;                   /* starting value for each zone */
 302   3            j = 0;
 303   3            if (block == start)                                           /* starting block for scan      */
 304   3            {
 305   4              block = start + 1023;
 306   4            }
 307   3            block_valid = FALSE;                                          /* init flag block valid */
 308   3            do
 309   3            {
 310   4              gl_address = (Uint32)(block) << NF_SHIFT_SECTOR_BLOCK;
 311   4              Nf_read_open_spare_area(gl_address, 0x05);
 312   4              byte_5 = Nf_rd_byte();
 313   4              byte_6 = Nf_rd_byte();
 314   4        
 315   4              if ( (byte_5 == 0xFF) && (byte_6 == 0xFF) ) /* not assigned and valid block */
 316   4              {
 317   5                block_valid = TRUE;                       /* find a correct block         */
 318   5              }
 319   4              else                                        /* else decrease block number   */
 320   4              {
 321   5                if (block == start)                       
 322   5                {
 323   6                  block = start + 1023;
 324   6                }
 325   5                else
 326   5                {
 327   6                  block--;
 328   6                }
 329   5              }
 330   4              j++;
 331   4            }
 332   3            while ( (!block_valid) && (j < 1024) );
 333   3        
 334   3            if (j == 1024)
 335   3            {
 336   4              return KO;
 337   4            }
 338   3            nf_lut_block[i] = block;                         /* Update look up table address */
 339   3          }
 340   2        }
 341   1        
 342   1      
 343   1        /**********************************************************/
 344   1        /* Create the look-up table                               */
 345   1        /* Process is done zone per zone and by step of 256 blocks*/
 346   1        /* block2 : logical block value                           */
 347   1        /* block  : physical block value                          */
 348   1        /* byte_6 : logical block index in the buffer             */
 349   1        /* ********************************************************/
 350   1        for (nf_zone = 0; nf_zone < NF_ZONE_MAX_CPT; nf_zone++)             /* for each zone */
 351   1        {
 352   2          if ( !(lut_is_present & (0x01 << nf_zone)))                   /* If not LUT */
 353   2          {
 354   3            start         = 0x00;
 355   3            end           = 0x80;                                               
 356   3            free_bloc_pos = (Uint16)(last_physical_used_block[nf_zone]);
 357   3            gl_address    = (Uint32)(nf_lut_block[nf_zone]) << NF_SHIFT_SECTOR_BLOCK;        
 358   3            page          = 0;
 359   3            do
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 7   

 360   3            {
 361   4              nf_init_buffer();                         
 362   4              temp_address  = (Uint32)(nf_zone) << NF_SHIFT_SECTOR_ZONE;   
 363   4              block         = (Uint16)(nf_zone) << NF_SHIFT_BLOCK_ZONE;
 364   4              Nf_wait_busy();
 365   4              for (j = NF_BLOCK_PER_ZONE; j != 0 ; j--)       /* for each block             */
 366   4              { 
 367   5                Nf_read_open_spare_area(temp_address, 0x05);
 368   5                if (Nf_rd_byte() == 0xFF)                     /* if not a bad block         */
 369   5                {
 370   6                  block2.b[0] = Nf_rd_byte();                 /* read logical block address */
 371   6                  block2.b[1] = Nf_rd_byte();
 372   6                  byte_6 = block2.b[1] & 0xFE;                /* block index in the buffer  */
 373   6                  if ( (block2.b[0] & 0xF8) == 0x10)          /* if this block is assigned  */
 374   6                  {
 375   7                    block2.w = (block2.w & 0x0FFF) >> 1;          
 376   7                    if ( (block2.w < end) && (block2.w >= start)) 
 377   7                    { 
 378   8                      if (gl_buffer[byte_6] != 0xFF)          /* check if the logical block */
 379   8                      {                                       /*was affected */
 380   9                        /* this physical block is already affected */
 381   9                        /* we have to find wich block have to be deleted */
 382   9                        i = block; /* save physical block value */
 383   9                        /* Byte addr 11 -> = 0x00 if the block have to be deleted */
 384   9                        Nf_read_open_spare_area(temp_address, 0x11); 
 385   9                        if (Nf_rd_byte() == 0x00)  
 386   9                        {
 387  10                          nf_block_to_be_deleted = block; /* this is the block to be deleted */
 388  10                          block = ((Uint16)(gl_buffer[byte_6]) << 8) + gl_buffer[byte_6 + 1];
 389  10                        }
 390   9                        else
 391   9                        { /* the block to be deleted is the block stored in the buffer */
 392  10                          nf_block_to_be_deleted = (Uint16)(gl_buffer[byte_6] << 8) + gl_buffer[byte_6 + 1];
 393  10                          /* update now the buffer with the good block value */
 394  10                          gl_buffer[byte_6]      = ((Byte*)&block)[0];
 395  10                          gl_buffer[byte_6 + 1]  = ((Byte*)&block)[1];
 396  10                        }
 397   9                        /* for the last block, find the last sector used */
 398   9                        temp_address = (Uint32)(block) << NF_SHIFT_SECTOR_BLOCK;
 399   9                        do
 400   9                        {
 401  10                          Nf_read_open_spare_area(temp_address, 0x06);
 402  10                          (((Byte*)&temp_address)[3])++;
 403  10                          byte_6 = Nf_rd_byte();
 404  10                        }
 405   9                        while ( (byte_6 != 0xFF) && ( (((Byte*)&temp_address)[3] & 0x3F) != 0));
 406   9                        if (byte_6 == 0xFF)
 407   9                        {
 408  10                          (((Byte*)&temp_address)[3])-=2;
 409  10                        }
 410   9                        else
 411   9                        {
 412  10                          (((Byte*)&temp_address)[3])--;
 413  10                       
 414  10                        }
 415   9                        Nf_read_open_spare_area(temp_address, 0x10);    /* Byte addr 10 -> internal counter page
             - */
 416   9                        /* we prepare now the copy block tail data */
 417   9                        /* first: we restore the logical sector value */
 418   9                        /* note : there is 1000 logicals blocks per zone */
 419   9                        /* block2 : logical block */
 420   9                        gl_ptr_mem =  ((Uint32)(block2.w) << NF_SHIFT_SECTOR_BLOCK) /* logical block value */
C51 COMPILER V7.06   NF                                                                    05/05/2005 12:12:06 PAGE 8   

 421   9                                    + (((Byte*)&temp_address)[3] & 0x3F) /* add sector address in the logical bl
             -ock */
 422   9                                    + (((Uint32)(nf_zone) * 1000) << NF_SHIFT_SECTOR_BLOCK); /* add 1000 logical
             - blocks per zone */
 423   9      
 424   9                        /* second : we restore the physical sector address */
 425   9                        /* block : physical block */
 426   9                        nf_current_physical_sector_addr = ((Uint32)(block) << NF_SHIFT_SECTOR_BLOCK) 
 427   9                                    + (((Byte*)&temp_address)[3] & 0x3F); 
 428   9                        gl_cpt_page = 0;
 429   9      
 430   9                        byte_5 = ~(Nf_rd_byte());
 431   9      
 432   9                        while (byte_5 != 0)
 433   9                        {
 434  10                          ((Byte*)&gl_cpt_page)[0] += 2;
 435  10                          byte_5 = byte_5 >> 1;
 436  10                        }
 437   9                        if (gl_cpt_page)
 438   9                          ((Byte*)&gl_cpt_page)[0] -= 2;
 439   9                        if (((Byte*)&gl_cpt_page)[0] == 0x08)
 440   9                        {
 441  10                          gl_ptr_mem++;
 442  10                          nf_current_physical_sector_addr++;
 443  10                          gl_cpt_page = 0;
 444  10                        }

⌨️ 快捷键说明

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