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

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

?? mci.c.bak

?? 優龍LPC2468開發板BIOS源程序,簡潔明了
?? BAK
?? 第 1 頁 / 共 3 頁
字號:
	once it's set as MCI power pin, it will be active high. */
	/*connect MCI signals to P0.19-P0.22, and P2.11-P2.13*/
	/*PINSEL1 &= ~(0xFF << 6);
	PINSEL4 &= ~(0x3F << 22);*/
	PINSEL2 &= ~(0x3C0FCF << 4);
#if MCB2300_VERSION_0
	PINSEL1 |= 0x228;
	PINSEL4 |= 0x0A800000;
	FIO0DIR |= 1 << 21;		/* MCI_PWR as GPIO output */
	FIO0SET = 1 << 21;      //power on mci
#else
    PINSEL1 |= 0x2A80;
	PINSEL4 |= 0x0A800000;
#endif

	/*set up clocking default mode, clear any registers as needed */
    MCI_COMMAND = 0;
    MCI_DATA_CTRL = 0;			
    MCI_CLEAR = 0x7FF;		/* clear all pending interrupts */

	MCI_POWER = 0x02;		/* power up */
	while ( !(MCI_POWER & 0x02) );
	for ( i = 0; i < 0x100; i++ );

	/* During identification phase, the clock should be less than
	400Khz. Once we pass this phase, the normal clock can be set up
	to 25Mhz on SD card and 20Mhz on MMC card. */	
	Set_MCIClock( SLOW_RATE );
	MCI_POWER |= 0x01;		/* bit 1 is set already, from power up to power on */
	
	for ( i = 0; i < 0x2000; i++ );
    if ( install_irq( MCI_INT, (void *)MCI_Handler, HIGHEST_PRIORITY ) == FALSE )
    {
		return ( FALSE );
    }

	/* During the initialization phase, to simplify the process, the CMD related 
	interrupts are disabled. The DATA related interrupts are enabled when
	the FIFOs are used and just before WRITE_BLOCK READ_BLOCK cmds are issues, and 
	disabled after the data block has been written and read. Please also note,
	before WRITE_BLOCK only TX related data interrupts are enabled, and before
	READ_BLOCK only RX related data interrupts are enabled. */   
    return (TRUE);
}

/******************************************************************************
** Function name:		MCI_SendCmd
**
** Descriptions:		The routine is used to send a CMD to the card		
**
** parameters:			CmdIndex, Argument, ExpectResp Flag, AllowTimeout flag
** Returned value:		None
** 
******************************************************************************/
void MCI_SendCmd( DWORD CmdIndex, DWORD Argument, DWORD ExpectResp, DWORD AllowTimeout )
{
    DWORD i, CmdData = 0;
	DWORD CmdStatus;
	
	/* the command engine must be disabled when we modify the argument
     or the peripheral resends */
	while ( (CmdStatus = MCI_STATUS) & MCI_CMD_ACTIVE )	/* Command in progress. */
	{
		MCI_COMMAND = 0;
		MCI_CLEAR = CmdStatus | MCI_CMD_ACTIVE;
	}
//printf("\n<%x>",CmdIndex);

	for ( i = 0; i < 0x100; i++ );	

    /*set the command details, the CmdIndex should 0 through 0x3F only */
	CmdData |= (CmdIndex & 0x3F);	/* bit 0 through 5 only */
	if ( ExpectResp == EXPECT_NO_RESP )			/* no response */
	{
		CmdData &= ~((1 << 6) | (1 << 7));		/* Clear long response bit as well */
	}
	else if ( ExpectResp == EXPECT_SHORT_RESP )	/* expect short response */
	{
		CmdData |= (1 << 6);
	}
	else if ( ExpectResp == EXPECT_LONG_RESP )	/* expect long response */
	{
		CmdData |= (1 << 6) | (1 << 7);
	}

	if ( AllowTimeout )			/* allow timeout or not */
	{
		CmdData |= (1 << 8);
	}
	else
	{
		CmdData &= ~(1 << 8);
	}

	/*send the command*/
	CmdData |= (1 << 10);		/* This bit needs to be set last. */
	MCI_ARGUMENT = Argument;	/* Set the argument first, finally command */
	MCI_COMMAND = CmdData;
	return;

}

/******************************************************************************
** Function name:		MCI_GetCmdResp
**
** Descriptions:		Get response from the card. This module is always used
**						in pair with MCI_SendCmd()		
**
** parameters:			Expected cmd data, expect response flag, pointer to the 
**						response
**						Expected cmd data should be the same as that in SendCmd()
**						expect response flag could be	EXPECT_NO_RESP
**														EXPECT_SHORT_RESP
**														EXPECT_LONG_RESP
**						if GetCmdResp() is 0, check the pointer to the response
**						field to get the response value, if GetCmdResp() returns 
**						non-zero, no need to check the response field, just resend
**						command or bailout. 
** Returned value:		Response status, 0 is valid response. 
** 
******************************************************************************/
DWORD MCI_GetCmdResp( DWORD ExpectCmdData, DWORD ExpectResp, DWORD *CmdResp )
{
	DWORD CmdRespStatus = 0;
	DWORD LastCmdIndex;

    if ( ExpectResp == EXPECT_NO_RESP )
	{
		return ( 0 );
	}

	while ( 1 )
	{
		CmdRespStatus = MCI_STATUS;	
//printf("[%x]",CmdRespStatus);
		if ( CmdRespStatus & (MCI_CMD_TIMEOUT) )
		{
			MCI_CLEAR = CmdRespStatus | MCI_CMD_TIMEOUT;
			MCI_COMMAND = 0;
			MCI_ARGUMENT = 0xFFFFFFFF;
			return ( CmdRespStatus );
		}
		if (  CmdRespStatus & MCI_CMD_CRC_FAIL )
		{
			MCI_CLEAR = CmdRespStatus | MCI_CMD_CRC_FAIL;
			LastCmdIndex = MCI_COMMAND & 0x003F;
			if ( (LastCmdIndex == SEND_OP_COND) || (LastCmdIndex == SEND_APP_OP_COND) 
					|| (LastCmdIndex == STOP_TRANSMISSION) )
			{
				MCI_COMMAND = 0;
				MCI_ARGUMENT = 0xFFFFFFFF;	 
				break;			/* ignore CRC error if it's a resp for SEND_OP_COND 
								or STOP_TRANSMISSION. */
			}
			else
			{ 
				return ( CmdRespStatus );
			}
		}
		else if ( CmdRespStatus & MCI_CMD_RESP_END )
		{
			MCI_CLEAR = CmdRespStatus | MCI_CMD_RESP_END;
			break;	/* cmd response is received, expecting response */
		}
	}
	if ( (MCI_RESP_CMD & 0x3F) != ExpectCmdData )
	{
		/* If the response is not R1, in the response field, the Expected Cmd data
		won't be the same as the CMD data in SendCmd(). Below four cmds have
		R2 or R3 response. We don't need to check if MCI_RESP_CMD is the same
		as the Expected or not. */
		if ( (ExpectCmdData != SEND_OP_COND) && (ExpectCmdData != SEND_APP_OP_COND) 
				&& (ExpectCmdData != ALL_SEND_CID) && (ExpectCmdData != SEND_CSD) )
		{
			CmdRespStatus = INVALID_RESPONSE;	/* Reuse error status */
			return ( INVALID_RESPONSE );
		}
	}

	if ( ExpectResp == EXPECT_SHORT_RESP )
	{
		*CmdResp = MCI_RESP0;
	}
	else if ( ExpectResp == EXPECT_LONG_RESP )
	{
		*CmdResp = MCI_RESP0;
		*(CmdResp+1) = MCI_RESP1;
		*(CmdResp+2) = MCI_RESP2;
		*(CmdResp+3) = MCI_RESP3;
	}
	return ( 0 );	/* Read MCI_RESP0 register assuming it's not long response. */
}

/******************************************************************************
** Function name:		MCI_Go_Idle_State
**
** Descriptions:		CMD0, the very first command to be sent to initialize
**						either MMC or SD card.		
**
** parameters:			None
** Returned value:		true or false, true if card has been initialized.
** 
******************************************************************************/
DWORD MCI_Go_Idle_State( void )
{
	DWORD retryCount;
	DWORD respStatus;
	DWORD respValue[4];

	retryCount = 0x20;
	while ( retryCount > 0 )
	{
		/* Send CMD0 command repeatedly until the response is back correctly */
    	MCI_SendCmd( GO_IDLE_STATE, 0x00000000, EXPECT_NO_RESP, 0 );
		respStatus = MCI_GetCmdResp( GO_IDLE_STATE, EXPECT_NO_RESP, (DWORD *)respValue );
		if ( respStatus == 0 )
		{
			break;
		}
		retryCount--;
	}
	
	if ( respStatus != 0 )		/* timeout, give up */
	{
		return ( FALSE );
	}
	return( TRUE );
}

/******************************************************************************
** Function name:		MCI_Send_OP_Cond
**
** Descriptions:		CMD1 for MMC		
**
** parameters:			None
** Returned value:		true or false, true if card has response back before
**						timeout, false is timeout on the command.
** 
******************************************************************************/
DWORD MCI_Send_OP_Cond( void )
{
	DWORD i, retryCount;
	DWORD respStatus;
	DWORD respValue[4];

	retryCount = 0x200;			/* reset retry counter */
	while ( retryCount > 0 )
	{
		/* Send CMD1 command repeatedly until the response is back correctly */
		MCI_SendCmd( SEND_OP_COND, OCR_INDEX, EXPECT_SHORT_RESP, 0 );
		respStatus = MCI_GetCmdResp( SEND_OP_COND, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
		/* bit 0 and bit 2 must be zero, or it's timeout or CRC error */
		if ( !(respStatus & MCI_CMD_TIMEOUT) && (respValue[0] & 0x80000000) )
		{
			return ( TRUE );	/* response is back and correct. */
		}
		for ( i = 0; i < 0x20; i++ );
		retryCount--;
	}
	return( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_ACMD
**
** Descriptions:		CMD55, before sending an ACMD, call this routine first  		
**
** parameters:			None
** Returned value:		true or false, true if card has responded before timeout.
**						false is timeout.
** 
******************************************************************************/
DWORD MCI_Send_ACMD( void )
{
	DWORD i, retryCount;
	DWORD CmdArgument;
	DWORD respStatus;
	DWORD respValue[4];

	if ( CardType == SD_CARD )
	{
		CmdArgument = CardRCA;	/* Use the address from SET_RELATIVE_ADDR cmd */
	}
	else			/* if MMC or unknown card type, use 0x0. */
	{
		CmdArgument = 0x00000000;
	}

	retryCount = 20;
	while ( retryCount > 0 )
	{
		/* Send CMD55 command followed by an ACMD */
		MCI_SendCmd( APP_CMD, CmdArgument, EXPECT_SHORT_RESP, 0 );
		respStatus = MCI_GetCmdResp( APP_CMD, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
		if ( !respStatus && (respValue[0] & CARD_STATUS_ACMD_ENABLE) )	/* Check if APP_CMD enabled */
		{
			return( TRUE );
		}
		for ( i = 0; i < 0x20; i++ );
		retryCount--;
	}
	return( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_ACMD_OP_Cond
**
** Descriptions:		If Send_OP_Cond is timeout, it's not a MMC card, try 
**						this combination to see if we can communicate with 
**						a SD card. 		
**
** parameters:			None
** Returned value:		true or false, true if card has been initialized.
**                      bug fixed:MCI_Send_ACMD false will cause loop forever
******************************************************************************/
DWORD MCI_Send_ACMD_OP_Cond( void )
{
	DWORD i, retryCount;
	DWORD respStatus;
	DWORD respValue[4];

	/* timeout on SEND_OP_COND command on MMC, now, try SEND_APP_OP_COND 
	command to SD */
	retryCount = 0x20;			/* reset retry counter */
	while ( retryCount-- > 0 )
	{
		MCI_POWER &= ~(1 << 6 );	/* Clear Open Drain output control for SD */
		for ( i = 0; i < 0x3000; i++ );

		if ( MCI_Send_ACMD() == FALSE )
		{
			continue;
		}
			
		/* Send ACMD41 command repeatedly until the response is back correctly */
		MCI_SendCmd( SEND_APP_OP_COND, OCR_INDEX, EXPECT_SHORT_RESP, 0 );
		respStatus = MCI_GetCmdResp( SEND_APP_OP_COND, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
		if ( !(respStatus & MCI_CMD_TIMEOUT) && (respValue[0] & 0x80000000) )
		{
			return ( TRUE );	/* response is back and correct. */
		}
		for ( i = 0; i < 0x20; i++ );
	}
	return( FALSE );
}

/******************************************************************************
** Function name:		MCI_CardInit
**
** Descriptions:		Try CMD1 first for MMC, if it's timeout, try CMD55 
**						and CMD41 for SD, if both failed, initialization faliure, 
**						bailout with unknown card type. Otherwise, return the
**						card type, either MMC or SD.		
**
** parameters:			None
** Returned value:		Card type.
** 
******************************************************************************/
DWORD MCI_CardInit( void )
{
	DWORD i, CardType;
	//lqm@ucdragon.net must reset CardRCA to 0,or MCI_CardInit fail for sd,the second time
	CardRCA = 0;
	if ( MCI_Go_Idle_State() == FALSE )
	{
		return( CARD_UNKNOWN );
	}

	MCI_POWER |= (1 << 6 );		/* Set Open Drain output control for MMC */
	for ( i = 0; i < 0x3000; i++ );

	/* Try CMD1 first for MMC, if it's timeout, try CMD55 and CMD41 for SD,
	if both failed, initialization faliure, bailout. */
	if ( MCI_Send_OP_Cond() == TRUE )	
	{
		CardType = MMC_CARD;
		MCI_CLOCK &= ~(1 << 11);		/* no wide bus for MMC */
		return ( CardType );	// Found the card, it's a MMC 
	}
	if ( MCI_Send_ACMD_OP_Cond() == TRUE )
	{
		CardType = SD_CARD;
		MCI_CLOCK |= (1 << 11);		/* Use wide bus for SD */
		return ( CardType );	// Found the card, it's a SD 
	}
	return ( CARD_UNKNOWN );
}

/******************************************************************************
** Function name:		MCI_Check_CID
**
** Descriptions:		Send CMD2, ALL_SEND_CID		
**
** parameters:			None
** Returned value:		If not timeout, return true.
** 
******************************************************************************/
DWORD MCI_Check_CID( void )
{
	DWORD i, retryCount;
	DWORD respStatus;
	DWORD respValue[4];

	/* This command is normally after CMD1(MMC) or ACMD41(SD). */
	retryCount = 0x20;			/* reset retry counter */
	while ( retryCount > 0 )
	{
		/* Send CMD2 command repeatedly until the response is back correctly */
		MCI_SendCmd( ALL_SEND_CID, 0, EXPECT_LONG_RESP, 0 );
		respStatus = MCI_GetCmdResp( ALL_SEND_CID, EXPECT_LONG_RESP, (DWORD *)&respValue[0] );
		/* bit 0 and bit 2 must be zero, or it's timeout or CRC error */
		if ( !(respStatus & MCI_CMD_TIMEOUT) )
		{
			return ( TRUE );	/* response is back and correct. */
		}
		for ( i = 0; i < 0x20; i++ );
		retryCount--;
	}
	return ( FALSE );
}

/******************************************************************************
** Function name:		MCI_Set_Address
**
** Descriptions:		Send CMD3, STE_RELATIVE_ADDR, should after CMD2		
**
** parameters:			None
** Returned value:		TRUE if response is back before timeout.
** 
******************************************************************************/
DWORD MCI_Set_Address( void )
{
	DWORD i, retryCount;
	DWORD respStatus;
	DWORD respValue[4];
	DWORD CmdArgument;

	/* If it's a SD card, SET_RELATIVE_ADDR is to get the address
	from the card and use this value in RCA, if it's a MMC, set default
	RCA addr. 0x00010000. */ 
	if ( CardType == SD_CARD )
	{
		CmdArgument = 0;
	}
	else			/* If it's unknown or MMC_CARD, fix the RCA address */
	{
		CmdArgument = 0x00010000;
	}

	retryCount = 0x20;			/* reset retry counter */
	while ( retryCount > 0 )
	{
		/* Send CMD3 command repeatedly until the response is back correctly */
		MCI_SendCmd( SET_RELATIVE_ADDR, CmdArgument, EXPECT_SHORT_RESP, 0 );
		respStatus = MCI_GetCmdResp( SET_RELATIVE_ADDR, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区日韩精品| bt欧美亚洲午夜电影天堂| 婷婷亚洲久悠悠色悠在线播放| 中文字幕一区二区不卡| 国产免费久久精品| 国产精品视频yy9299一区| 国产视频视频一区| 国产农村妇女精品| 国产精品久久久久久久久图文区| 国产日韩精品一区| 国产精品久久午夜夜伦鲁鲁| 国产精品精品国产色婷婷| 亚洲人123区| 一区二区三区免费网站| 亚洲成人免费av| 首页国产欧美日韩丝袜| 日韩电影在线一区二区三区| 麻豆精品在线播放| 国产主播一区二区| 成人av电影免费观看| 91亚洲大成网污www| 欧美午夜一区二区三区| 91精品国产综合久久久久久| 欧美一区二区在线观看| 久久精品无码一区二区三区| 中文字幕一区二区三区蜜月| 狠狠久久亚洲欧美| 国产成人在线网站| jlzzjlzz亚洲日本少妇| 在线观看日韩毛片| 日韩视频在线一区二区| 国产日产亚洲精品系列| 亚洲人成网站影音先锋播放| 日韩福利视频导航| 国产乱人伦精品一区二区在线观看| 成人在线视频一区| 在线观看视频欧美| 久久影音资源网| 亚洲天堂精品视频| 日韩电影一区二区三区四区| 国产激情视频一区二区三区欧美| 色视频一区二区| 56国语精品自产拍在线观看| 国产欧美日本一区二区三区| 亚洲图片有声小说| 国产一区 二区| 91小视频在线观看| 精品少妇一区二区三区视频免付费 | 欧美一区二区三区视频在线观看 | 综合亚洲深深色噜噜狠狠网站| 日韩中文字幕亚洲一区二区va在线 | 午夜私人影院久久久久| 精品一区二区三区免费视频| 91在线porny国产在线看| 日韩视频在线你懂得| 国产精品不卡在线| 日韩精品亚洲一区| 成人动漫一区二区三区| 欧美一级日韩免费不卡| 亚洲色图欧美激情| 国产老肥熟一区二区三区| 欧美亚洲一区二区在线| 中文字幕精品综合| 免费成人美女在线观看| 日本黄色一区二区| 久久众筹精品私拍模特| 亚洲高清免费在线| 成人免费视频一区| 日韩色视频在线观看| 亚洲午夜免费福利视频| 成人午夜精品在线| xf在线a精品一区二区视频网站| 亚洲精品日日夜夜| 成人性视频免费网站| 日韩欧美亚洲一区二区| 亚洲高清免费在线| 91欧美一区二区| 国产亚洲成aⅴ人片在线观看| 日韩高清在线不卡| 色综合久久88色综合天天| 中文字幕精品在线不卡| 在线视频你懂得一区| 久久精品夜色噜噜亚洲aⅴ| 奇米精品一区二区三区在线观看| 色国产综合视频| 亚洲天堂久久久久久久| 成人激情视频网站| 久久久久99精品国产片| 久久99精品久久久久| 欧美一区二区三区人| 亚洲va天堂va国产va久| 91国偷自产一区二区开放时间 | 精品日韩一区二区| 天天射综合影视| 欧美日韩精品是欧美日韩精品| 综合电影一区二区三区| 国产精一品亚洲二区在线视频| 欧美成人精品高清在线播放 | 精品视频在线视频| 一区二区久久久| 色综合久久久网| 国产精品福利一区二区| 成人精品在线视频观看| 国产精品久久三| 波多野洁衣一区| 国产精品女上位| 成人h动漫精品一区二| 国产精品第四页| 91免费精品国自产拍在线不卡| 国产精品理论片在线观看| jlzzjlzz亚洲日本少妇| 亚洲黄网站在线观看| 欧美三级韩国三级日本一级| 亚洲国产日韩精品| 欧美福利视频一区| 秋霞电影网一区二区| 久久一日本道色综合| 成人精品电影在线观看| 亚洲精品成人少妇| 在线国产电影不卡| 五月激情综合色| 日韩欧美国产电影| 国产91精品露脸国语对白| 国产精品久久一卡二卡| 欧美又粗又大又爽| 日本伊人色综合网| 久久久久久夜精品精品免费| proumb性欧美在线观看| 亚洲综合视频在线观看| 日韩一区二区三区电影| 国产91精品欧美| 亚洲精品精品亚洲| 欧美久久婷婷综合色| 国产精一品亚洲二区在线视频| 国产精品高潮呻吟| 欧美日韩一区不卡| 精品一区二区av| 国产欧美日韩精品在线| 在线视频综合导航| 久久99国产精品麻豆| 中文字幕av一区二区三区高| 国产精品国产三级国产aⅴ原创| 色综合久久久久| 裸体歌舞表演一区二区| 国产欧美一区二区精品秋霞影院| 欧洲一区二区三区免费视频| 激情小说欧美图片| 1024成人网色www| 51久久夜色精品国产麻豆| 国产精品99久久久久| 亚洲国产精品天堂| 久久女同互慰一区二区三区| 在线免费观看视频一区| 精品一区中文字幕| 亚洲综合激情另类小说区| 日韩欧美中文一区二区| 91美女福利视频| 国内久久精品视频| 亚洲精品ww久久久久久p站| 久久亚洲精品国产精品紫薇| 91国在线观看| 国产91富婆露脸刺激对白| 日韩中文字幕亚洲一区二区va在线| 中文欧美字幕免费| 8x福利精品第一导航| 色哟哟亚洲精品| 国产精品自拍一区| 日韩精品色哟哟| 日韩一区在线免费观看| 26uuu亚洲综合色| 欧美日韩一区二区三区不卡| 99久久国产综合精品色伊| 久久不见久久见中文字幕免费| 亚洲高清免费观看| 国产精品国产三级国产普通话三级 | 在线影视一区二区三区| 国产一区二区福利| 日韩av中文字幕一区二区三区| 亚洲欧洲av另类| 久久久久高清精品| 欧美一卡二卡在线| 欧美日韩国产一级| 91在线云播放| 国产美女精品人人做人人爽| 日本不卡在线视频| 亚洲综合av网| 综合自拍亚洲综合图不卡区| 国产欧美日韩亚州综合| 久久蜜臀精品av| 亚洲精品在线观| 欧美一区二区成人| 91麻豆精品国产自产在线观看一区 | 色婷婷综合久久久中文字幕| 久久成人av少妇免费| 色婷婷久久99综合精品jk白丝| 国产999精品久久久久久| 久久99精品久久久久久国产越南| 天堂影院一区二区| 亚洲成人激情av| 亚洲一区二区欧美日韩|