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

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

?? mci.c

?? Hello I Send som Source Code Aboat LPC2000
?? C
?? 第 1 頁 / 共 3 頁
字號:
DWORD MCI_Init( void )
{
  DWORD i;
  
  PCONP |= ( 1 << 28 );			/* Enable clock to the MCI block */

  if ( MCI_CLOCK & (1 << 8) )
  {
	MCI_CLOCK &= ~(1 << 8);
  }
  if ( MCI_POWER & 0x02 )
  {
	MCI_POWER = 0x00;
  }
  for ( i = 0; i < 0x1000; i++ );

  /* Disable all interrupts for now */
  MCI_MASK0 = 0;
  MCI_MASK1 = MCI_MASK0;    

  /* Due to reversed H/W logic in the MCB2300 board, the MCI power pin
  needs to be configured as GPIO pin that I need to set it active low manually, 
  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 = 0x2A80;
  PINSEL4 = 0x0A800000;
#if MCB2300_VERSION_0
  SCS |= 0x08;
#if 0
  PINSEL1 = 0x2280;
  PINSEL4 = 0x0A800000;
  IODIR0 = 1 << 21;		/* MCI_PWR as GPIO output */
  IOCLR0 = 1 << 21;
#endif
#else
  SCS &= ~0x08;
#if 0
  PINSEL1 = 0x2A80;
  PINSEL4 = 0x0A800000;
#endif
#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. */	
  MCI_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_IRQHandler, 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;
  }
  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;	
	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 ( MCI_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.
** 
******************************************************************************/
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 = 0x200;			/* 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++ );
	retryCount--;
  }
  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;

  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;
	return ( CardType );	/* Found the card, it's a MMC */
  }
  else if ( MCI_Send_ACMD_OP_Cond() == TRUE )
  {
	CardType = SD_CARD;
	return ( CardType );	/* Found the card, it's a SD */
  }	
  /* tried both MMC and SD card, give up */
  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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区波多野结衣在线观看| 国产精品你懂的在线| 国产成人免费视| 亚洲va韩国va欧美va| 中国av一区二区三区| 欧美一级高清大全免费观看| 色偷偷久久一区二区三区| 狠狠色2019综合网| 午夜视黄欧洲亚洲| 日韩一区欧美一区| 国产欧美一区二区精品性| 欧美剧情电影在线观看完整版免费励志电影 | 亚洲欧美区自拍先锋| 精品福利一区二区三区免费视频| 欧美中文字幕一区| 91亚洲精品一区二区乱码| 国产精品12区| 久久精品国产99| 天堂av在线一区| 亚洲精品国产第一综合99久久 | 亚洲激情一二三区| 中文字幕在线播放不卡一区| 久久久久久影视| 日韩色在线观看| 欧美肥妇毛茸茸| 欧美午夜影院一区| 91偷拍与自偷拍精品| 成人国产精品免费| 国产成人av一区二区三区在线| 裸体健美xxxx欧美裸体表演| 午夜国产精品一区| 午夜视频在线观看一区二区| 亚洲永久免费av| 一区二区三区国产精华| 亚洲精品久久嫩草网站秘色| 17c精品麻豆一区二区免费| 中文字幕第一页久久| 国产欧美日韩综合| 国产欧美日韩中文久久| 国产日韩亚洲欧美综合| 久久免费视频色| 国产农村妇女毛片精品久久麻豆| 久久女同精品一区二区| 国产欧美日韩在线| 国产精品视频九色porn| 国产视频在线观看一区二区三区| 久久嫩草精品久久久久| 国产日韩欧美精品综合| 国产精品亲子乱子伦xxxx裸| 中文字幕精品一区二区三区精品| 国产精品免费观看视频| 亚洲精品伦理在线| 亚洲成人免费视频| 免费在线欧美视频| 激情综合色播激情啊| 国产精品一卡二卡| www.日韩大片| 欧美亚洲一区二区在线| 91麻豆精品国产自产在线观看一区| 欧美日韩二区三区| 精品毛片乱码1区2区3区| 2020国产精品久久精品美国| 国产精品少妇自拍| 一区二区三区**美女毛片| 日韩va亚洲va欧美va久久| 国产成人一区二区精品非洲| 91精品国模一区二区三区| 日本欧美韩国一区三区| 亚洲成人动漫精品| 热久久国产精品| 国产一区二区0| 91小视频在线免费看| 欧美日韩一区二区三区高清 | 另类成人小视频在线| 国产传媒一区在线| 色狠狠av一区二区三区| 7777精品伊人久久久大香线蕉超级流畅 | 精品一区二区三区在线视频| 国产精品18久久久久久久久| 91丝袜美女网| 欧美丰满一区二区免费视频 | 亚洲国产wwwccc36天堂| 久久99久久精品欧美| 99这里只有精品| 91精品国产综合久久香蕉的特点 | 亚洲欧美色一区| 日韩综合一区二区| 成人激情综合网站| 91精品婷婷国产综合久久性色| 国产蜜臀av在线一区二区三区| 一区二区免费看| 久久aⅴ国产欧美74aaa| 在线免费不卡电影| 久久女同精品一区二区| 亚洲一区二区偷拍精品| 丁香桃色午夜亚洲一区二区三区| 欧美私人免费视频| 国产精品每日更新在线播放网址 | 亚洲午夜精品久久久久久久久| 精品一区二区在线视频| 欧美视频第二页| 日本一区二区三区四区在线视频 | 国产一区二区在线看| 91精品福利视频| 国产亚洲成av人在线观看导航| 五月婷婷综合网| 色视频成人在线观看免| 国产欧美日韩在线| 另类人妖一区二区av| 欧美日韩久久久一区| 亚洲三级在线免费观看| 国产精品一区久久久久| 欧美二区在线观看| 亚洲国产精品久久久久婷婷884 | 欧美老年两性高潮| 亚洲日穴在线视频| 成人久久久精品乱码一区二区三区| 日韩欧美国产综合一区| 视频一区欧美日韩| 欧美三级中文字幕在线观看| 亚洲乱码精品一二三四区日韩在线| 国产成人精品亚洲777人妖| 欧美成人女星排行榜| 日本强好片久久久久久aaa| 欧美日韩国产天堂| 亚洲一级在线观看| 欧美手机在线视频| 亚洲尤物视频在线| 欧美性一级生活| 亚洲一区二区三区爽爽爽爽爽| 日本乱人伦一区| 亚洲精品伦理在线| 欧美网站大全在线观看| 亚洲电影中文字幕在线观看| 欧美性受xxxx黑人xyx| 亚洲图片欧美一区| 欧美精品777| 青青草国产成人av片免费| 欧美一级高清大全免费观看| 蜜臀99久久精品久久久久久软件| 欧美一级精品在线| 国内精品伊人久久久久av一坑| 久久在线免费观看| 懂色中文一区二区在线播放| 国产精品嫩草99a| 99re这里只有精品首页| 亚洲视频一区二区免费在线观看| 99久久久免费精品国产一区二区| 成人欧美一区二区三区黑人麻豆 | 日本精品视频一区二区| 亚洲另类一区二区| 欧美日韩不卡一区二区| 免费在线观看成人| 久久久国际精品| 91免费视频大全| 亚洲成av人片观看| 欧美mv日韩mv国产网站app| 国产一区二区伦理| 亚洲欧洲在线观看av| 欧美午夜精品理论片a级按摩| 日本午夜精品视频在线观看 | 2014亚洲片线观看视频免费| 国产精品1024久久| 一区二区三区在线视频免费| 国产米奇在线777精品观看| 亚洲mv在线观看| 欧美年轻男男videosbes| 亚洲二区在线观看| 精品美女在线观看| 成人高清免费在线播放| 亚洲韩国精品一区| 2020国产精品自拍| 色94色欧美sute亚洲线路一久 | 精品女同一区二区| 国产高清精品网站| 一区二区在线免费| 欧美一区二区三区播放老司机| 国产久卡久卡久卡久卡视频精品| 最新国产精品久久精品| 91精品国产综合久久蜜臀| 成人激情小说乱人伦| 五月婷婷久久综合| 中文字幕精品一区二区精品绿巨人 | 日韩成人免费看| 国产精品日韩成人| 欧美精品亚洲一区二区在线播放| 国产高清久久久久| 亚洲777理论| 欧美激情在线一区二区| 91精品国产综合久久蜜臀| 成人av电影在线观看| 日韩va欧美va亚洲va久久| 中日韩av电影| 精品入口麻豆88视频| 在线观看欧美日本| 国产成人亚洲综合a∨婷婷图片| 亚洲成av人影院| 中文字幕日韩欧美一区二区三区| 精品国产一区二区三区久久影院| 一本久久a久久免费精品不卡|