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

📄 mmcsd_user.c

📁 TI的DM6446的硬件平台搭建的相关例子
💻 C
字号:
/*
    DaVinci ARM Evaluation Software

    (c)Texas Instruments 2004
*/


/**
    \file mmcsd_user.c
    \brief  Contains APIs that are user specific

*/

#include <cslr_mmcsd.h>
#include <memcd_rettypes.h>
#include <mmcsd_protocol.h>
#include <mmc_protocol.h>
#include <sd_protocol.h>


//#include <clkc320.h>

MMCSD_ResponseData mmcsdResponse;
MMCSD_csdRegInfo mmcsdCSDRegInfo;
MMCSD_rwDataDoneStatus  mmcsdRWDataDoneStat;


/**
    \brief  MMC/SD interface selection, Controller and Card Initialization

    \param  relCardAddr RCA ased ot the MMC/SD card
    \param  cardStatus  Card Status is received in this parameter
    \param  mmcsdConfig Structure containing controller and card configuration info

    \return if success, \c E_PASS, else error code

*/
STATUS MMCSD_initCard( Uint32 *relCardAddr, MMCSD_cardStatusReg *cardStatus, MMCSD_ConfigData *mmcsdConfig,MMCSD_FIFOTHR_LEVEL fifoThrlevel,MMCSD_CARD_TYPE cardType)
{
	STATUS status;
	Uint16 i;

	Uint32 * VDD3P3V_PWDN =(Uint32 *)0x01C40048;

	/*PowerUp the 3P3V I/O Cells used for SD/MMC pins:
	Bit 1 represents SD/MMC and Bit 0 represents 3.3V GPIO signals
	0:Enable
	1:Disabled(Default Value on PowerUp) */

	*VDD3P3V_PWDN=0x00000001;


	/* Enable the Clock and set the divide-down value as 2*/
	CSL_MMCSD_0_REGS->MMCCLK =0x0100;

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

	/*Set the FIFO level to 16bytes or 32 bytes*/
	CSL_FINS(CSL_MMCSD_0_REGS->MMCFIFOCTL,MMCSD_MMCFIFOCTL_FIFOLEV,fifoThrlevel);

	/* put the CMD and Data Logic in RESET state */
	CSL_MMCSD_0_REGS->MMCCTL=0x0007;


	/* Configuration Set; Clk: MMC Clk Rt = ARMClock/fnClkRate+1, MMC Clk o/p = (MMC Clk Rt/2*(mmcClockRateDiv+1)) */
	status = MMCSD_setConfig( mmcsdConfig );
	if( status != E_PASS )
		return ( status );


	/* Identification cycle of MMC/SD */
	status = MMCSD_cardIdentification( mmcsdConfig, relCardAddr, cardStatus, MMCSD_OP_TIMEOUT,cardType );

	return ( status );
}

/**
    \brief  Read N Sectors of data from the MMC/SD card

    \param  phySector  Sector address on the card for performing read
    \param  dataBuffer  Buffer (must be 32-bit aligned) in which read data is received
    \param  numBlks  Number of sectors to be read from the MMC/SD card
    \param  dmaEnable if \c TRUE: DMA is enabled else if \c FALSE: DMA is disabled

    \return if success, \c E_PASS, else error code

*/
int MMCSD_readNSector( int phySector, char *dataBuffer, int numBlks, int dmaEnable )
{
	int status;

	//Check for 4-byte alignment of data
	if(dmaEnable)
	{
		if((Uint8)dataBuffer%4 )
		{
			return E_INVALID_INPUT;
		}
	}

	status = MMCSD_multipleBlkRead( (phySector*512), (Uint32*)dataBuffer, (Uint16)numBlks,(Bool)dmaEnable, 0 );

	return ( status );
}

/**
    \brief  Write N Sectors of data onto the MMC/SD card

    \param  phySector  Sector address on the card for performing write
    \param  dataBuffer  Buffer (must be 32-bit aligned) containing data to be written to the card
    \param  numBlks  Number of sectors to be written to the MMC/SD card

    \return if success, \c E_PASS, else error code

    \note MMCSD_DMA_ENABLE is a compiler option. If defined, DMA is used for data transfer
*/
int MMCSD_writeNSector( int phySector, char *dataBuffer, int numBlks, int dmaEnable )
{
	int status;

	//Check for 4-byte alignment of data
	if(dmaEnable)
	{
		if( (Uint8)dataBuffer%4 )
		{
			return E_INVALID_INPUT;
		}
	}
	status = MMCSD_multipleBlkWrite( (phySector*512), (Uint32*)dataBuffer, (Uint16)numBlks,(Bool)dmaEnable, 0 );

	return ( status );
}

/**
    \brief  MMC/SD interface selection, Controller and Card Initialization


    \return if success, \c E_PASS, else error code

*/

STATUS MMCSD_cardDetect()
{

   STATUS status = E_PASS;

   return(status);

}


/* Rev.No.   Date/Time               ECN No.          Modifier      */
/* -------   ---------               -------          --------      */

/* 1         24 Jun 2004 14:41:03    1864             xjarlika      */
/*                                                                  */
/* Checking in MMCSD drv include and src files                      */
/********************************************************************/
/* Rev.No.   Date/Time               ECN No.          Modifier      */
/* -------   ---------               -------          --------      */

/* 2          Jul 15:22:22 8         2049             xjarlika      */
/*                                                                  */
/* FIFOCTL renamed as MMCFIFOCTL                                    */
/* Update due to Register Name Change                               */
/********************************************************************/
/* Rev.No.   Date/Time               ECN No.          Modifier      */
/* -------   ---------               -------          --------      */

/* 3         13 Aug 2004 18:21:56    2296             xjarlika      */
/*                                                                  */
/* Updating MMCSD include and src file after inital testing on Hibari*/
/* Updating MMCSD include and src file after inital testing on Hibari*/
/********************************************************************/
/* Rev.No.   Date/Time               ECN No.          Modifier      */
/* -------   ---------               -------          --------      */

/* 4         24 Aug 2004 14:45:35    2401             xjarlika      */
/*                                                                  */
/* Updating MMCSD drv include and src files after testing on Hibari */
/********************************************************************/
/* Rev.No.   Date/Time               ECN No.          Modifier      */
/* -------   ---------               -------          --------      */

/* 5         14 Jan 2005 11:28:33    5879             xjarlika      */
/*                                                                  */
/* Updating after testing on DaVinci QT                             */
/********************************************************************/
/* Rev.No.   Date/Time               ECN No.          Modifier      */
/* -------   ---------               -------          --------      */

/* 6         21 Feb 2005 14:58:55    7286             xjarlika      */
/*                                                                  */
/* Updating MMC/SD and MS/MSPRO files for regression. Added code for enabling 3P3V I/O cells used for MMC/SD MS/MSPRO pins*/
/********************************************************************/

⌨️ 快捷键说明

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