#define NAND_PAGE_SIZE 512
#define NAND_PAGE_PER_BLOCK 32
#define NAND_BLOCK_COUNT 4096
#define NAND_READ0 0x00
#define NAND_READ1 0x01
#define NAND_READ2 0x50
#define NAND_READ_ID 0x90
#define NAND_RST 0xFF
#define NAND_PAGE_PROG_C1 0x80
#define NAND_PAGE_PROG_C2 0x10
#define NAND_PAGE_COPYBACK 0x8A
#define NAND_BLOCKERASE_C1 0x60
#define NAND_BLOCKERASE_C2 0xD0
#define NAND_READSTATUS 0x70
#define NAND_WAITREADY {while(RB == 0);}
#define DataPort P1
sbit WE = P2^0;
sbit ALE = P2^1;
sbit CLE = P2^2;
sbit CE = P2^3;
sbit RE = P2^4;
sbit RB = P2^5;
///////flash 写命令函数/////////
void FlashWriteCmd(unsigned char cmd)
{
CLE = 1;
ALE = 0;
RE = 1;
WE = 0;
DataPort = cmd;
WE = 1;
}
///////flash 写地址函数/////////
void FlashWriteAddr(unsigned char addr)
{
CLE = 0;
ALE = 1;
RE = 1;
WE = 0;