www.pudn.com > ADS_s3c2440a.rar > am29f800.c
#include#include "def.h" #include "option.h" #include "2440addr.h" #include "2440lib.h" #include "2440slib.h" #include "Am29f800.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; Uart_Printf("[Check AM29LVxxx]\n"); switch(AM29F800_CheckId()) //04.01.12 junon { case 1 : Uart_Printf("This device is AM29LV200B!\n"); break; case 2 : Uart_Printf("This device is AM29LV400B!\n"); break; case 3 : Uart_Printf("This device is AM29LV800B!\n"); break; case 4 : Uart_Printf("This device is AM29LV160BT!\n"); break; default: Uart_Printf("ID Check Error!!!\n"); return; } Uart_Printf("\nErase the sector:0x%x.\n",targetAddress); for (i=0;i<0x4;i++) { AM29F800_EraseSector(0x10000*i+0x0000); } Uart_Printf("erase over!!!\n"); for (i=0;i<0x4;i++) { if(!BlankCheck(0x10000*i+0x0000,0x10000)) { Uart_Printf("Blank %x Check Error!!!\n",i); return; } } Uart_Printf("\nStart of the data writing.\n"); //for(i=0x0;i