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

📄 nf_drv.lst

📁 该源码是基于atmel公司的89C51SND1C的mp3解决方案
💻 LST
📖 第 1 页 / 共 3 页
字号:
 480   2          Nf_wr_byte(0xFF);
 481   2          Nf_wr_byte(0xFF);
 482   2          Nf_wr_byte(0xFF);
 483   2      
 484   2          /* Valid the page programmation */
 485   2          Nf_send_command(NF_PAGE_PROGRAM_CMD);
C51 COMPILER V7.00  NF_DRV                                                                 04/28/2004 09:31:55 PAGE 9   

 486   2      
 487   2          start += 128;
 488   2          ((Byte*)&address2)[3]++;
 489   2          ((Byte*)&gl_address)[3]++;
 490   2        }
 491   1        while (start < 1024);
 492   1      
 493   1        nf_gl_buf_idx_max = 0;
 494   1      
 495   1        if (nf_lut_index[nf_zone] == 0)
 496   1        {
 497   2          address2 = (Uint32)(nf_lut_block[nf_zone])<<5;
 498   2          nf_lut_block[nf_zone] = nf_look_up_table_block;           /* Update address of look up table */
 499   2          Nf_wait_busy();
 500   2          Nf_send_command (NF_READ_A_AREA_CMD);
 501   2          Nf_send_command (NF_BLOCK_ERASE_CMD);                     /* Auto Block Erase Setup */
 502   2          Nf_send_address ( ((Byte*)&address2)[3] );                /* 2nd address cycle*/
 503   2          Nf_send_address ( ((Byte*)&address2)[2] );                /* 3rd address cycle*/
 504   2          if (NF_4_CYCLE_ADDRESS_BIT)                               /* Size of card >= 64Mbytes ?*/
 505   2            Nf_send_address ( ((Byte*)&address2)[1] );              /* 4th address cycle*/
 506   2          Nf_send_command(NF_BLOCK_ERASE_CONFIRM_CMD);              /* Erase command */
 507   2        }
 508   1      }
 509          
 510          
 511          /*F**************************************************************************
 512          * NAME: nf_mark_bad_block
 513          *----------------------------------------------------------------------------
 514          * PARAMS:   
 515          *           
 516          * return:   
 517          *----------------------------------------------------------------------------
 518          * PURPOSE:
 519          *   Write 0x00 on block status byte (Byte 5 of spare data)
 520          *----------------------------------------------------------------------------
 521          * EXAMPLE:
 522          *----------------------------------------------------------------------------
 523          * NOTE:
 524          *   This function use the global variable Uint32 address
 525          *----------------------------------------------------------------------------
 526          * REQUIREMENTS: 
 527          * ram/xram:
 528          * cycle:
 529          * stack: 
 530          * code:
 531          *****************************************************************************/
 532          void nf_mark_bad_block (void)
 533          {
 534   1        Nf_wait_busy();
 535   1        Nf_write_open_C_area(gl_address, 0x03);
 536   1      
 537   1        Nf_wr_byte(0x00);
 538   1        Nf_wr_byte(0x00);
 539   1        Nf_wr_byte(0x00);
 540   1      
 541   1        Nf_send_command (NF_PAGE_PROGRAM_CMD);  /* Send program command */
 542   1      }
 543          
 544          
 545          /*F**************************************************************************
 546          * NAME: nf_block_erase
 547          *----------------------------------------------------------------------------
C51 COMPILER V7.00  NF_DRV                                                                 04/28/2004 09:31:55 PAGE 10  

 548          * PARAMS:   
 549          *
 550          * return:
 551          *   OK : erase done
 552          *   KO : erase not done
 553          *----------------------------------------------------------------------------
 554          * PURPOSE: Erase a block on Nand Flash Media
 555          *----------------------------------------------------------------------------
 556          * EXAMPLE:
 557          *----------------------------------------------------------------------------
 558          * NOTE:
 559          *   This function use the global variable Uint32 address
 560          *----------------------------------------------------------------------------
 561          * REQUIREMENTS: 
 562          * ram/xram:
 563          * cycle:
 564          * stack: 
 565          * code:
 566          *****************************************************************************/
 567          bit nf_block_erase (Uint32 pos)
 568          {
 569   1        Nf_wait_busy();
 570   1        Nf_send_command (NF_READ_A_AREA_CMD);
 571   1        Nf_send_command (NF_BLOCK_ERASE_CMD);       /* Auto Block Erase Setup     */
 572   1      
 573   1        Nf_send_address ( ((Byte*)&pos)[3] );       /* 2nd address cycle          */
 574   1        Nf_send_address ( ((Byte*)&pos)[2] );       /* 3rd address cycle          */
 575   1        if (NF_4_CYCLE_ADDRESS_BIT)                 /* Size of card >= 64Mbytes ? */
 576   1          Nf_send_address ( ((Byte*)&pos)[1] );     /* 4th address cycle          */
 577   1      
 578   1        Nf_send_command(NF_BLOCK_ERASE_CONFIRM_CMD);/* Erase command              */
 579   1        return OK;
 580   1      }
 581          
 582          
 583          /*F**************************************************************************
 584          * NAME: nf_erase_all_block
 585          *----------------------------------------------------------------------------
 586          * PARAMS:   
 587          *           
 588          * return:   
 589          *   OK : erase done
 590          *   KO : erase not done
 591          *----------------------------------------------------------------------------
 592          * PURPOSE:
 593          *   This function erase all blocks on a NF card and write CIS information
 594          *----------------------------------------------------------------------------
 595          * EXAMPLE:
 596          *----------------------------------------------------------------------------
 597          * NOTE:
 598          *   This function use the global variable Uint32 address
 599          *----------------------------------------------------------------------------
 600          * REQUIREMENTS: 
 601          * ram/xram:
 602          * cycle:
 603          * stack: 
 604          * code:
 605          *****************************************************************************/
 606          bit nf_erase_all_block (void)
 607          {
 608   1      Byte i;
 609   1      Uint16 j;
C51 COMPILER V7.00  NF_DRV                                                                 04/28/2004 09:31:55 PAGE 11  

 610   1      Uint16 block;
 611   1      Uint16 block_reserved_space;
 612   1      bit erase;
 613   1       
 614   1        Nf_CS_ON();
 615   1        /* Erase all block */
 616   1        block_reserved_space = (Uint16) (((nf_reserved_space_start >> 5) % 1000));
 617   1        gl_address = 0;
 618   1        for (nf_zone = 0; nf_zone < NF_ZONE_MAX_CPT; nf_zone++)
 619   1        {
 620   2          for (j = 1024; j != 0; j--)
 621   2          {
 622   3            Nf_wait_busy();
 623   3            Nf_read_open_C_area(gl_address, 0x05); /* Read block status byte */
 624   3            erase = TRUE;
 625   3            if (Nf_rd_byte() != 0xFF) /* if bad block */
 626   3            {
 627   4              erase = FALSE;          /* don't erase block */
 628   4            }
 629   3            else
 630   3            {
 631   4              ((Byte*)&block)[0] = Nf_rd_byte(); /* Read logical block address */
 632   4              ((Byte*)&block)[1] = Nf_rd_byte();
 633   4              if ( (MEM_RESERVED_SIZE != 0) && (nf_zone == (NF_ZONE_MAX_CPT - 1)))
 634   4              {
 635   5                if ((((Byte*)&block)[0] & 0xF8) == 0x10)
 636   5                {
 637   6                  block = (block & 0x0FFF) >> 1;
 638   6                  if (block >= block_reserved_space)      /* If it is a reserved block */
 639   6                  {
 640   7                    erase = FALSE;                        /* Don't erase block */
 641   7                  }
 642   6                }
 643   5              }
 644   4            }
 645   3      
 646   3            if (NF_FULL_CHIP_ERASE == FALSE)
 647   3            {
 648   4              if (((Byte*)&block)[0] != 0xE8)
 649   4              {
 650   5                erase = FALSE;
 651   5              }
 652   4            }
 653   3            else
 654   3            {
 655   4              if (((Byte*)&block)[0] == 0x00)
 656   4              {
 657   5                erase = FALSE;
 658   5              }
 659   4            }
 660   3      
 661   3            if (erase)
 662   3            {
 663   4              nf_block_erase(gl_address);
 664   4              if (nf_check_status() == KO)
 665   4              { 
 666   5                nf_mark_bad_block(); /* Failure on erase operation */     
 667   5              }
 668   4              else
 669   4              { /* Fill redundant area with 0x00 */
 670   5                Nf_write_open_C_area(gl_address, 0x00);
 671   5                for (i = 16; i != 0; i--)
C51 COMPILER V7.00  NF_DRV                                                                 04/28/2004 09:31:55 PAGE 12  

 672   5                  Nf_wr_byte(0x00);
 673   5                Nf_send_command(NF_PAGE_PROGRAM_CMD);        /* Valid the page programmation */
 674   5                if ( nf_check_status() == KO)
 675   5                { 
 676   6                  nf_mark_bad_block();                        /* Failure on program operation */
 677   6                }
 678   5                else
 679   5                {
 680   6                  Nf_read_open_C_area(gl_address, 0x00);        /* Read 16 bytes */
 681   6                  i = 16;
 682   6                  while ((i != 0) && (Nf_rd_byte() == 0x00)) i--;
 683   6      
 684   6                  if (i)
 685   6                  {
 686   7                    nf_mark_bad_block();
 687   7                  }
 688   6                  else
 689   6                  {
 690   7                    nf_block_erase(gl_address);          /* Finally, erase the block */      
 691   7                    if ( nf_check_status() == KO)
 692   7                    { /* Failure on erase operation */
 693   8                      nf_mark_bad_block();      
 694   8                    }
 695   7                  }
 696   6                }
 697   5              }
 698   4            }
 699   3            gl_address += 32;
 700   3          }
 701   2        }
 702   1        return (nf_read_spare_byte());
 703   1      }
 704          
 705          
 706          
 707          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1855    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----       4
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      17
   IDATA SIZE       =      2    ----
   BIT SIZE         =      1       1
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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