www.pudn.com > OS.rar > NAND3.c, change:2006-12-11,size:1264b


 
#include 	"typedef.h" 
#include	".\component\GPL162002_Far\include\FileSystem\Nand.h" 
#include	".\component\GPL162002_Far\include\FileSystem\Nand_Oper.h" 
 
extern INT16 bNandInit; 
 
 
INT16 NAND_Initial_3(void) 
{ 
	 
	 return bNandInit; 
} 
 
INT16 NAND_Uninitial_3(void) 
{ 
	 return 0; 
} 
 
UDWORD NAND_GetMemSize_3() 
{ 
	if(gFS_USBReadWriteFlag && (Nand_Part2_Size >= UNSP_FS_RESERVED)) 
	{ 
		return (Nand_Part2_Size - UNSP_FS_RESERVED); 
	}	 
	 
	return Nand_Part2_Size; 
} 
 
INT16 NAND_ReadSector_3(UDWORD blkno , UWORD blkcnt ,  UINT32 buf) 
{ 
	 return _NAND_ReadSector(blkno+Nand_Part2_Offset , blkcnt , buf); 
} 
 
INT16 NAND_WriteSector_3(UDWORD blkno , UWORD blkcnt ,  UINT32 buf) 
{ 
	int i,ret; 
 
	 if((Nand_Part2_Mode&DEVICE_WRITE_ALLOW)==0) 
	 { 
		 return -1; 
	 } 
 
	if(!gFS_USBReadWriteFlag)  
	{ 
		return _NAND_WriteSector(blkno+Nand_Part2_Offset , blkcnt , buf);		 
	} 
 
	 for(ret=0x00, i=0x00; i<blkcnt; i++, blkno++, buf += 0x100) 
	 {	  
		#ifdef _PC_UNABLE_FORMAT_UDISK 
		 if(gFS_USBReadWriteFlag &&(blkno == BPB_START_SECTOR)) 
		 { 
			 continue;		 
		 }		 
		#endif		  
		 ret = _NAND_WriteSector(blkno+Nand_Part2_Offset,1,buf);	// 每次只写一个扇区		  
		 if(ret) { break; }		// 失败,直接返回 
	 } 
 
	 return ret; 
}