www.pudn.com > u241test.rar > am29f800.c, change:2002-05-21,size:6337b


#include  
#include "def.h" 
#include "option.h" 
#include "2410addr.h" 
#include "2410lib.h" 
#include "2410slib.h"  
//#include "strata.h" 
 
//Revision History 
// 2001.8.25:purnnamu:If the data is downloaded by ICE, the writing isn't done correct. 
  
int AM29F800_ProgFlash(U32 realAddr,U16 data); 
void AM29F800_EraseSector(int targetAddr); 
int AM29F800_CheckId(void); 
int BlankCheck(int targetAddr,int targetSize); 
int _WAIT(void); 
 
static void InputTargetAddr(void); 
 
// Because KS32C41000_A1 is connected to AM29LV800_A0, 
// the addr parameter has to be a WORD address, so called in AMD specification. 
 
#define _WR(addr,data)	*((U16 *)(addr<<1))=(U16)data 
#define _RD(addr)	( *((U16 *)(addr<<1)) ) 
#define _RESET()	_WR(0x0,0xf0f0) 
#define BADDR2WADDR(addr)   (addr>>1) 
extern U32 downloadAddress; 
extern U32 downloadProgramSize; 
static U32 srcAddress; 
static U32 srcOffset; 
static U32 targetAddress; 
static U32 targetSize; 
 
 
void ProgramAM29F800(void) 
{ 
    int i; 
 
    InputTargetAddr(); 
     
    if(downloadProgramSize==0) 
    { 
        Uart_Printf("The data must be downloaded using ICE from %x\n",downloadAddress); 
    	srcAddress=downloadAddress; 
    } 
    else 
    	srcAddress=downloadAddress+4; //to discard the data head for the size 
    	 
 
    Uart_Printf("[Check AM29LV800]\n"); 
    if(!AM29F800_CheckId()) 
    { 
	Uart_Printf("ID Check Error!!!\n"); 
	return; 
    } 
     
    Uart_Printf("\nErase the sector:0x%x.\n",targetAddress); 
     
    AM29F800_EraseSector(targetAddress); 
    if(!BlankCheck(targetAddress,targetSize)) 
    { 
	Uart_Printf("Blank Check Error!!!\n"); 
	return; 
    } 
 
    Uart_Printf("\nStart of the data writing.\n"); 
 
    for(i=0x0;i