#define NFDATA_READ *(volatile unsigned char*)0x70200010
字节读写
#define NFDATA_READ *(volatile unsigned int*)0x70200010
字读写
读ID代码:
int nand_read_id(void){ int id; NAND_CHIP_ENABLE(); set_val(NFCMMD, 0x90); set_val(NFADDR, 0x00); NAND_READY(); printf("id0 = %02x", NFDATA_READ); printf(" id1 = %02x\n", NFDATA_READ); NAND_CHIP_DISABLE();}
擦块代码:
void nand_block_erase(u32 addr){ int i; NAND_CHIP_ENABLE(); set_val(NFCMMD, CMD_NAND_BLOCK_ERASE_STAGE1); //命令0x60 //发送地址 send_row_addr(addr); set_val(NFCMMD, CMD_NAND_BLOCK_ERASE_STAGE2); //命令0xD0 //等待数据擦除 NAND_READY(); set_val(NFCMMD, CMD_NAND_READ_STATUS); //命令0x70 if (NFDATA_READ & 0x1) printf("Nand Block Erase Faile.\n"); NAND_CHIP_DISABLE();}