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

📄 main.c

📁 对S3C4510挂接的FLASH整片擦除
💻 C
字号:
//******************************************************
//Chinese Academy of Sciences, Institute of Automation
//File Name:	main.c
//Description: 	
//Author:	JuGuang,Li
//Date:		2003-3-20
//******************************************************	
#include "Def.h"
#include "s3c4510b_add.h"

#define AM_START_ADDR          0x0		//0x1100000
#define AM_ADDR_UNLOCK1        0x555
#define AM_ADDR_UNLOCK2        0x2aa
#define AM_DATA_UNLOCK1        0xaaaa
#define AM_DATA_UNLOCK2        0x5555
#define AM_SETUP_WRITE         0xa0a0
#define AM_SETUP_ERASE         0x8080
#define AM_CHIP_ERASE          0x1010
#define AM_SECTOR_ERASE	    0x3030
#define AM_RESET		    0xf0f0

int amOpOverDetect(UINT16 *ptr,  UINT16 trueData, int timeCounter);
int Main()
{
	//volatile UINT16 *flashPtr;
	//flashPtr = (UINT16 *)AM_START_ADDR;
	*((volatile UINT16 *)AM_START_ADDR+ AM_ADDR_UNLOCK1) = AM_DATA_UNLOCK1;       
	*((volatile UINT16 *)AM_START_ADDR+ AM_ADDR_UNLOCK2) = AM_DATA_UNLOCK2;
	*((volatile UINT16 *)AM_START_ADDR+ AM_ADDR_UNLOCK1) = AM_SETUP_ERASE;     
    	*((volatile UINT16 *)AM_START_ADDR+ AM_ADDR_UNLOCK1) = AM_DATA_UNLOCK1;       
	*((volatile UINT16 *)AM_START_ADDR+ AM_ADDR_UNLOCK2) = AM_DATA_UNLOCK2;
  	*((volatile UINT16 *)AM_START_ADDR+ AM_ADDR_UNLOCK1) = AM_CHIP_ERASE;
	return(0);	
}

int amOpOverDetect(UINT16 *ptr,  UINT16 trueData, int timeCounter)
{
	int timeTmp = timeCounter;
	volatile UINT16 *pFlash = ptr;
	UINT16 buf1, buf2,curTrueData;
	
	curTrueData = trueData & 0x8080;                  
	while((*pFlash & 0x8080) != curTrueData)
	{
		if(timeTmp-- <= 0) break;
	}
	
	timeTmp = timeCounter;
	buf1 = *pFlash & 0x4040;						
	while(1)
	{
		    buf2  = *pFlash & 0x4040;
		    if(buf1 == buf2) 
				break;
		    else
			    buf1 = buf2;
		    if(timeTmp-- <= 0) 
		    {
				return 0;
		    }
	}

	return 1;
}

⌨️ 快捷键说明

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