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

📄 nand_dev.c

📁 君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图片解码,浏览,电子书,录音,想学ucos,识货的人就下吧 russblock fmradio explore set
💻 C
字号:
/********************** BEGIN LICENSE BLOCK ************************************ * * JZ4740  mobile_tv  Project  V1.0.0 * INGENIC CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM * Copyright (c) Ingenic Semiconductor Co. Ltd 2005. All rights reserved. *  * This file, and the files included with this file, is distributed and made  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.  *  * http://www.ingenic.cn  * ********************** END LICENSE BLOCK ************************************** * *  Author:  <dsqiu@ingenic.cn>  <jgao@ingenic.cn>  * *  Create:   2008-06-26, by dsqiu *             *  Maintain: 2008-06-26, by jgao *             * ******************************************************************************* */#if NAND_UDC_DISK#if (NAND==0)    #error "makefile no add nand flag!"#endif#include "header.h"#include <mass_storage.h>#include <fs_api.h>#include "function.h"static UDC_LUN udcLun;extern int NAND_LB_Read(unsigned int Sector, void *pBuffer);extern int NAND_LB_Write(unsigned int Sector, void *pBuffer);static int InitStall = 0;static int FlushDataState = 0;static unsigned int init_dev(unsigned int handle){	if(InitStall == 0)	{				printf("nand Disk unMount\r\n");		FS_IoCtl("nfl:",FS_CMD_UNMOUNT,0,0);		NAND_LB_Init();		InitStall = 1;		FlushDataState = 0;	}		}static unsigned int read_dev_sector(unsigned int handle,unsigned char *buf,unsigned int startsect,unsigned int sectcount){	if(sectcount <= 8)	{			unsigned int i;		for(i = 0;i < sectcount; i++)	{		NAND_LB_Read(startsect + i,(void *)(buf));		buf += 512;		//printf("read dev = ia:%x, s:%d c:%d\r\n",buf,startsect + i,sectcount);			}	//	NAND_LB_Read(startsect,(void *)((unsigned int)buf));	}else	{		NAND_LB_MultiRead(startsect,(void *)((unsigned int)buf),sectcount);	}			return 1;	}static unsigned int write_dev_sector(unsigned int handle,unsigned char *buf,unsigned int startsect,unsigned int sectcount){	if(sectcount <= 8)	{		    unsigned int i;	//printf("write dev = ia:%x, s:%d c:%d\r\n",buf,startsect,sectcount);	for(i = 0;i<sectcount;i++)			{		NAND_LB_Write(startsect + i,(void *)(buf));		buf += 512;		FlushDataState = 1;			}	}else	{		NAND_LB_MultiWrite(startsect,(void *)((unsigned int)buf),sectcount);	}				}static unsigned int check_dev_state(unsigned int handle){	return 1;}static unsigned int flush_dev(unsigned int handle){	if( FlushDataState >= 1)		FlushDataState++;	if(FlushDataState > 10)	{			NAND_LB_FLASHCACHE();		//printf("flush data!\n");		FlushDataState = 0;	}		}static unsigned int get_dev_info(unsigned int handle,PDEVINFO pinfo){	//printf("pagesize = %d\n pinfo->partsize = %d,blocks = %d\n",pagesize,pagesize / 512 * pageperblock *blocks,blocks);	flash_info_t flashinfo;  ssfdc_nftl_getInfo(0,&flashinfo);	pinfo->hiddennum = 0;	pinfo->headnum = 0;	pinfo->sectnum = 4;	pinfo->partsize =  flashinfo.dwFSTotalSectors;		pinfo->sectorsize = flashinfo.dwDataBytesPerSector;}static unsigned int deinit_dev(unsigned handle){		if(InitStall == 1)	{		printf("udc mount nand fs!\n");				NAND_LB_Deinit();		FS_IoCtl("nfl:",FS_CMD_MOUNT,0,0);		InitStall = 0;	}		}void init_udc_nand(){//	printf("InitUdcRam\r\n");		Init_Mass_Storage();	udcLun.InitDev = init_dev;	udcLun.ReadDevSector = read_dev_sector;	udcLun.WriteDevSector = write_dev_sector;	udcLun.CheckDevState = check_dev_state;	udcLun.GetDevInfo = get_dev_info;	udcLun.FlushDev = flush_dev;	udcLun.DeinitDev = deinit_dev;	//udcLun.DevName = (unsigned int)'NAND';	udcLun.DevName = ('N' << 24) | ('A' << 16) | ('N' << 8) | 'D';	if(RegisterDev(&udcLun))		printf("UDC Register Fail!!!\r\n");	//printf("InitUdcRam finish = %08x\r\n",&udcLun);	}#endif

⌨️ 快捷键说明

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