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

📄 nand_if.txt

📁 STM32F103ZET6+UCOSII+UCGUI源码
💻 TXT
📖 第 1 页 / 共 3 页
字号:
; generated by ARM C/C++ Compiler with , RVCT4.0 [Build 524] for uVision
; commandline ArmCC [--split_sections --debug -c --asm --interleave -o.\Obj\nand_if.o --depend=.\Obj\nand_if.d --device=DARMSTM --apcs=interwork -O3 -I..\..\include -I..\..\..\FWLib\library\inc -I..\..\..\USBLib\library\inc -I..\..\Config -I..\..\GUI\Core -I..\..\GUI\Font -I..\..\GUI\ConvertColor -I..\..\GUI\AntiAlias -I..\..\GUI\ConvertMono -I..\..\GUI\JPEG -I..\..\GUI\MemDev -I..\..\GUI\MultiLayer -I..\..\GUI\Widget -I..\..\GUI\WM -IC:\Keil\ARM\INC\ST\STM32F10x ..\..\source\nand_if.c]
                          THUMB

                          AREA ||i.NAND_BuildLUT||, CODE, READONLY, ALIGN=2

                  NAND_BuildLUT PROC
;;;470    *******************************************************************************/
;;;471    static u16 NAND_BuildLUT (u8 ZoneNbr)
000000  e92d41fc          PUSH     {r2-r8,lr}
;;;472    {
000004  4680              MOV      r8,r0
;;;473    
;;;474      u16  pBadBlock, pCurrentBlock, pFreeBlock;
;;;475      SPARE_AREA  SpareArea;
;;;476      /*****************************************************************************
;;;477                                      1st step : Init.
;;;478      *****************************************************************************/
;;;479      /*Init the LUT (assume all blocks free) */
;;;480      for (pCurrentBlock = 0 ; pCurrentBlock < MAX_PHY_BLOCKS_PER_ZONE ; pCurrentBlock++)
000006  2000              MOVS     r0,#0
;;;481      {
;;;482        LUT[pCurrentBlock] = FREE_BLOCK;  /* 12th bit is set to 1 */
000008  f44f5180          MOV      r1,#0x1000
00000c  4d31              LDR      r5,|L1.212|
00000e  108e              ASRS     r6,r1,#2              ;480
                  |L1.16|
000010  f8251010          STRH     r1,[r5,r0,LSL #1]
000014  1c40              ADDS     r0,r0,#1              ;480
000016  b280              UXTH     r0,r0                 ;480
000018  42b0              CMP      r0,r6                 ;480
00001a  d3f9              BCC      |L1.16|
;;;483      }
;;;484    
;;;485      /* Init Pointers */
;;;486      pBadBlock    = MAX_PHY_BLOCKS_PER_ZONE - 1;
00001c  f24037ff          MOV      r7,#0x3ff
;;;487      pCurrentBlock = 0;
000020  2400              MOVS     r4,#0
                  |L1.34|
;;;488    
;;;489      /*****************************************************************************
;;;490                             2nd step : locate used and bad blocks
;;;491      *****************************************************************************/
;;;492    
;;;493      while (pCurrentBlock < MAX_PHY_BLOCKS_PER_ZONE)
;;;494      {
;;;495    
;;;496        SpareArea = ReadSpareArea(pCurrentBlock * NAND_BLOCK_SIZE + (ZoneNbr * NAND_BLOCK_SIZE * MAX_PHY_BLOCKS_PER_ZONE));
000022  0161              LSLS     r1,r4,#5
000024  eb0131c8          ADD      r1,r1,r8,LSL #15
000028  4668              MOV      r0,sp
00002a  f7fffffe          BL       ReadSpareArea
;;;497    
;;;498        if ((SpareArea.DataStatus == 0) || (SpareArea.BlockStatus == 0))
00002e  f8bd0002          LDRH     r0,[sp,#2]
000032  b110              CBZ      r0,|L1.58|
000034  f8bd0004          LDRH     r0,[sp,#4]
000038  b9a0              CBNZ     r0,|L1.100|
                  |L1.58|
;;;499        {
;;;500    
;;;501          LUT[pBadBlock--]    |= pCurrentBlock | (u16)BAD_BLOCK ;
00003a  f8350017          LDRH     r0,[r5,r7,LSL #1]
00003e  f4445100          ORR      r1,r4,#0x2000
000042  4308              ORRS     r0,r0,r1
000044  f8250017          STRH     r0,[r5,r7,LSL #1]
;;;502          LUT[pCurrentBlock] &= (u16)~FREE_BLOCK;
000048  f8350014          LDRH     r0,[r5,r4,LSL #1]
00004c  1e7f              SUBS     r7,r7,#1              ;501
00004e  b2bf              UXTH     r7,r7                 ;501
000050  f4205080          BIC      r0,r0,#0x1000
000054  f8250014          STRH     r0,[r5,r4,LSL #1]
;;;503          if (pBadBlock == MAX_LOG_BLOCKS_PER_ZONE)
000058  f5b77f7a          CMP      r7,#0x3e8
00005c  d117              BNE      |L1.142|
;;;504          {
;;;505            return NAND_FAIL;
00005e  2001              MOVS     r0,#1
                  |L1.96|
;;;506          }
;;;507        }
;;;508        else if (SpareArea.LogicalIndex != 0xFFFF)
;;;509        {
;;;510    
;;;511          LUT[SpareArea.LogicalIndex & 0x3FF] |= pCurrentBlock | VALID_BLOCK | USED_BLOCK;
;;;512          LUT[pCurrentBlock] &= (u16)( ~FREE_BLOCK);
;;;513        }
;;;514        pCurrentBlock++ ;
;;;515      }
;;;516    
;;;517      /*****************************************************************************
;;;518         3rd step : locate Free Blocks by scanning the LUT already built partially
;;;519      *****************************************************************************/
;;;520      pFreeBlock = 0;
;;;521      for (pCurrentBlock = 0 ; pCurrentBlock < MAX_PHY_BLOCKS_PER_ZONE ; pCurrentBlock++ )
;;;522      {
;;;523    
;;;524        if ( !(LUT[pCurrentBlock]& USED_BLOCK))
;;;525        {
;;;526          do
;;;527          {
;;;528            if (LUT[pFreeBlock] & FREE_BLOCK)
;;;529            {
;;;530    
;;;531              LUT [pCurrentBlock] |= pFreeBlock;
;;;532              LUT [pFreeBlock]   &= ~FREE_BLOCK;
;;;533              break;
;;;534            }
;;;535            pFreeBlock++;
;;;536          }
;;;537          while ( pFreeBlock < MAX_PHY_BLOCKS_PER_ZONE );
;;;538        }
;;;539      }
;;;540      return NAND_OK;
;;;541    }
000060  e8bd81fc          POP      {r2-r8,pc}
                  |L1.100|
000064  f8bd0000          LDRH     r0,[sp,#0]            ;508
000068  f5a0417f          SUB      r1,r0,#0xff00         ;508
00006c  39ff              SUBS     r1,r1,#0xff           ;508
00006e  d00e              BEQ      |L1.142|
000070  f3c00009          UBFX     r0,r0,#0,#10          ;511
000074  f8351010          LDRH     r1,[r5,r0,LSL #1]     ;511
000078  f4444240          ORR      r2,r4,#0xc000         ;511
00007c  4311              ORRS     r1,r1,r2              ;511
00007e  f8251010          STRH     r1,[r5,r0,LSL #1]     ;511
000082  f8350014          LDRH     r0,[r5,r4,LSL #1]     ;512
000086  f4205080          BIC      r0,r0,#0x1000         ;512
00008a  f8250014          STRH     r0,[r5,r4,LSL #1]     ;512
                  |L1.142|
00008e  1c64              ADDS     r4,r4,#1              ;514
000090  b2a4              UXTH     r4,r4                 ;514
000092  42b4              CMP      r4,r6                 ;493
000094  d3c5              BCC      |L1.34|
000096  2000              MOVS     r0,#0                 ;520
000098  ea4f0100          MOV.W    r1,r0                 ;521
                  |L1.156|
00009c  f8352011          LDRH     r2,[r5,r1,LSL #1]     ;524
0000a0  0413              LSLS     r3,r2,#16             ;524
0000a2  d411              BMI      |L1.200|
                  |L1.164|
0000a4  f8353010          LDRH     r3,[r5,r0,LSL #1]     ;528
0000a8  04db              LSLS     r3,r3,#19             ;528
0000aa  d509              BPL      |L1.192|
0000ac  4302              ORRS     r2,r2,r0              ;531
0000ae  f8252011          STRH     r2,[r5,r1,LSL #1]     ;531
0000b2  f8352010          LDRH     r2,[r5,r0,LSL #1]     ;532
0000b6  f4225280          BIC      r2,r2,#0x1000         ;532
0000ba  f8252010          STRH     r2,[r5,r0,LSL #1]     ;532
0000be  e003              B        |L1.200|
                  |L1.192|
0000c0  1c40              ADDS     r0,r0,#1              ;535
0000c2  b280              UXTH     r0,r0                 ;535
0000c4  42b0              CMP      r0,r6                 ;537
0000c6  d3ed              BCC      |L1.164|
                  |L1.200|
0000c8  1c49              ADDS     r1,r1,#1              ;521
0000ca  b289              UXTH     r1,r1                 ;521
0000cc  42b1              CMP      r1,r6                 ;521
0000ce  d3e5              BCC      |L1.156|
0000d0  2000              MOVS     r0,#0                 ;540
0000d2  e7c5              B        |L1.96|
;;;542    
                          ENDP

                  |L1.212|
                          DCD      ||.bss||

                          AREA ||i.NAND_ConvertPhyAddress||, CODE, READONLY, ALIGN=1

                  NAND_ConvertPhyAddress PROC
;;;446    *******************************************************************************/
;;;447    static NAND_ADDRESS NAND_ConvertPhyAddress (u32 Address)
000000  b51c              PUSH     {r2-r4,lr}
;;;448    {
;;;449      NAND_ADDRESS Address_t;
;;;450    
;;;451      Address_t.Page  = Address & (NAND_BLOCK_SIZE - 1);
000002  f001021f          AND      r2,r1,#0x1f
;;;452      Address_t.Block = Address / NAND_BLOCK_SIZE;
000006  0949              LSRS     r1,r1,#5
000008  f8ad1002          STRH     r1,[sp,#2]
00000c  f8ad2004          STRH     r2,[sp,#4]            ;451
;;;453      Address_t.Zone = 0;
000010  2100              MOVS     r1,#0
000012  f8ad1000          STRH     r1,[sp,#0]
;;;454    
;;;455      while (Address_t.Block >= MAX_PHY_BLOCKS_PER_ZONE)
000016  f44f6280          MOV      r2,#0x400
;;;456      {
;;;457        Address_t.Block -= MAX_PHY_BLOCKS_PER_ZONE;
;;;458        Address_t.Zone++;
00001a  e008              B        |L2.46|
                  |L2.28|
00001c  f5a16180          SUB      r1,r1,#0x400          ;457
000020  f8ad1002          STRH     r1,[sp,#2]            ;457
000024  f8bd1000          LDRH     r1,[sp,#0]
000028  1c49              ADDS     r1,r1,#1
00002a  f8ad1000          STRH     r1,[sp,#0]
                  |L2.46|
00002e  f8bd1002          LDRH     r1,[sp,#2]            ;455
000032  4291              CMP      r1,r2                 ;455
000034  d2f2              BCS      |L2.28|
;;;459      }
;;;460      return Address_t;
000036  2206              MOVS     r2,#6
000038  4669              MOV      r1,sp
00003a  f7fffffe          BL       __aeabi_memcpy
;;;461    }
00003e  bd1c              POP      {r2-r4,pc}
;;;462    
                          ENDP


                          AREA ||i.NAND_Copy||, CODE, READONLY, ALIGN=1

                  NAND_Copy PROC
;;;342    *******************************************************************************/
;;;343    static u16 NAND_Copy (NAND_ADDRESS Address_Src, NAND_ADDRESS Address_Dest, u16 PageToCopy)
000000  b51f              PUSH     {r0-r4,lr}
;;;344    {
000002  f5ad7d00          SUB      sp,sp,#0x200
;;;345      u8 Copybuff[512];
;;;346      for ( ; PageToCopy > 0 ; PageToCopy-- )
000006  9c86              LDR      r4,[sp,#0x218]
000008  e013              B        |L3.50|
                  |L3.10|
;;;347      {
;;;348        FSMC_NAND_ReadSmallPage  ((u8 *)Copybuff, Address_Src , 1 );
00000a  2301              MOVS     r3,#1
00000c  4668              MOV      r0,sp
00000e  9a81              LDR      r2,[sp,#0x204]
000010  9980              LDR      r1,[sp,#0x200]
000012  f7fffffe          BL       FSMC_NAND_ReadSmallPage
;;;349        FSMC_NAND_WriteSmallPage ((u8 *)Copybuff, Address_Dest, 1);
000016  2301              MOVS     r3,#1
000018  4668              MOV      r0,sp
00001a  9a83              LDR      r2,[sp,#0x20c]
00001c  9982              LDR      r1,[sp,#0x208]
00001e  f7fffffe          BL       FSMC_NAND_WriteSmallPage
;;;350        FSMC_NAND_AddressIncrement(&Address_Src);
000022  a880              ADD      r0,sp,#0x200
000024  f7fffffe          BL       FSMC_NAND_AddressIncrement
;;;351        FSMC_NAND_AddressIncrement(&Address_Dest);
000028  a882              ADD      r0,sp,#0x208
00002a  f7fffffe          BL       FSMC_NAND_AddressIncrement
00002e  1e64              SUBS     r4,r4,#1              ;346
000030  b2a4              UXTH     r4,r4                 ;346
                  |L3.50|
000032  2c00              CMP      r4,#0                 ;346
000034  d1e9              BNE      |L3.10|
;;;352      }
;;;353    
;;;354      return NAND_OK;
000036  2000              MOVS     r0,#0
;;;355    }
000038  f50d7d04          ADD      sp,sp,#0x210
00003c  bd10              POP      {r4,pc}
;;;356    
                          ENDP


                          AREA ||i.NAND_Format||, CODE, READONLY, ALIGN=1

                  NAND_Format PROC
;;;363    *******************************************************************************/
;;;364    u16 NAND_Format (void)
000000  b57f              PUSH     {r0-r6,lr}
;;;365    {
;;;366      NAND_ADDRESS phAddress;
;;;367      SPARE_AREA  SpareArea;
;;;368      u32 BlockIndex;
;;;369    
;;;370      for (BlockIndex = 0 ; BlockIndex < NAND_ZONE_SIZE * NAND_MAX_ZONE; BlockIndex++)
000002  2400              MOVS     r4,#0
000004  f44f5680          MOV      r6,#0x1000
                  |L4.8|
;;;371      {
;;;372        phAddress = NAND_ConvertPhyAddress(BlockIndex * NAND_BLOCK_SIZE );
000008  0165              LSLS     r5,r4,#5
00000a  4629              MOV      r1,r5
00000c  a802              ADD      r0,sp,#8
00000e  f7fffffe          BL       NAND_ConvertPhyAddress
000012  4629              MOV      r1,r5
;;;373        SpareArea = ReadSpareArea(BlockIndex * NAND_BLOCK_SIZE);
000014  4668              MOV      r0,sp
000016  f7fffffe          BL       ReadSpareArea
;;;374       
;;;375        if((SpareArea.DataStatus != 0)||(SpareArea.BlockStatus != 0)){
00001a  f8bd0002          LDRH     r0,[sp,#2]
00001e  b910              CBNZ     r0,|L4.38|
000020  f8bd0004          LDRH     r0,[sp,#4]
000024  b118              CBZ      r0,|L4.46|
                  |L4.38|
;;;376            FSMC_NAND_EraseBlock (phAddress);
000026  e9dd0102          LDRD     r0,r1,[sp,#8]
00002a  f7fffffe          BL       FSMC_NAND_EraseBlock
                  |L4.46|
00002e  1c64              ADDS     r4,r4,#1              ;370
000030  42b4              CMP      r4,r6                 ;370
000032  d3e9              BCC      |L4.8|
;;;377        }  
;;;378      }
;;;379      NAND_BuildLUT(0);
000034  2000              MOVS     r0,#0
000036  f7fffffe          BL       NAND_BuildLUT
;;;380      return NAND_OK;
00003a  2000              MOVS     r0,#0
;;;381    }
00003c  b004              ADD      sp,sp,#0x10
00003e  bd70              POP      {r4-r6,pc}
;;;382    
                          ENDP


                          AREA ||i.NAND_GetAddress||, CODE, READONLY, ALIGN=1

                  NAND_GetAddress PROC
;;;287    *******************************************************************************/
;;;288    static NAND_ADDRESS NAND_GetAddress (u32 Address)
000000  b51c              PUSH     {r2-r4,lr}
;;;289    {
;;;290      NAND_ADDRESS Address_t;
;;;291    
;;;292      Address_t.Page  = Address & (NAND_BLOCK_SIZE - 1);
000002  f001021f          AND      r2,r1,#0x1f
;;;293      Address_t.Block = Address / NAND_BLOCK_SIZE;
000006  0949              LSRS     r1,r1,#5
000008  f8ad1002          STRH     r1,[sp,#2]
00000c  f8ad2004          STRH     r2,[sp,#4]            ;292
;;;294      Address_t.Zone = 0;
000010  2100              MOVS     r1,#0
000012  f8ad1000          STRH     r1,[sp,#0]
;;;295    
;;;296      while (Address_t.Block >= MAX_LOG_BLOCKS_PER_ZONE)
000016  f44f727a          MOV      r2,#0x3e8

⌨️ 快捷键说明

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