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

📄 flash.c

📁 这是三星公司的arm7 s3c44b0x芯片的所有外设中断程序
💻 C
字号:
//44BTEST : flash.c
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\am29f800.h"
int DownloadData(void);
U32 downloadAddress;
U32 downloadProgramSize;
void *flashType[][2]=
{
(void *)ProgramAM29F800, "AM29LV800BB ",
0,0
};
void ProgramFlash(void)
{
	int i=0;
	Uart_Printf("\n*** NOR Flash Memory writer ver 0.3 ***\n\n");
	downloadAddress=(unsigned)malloc(0x400000);
	if(downloadAddress==0)
		return;
	rNCACHBE0=( (0x2000000>>12)<<16 )|(0>>12); //flash area must be non-cachable area.
	rSYSCFG=rSYSCFG&(~0x8); //write buffer has to be off for proper timing.
	while(1)
	{ //display menu
		Uart_Printf("%c: %s",'a'+i,flashType[i][1]);
		i++;
		if((int)(flashType[i][0])==0)
		{
			Uart_Printf("\n");
			break;
		}
		if((i%4)==0)
			Uart_Printf("\n");
	}
	Uart_Printf("Select the type of a flash memory? ");
	i=Uart_Getch()-'a';
	Uart_Printf("\n");
	if( i<0 || (i>=(sizeof(flashType)/8)) )
		return;
	if(!DownloadData())
		return;
	( (void (*)(void))(flashType[i][0]) )();
	free((void *)downloadAddress);
	rNCACHBE0=0x0;
}
int DownloadData(void)
{
	int i,tmp;
	U16 checkSum=0,dnCS;
	U32 fileSize=10;
	U8 *downPt;
	downPt=(U8 *)downloadAddress;
	Uart_Printf("downloadAddress=%x\n",downloadAddress);
	Uart_Printf("Download the plain binary file(.BHC) to be written\n");
	Uart_Printf(".BHC file format: <n+6>(4)+(n)+CS(2)\n");
	Uart_Printf("To transmit .BHC file : wkocm2 xxx.BHC /1 /g /d:1\n");
	Uart_Printf("Or, to transmit .BIN file: wkocm2 xxx.BIN /1 /d:1\n");
	Uart_Printf("Download methods: COM:8Bit,NP,1STOP\n");
	Uart_Printf("\nSTATUS:");
	rINTMSK=~BIT_GLOBAL;
	tmp=RdURXH0(); //To remove overrun error state.
	i=0;
	while(i<fileSize)
	{
		while(!(rUTRSTAT0&0x1))
			;
		*(downPt+i)=RdURXH0();
		if(i==3)
		{
			fileSize=*((U8 *)(downloadAddress+0))+
			(*((U8 *)(downloadAddress+1))<<8)+
			(*((U8 *)(downloadAddress+2))<<16)+
			(*((U8 *)(downloadAddress+3))<<24);
		}
		if((i%1000)==0)WrUTXH0('#');
		i++;
	}
	downloadProgramSize=fileSize-6;
	for(i=4;i<(fileSize-2);i++)
	{
		checkSum+=*((U8 *)(i+downloadAddress));
	}
	dnCS=*((U8 *)(downloadAddress+fileSize-2))+
	(*( (U8 *)(downloadAddress+fileSize-1) )<<8);
	if(checkSum!=dnCS)
	{
		Uart_Printf("Checksum Error!!! MEM:%x DN:%x\n",checkSum,dnCS);
		return 0;
	}
	Uart_Printf("\nDownload O.K.\n");
	return 1;
}

⌨️ 快捷键说明

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