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

📄 nand_read.c

📁 英培特ARM教学平台EDUKIT-III
💻 C
字号:
#include "s3c2410.h"#include "machine.h"#define BUSY 1inline void wait_idle(void) {	int i;	while (!(NFSTAT & BUSY)) {		for(i=0; i<10; i++) {			;		}	}}#define NAND_SECTOR_SIZE	512#define NAND_BLOCK_MASK		(NAND_SECTOR_SIZE - 1)/* low level nand read function */int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size){	int i, j;	/*	 * K9F5608UOC asks for 512B per page, and read/write operation must	 * do with page. Therefore, first judge whether start_addr and size	 * are valid.	 */ 	if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) {		return -1;	/* invalid alignment */	}	/* chip Enable */	NFCONF &= ~0x800;	for (i=0; i<10; i++) {		;	}	for (i=start_addr; i < (start_addr + size); i+=NAND_SECTOR_SIZE) {		NFCMD = 0;		/* Write Address */		NFADDR = i & 0xff;		NFADDR = (i >> 9) & 0xff;		NFADDR = (i >> 17) & 0xff;		NFADDR = (i >> 25) & 0xff;		wait_idle(); 		for(j=0; j < NAND_SECTOR_SIZE; j++) {			*buf++ = (NFDATA & 0xff);		}	}	/* chip Disable */	NFCONF |= 0x800;	/* chip disable */	return 0;}

⌨️ 快捷键说明

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