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

📄 nfshemu.h

📁 PDA上的CF CARD 文件系统的建立程式
💻 H
字号:
/*
*******************************************************************************
*                          		Himark Tech. Inc.	                          *
*                  Copyright (c) 2003, All Rights Reserved                    *
*                                                                             *
* nflash module.                                                    	      *
*                                                                             *
* File : nflash.h                                                             *
* By : thhuang                                                                *
*                                                                             *
* History : 2001/11/01 File created.                                          *
*			Header file of nand flash driver								  *
*                                                                             *
*******************************************************************************
*/
#ifndef __NAND_FLASH_H__
#define __NAND_FLASH_H__

typedef struct
{
	unsigned short device_ID ;
	unsigned char  prg_addr  ;	// 0=3 cycle   1=4 cycle
	unsigned short block_size ;
	unsigned long  total_size ;
	unsigned char  device_name[12] ;
}flash_chip ;

/*
#define	__DELAY()\
	__asm("nop");\
	__asm("nop");\
	__asm("nop");\
	__asm("nop");\
	__asm("nop")

*/               
#define	__DELAY()

#ifndef MACHINE_TYPE_MIPS_ARTI
 #define MACHINE_TYPE_MIPS_ARTI
#endif


#define NFLASH_BASE_ADDR	(0xb0000000)

//Jason
//**********************************
//#define NFLASH_FRAME_SIZE	256
//#define NAND_FLASH_BLOCK_SIZE	16384
//**********************************

#define NFLASH_FRAME_SIZE	512
//#define NFLASH_FRAMES_OF_BLOCK	16
#define NFLASH_FRAMES_OF_BLOCK	32	/* over 8 Mbytes */
//#define NAND_FLASH_BLOCK_SIZE	(512*NFLASH_FRAMES_OF_BLOCK)

#define MAX_PHYSICAL_BLOCKS	8192	/* Reserved for 128M */
#define MAX_LOGICAL_BLOCKS	8000


#define NFLASH_DATA_READ	(*(unsigned char*)( NFLASH_BASE_ADDR + 1))
#define NFLASH_DATA_WRITE	(*(unsigned char*)( NFLASH_BASE_ADDR + 1))
#define NFLASH_CLE   		(*(unsigned char*)( NFLASH_BASE_ADDR + 1))
#define NFLASH_ALE   		(*(unsigned char*)( NFLASH_BASE_ADDR + 1))


#if defined(PR2001B)||defined(CHIPMOS)||defined(BR2001D)
#define NFLASH_DEVICE		0xbfbf0010
#define _READYpoint		0xbfbf00a0
#define _CEpoint()		0xbfbf00a3

#define NFLASH_ENB_CE		*(unsigned int *)(0xbfbf00a0)  &= 0x0fffffffe
#define NFLASH_DIS_CE		*(unsigned int	*)(0xbfbf00a0) |= 0x01010101
#define NFLASH_CLE_HIGH		*(unsigned char *)(_CEpoint()) |= 0x04
#define NFLASH_CLE_LOW		*(unsigned char *)(_CEpoint()) &= 0xfb
#define NFLASH_ALE_HIGH		*(unsigned char *)(_CEpoint()) |= 0x02
#define NFLASH_ALE_LOW		*(unsigned char *)(_CEpoint()) &= 0xfd

/* Arti do not have write protect control pin */
#define _WaitREADY()		while( ! ((*(unsigned int *)_READYpoint())&0x08) )
#else
#define NFLASH_DEVICE	0xbfbf0010
#define _READYpoint		0xbfbf00b4
#define _CEpoint()		0xbfbf00b3
#define NFLASH_ENB_CE		*(unsigned char *)(_CEpoint()) &= 0xf7
#define NFLASH_DIS_CE		*(unsigned char	*)(_CEpoint()) |= 0x08
#define NFLASH_CLE_HIGH		*(unsigned char *)(_CEpoint()) |= 0x10
#define NFLASH_CLE_LOW		*(unsigned char *)(_CEpoint()) &= 0xef
#define NFLASH_ALE_HIGH		*(unsigned char *)(_CEpoint()) |= 0x20
#define NFLASH_ALE_LOW		*(unsigned char *)(_CEpoint()) &= 0xdf

/* Arti do not have write protect control pin */
#define _WaitREADY()		while( ! ((*(unsigned int *)_READYpoint())&0x08) )
#endif


#define NFLASH_READ0		0x00
#define NFLASH_READ1		0x01
#define NFLASH_READ2		0x50//thhuang, 2002/1/8
#define NFLASH_RESET		0xff
#define NFLASH_FRAME_PROGRAM0	0x80
#define NFLASH_FRAME_PROGRAM1	0x10
#define NFLASH_BLOCK_ERASE0	0x60
#define NFLASH_BLOCK_ERASE1	0xD0
#define NFLASH_STATUS_READ	0x70
#define NFLASH_READ_ID		0x90

#define NFLASH_PROGRAM_SUCCESS	0x01
#define NFLASH_READY		0x40
#define NFLASH_NOT_PROTECTED	0x80

#define NFLASH_OK 1  //Sean Fri 06-21-2002
#define NFLASH_FAIL 0  //Sean Fri 06-21-2002

unsigned int nfshInit(void);
int nfshReadFrame(unsigned long offset, unsigned char data[]);
int nfshProgramFrame(unsigned long offset, unsigned char data[]);
int nfshEraseBlock(unsigned long offset);
/* thhuang, 2002/1/8 */
int nfshCheckBadBlock(unsigned long offset);
int nfshReadSpareOfFrame( unsigned long offset ,unsigned char data[] );
int nfshWriteSpareOfFrame( unsigned long offset, unsigned char data[] );
//int nfshSetBadPage(unsigned long offset);
int nfshSeqRead(unsigned long offset, unsigned char *data, unsigned int blockNo);

#endif

⌨️ 快捷键说明

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