romnandflash.h

来自「NandFlash 读写程序」· C头文件 代码 · 共 36 行

H
36
字号

#ifndef __ROMNANDFLASH_H__
#define __ROMNANDFLASH_H__

#define NFlashPageSize	2048
#define MAX_PAGE		64
#define NFlashBlockSize NFlashPageSize*MAX_PAGE
#define MAX_BLOCK		2048

#define P_NAND_BASE									0x80013000

#define P_NAND_CFG				(*((volatile UINT16 *) (P_NAND_BASE + 0x00) ))
#define P_NAND_ADD				(*((volatile UINT8 *) (P_NAND_BASE + 0x04) ))
#define P_NAND_DATA				(*((volatile UINT8 *) (P_NAND_BASE + 0x08) ))
#define P_NAND_CMD				(*((volatile UINT8 *) (P_NAND_BASE + 0x10) ))
                                                                      
//Idle[0] = 1, idle state
#define P_NAND_STATUS			(*((volatile UINT8 *) (P_NAND_BASE + 0x14) ))
//ECC data, 256 bytes ECC get 22 bits(3 BYTES)
#define P_NAND_ECC				(*((volatile UINT32 *) (P_NAND_BASE + 0x18) ))

#define NAND_FLAG		31
#define	NandCsEn		1
#define NandDataWidth	0
#define NandWaitTime	7
#define NandEccRst		1
#define NandEccEn		1
#define	NANDFLASH_CFG	(NandEccEn<<9)|(NandEccRst<<8)|(NandWaitTime<<3)|(NandDataWidth<<2)|(NandCsEn<<1)

void RomOpenNFlash(void);
void RomCloseNFlash(void);
BOOL NFlsh_EraseBlock(UINT16 mBlockAddr);
UINT8 NFlash_ReadByte(UINT32 *mNandAddr);
BOOL NFlsh_WritePage(UINT16 mBlockID, UINT16 mPageID, UINT8 *pBuffer);
BOOL NFlsh_ReadPage(UINT16 mBlockID, UINT16 mPageID, UINT8 *pBuffer);
#endif // __ROMNANDFLASH_H__

⌨️ 快捷键说明

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