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

📄 at45db161.txt

📁 使用STR710的SPI接口访问外部EEPROM的例子程序.使用KEIL UV3编译.使用了MDK3.05操作系统.
💻 TXT
📖 第 1 页 / 共 5 页
字号:
000498  f7ff fffe         BL       AT45_Read_REG         ;423
00049c  2180              MOVS     r1,#0x80              ;423
00049e  4208              TST      r0,r1                 ;423
0004a0  d104              BNE      |L1.1196|             ;423
0004a2  1e78              SUBS     r0,r7,#1              ;423
0004a4  0600              LSLS     r0,r0,#24             ;423
0004a6  0e00              LSRS     r0,r0,#24             ;423
0004a8  0007              MOVS     r7,r0                 ;423
0004aa  d1f5              BNE      |L1.1176|             ;423
                  |L1.1196|
0004ac  2f00              CMP      r7,#0                 ;424
0004ae  d101              BNE      |L1.1204|             ;424
0004b0  2000              MOVS     r0,#0                 ;427
0004b2  e7eb              B        |L1.1164|             ;427
                  |L1.1204|
0004b4  0020              MOVS     r0,r4                 ;431
0004b6  f7ff fffe         BL       MainMemoryPageToBuffer1 ;431
0004ba  27ff              MOVS     r7,#0xff              ;432
0004bc  46c0              MOV      r8,r8                 ;433
                  |L1.1214|
0004be  f7ff fffe         BL       AT45_Read_REG         ;433
0004c2  2180              MOVS     r1,#0x80              ;433
0004c4  4208              TST      r0,r1                 ;433
0004c6  d104              BNE      |L1.1234|             ;433
0004c8  1e78              SUBS     r0,r7,#1              ;433
0004ca  0600              LSLS     r0,r0,#24             ;433
0004cc  0e00              LSRS     r0,r0,#24             ;433
0004ce  0007              MOVS     r7,r0                 ;433
0004d0  d1f5              BNE      |L1.1214|             ;433
                  |L1.1234|
0004d2  2f00              CMP      r7,#0                 ;434
0004d4  d101              BNE      |L1.1242|             ;434
0004d6  2000              MOVS     r0,#0                 ;437
0004d8  e7d8              B        |L1.1164|             ;437
                  |L1.1242|
0004da  0032              MOVS     r2,r6                 ;439
0004dc  0028              MOVS     r0,r5                 ;439
0004de  9902              LDR      r1,[sp,#8]            ;439
0004e0  f7ff fffe         BL       WriteMultiByteToBuffer1 ;439
0004e4  0020              MOVS     r0,r4                 ;440
0004e6  f7ff fffe         BL       ProgramBuffer1ToMainMemory ;440
0004ea  2001              MOVS     r0,#1                 ;442
0004ec  e7ce              B        |L1.1164|             ;442
                          ENDP

                  WriteDataToFlash PROC
;;;457    void WriteDataToFlash(u32 TargetAddr, u8 *save_data, u16 data_len)
;;;458    {
0004ee  b5f7              PUSH     {r0-r2,r4-r7,lr}
0004f0  b082              SUB      sp,sp,#8
0004f2  000c              MOVS     r4,r1
0004f4  0015              MOVS     r5,r2
;;;459    	u16 PageNum,SubAddress;
;;;460    	u16 w_len;
;;;461    
;;;462    	if(!data_len)
0004f6  2d00              CMP      r5,#0
0004f8  d103              BNE      |L1.1282|
;;;463    		return ;
;;;464    	PageNum = TargetAddr / PAGE_BYTE;
;;;465    	SubAddress = TargetAddr % PAGE_BYTE;		
;;;466    	while(data_len)
;;;467    	{
;;;468    		if(data_len > (PAGE_BYTE - SubAddress))
;;;469    			w_len = PAGE_BYTE - SubAddress;
;;;470    		else
;;;471    			w_len = data_len;
;;;472    		while ( IS_DATA_FLASH_BUSY()  );				// 等待芯片空闲
;;;473    		MainMemoryPageToBuffer1(PageNum);				// 把指定页读取到buffer1
;;;474    		while ( IS_DATA_FLASH_BUSY()  );				// 等待芯片空闲
;;;475    		WriteMultiByteToBuffer1(SubAddress,save_data,w_len);	// 向buffer1写入数据
;;;476    		while ( IS_DATA_FLASH_BUSY()  );				// 等待芯片空闲
;;;477    		ProgramBuffer1ToMainMemory(PageNum);				// 将buffer1的内容写入flash
;;;478    		while ( IS_DATA_FLASH_BUSY()  );
;;;479    
;;;480    		data_len -= w_len;
;;;481    		save_data += w_len;
;;;482    		PageNum += 1;
;;;483    		SubAddress = 0;
;;;484    	}
;;;485    	return ;
;;;486    }
                  |L1.1274|
0004fa  b005              ADD      sp,sp,#0x14
0004fc  bcf0              POP      {r4-r7}
0004fe  bc08              POP      {r3}
000500  4718              BX       r3
                  |L1.1282|
000502  2121              MOVS     r1,#0x21              ;464
000504  0109              LSLS     r1,r1,#4              ;464
000506  9802              LDR      r0,[sp,#8]            ;464
000508  f7ff fffe         BL       __aeabi_uidivmod      ;464
00050c  0406              LSLS     r6,r0,#16             ;464
00050e  0c36              LSRS     r6,r6,#16             ;464
000510  2121              MOVS     r1,#0x21              ;465
000512  0109              LSLS     r1,r1,#4              ;465
000514  9802              LDR      r0,[sp,#8]            ;465
000516  f7ff fffe         BL       __aeabi_uidivmod      ;465
00051a  040f              LSLS     r7,r1,#16             ;465
00051c  0c3f              LSRS     r7,r7,#16             ;465
00051e  e039              B        |L1.1428|             ;466
                  |L1.1312|
000520  2021              MOVS     r0,#0x21              ;468
000522  0100              LSLS     r0,r0,#4              ;468
000524  1bc0              SUBS     r0,r0,r7              ;468
000526  42a8              CMP      r0,r5                 ;468
000528  da06              BGE      |L1.1336|             ;468
00052a  2021              MOVS     r0,#0x21              ;469
00052c  0100              LSLS     r0,r0,#4              ;469
00052e  1bc0              SUBS     r0,r0,r7              ;469
000530  0400              LSLS     r0,r0,#16             ;469
000532  0c00              LSRS     r0,r0,#16             ;469
000534  9001              STR      r0,[sp,#4]            ;469
000536  e000              B        |L1.1338|             ;469
                  |L1.1336|
000538  9501              STR      r5,[sp,#4]            ;471
                  |L1.1338|
00053a  46c0              MOV      r8,r8                 ;472
                  |L1.1340|
00053c  f7ff fffe         BL       AT45_Read_REG         ;472
000540  2180              MOVS     r1,#0x80              ;472
000542  4208              TST      r0,r1                 ;472
000544  d0fa              BEQ      |L1.1340|             ;472
000546  0030              MOVS     r0,r6                 ;473
000548  f7ff fffe         BL       MainMemoryPageToBuffer1 ;473
00054c  46c0              MOV      r8,r8                 ;474
                  |L1.1358|
00054e  f7ff fffe         BL       AT45_Read_REG         ;474
000552  2180              MOVS     r1,#0x80              ;474
000554  4208              TST      r0,r1                 ;474
000556  d0fa              BEQ      |L1.1358|             ;474
000558  0021              MOVS     r1,r4                 ;475
00055a  0038              MOVS     r0,r7                 ;475
00055c  9a01              LDR      r2,[sp,#4]            ;475
00055e  f7ff fffe         BL       WriteMultiByteToBuffer1 ;475
000562  46c0              MOV      r8,r8                 ;476
                  |L1.1380|
000564  f7ff fffe         BL       AT45_Read_REG         ;476
000568  2180              MOVS     r1,#0x80              ;476
00056a  4208              TST      r0,r1                 ;476
00056c  d0fa              BEQ      |L1.1380|             ;476
00056e  0030              MOVS     r0,r6                 ;477
000570  f7ff fffe         BL       ProgramBuffer1ToMainMemory ;477
000574  46c0              MOV      r8,r8                 ;478
                  |L1.1398|
000576  f7ff fffe         BL       AT45_Read_REG         ;478
00057a  2180              MOVS     r1,#0x80              ;478
00057c  4208              TST      r0,r1                 ;478
00057e  d0fa              BEQ      |L1.1398|             ;478
000580  9801              LDR      r0,[sp,#4]            ;480
000582  1a28              SUBS     r0,r5,r0              ;480
000584  0405              LSLS     r5,r0,#16             ;480
000586  0c2d              LSRS     r5,r5,#16             ;480
000588  9801              LDR      r0,[sp,#4]            ;481
00058a  1824              ADDS     r4,r4,r0              ;481
00058c  1c70              ADDS     r0,r6,#1              ;482
00058e  0406              LSLS     r6,r0,#16             ;482
000590  0c36              LSRS     r6,r6,#16             ;482
000592  2700              MOVS     r7,#0                 ;483
                  |L1.1428|
000594  2d00              CMP      r5,#0                 ;483
000596  d1c3              BNE      |L1.1312|             ;483
000598  e7af              B        |L1.1274|             ;485
                          ENDP

                  WritePageData PROC
;;;500    void WritePageData(u16 PageNum, u8 *save_data, u16 data_len)
;;;501    {
00059a  b5f7              PUSH     {r0-r2,r4-r7,lr}
00059c  0004              MOVS     r4,r0
00059e  0015              MOVS     r5,r2
;;;502    	u16 SubAddress;
;;;503    	u16 w_len;
;;;504    
;;;505    	if(!data_len)
0005a0  2d00              CMP      r5,#0
0005a2  d102              BNE      |L1.1450|
;;;506    		return ;
;;;507    	SubAddress = 0;		
;;;508    	while(data_len)
;;;509    	{
;;;510    		if(data_len > (PAGE_BYTE - SubAddress))
;;;511    			w_len = PAGE_BYTE - SubAddress;
;;;512    		else
;;;513    			w_len = data_len;
;;;514    		while ( IS_DATA_FLASH_BUSY()  );				// 等待芯片空闲
;;;515    		MainMemoryPageToBuffer1(PageNum);				// 把指定页读取到buffer1
;;;516    		while ( IS_DATA_FLASH_BUSY()  );				// 等待芯片空闲
;;;517    		WriteMultiByteToBuffer1(SubAddress,save_data,w_len);	// 向buffer1写入数据
;;;518    		ProgramBuffer1ToMainMemory(PageNum);				// 将buffer1的内容写入flash
;;;519    
;;;520    		data_len -= w_len;
;;;521    		save_data += w_len;
;;;522    		PageNum += 1;
;;;523    		SubAddress = 0;
;;;524    	}
;;;525    	return ;
;;;526    }
                  |L1.1444|
0005a4  bcfe              POP      {r1-r7}
0005a6  bc08              POP      {r3}
0005a8  4718              BX       r3
                  |L1.1450|
0005aa  2600              MOVS     r6,#0                 ;507
0005ac  e02c              B        |L1.1544|             ;508
                  |L1.1454|
0005ae  2021              MOVS     r0,#0x21              ;510
0005b0  0100              LSLS     r0,r0,#4              ;510
0005b2  1b80              SUBS     r0,r0,r6              ;510
0005b4  42a8              CMP      r0,r5                 ;510
0005b6  da05              BGE      |L1.1476|             ;510
0005b8  2021              MOVS     r0,#0x21              ;511
0005ba  0100              LSLS     r0,r0,#4              ;511
0005bc  1b80              SUBS     r0,r0,r6              ;511
0005be  0407              LSLS     r7,r0,#16             ;511
0005c0  0c3f              LSRS     r7,r7,#16             ;511
0005c2  e000              B        |L1.1478|             ;511
                  |L1.1476|
0005c4  002f              MOVS     r7,r5                 ;513
                  |L1.1478|
0005c6  46c0              MOV      r8,r8                 ;514
                  |L1.1480|
0005c8  f7ff fffe         BL       AT45_Read_REG         ;514
0005cc  2180              MOVS     r1,#0x80              ;514
0005ce  4208              TST      r0,r1                 ;514
0005d0  d0fa              BEQ      |L1.1480|             ;514
0005d2  0020              MOVS     r0,r4                 ;515
0005d4  f7ff fffe         BL       MainMemoryPageToBuffer1 ;515
0005d8  46c0              MOV      r8,r8                 ;516
                  |L1.1498|
0005da  f7ff fffe         BL       AT45_Read_REG         ;516
0005de  2180              MOVS     r1,#0x80              ;516
0005e0  4208              TST      r0,r1                 ;516
0005e2  d0fa              BEQ      |L1.1498|             ;516
0005e4  003a              MOVS     r2,r7                 ;517
0005e6  0030              MOVS     r0,r6                 ;517
0005e8  9901              LDR      r1,[sp,#4]            ;517
0005ea  f7ff fffe         BL       WriteMultiByteToBuffer1 ;517
0005ee  0020              MOVS     r0,r4                 ;518
0005f0  f7ff fffe         BL       ProgramBuffer1ToMainMemory ;518
0005f4  1be8              SUBS     r0,r5,r7              ;520
0005f6  0405              LSLS     r5,r0,#16             ;520
0005f8  0c2d              LSRS     r5,r5,#16             ;520
0005fa  9801              LDR      r0,[sp,#4]            ;521
0005fc  19c0              ADDS     r0,r0,r7              ;521
0005fe  9001              STR      r0,[sp,#4]            ;521
000600  1c60              ADDS     r0,r4,#1              ;522
000602  0404              LSLS     r4,r0,#16             ;522
000604  0c24              LSRS     r4,r4,#16             ;522
000606  2600              MOVS     r6,#0                 ;523
                  |L1.1544|
000608  2d00              CMP      r5,#0                 ;523
00060a  d1d0              BNE      |L1.1454|             ;523
00060c  e7ca              B        |L1.1444|             ;525
                          ENDP

                  ReadDataFromFlash PROC
;;;538    u8 ReadDataFromFlash(u32 TargetAddr, u8 *read_data, u8 data_len)
;;;539    {
00060e  b5f7              PUSH     {r0-r2,r4-r7,lr}
000610  b082              SUB      sp,sp,#8
000612  000e              MOVS     r6,r1
;;;540    	u16 PageNum,SubAddress;
;;;541    	u8 i;
;;;542    	i = 255;
000614  20ff              MOVS     r0,#0xff
000616  9001              STR      r0,[sp,#4]
;;;543    	if ( data_len == 0 )
000618  9804              LDR      r0,[sp,#0x10]
00061a  2800              CMP      r0,#0
00061c  d103              BNE      |L1.1574|
;;;544    	{

⌨️ 快捷键说明

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