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

📄 flashrom.c

📁 编写程序
💻 C
字号:
#include "flashrom.h"
#include "def.h"

/*** SST39VF160 检查是否为空 ***
 扇区的值若为oxFF则判断为空 ****/
int SST39VF160_CheckBlank(U32 addr,U32 WordSize) 
{
	U32 i,temp;
	for (i=addr;i<(addr+WordSize);i++)
	{
		temp=*((volatile U16 *)(i<<1));
		if(temp!=0xffff)
			return 0;
	}
	return 1;	
}

/****** SST39VF160 的检测 ******
 Check if the bit6 toggle ends */
int Waitfor_endofprg(void)
{
	volatile U16 flashStatus,old;
	old=*((volatile U16 *)0x0);

	while(1)
	{
		flashStatus=*((volatile U16 *)0x0);
		if( (old&0x40) == (flashStatus&0x40) )
			break;
		else
		old=flashStatus;
	}
	return 1;
}

/*** SST39VF160 的写入操作,是一个word(16bit)写入的 ***/
int SST39VF160_WordProg (U32 addr,U16 dat)
{
	Writeflash (0x5555,0xAA);
	Writeflash (0x2AAA,0x55);
	Writeflash (0x5555,0xA0);
	Writeflash (addr,dat);
	return(Waitfor_endofprg());
	
}

/*** SST39VF160 扇区擦除 ***/
void  SST39VF160_SectorErase(U32 SAaddr)
{
	Writeflash(0x5555,0xAA);
	Writeflash(0x2AAA,0x55);
	Writeflash(0x5555,0x80);
	Writeflash(0x5555,0xAA);
	Writeflash(0x2AAA,0x55);
	Writeflash(SAaddr,0x30);
    Waitfor_endofprg();
}


⌨️ 快捷键说明

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