📄 nand.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifndef __NAND_H__
#define __NAND_H__
#define NAND_BLOCK_CNT (1024 * 4) /* Each Plane has 1024 Blocks */
#define NAND_PAGE_CNT (32) /* Each Block has 32 Pages */
#define NAND_PAGE_SIZE (512) /* Each Page has 512 Bytes */
#define NAND_BLOCK_SIZE (NAND_PAGE_CNT * NAND_PAGE_SIZE)
#define CMD_READID 0x90 // ReadID
#define CMD_READ 0x00 // Read
#define CMD_READ2 0x50 // Read2
#define CMD_RESET 0xff // Reset
#define CMD_ERASE 0x60 // Erase phase 1
#define CMD_ERASE2 0xd0 // Erase phase 2
#define CMD_WRITE 0x80 // Write phase 1
#define CMD_WRITE2 0x10 // Write phase 2
#define CMD_STATUS 0x70 // STATUS
// Status bit pattern
#define STATUS_READY 0x40 // Ready
#define STATUS_ERROR 0x01 // Error
/* !!! Maximum Delay Setting, Please Adjust these value to Optimize */
#define TACLS 0
#define TWRPH0 5
#define TWRPH1 3
#define NF_CMD(cmd) {s2440NAND->NFCMD = (unsigned char)(cmd);}
#define NF_ADDR(addr) {s2440NAND->NFADDR = (unsigned char)(addr);}
#define NF_nFCE_L() {s2440NAND->NFCONT &= ~(1 << 1);}
#define NF_nFCE_H() {s2440NAND->NFCONT |= (1 << 1);}
#define NF_RSTECC() {s2440NAND->NFCONT |= (1 << 4);}
#define NF_MECC_UnLock() {s2440NAND->NFCONT &= ~(1<<5);}
#define NF_MECC_Lock() {s2440NAND->NFCONT |= (1<<5);}
#define NF_SECC_UnLock() {s2440NAND->NFCONT &= ~(1<<6);}
#define NF_SECC_Lock() {s2440NAND->NFCONT |= (1<<6);}
#define NF_CLEAR_RB() {s2440NAND->NFSTAT |= (1 << 2);}
#define NF_DETECT_RB() {while(!(s2440NAND->NFSTAT&(1<<2)));}
#define NF_WAITRB() {while (!(s2440NAND->NFSTAT & (1 << 0)));}
#define NF_RDDATA() (s2440NAND->NFDATA)
#define NF_WRDATA(data) {s2440NAND->NFDATA = (data);}
#define NF_RDMECC0() (s2440NAND->NFMECC0)
#define NF_RDMECC1() (s2440NAND->NFMECC1)
#define NF_RDSECC() (s2440NAND->NFSECC)
#define NF_RDMECCD0() (s2440NAND->NFMECCD0)
#define NF_RDMECCD1() (s2440NAND->NFMECCD1)
#define NF_RDSECCD() (s2440NAND->NFSECCD)
#define NF_WRMECCD0(data) {s2440NAND->NFMECCD0 = (data);}
#define NF_WRMECCD1(data) {s2440NAND->NFMECCD1 = (data);}
#define NF_WRSECCD(data) {s2440NAND->NFSECCD = (data);}
#define NF_RDESTST0 (s2440NAND->NFESTAT0)
#define NF_RDESTST1 (s2440NAND->NFESTAT1)
#endif // __NAND_H_.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -