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

📄 iflash.c

📁 Dignostic test program for SMDK441f board chip peripellel. ADS1.2 compiler
💻 C
字号:
#include "def.h"
#include "option.h"
#include <string.h>
#include "k44.h"
#include "k44lib.h"
#include "iflashl.h"

void WriteIflash(U32 data);
int ReadIflash(U32 data);

#define IFLASH_START_ADDR		(0x1f00000)

void Test_Iflash(void)
{
    int result;
    Uart_Printf("[]Internal Flash memory erase/write/read test\n");	

    Uart_Printf("ERASE TEST(1=OK,0=FAIL):");
    result=Iflash_EraseSectors(0,511);
    Uart_Printf("%d\n",result);

    Uart_Printf("WRITE TEST(55555555):\n");	
    WriteIflash(0x55555555);
    
    Uart_Printf("READ TEST(55555555)\n");	
    ReadIflash(0x55555555);    


    Uart_Printf("ERASE TEST(1=OK,0=FAIL):");
    result=Iflash_EraseSectors(0,511);
    Uart_Printf("%d\n",result);
    
    Uart_Printf("WRITE TEST(aaaaaaaah)\n");	
    WriteIflash(0xaaaaaaaa);
    
    Uart_Printf("READ TEST(aaaaaaaah)\n");	
    ReadIflash(0xaaaaaaaa);    


    Uart_Printf("ERASE TEST(1=OK,0=FAIL):");
    result=Iflash_EraseSectors(0,511);
    Uart_Printf("%d\n",result);
        
    Uart_Printf("WRITE TEST(0,1,2,3..)\n");	
    WriteIflash(0);
    
    Uart_Printf("READ TEST(0,1,2,3..)\n");	
    ReadIflash(0);    
}




void WriteIflash(U32 data)
{
    int i;
    for(i=0x0;i<0x40000;i+=4)
    {
    	if(data==0)
	    Iflash_WrWord(i,i);
	else
	    Iflash_WrWord(i,data);
    }
}




int ReadIflash(U32 data)
{
    U32 i,j;
    for(i=0x0;i<0x40000;i+=4)
    {
	j=*((U32 *)(i+IFLASH_START_ADDR));
    	if(data==0)
    	{
    	    if(j!=i)
    	    {
    	    	Uart_Printf("[ERR@%x,%x]",i,j);
  	  	return 0;
  	    }
    	}    
    	else
    	{
    	    if(j!=data)
    	    {
    	    	Uart_Printf("[ERR@%x,%x]",i,j);
    	    	return 0;
    	    }
    	}
    }
    return 1;
}


⌨️ 快捷键说明

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