www.pudn.com > NAND.rar > NAND_DRV.h


 
#ifndef __NAND512__H__ 
#define __NAND512__H__ 
#include "hdcfg.h" 
 
#define NUM_BLOCKS				 4096 
#define NUM_PAGE_BLOCK  			 32 
 
 
#if (NFLASH_TYPE == TYPE_IS_K9F1208X0B)  
#define ID_IS_K9F1208R0B	  		0x36 
#define ID_IS_K9F1208B0B	  		0x76 
#define ID_IS_K9F1208U0B	  		0x76 
#define MULTI_PLANE_CODE	 		0xc0 
#endif    // #if (NFLASH_TYPE == TYPE_IS_K9F1208X0B)  
 
#define TOGGLE_BIT					0x40 
#define TOTAL_PASS_BIT				0x01 
#define MULTI_PASS_BIT				0x01f 
#define WRITE_PROTECT_BIT   			  0x80 
#define PAGES_OF_BLOCK    			0x20	/*pages in one physical block  */ 
#define FLASH_SIZE_64MB 			0x04000000   //64M bytes +2048k 
#define MAX_BLOCK 					4096  
#define MAX_PAGE 					(4096*32)  
#define PAGE_SPARE_SIZE			16 
#define FLASH_WIDTH 		  8 			 /* Flash data width */ 
#define PAGE_SIZE   		  528   		 /* Page size in byte */  
#define PAGE_DATA_SIZE     	 512			/* Page data size in byte */ 
#define PAGE_SPARE_SIZE 	  16			 /* Spare page size in byte */ 
#define HALF_PAGE_POINTER     (UINT8) 0x01   /* Half page Pointer */ 
#define SHIFT_A8				 1 
 
 
/**************************************************************************** 
			Utility 
****************************************************************************/   						 
#define ADDRESS_2_BLOCK(Address)		(Address >> (13+HALF_PAGE_POINTER))  
#define BLOCK_SIZE 					  (PAGE_DATA_SIZE*NUM_PAGE_BLOCK) 
#define BLOCK_2_ADDRESS(Num_block)  	((UINT32) (Num_block* BLOCK_SIZE)) 
/**************  Utility ***************/  
 
 
/**************************************************************************** 
			Return Codes 
****************************************************************************/ 
typedef UINT8 NAND_Ret; 
typedef UINT8 dataWidth; 
 
typedef struct tNLFASH_INFO_STRUCT 
{ 
	UINT8 maker_code ; 
	UINT8 device_code ; 
	UINT8 multi_plane_code ; 
}tNLFASH_INFO_STRUCT; 
 
 
 
/*********error code definition  start***********/ 
#define NAND_FAIL 				0 
#define NAND_PASS  				1 
#define NAND_SW_ERR 				2 
#define NAND_FULL_ERR 			3 
#define NAND_DMA_TIMEOUT 		4 
#define NAND_TABLE_ERR 			5 
#define NAND_ECC_PASS  			1 
#define NAND_ECC_ERR     			6 
#define NAND_WRPRT_ERR			7 
#define NAND_VERIFY_ERR   		8 
#define NAND_ID_ERR   				9 
#define NAND_HW_ERR     			10 
#define NAND_PRG_FAIL    			11 
#define NAND_MAP_ERR			12 
#define NAND_LBA_NOEXSIT 			13 
#define NAND_MAP_NOEXSIT 			14 
#define NAND_FULL						15  
#define NAND_PAGE_OVERFLOW			16 
#define NAND_ADDR_OVERFLOW			17 
#define NAND_DMA_INVALID			18 
#define NAND_UNDEFINED_ERR                 19 
/*********error code difinition end ***********/ 
 
/**************  Return Codes ***************/  
 
 
 
/**************************************************************************** 
			Hardware independent function 
****************************************************************************/ 
NAND_Ret NAND_Init(void); 
 
NAND_Ret NAND_BlockErase(UINT32 udAddress); 
#if (NFLASH_TYPE == TYPE_IS_K9F1208X0B)  
NAND_Ret NandChipFastErase(void); 
#endif/*(NFLASH_TYPE == TYPE_IS_K9F1208X0B) */ 
 
NAND_Ret NAND_CopyBack(UINT32 udSourceAddr, UINT32 udDestinationAddr); 
 
NAND_Ret NAND_PageRead(UINT32 udAddress, dataWidth *Buffer, UINT32 udLenght); 
 
NAND_Ret NAND_PageReadWithEcc(UINT32 udAddress, dataWidth *pReadBuf, UINT32 len); 
 
NAND_Ret NAND_PageProgram(UINT32 udAddress, dataWidth *Buffer, UINT32 udLenght); 
 
NAND_Ret NAND_PageProgramWithEcc(UINT32 udAddress, dataWidth *Buffer, UINT32 udLenght); 
 
NAND_Ret NAND_SpareProgram(UINT32 udAddress, dataWidth *Buffer, UINT32 udLenght); 
 
NAND_Ret NAND_SpareRead(UINT32 udAddress, dataWidth *Buffer, UINT32 udLenght); 
 
NAND_Ret NAND_SpareReadRandom(UINT32 udAddress, dataWidth *pOobBuf, UINT32 udLenght); 
 
/**************  Hardware independent function ***************/ 
 
#endif //__NAND512__H__