亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? flash39vf.c

?? 用于在SDT環境下實現交叉環境中代碼寫入FLASH的過程
?? C
字號:


#include "flash39vf.h"

UINT32 g_timeOut;

void FlashSectorEraseComm()
{
	
	UINT16 *ptrTemp1,*ptrTemp2;

       /*  Issue the Sector Erase command to 39VF400A  */
	ptrTemp1 = (UINT16 *)(0x01000000+ 2 * 0x00005555); /* set up address to be 0100:5555h  */
	ptrTemp2 = (UINT16 *)(0x01000000+ 2 * 0x00002AAA); /* set up address to be 0100:2AAAh  */  

	*ptrTemp1= 0x0AAAA;
	*ptrTemp2 = 0x05555;                     /* write data 0x5555 to the address */
	*ptrTemp1= 0x08080;                      /* write data 0x8080 to the address */


}


/*************************************************************************/
/*  check whether the operation has finished                             */
/*  input: the address of flash to be checked			 */
/*  output:none			          */
/*************************************************************************/
UINT16 CheckToggleReady(UINT16 *ptrDst)
{   
	UINT16 preData;
	UINT16 currData;

	g_timeOut = 0;
	preData = *ptrDst;
    	preData = preData & 0x4040;
    	
    	while (g_timeOut< 0xffff)
    	{
		currData = *ptrDst;
        	currData = currData & 0x4040;
		g_timeOut ++;
		
        	if (preData == currData)
        		return(1);             // exit the while loop 
   
        	preData = currData;	
    	}
	return(0);
}



/*************************************************************************/
/* erase a sector of flash(2048 WORDS)					 */
/* input:Sector_Address -- the sector address of flash to be erased	 */	
/* output:none								 */
/*************************************************************************/
UINT16 FlashSectorErase (UINT16 *ptrSectorAddress)
{
	UINT16 *ptrTemp1,*ptrTemp2;
	UINT16 ret;
	UINT32 i;

	FlashSectorEraseComm();

       /*  Issue the Sector Erase command to 39VF400A  */
	ptrTemp1 = (UINT16 *)(0x01000000+ 2 * 0x00005555); /* set up address to be 0100:5555h  */
	ptrTemp2 = (UINT16 *)(0x01000000+ 2 * 0x00002AAA); /* set up address to be 0100:2AAAh  */  
	
	
	*ptrTemp1 = 0x0AAAA;                     /* write data 0xAAAA to the address */
	*ptrTemp2 = 0x05555;                     /* write data 0x5555 to the address */

	*ptrSectorAddress = 0x3030;
	
	//for(i = 0;i<100;i++)
	//	g_rdata[i] = * ptrSectorAddress;
	ret = CheckToggleReady(ptrSectorAddress);
	if(g_timeOut < 100)
		for(i = 0; i< 72000;i++);
	return(ret);	

}




/*************************************************************************/
/*  read data from flash			    		         */
/*  input:  Src -- the start address of readdata in flash	         */
/*	    Dst -- address of data be put		                 */
/*	    length -- the length of the data(half_word)	    	         */	
/*  output: 1 -- success						 */
/*          0 -- failure    					         */
/*************************************************************************/
UINT16 FlashRead(UINT16 *ptrSrc, UINT16 *ptrDst,UINT32 readLength)
{
	UINT16 temp1;
	UINT16 temp2;
	UINT16 retry;
	UINT16 i;
	
	UINT16 *ptrTemp1, *ptrTemp2;
	ptrTemp1 = (UINT16 *)(0x01000000+ 2 * 0x00005555); /* set up address to be 0100:5555h  */
	ptrTemp2 = (UINT16 *)(0x01000000+ 2 * 0x00002AAA); /* set up address to be 0100:2AAAh  */

    	*ptrTemp1= 0x0AAAA;                     /* write data 0xAAAA to the address */
    	*ptrTemp2= 0x05555;                     /* write data 0x5555 to the address */
    	*ptrTemp1= 0x0F0F0;                     /* write data 0xF0F0 to the address */

	while(readLength != 0)
	{
		retry = 4;
		again:
			retry --;
			if (retry == 0)
				return(0);

			temp1 = * ptrSrc;
			i = 0;
			temp2 = * ptrSrc;

			if(temp1 == temp2)
			{
				*ptrDst = temp1;
				ptrDst ++; 
				ptrSrc = ptrSrc + 1;
				readLength --;
			}
			else 
				goto again;

	}
	return(1);
}


/************************************************************************************/
/*  check whether the manufactor ID and device ID is right (used when initiazation )*/
/*  input: none						  	                    */
/*  output:1 -- success	                                                            */
/*	   0 -- failure 						            */
/************************************************************************************/
UINT16 CheckFlash39vf()
{
	UINT16 *ptrTemp;
	UINT16 *ptrTemp1, *ptrTemp2;
	UINT16 sstId1;
    	UINT16 sstId2;
    	UINT16 ret;
    	/*  Issue the Software Product ID code to 39VF400A   */

	ptrTemp1 = (UINT16 *)(0x01000000+ 2 * 0x00005555); /* set up address to be 0100:5555h  */
	ptrTemp2 = (UINT16 *)(0x01000000+ 2 * 0x00002AAA); /* set up address to be 0100:2AAAh  */

    	*ptrTemp1= 0x0AAAA;                     /* write data 0xAAAA to the address */
    	*ptrTemp2= 0x05555;                     /* write data 0x5555 to the address */
    	*ptrTemp1= 0x09090;                        /* write data 0x9090 to the address */


    	/* Read the product ID from 39VF400A */
	ptrTemp  = (unsigned short *)0x01000000; /* set up address to be 0100:0000h */
    	sstId1  =  *ptrTemp;              /* get first ID unsigned int               */
	sstId1  =  sstId1 & 0x00FF;     /* mask of higher byte             */

    	ptrTemp = (unsigned short *)0x01000002; /* set up address to be 0100:0001h */
    	sstId2  =  *ptrTemp;             /* get second ID unsigned int              */

    	/* Determine whether there is a SST39VF400A installed or not */
	if ((sstId1 == SST_ID) && (sstId2 ==SST_39VF400A))
        		ret = 1;
    	else
		ret = 0;

	*ptrTemp1 = 0x0AAAA;                        /* write data 0xAAAA to the address  */
    	*ptrTemp2 = 0x05555;                        /* write data 0x5555 to the address  */
	*ptrTemp1 = 0x0F0F0; 	

    	return(ret);
}


/*************************************************************************/
/*  write one half_word to flash			                 */
/*  input: SrcWord -- a half_word to be written			         */
/*	   Dst -- the address of flash        		                 */
/*  output: 1 -- success						 */
/*	    0 -- failure					         */
/*************************************************************************/
UINT16 FlashWriteHalfWord (UINT16 srcWord,  UINT16 *ptrDst)
{
	UINT16 * ptrTemp1, * ptrTemp2;
    	UINT16 rdata,temp;
	UINT16 retry,ret,i;
	retry = 3;

again:
	retry --;
	if (retry == 0)
		return(0);
	
	ptrTemp1 = (UINT16 *)(0x01000000+ 2 * 0x00005555); /* set up address to be 0100:5555h  */
	ptrTemp2 = (UINT16 *)(0x01000000+ 2 * 0x00002AAA); /* set up address to be 0100:2AAAh  */

        *ptrTemp1 = 0x0AAAA;                                       /* write data 0xAAAA to the address */
	*ptrTemp2 = 0x05555;                       		/* write data 0x5555 to the address */
	*ptrTemp1 = 0x0A0A0;                                       /* write data 0xA0A0 to the address    */

    	*ptrDst = srcWord;                       /* transfer the byte to destination */
    	
	ret = CheckToggleReady(ptrDst);             /* wait for TOGGLE bit to get ready */
	if(g_timeOut < 3)
		for(i =0;i<60;i++);
		
	if(ret == 0)
		return(0);
	
	rdata = *ptrDst;
	temp = rdata ^ srcWord;

	if(temp == 0)
		return(1);
	else
		goto again;
}

/*************************************************************************/
/*  write data to flash							 */
/*  input : Dst -- the start address of flash to be written 	         */
/*	    Src -- the address of data to be written	                 */
/*          length --  the length of data to write  (byte)               */
/*  output: 1 -- success					         */
/*          0 -- failure				                 */
/*************************************************************************/
UINT16 FlashWrite( UINT16 *ptrDst,UINT16 *ptrSrc, UINT32 writeLength)
{	
	UINT32 temp;
	UINT16 ret;
	writeLength = (writeLength +1) /2;
    	while( writeLength != 0 )
    	{
	/*if the address is at the begin of a sector, then erase the sector at first*/
		temp = (UINT32)ptrDst & 0x0FFF;
		if(temp == 0)
		{
		ret = FlashSectorErase (ptrDst);
		if(ret == 0)
			return(0);
		}

		ret = FlashWriteHalfWord(*ptrSrc,ptrDst);
		if(ret == 1)
		{   /*add address */
			ptrDst ++;
			ptrSrc ++;
			writeLength --;
		}
		else 
			return(0);
		 
    	}
	return(1);
}	

/*************************************************************************/
/*  check whether the flash written data is right							 */
/*  input : Dst -- the start address of flash to be written 	         */
/*	    Src -- the address of data to be written	                 */
/*          length --  the length of data to write  (byte)               */
/*  output: 1 -- success					         */
/*          0 -- failure				                 */
/*************************************************************************/
UINT16 CheckImage(UINT16 *ptrFlash,UINT16 *ptrRam, UINT32 writeLength)
{
	UINT16 ram_chsum,flash_chsum;
	
	UINT16 temp1,temp2;
	UINT16 retry, i,j;
	UINT16 *ptrTemp1, *ptrTemp2;
	
	writeLength = (writeLength +1) /2;
	ram_chsum = 0x0;
	flash_chsum = 0x0;
    	for(j=0;j<writeLength;j++)
    	{
		ram_chsum = ram_chsum + * ptrRam;
		ptrRam ++;
	}
	
	ptrTemp1 = (UINT16 *)(0x01000000+ 2 * 0x00005555); /* set up address to be 0100:5555h  */
	ptrTemp2 = (UINT16 *)(0x01000000+ 2 * 0x00002AAA); /* set up address to be 0100:2AAAh  */

    	*ptrTemp1= 0x0AAAA;                     /* write data 0xAAAA to the address */
    	*ptrTemp2= 0x05555;                     /* write data 0x5555 to the address */
    	*ptrTemp1= 0x0F0F0;                     /* write data 0xF0F0 to the address */

	for(j=0;j<writeLength;j++)
	{
		retry = 4;
		again:
			retry --;
			if (retry == 0)
				return(0);

			temp1 = * ptrFlash;
			i = 0;
			temp2 = * ptrFlash;

			if(temp1 == temp2)
			{
				flash_chsum = temp1 + flash_chsum;
				ptrFlash = ptrFlash + 1;
			}
			else 
				goto again;

	}
	if(flash_chsum == ram_chsum)
		return(1);
	else
		return(0);
}


int FlashTest()
{
	UINT16 ret;
	UINT16 Src[3072];
	//UINT16 Dst[512];
	UINT16 i;
	UINT16 * temp;

	for(i = 0;i<3072;i++)
		Src[i] = i;

	ret = CheckFlash39vf();
	if(ret == 0)
		return(0);
		
	/*temp = (UINT16 *) 0x107a000;
	ret = FlashSectorErase (temp);
	if(ret == 0)
		return(0);*/

	temp = (UINT16 *)0x107c000;
	ret = FlashWrite(temp,Src,1024);
	if(ret == 0)
		return(0);
		
	temp = (UINT16 *)0x107c400;
	ret = FlashWrite(temp,Src,1024);
	if(ret == 0)
		return(0);
		
	temp = (UINT16 *)0x107c800;
	ret = FlashWrite(temp,Src,1024);
	if(ret == 0)
		return(0);
		
	return(1);
}


int WriteImage()
{
	UINT16 *Dst,*Src;
	UINT32 length;
	int ret;

	ret = CheckFlash39vf();
	if(ret == 0)
		return(0);
		
	Dst = (UINT16 *)0x1000000;
	Src = (UINT16 *)0x20000;
	/*length < 500000,以字節為單位*/
	length = 1000;
	
	//Dst = (UINT16 *)0x107a000;
	//Src = (UINT16 *)0x0;

	ret = FlashWrite(Dst,Src,length);
	if(ret == 0)
		return(0);
	ret = CheckImage(Dst,Src, length);
	if(ret == 0)
		return(0);
	return(1);

}


int Main()
{
	int ret;
	UINT32 * raddr;
	UINT32 i;
	raddr = (UINT32 *)0x3ff5000;
	*raddr = *raddr | 0xff;
	raddr = (UINT32 *)0x3ff5008;	
	
	ret = WriteImage();
	
	if(ret == 0)
	{
		*raddr = *raddr & 0xff0f; 
		return(0);
	}
		
	while(1)
	{
		*raddr = * raddr | 0x10;    
		for(i = 0;i<100000;i++);
		*raddr = * raddr & 0xffef;
		for(i = 0;i<100000;i++);	
	}
	
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情一区二区三区蜜桃视频| 国产成人av一区| 亚洲乱码中文字幕综合| 成人免费视频在线观看| 国产精品区一区二区三区| 欧美国产精品久久| 国产精品网曝门| 亚洲人成网站色在线观看| 亚洲免费毛片网站| 亚洲主播在线观看| 首页综合国产亚洲丝袜| 麻豆成人久久精品二区三区红| 久久99这里只有精品| 久久99精品国产| 国产高清一区日本| www.亚洲色图.com| 一本色道a无线码一区v| 欧美午夜精品久久久久久超碰 | 中国色在线观看另类| 欧美经典一区二区| 亚洲欧美一区二区三区极速播放| 亚洲天堂免费看| 午夜婷婷国产麻豆精品| 蜜桃视频一区二区| 国产91清纯白嫩初高中在线观看| 99久久婷婷国产综合精品电影| 91国产免费观看| 日韩欧美另类在线| 国产精品无圣光一区二区| 一区二区三区91| 久久99精品久久久久久 | 精品蜜桃在线看| 国产精品色哟哟网站| 亚洲自拍偷拍麻豆| 极品少妇一区二区三区精品视频| 国产mv日韩mv欧美| 色婷婷av久久久久久久| 欧美一级久久久久久久大片| 久久久久国产一区二区三区四区| 亚洲视频在线一区观看| 丝袜亚洲精品中文字幕一区| 国产成人精品一区二区三区网站观看| 91在线码无精品| 日韩丝袜美女视频| 成人欧美一区二区三区| 蜜臀国产一区二区三区在线播放| 成人免费高清视频在线观看| 在线不卡一区二区| 中文文精品字幕一区二区| 亚洲国产sm捆绑调教视频| 欧美日韩一区二区三区高清| 欧美一区二区黄色| 欧美日韩免费在线视频| 久久综合色婷婷| 亚洲激情图片一区| 久久成人综合网| 欧美专区日韩专区| 中文字幕欧美区| 蜜臀精品一区二区三区在线观看| 99精品一区二区三区| 精品美女一区二区| 亚洲福利视频导航| 成人激情黄色小说| 精品欧美黑人一区二区三区| 亚洲精品成a人| 国产91露脸合集magnet| 91超碰这里只有精品国产| 最新国产成人在线观看| 国产在线精品免费av| 在线不卡a资源高清| 亚洲精品水蜜桃| 成人精品免费网站| 欧美xxxxx牲另类人与| 亚洲线精品一区二区三区八戒| 国产成人久久精品77777最新版本| 91精品啪在线观看国产60岁| 亚洲视频精选在线| 成人午夜激情片| 精品国产成人在线影院 | 蜜臀av亚洲一区中文字幕| 欧美在线观看视频一区二区 | 另类中文字幕网| 欧美日本不卡视频| 亚洲精品欧美综合四区| 91丨九色丨蝌蚪富婆spa| 国产午夜亚洲精品理论片色戒| 激情综合网天天干| 欧美刺激午夜性久久久久久久| 三级久久三级久久久| 欧美性色黄大片| 洋洋成人永久网站入口| 91麻豆.com| 亚洲免费资源在线播放| 99精品1区2区| 自拍偷在线精品自拍偷无码专区| 成人永久免费视频| 国产亚洲综合在线| 国产mv日韩mv欧美| 国产精品欧美一级免费| 成人黄色网址在线观看| 欧美韩日一区二区三区| 成人高清伦理免费影院在线观看| 久久精品人人做人人爽97| 国产福利精品一区二区| 欧美国产亚洲另类动漫| 成人ar影院免费观看视频| 1区2区3区精品视频| av毛片久久久久**hd| 亚洲视频在线观看一区| av不卡免费在线观看| 亚洲免费观看高清完整 | 一区二区在线观看免费| 在线一区二区三区四区| 亚州成人在线电影| 欧美一区二区视频网站| 国内精品国产成人| 国产偷v国产偷v亚洲高清| 成人av在线电影| 一区二区三区欧美日韩| 欧美巨大另类极品videosbest | 欧美三级电影网| 日韩国产高清在线| 欧美zozozo| 波多野结衣在线一区| 一区二区三区四区在线播放| 欧美美女视频在线观看| 久久不见久久见中文字幕免费| 国产亚洲精品资源在线26u| a级精品国产片在线观看| 亚洲一区在线视频观看| 日韩亚洲欧美高清| 福利电影一区二区| 一二三区精品视频| 日韩欧美综合在线| 国产不卡在线播放| 亚洲激情男女视频| 日韩精品一区二区三区在线播放| 国产ts人妖一区二区| 亚洲激情自拍视频| 精品久久久三级丝袜| av不卡在线观看| 婷婷中文字幕综合| 国产欧美中文在线| 欧美日韩卡一卡二| 精品一区二区三区视频| 亚洲色图一区二区| 日韩午夜激情av| 一本一道久久a久久精品综合蜜臀| 日韩不卡免费视频| 成人免费一区二区三区视频| 欧美一卡2卡3卡4卡| 99国产精品国产精品久久| 日韩高清不卡一区二区三区| 国产精品毛片久久久久久| 欧美一区二区三区在线电影| 成人精品视频网站| 蜜桃久久久久久| 亚洲免费av网站| 精品粉嫩aⅴ一区二区三区四区| 色婷婷综合视频在线观看| 精品一区二区免费| 亚洲综合精品久久| 国产精品久久久久国产精品日日| 欧美一区二区福利视频| 在线免费观看日韩欧美| 国产激情一区二区三区桃花岛亚洲 | 一区二区三区四区不卡在线 | 欧美日韩在线播放三区| 成人午夜电影网站| 久久99久久精品欧美| 亚洲成人激情自拍| 亚洲色图在线播放| 久久精品一区二区| 日韩午夜精品视频| 欧美日韩精品电影| 91女厕偷拍女厕偷拍高清| 国产乱码精品一区二区三| 日韩高清电影一区| 亚洲一二三级电影| 中文字幕亚洲一区二区va在线| 久久久久久久久久久久久夜| 91麻豆精品国产91久久久久久久久 | 久久这里只有精品6| 91麻豆精品国产91久久久更新时间| 91丨porny丨中文| 成人成人成人在线视频| 国产福利一区二区三区在线视频| 麻豆91免费看| 日韩成人免费在线| 图片区日韩欧美亚洲| 亚洲国产精品久久人人爱| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 久久久午夜精品理论片中文字幕| 精品久久久久久最新网址| 51久久夜色精品国产麻豆| 欧美嫩在线观看| 欧美久久久久免费| 欧美精品在线一区二区| 3atv在线一区二区三区| 欧美日韩不卡视频|