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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mci.c

?? Hello I Send som Source Code Aboat LPC2000
?? C
?? 第 1 頁 / 共 3 頁
字號:

  /* 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 ( MCI_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] );
	/* bit 0 and bit 2 must be zero, or it's timeout or CRC error */
	/* It should go to IDEN state and bit 8 should be 1 */
	if ( !(respStatus & MCI_CMD_TIMEOUT) && ((respValue[0] & (0x0F << 8)) == 0x0500) )
	{
	  CardRCA = respValue[0] & 0xFFFF0000;	/* Save the RCA value from SD card */
	  return ( TRUE );	/* response is back and correct. */
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_CSD
**
** Descriptions:		CMD9, SEND_CSD cmd, it should be sent only at
**						STBY state and after CMD3. See MMC and SD spec. state 
**						diagram.		
**
** parameters:			None
** Returned value:		Response value
** 
******************************************************************************/
DWORD MCI_Send_CSD( void )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];
  DWORD CmdArgument;

  if ( MCI_CardType == SD_CARD )
  {
	CmdArgument = CardRCA;
  }
  else			/* if MMC or unknown card type, use default RCA addr. */
  {
	CmdArgument = 0x00010000;
  }

  retryCount = 0x20;
  while ( retryCount > 0 )
  {
	/* Send SET_BLOCK_LEN command before read and write */
	MCI_CLEAR |= (MCI_CMD_TIMEOUT | MCI_CMD_CRC_FAIL | MCI_CMD_RESP_END);
	MCI_SendCmd( SEND_CSD, CmdArgument, EXPECT_LONG_RESP, 0 );
	respStatus = MCI_GetCmdResp( SEND_CSD, EXPECT_LONG_RESP, (DWORD *)&respValue[0] );
	if ( !respStatus )
	{
	  return ( TRUE );
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );
}

/******************************************************************************
** Function name:		MCI_Select_Card
**
** Descriptions:		CMD7, SELECT_CARD, should be after CMD9, the state
**						will be inter-changed between STBY and TRANS after 
**						this cmd.		
**
** parameters:			None
** Returned value:		return false if response times out.
** 
******************************************************************************/
DWORD MCI_Select_Card( void )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];
  DWORD CmdArgument;

  if ( MCI_CardType == SD_CARD )
  {
	CmdArgument = CardRCA;
  }
  else			/* if MMC or unknown card type, use default RCA addr. */
  {
	CmdArgument = 0x00010000;
  }

  retryCount = 0x20;
  while ( retryCount > 0 )
  {
	/* Send SELECT_CARD command before read and write */
	MCI_CLEAR |= (MCI_CMD_TIMEOUT | MCI_CMD_CRC_FAIL | MCI_CMD_RESP_END);
	MCI_SendCmd( SELECT_CARD, CmdArgument, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( SELECT_CARD, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
	if ( !respStatus && ((respValue[0] & (0x0F << 8)) == 0x0700 ))
	{						/* Should be in STANDBY state now and ready */
	  return ( TRUE );
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_Status
**
** Descriptions:		CMD13, SEND_STATUS, the most important cmd to
**						debug the state machine of the card.		
**
** parameters:			None
** Returned value:		Response value(card status), true if the ready bit 
**						is set in the card status register, if timeout, return 
**						INVALID_RESPONSE 0xFFFFFFFF.
** 
******************************************************************************/
DWORD MCI_Send_Status( void )
{
  DWORD retryCount;
  DWORD respStatus;
  DWORD respValue[4];
  DWORD CmdArgument;

  if ( MCI_CardType == SD_CARD )
  {
	CmdArgument = CardRCA;
  }
  else			/* if MMC or unknown card type, use default RCA addr. */
  {
	CmdArgument = 0x00010000;
  }

  /* Note that, since it's called after the block write and read, this timeout 
  is important based on the clock you set for the data communication. */
  retryCount = 0x2000;
  while ( retryCount > 0 )
  {
	/* Send SELECT_CARD command before read and write */
	MCI_CLEAR |= (MCI_CMD_TIMEOUT | MCI_CMD_CRC_FAIL | MCI_CMD_RESP_END);
	MCI_SendCmd( SEND_STATUS, CmdArgument, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( SEND_STATUS, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
	if ( !respStatus && (respValue[0] & (1 << 8)) )
	{ /* The ready bit should be set, it should be in either TRAN or RCV state now */
	  return ( respValue[0] );
	}
	retryCount--;
  }
  return ( INVALID_RESPONSE );
}
		
/******************************************************************************
** Function name:		MCI_Set_BlockLen
**
** Descriptions:		CMD16, SET_BLOCKLEN, called after CMD7(SELECT_CARD)
**						called in the TRANS state.		
**
** parameters:			The length of the data block to be written or read.
** Returned value:		true or false, return TRUE if ready bit is set, and it's
**						in TRANS state.
** 
******************************************************************************/
DWORD MCI_Set_BlockLen( DWORD blockLength )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];

  retryCount = 0x20;
  while ( retryCount > 0 )
  {
	/* Send SET_BLOCK_LEN command before read and write */
	MCI_CLEAR |= (MCI_CMD_TIMEOUT | MCI_CMD_CRC_FAIL | MCI_CMD_RESP_END);
	MCI_SendCmd( SET_BLOCK_LEN, blockLength, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( SET_BLOCK_LEN, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
	/* bit 9 through 12 should be in transfer state now. bit 8 is ready. */
	if ( !respStatus && ((respValue[0] & (0x0F << 8)) == 0x0900))			  		
	{		
	  return ( TRUE );
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_ACMD_Bus_Width
**
** Descriptions:		ACMD6, SET_BUS_WIDTH, if it's SD card, we can
**						use the 4-bit bus instead of 1-bit. This cmd
**						can only be called during TRANS state.
**						Since it's a ACMD, CMD55 APP_CMD needs to be
**						sent out first. 		
**
** parameters:			Bus width value, 1-bit is 0, 4-bit is 10
** Returned value:		true or false, true if the card is still in the 
**						TRANS state after the cmd.
** 
******************************************************************************/
DWORD MCI_Send_ACMD_Bus_Width( DWORD buswidth )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];

  retryCount = 0x20;			/* reset retry counter */
  while ( retryCount > 0 )
  {
	if ( MCI_Send_ACMD() == FALSE )
	{
	  continue;
	}	
	/* Send ACMD6 command to set the bus width */
	MCI_SendCmd( SET_ACMD_BUS_WIDTH, buswidth, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( SET_ACMD_BUS_WIDTH, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
	if ( !respStatus && ((respValue[0] & (0x0F << 8)) == 0x0900) )
	{
	  return ( TRUE );	/* response is back and correct. */
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_Stop
**
** Descriptions:		CMD12, STOP_TRANSMISSION. if that happens, the card is 
**						maybe in a unknown state that need a warm reset.		
**
** parameters:			None
** Returned value:		true or false, true if, at least, the card status
**						shows ready bit is set.
** 
******************************************************************************/
DWORD MCI_Send_Stop( void )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];

  retryCount = 0x20;
  while ( retryCount > 0 )
  {
	MCI_CLEAR = 0x7FF;
	MCI_SendCmd( STOP_TRANSMISSION, 0x00000000, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( STOP_TRANSMISSION, EXPECT_SHORT_RESP, (DWORD *)respValue );
	/* ready bit, bit 8, should be set in the card status register */
	if ( !respStatus && (respValue[0] & (1 << 8)) )
	{
	  return( TRUE );
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );
}

/******************************************************************************
** Function name:		MCI_Send_Write_Block
**
** Descriptions:		CMD24, WRITE_BLOCK, send this cmd in the TRANS state
**						to write a block of data to the card.
**
** parameters:			block number
** Returned value:		Response value
** 
******************************************************************************/
DWORD MCI_Send_Write_Block( DWORD blockNum )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];

  retryCount = 0x20;
  while ( retryCount > 0 )
  {
	MCI_CLEAR = 0x7FF;
	MCI_SendCmd( WRITE_BLOCK, blockNum * BLOCK_LENGTH, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( WRITE_BLOCK, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
	/* it should be in the transfer state, bit 9~12 is 0x0100 and bit 8 is 1 */
	if ( !respStatus && ((respValue[0] & (0x0F << 8)) == 0x0900) )
	{
	  return( TRUE );			/* ready and in TRAN state */
	}

	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );				/* Fatal error */
}

/******************************************************************************
** Function name:		MCI_Send_Read_Block
**
** Descriptions:		CMD17, READ_SINGLE_BLOCK, send this cmd in the TRANS 
**						state to read a block of data from the card.
**
** parameters:			block number
** Returned value:		Response value
** 
******************************************************************************/
DWORD MCI_Send_Read_Block( DWORD blockNum )
{
  DWORD i, retryCount;
  DWORD respStatus;
  DWORD respValue[4];

  retryCount = 0x20;
  while ( retryCount > 0 )
  {
	MCI_CLEAR = 0x7FF;
	MCI_SendCmd( READ_SINGLE_BLOCK, blockNum * BLOCK_LENGTH, EXPECT_SHORT_RESP, 0 );
	respStatus = MCI_GetCmdResp( READ_SINGLE_BLOCK, EXPECT_SHORT_RESP, (DWORD *)&respValue[0] );
	/* it should be in the transfer state, bit 9~12 is 0x0100 and bit 8 is 1 */
	if ( !respStatus && ((respValue[0] & (0x0F << 8)) == 0x0900) )
	{
	  return( TRUE );			/* ready and in TRAN state */
	}
	for ( i = 0; i < 0x20; i++ );
	retryCount--;
  }
  return ( FALSE );					/* Fatal error */
}
	
/******************************************************************************
** Function name:		MCI_Write_Block
**
** Descriptions:		Set MCI data control register, data length and data
**						timeout, send WRITE_BLOCK cmd, finally, enable
**						interrupt. On completion of WRITE_BLOCK cmd, TX_ACTIVE
**						interrupt will occurs, data can be written continuously
**						into the FIFO until the block data length is reached.		
**
** parameters:			block number
** Returned value:		true or false, if cmd times out, return false and no 
**						need to continue.
** 
******************************************************************************/
DWORD MCI_Write_Block( DWORD blockNum )
{
  DWORD i;
  DWORD DataCtrl = 0;

  MCI_CLEAR = 0x7FF;
  MCI_DATA_CTRL = 0;
  for ( i = 0; i < 0x10; i++ );

  /* Below status check is redundant, but ensure card is in TRANS state
  before writing and reading to from the card. */
  if ( MCI_CheckStatus() != TRUE )
  {
	MCI_Send_Stop();
	return( FALSE );
  }

  MCI_DATA_TMR = DATA_TIMER_VALUE;
  MCI_DATA_LEN = BLOCK_LENGTH;
  MCI_Block_End_Flag = 1;
  MCI_TXEnable();
  if ( MCI_Send_Write_Block( blockNum ) == FALSE )
  {
	return ( FALSE );
  }

#if MCI_DMA_ENABLED
  DMA_Move( 0, M2P );
  GPDMA_CH0_CFG |= 0x10001 | (0x00 << 1) | (0x04 << 6) | (0x05 << 11);
  /* Write, block transfer, DMA, and data length */
  DataCtrl |= ((1 << 0) | (1 << 3) | (DATA_BLOCK_LEN << 4));	
#else
  /* Write, block transfer, and data length */
  DataCtrl |= ((1 << 0) | (DATA_BLOCK_LEN << 4));
#endif	
  MCI_DATA_CTRL = DataCtrl;
  for ( i = 0; i < 0x10; i++ );
	
  return ( TRUE );
}

/******************************************************************************
** Function name:		MCI_Read_Block
**
** Descriptions:		Set MCI data control register, data length and data
**						timeout, send READ_SINGLE_BLOCK cmd, finally, enable
**						interrupt. On completion of READ_SINGLE_BLOCK cmd, 
**						RX_ACTIVE interrupt will occurs, data can be read 
**						continuously into the FIFO until the block data 
**						length is reached.		
**
** parameters:			block number
** Returned value:		true or false, if cmd times out, return false and no 
**						need to continue.
**
** 
******************************************************************************/
DWORD MCI_Read_Block( DWORD blockNum )
{
  DWORD i;
  DWORD DataCtrl = 0;

  MCI_CLEAR = 0x7FF;
  MCI_DATA_CTRL = 0;
  for ( i = 0; i < 0x10; i++ );

  /* Below status check is redundant, but ensure card is in TRANS state
  before writing and reading to from the card. */
  if ( MCI_CheckStatus() != TRUE )
  {
	MCI_Send_Stop();
	return( FALSE );
  }
  MCI_RXEnable();

  MCI_DATA_TMR = DATA_TIMER_VALUE;
  MCI_DATA_LEN = BLOCK_LENGTH;
  MCI_Block_End_Flag = 1;
  if ( MCI_Send_Read_Block( blockNum ) == FALSE )
  {
	return ( FALSE );
  }

#if MCI_DMA_ENABLED
  DMA_Move( 1, P2M );
  GPDMA_CH1_CFG |= 0x10001 | (0x04 << 1) | (0x00 << 6) | (0x06 << 11);
  /* Write, block transfer, DMA, and data length */
  DataCtrl |= ((1 << 0) | (1 << 1) | (1 << 3) | (DATA_BLOCK_LEN << 4));	
#else
  /* Read, enable, block transfer, and data length */
  DataCtrl |= ((1 << 0) | (1 << 1) | (DATA_BLOCK_LEN << 4));	
#endif
  MCI_DATA_CTRL = DataCtrl;
  for ( i = 0; i < 0x10; i++ ); 
  return ( TRUE );
}

/*****************************************************************************
**                            End Of File
******************************************************************************/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品少妇一区二区三区 | 国产婷婷精品av在线| 99久久伊人精品| 日韩不卡在线观看日韩不卡视频| 精品成人一区二区三区四区| 不卡av在线网| 精品在线一区二区三区| 亚洲综合一区二区精品导航| 久久日韩粉嫩一区二区三区| 欧洲精品在线观看| 日韩高清中文字幕一区| 欧美videossexotv100| 欧美视频中文字幕| 91在线观看成人| 国产91精品免费| 国产精品影音先锋| 久久成人av少妇免费| 亚洲超丰满肉感bbw| 亚洲国产精品麻豆| 亚洲第一会所有码转帖| 亚洲精选一二三| 国产精品久久久久久久第一福利 | 欧美不卡一区二区三区四区| 在线亚洲免费视频| 欧美三级视频在线| 91国产免费看| 欧美色综合天天久久综合精品| 一本色道久久加勒比精品| 成人爱爱电影网址| 成av人片一区二区| 在线精品视频免费播放| 欧美这里有精品| 777午夜精品免费视频| 欧美精选在线播放| 日韩欧美第一区| 中文字幕第一页久久| 亚洲欧美影音先锋| 亚洲尤物视频在线| 紧缚奴在线一区二区三区| 国产乱码精品一区二区三区av| 成人激情动漫在线观看| 在线免费观看日韩欧美| 欧美一区二区啪啪| 中文字幕一区二区三区av| 午夜视频在线观看一区二区| 另类调教123区| 99久久精品免费| 欧美一级在线观看| 国产精品拍天天在线| 午夜欧美视频在线观看| 国产成人免费视频网站高清观看视频 | 亚洲观看高清完整版在线观看 | 国产精品911| 欧美在线观看一区二区| 中文字幕 久热精品 视频在线| 亚洲一区二区精品3399| 国产曰批免费观看久久久| 色偷偷久久一区二区三区| 久久亚洲欧美国产精品乐播| 亚洲成人av中文| 北岛玲一区二区三区四区| 久久久亚洲精品石原莉奈| 久久久久国产精品麻豆ai换脸| 午夜电影久久久| 欧美性做爰猛烈叫床潮| 亚洲三级小视频| 9色porny自拍视频一区二区| 久久精品人人爽人人爽| 日韩成人免费看| 欧美男男青年gay1069videost| 国产精品三级在线观看| 岛国av在线一区| 日本一区二区久久| 国产精一品亚洲二区在线视频| 色av成人天堂桃色av| 亚洲欧美色图小说| 色噜噜狠狠成人中文综合| 中文字幕在线不卡国产视频| 国产呦精品一区二区三区网站| 欧美日韩精品欧美日韩精品一综合| 国产精品嫩草久久久久| 久久精品国产亚洲a| 精品国产一区二区亚洲人成毛片 | 成人av动漫在线| 日韩美女视频一区| 欧美日韩精品一区二区| 日日夜夜精品视频天天综合网| 日本一区二区免费在线观看视频| 国产在线观看一区二区| 中文字幕av一区 二区| 欧美伊人久久大香线蕉综合69| 亚洲国产精品久久人人爱| 精品精品欲导航| 国产一区二区三区日韩| 亚洲日本乱码在线观看| 日韩亚洲欧美在线| 99精品黄色片免费大全| 免费观看在线综合| 综合在线观看色| 欧美一级日韩免费不卡| 91免费观看视频在线| 久久99这里只有精品| 亚洲精品自拍动漫在线| 久久午夜免费电影| 制服.丝袜.亚洲.中文.综合| 国产成a人亚洲| 肉肉av福利一精品导航| 91麻豆免费观看| 国产美女一区二区| 免费看欧美美女黄的网站| 欧美高清在线一区二区| 欧美一区二区三区四区高清 | 国产精品一区二区三区四区| 亚洲精品成人精品456| 国产人成一区二区三区影院| 欧美一区二区三级| 欧美日韩精品欧美日韩精品一 | 老司机免费视频一区二区三区| 99久久精品免费看国产| 成人国产精品视频| 粉嫩av亚洲一区二区图片| 国产盗摄女厕一区二区三区| 韩国女主播成人在线| 国产综合久久久久影院| 另类中文字幕网| 国产精一区二区三区| 国产毛片精品一区| 99久久99久久精品免费观看| 国产91露脸合集magnet| 丰满亚洲少妇av| 不卡的av在线播放| 色偷偷成人一区二区三区91| 色综合久久88色综合天天免费| 欧洲一区在线电影| 欧美人与性动xxxx| 欧美成人a在线| 中文字幕在线免费不卡| 亚洲国产成人高清精品| 久久66热偷产精品| 国产盗摄精品一区二区三区在线| www.亚洲精品| 欧美日韩激情一区二区| 国产亚洲污的网站| 一区二区三区高清不卡| 日韩电影在线一区二区三区| 国产一区二区三区四| 色婷婷国产精品| 26uuu色噜噜精品一区| 亚洲理论在线观看| 粉嫩在线一区二区三区视频| 欧美一a一片一级一片| 久久久久久久久岛国免费| 一区二区三区四区激情| 毛片一区二区三区| 色先锋aa成人| 色94色欧美sute亚洲线路一久| 99久久久精品| 91视频免费看| 久久精品亚洲国产奇米99| 亚洲码国产岛国毛片在线| 国产一区二区三区久久悠悠色av| 91蜜桃传媒精品久久久一区二区| 欧美一级在线免费| 天天av天天翘天天综合网色鬼国产 | 蜜臀av一区二区在线观看| 欧美理论电影在线| 亚洲精品视频在线观看网站| 国产99精品国产| 91精品国产色综合久久| 午夜精品久久久| 欧美日韩国产高清一区二区三区| 亚洲日本青草视频在线怡红院| 99久久亚洲一区二区三区青草| 国产精品天干天干在线综合| 91蜜桃婷婷狠狠久久综合9色| 久久久久久久久久电影| 国产在线看一区| 久久久久国产精品麻豆ai换脸 | 日韩高清在线电影| 欧美视频日韩视频在线观看| 婷婷国产在线综合| 日韩欧美国产精品一区| 国产精品99精品久久免费| 国产精品久久一卡二卡| 99精品国产91久久久久久 | 91精品在线观看入口| 亚洲高清视频的网址| 欧美精品一二三区| 国产一区二区三区综合| 亚洲精品视频免费看| 91精品国产高清一区二区三区| 免费成人av在线播放| 日本一区二区三级电影在线观看| 91在线免费视频观看| 舔着乳尖日韩一区| 亚洲国产成人一区二区三区| 91国产免费看| 韩国一区二区三区| 欧美国产丝袜视频| 国产麻豆精品视频|