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

📄 flash.c

📁 LwIP adaptation for Fujitsu MB90f497 and CS8900A Ethernet driver
💻 C
字号:
//#include "aquaco.h"
#include "mb90495.h"
#include "Flash.h"

#include "lwip/lcd.h"
#pragma section FAR_CODE=RAMCODE	/* located the program into RAM */
#pragma section CODE=RAMCODE
 void start(void);

 void (*reset) (void) = ( void (*)(void)) &start;


void Store_flash(volatile __far uint *Flash_adr, volatile uint *Ram_adr, int counter) {
 unsigned int z;
__DI();
  //  (*reset)();
	Flash_sector_erase(SA3);
    while(counter--!=0) {
		Flash_write(Flash_adr, *Ram_adr);
	    ++Flash_adr;
	    ++Ram_adr;
   }
 Put_String("\nFlash stored");	
   for(z=0;z<50000;z++);
 //  (*reset)();
//	while(1);
	__EI();
}

uchar Flash_write(volatile __far uint *start1_adr,volatile uint wdata)
{
	uchar flag = 0;

	/* start write sequence */
//    __DI();
	FMCS_WE = TRUE;
	
	*seq_AAAA = 0x00AA;	/* sends the command to the pointed address */
	*seq_5554 = 0x0055;
	*seq_AAAA = 0x00A0;
	*start1_adr = wdata;		/* send data to the pointed address */


	while(flag == 0)
	{
		if((*start1_adr & DQ7) == (wdata & DQ7))
		{
			flag = 1;
		}

		if((*start1_adr & DQ5) == 1) flag=2;

	}
	FMCS_WE = FALSE;			/* reset write enable flag */
//    __EI();
	return(flag);
}

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* Reads the contents of the Flash / no values 									*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
uint Flash_read(volatile __far uint *start2_adr)
{
	uint data1;
	
	/* start read sequence */
	*seq_AAAA = 0x00AA;			/* sends the command to the pointed address */
	*seq_5554 = 0x0055;
	*seq_AAAA = 0x00F0;
	data1 = *start2_adr;
	
	return(data1);
}
//int size;

uchar Flash_sector_erase( volatile __far uint *sector_adr)
{
	uchar flag = 0;

 //__DI();
	/* start with chip erase sequence */
	FMCS_WE = TRUE;
	*seq_AAAA = 0x00AA;	/* sends the command to the pointed address */
	*seq_5554 = 0x0055;
	*seq_AAAA = 0x0080;
	*seq_AAAA = 0x00AA;
	*seq_5554 = 0x0055;
	*sector_adr = 0x0030;

	while(flag == 0)
	{
        
		if((*sector_adr & DQ7) == DQ7)	/* Toggle bit */
		{
			flag = 1;		/* successful erased */
		}
		if((*sector_adr & DQ5) == DQ5) flag=2;	/* time out */

	}
	FMCS_WE = FALSE;
// __EI();
	return(flag);
}

⌨️ 快捷键说明

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