/*
* Copyright 2004 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*/
/*
*---------mmc_sd_setup.c---------
* This example initializes the MMC controller and reads data from the CSD
* depending on whether an MMC or SD card is chosen
* This example is written for c5509. To run on c5509a, link in the
* c5509a CSL library and define CHIP_5509A in the build options
*/
/* What we do in this example.
*
* The MMC Controller supports both an MMC and an SD card. During the initialization,
* we first check if the card is an SD card and initialize accordingly. Then onwards,
* a sequence of instructions is to be passed to traverse it's state machine and bring
* it to a data transfer state. The MMC and SD card initialization sequence varies when
* it comes to the Relative Card Address, which is used by the host to communicate with
* a particular card. The MMC card has to be sent an RCA from the host, while the SD card
* publishes it's own RCA and sends it to the host.
*
* NOTE: The EVM5509 MMC Controller can be operated only in the Native mode. Support for
* SPI mode is now obsolete and the MMC CSL source has been modified accordingly.
*
* Data Structures used-
* - MMC_Handle :
* Structure that contains information about the device chosen.
* Important fields are eventId (CPU interrupt line for MMC device),
* MMC ISR Dispatcher address to be plugged as ISR for the MMC,
* pointer to MMC registers and a pointer to the call back table
* holding functions, one of which is called when the ISR is hit
* (the interrupt example offers more explanation on MMC interrupts)
*
* - MMC_CardObj :
* Structure that holds information about the card. Important fields
* are rca (Relative Card Address), manufacturer's card ID and pointers
* to an MMC CSD structure and an SD CSD structure, one of which will
* be used based on which card is being accessed.
*
* - MMC_CardIdObj :
* Structure that holds the manufacturer's Card Id present on the card.
* This information is read-only.
*
* _ MMC_CardCsdObj :
* Structure that holds the card specific data provided on an MMC Card.
* This information is read-only.
*
* - SD_CardCsdObj :
* Structure that holds the card specific data provided on an SD Card.
* This information is read-only.
*
*/
#include <csl_pll.h>
#include <csl_mmc.h>
#include <stdio.h>
//#pragma DATA_SECTION(mmc0,"cslmem")
MMC_Handle mmc0;
MMC_CardObj *card, cardalloc;
MMC_CardIdObj *cid, cardid;
MMC_CardCsdObj *csd, cardcsd;
SD_CardCsdObj *sdcsd, sdcardcsd;
MMC_Config test;
int retVal,count;
Uint16 rca;
Uint16 cardtype;
Uint16 taac, naac, tranSpeed, readBlLen, readBlPartial;
Uint16 writeBlkMisalign, readBlkMisalign, writeBlLen, writeBlPartial;
PLL_Config myConfig = {
0, //IAI: the PLL locks using the same process that was underway
//before the idle mode was entered
1, //IOB: If the PLL indicates a break in the phase lock,
//it switches to its bypass mode and restarts the PLL phase-locking
//sequence
12, //PLL multiply value; multiply 24 times
1 //Divide by 2 PLL divide value; it can be either PLL divide value
//(when PLL is enabled), or Bypass-mode divide value
//(PLL in bypass mode, if PLL multiply value is set to 1)
};
/* Because of different operating clock frequencies, the Init structure for c5509 *
* and c5509a have different values for memory and function clock divide down values */
#if CHIP_5509A
MMC_SetupNative Init = {
0, /* disable DMA for data read/write */
0, /* Set level of edge detection for DAT3 pin */
0, /* Determines if MMC goes IDLE during IDLE instr */
0, /* Memory clk reflected on CLK Pin */
7, /* CPU CLK to MMC function clk divide down */
5, /* MMC function clk to memory clk divide down */
0, /* No. memory clks to wait before response timeout */
0, /* No. memory clks to wait before data timeout */
512, /* Block Length must be same as CSD */
};
#else
MMC_SetupNative Init = {
0, /* disable DMA for data read/write */
0, /* Set level of edge detection for DAT3 pin */
0, /* Determines if MMC goes IDLE during IDLE instr */
0, /* Memory clk reflected on CLK Pin */
7, /* CPU CLK to MMC function clk divide down */
5, /* MMC function clk to memory clk divide down */
0, /* No. memory clks to wait before response timeout */
0, /* No. memory clks to wait before data timeout */
512, /* Block Length must be same as CSD */
};
#endif
void main()
{
CSL_init();
//PLL_config(&myConfig);
printf ("MMC Controller setup test...\n");
/* The MMC shares a event line with McBSP. In this function, we *
* - reserve the system event line for MMC *
* - initialize the handle with data about register locations, *
* event id and other device details *
* - initialize the dispatcher for the device to point to the *
* dispatcher for the MMC device instance */
/* Prototype: MMC_open(<device instance>); *
* We choose device 1 on the board */
mmc0 = MMC_open(MMC_DEV1);
/* In this function, we initialize the MMC registers with the *
* parameters passed in the Init structure *
* Prototype: MMC_setupNative(Handle, MMC_setupNative*); */
MMC_setupNative(mmc0,&Init); //initialize the MMC controller
/* Ask all cards to go to idle state. This is equivalent to a *
* s/w reset. *
* Prototype: MMC_sendGoIdle(Handle); */
MMC_getConfig(mmc0,&test);
MMC_sendGoIdle(mmc0);
for (count=0;count<4016;count++)
asm(" NOP");
/* Set the voltage window for the card. If the card does not *
* support this voltage range, it will return -1. *
* *
* Working: *
* We first send an APP_CMD. An SD card responds to this command *
* while an MMC does not. If the card responds, we now send the *
* ACMD41 to initialize the SD card with the desiered voltage *
* range. If there is no response, we send the CMD1 to initialize *
* the MMC card with the desired voltage range. *
* *
* Return Value: *
* If an MMC card is identified, it returns 0. *
* If an SD card is identified, it returns 1. *
* If the voltage range is not supported or the card does not *
* initialize correctly, it returns -1. */
cardtype = MMC_sendOpCond(mmc0,0x00100000);
if (cardtype == 0xFFFF){
printf ("Card not recognized\n");
exi
SD.zip_dsp sd
版权申诉
165 浏览量
2022-09-23
12:58:25
上传
评论
收藏 191KB ZIP 举报
邓凌佳
- 粉丝: 65
- 资源: 1万+
最新资源
- 小蚁1080p固件,msc313主控
- Java输出先序遍历二叉树的代码
- 【资源免费分享】基于51单片机锂电池电压电流容量检测仪表液晶显示设计(含源程序+原理图+PCB图+实物图+演示视频+论文等)
- 断网攻击.txt
- 基于java开发的声纹识别解锁系统,一款使用声纹加密Android APP的应用+源码(毕业设计&课程设计&项目开发)
- Pywinauto-0.6.8 学习总结笔记 Windows 电脑端软件GUI鼠标键盘Python自动化办公测试、重复性工作运维
- 基于matlabi解抛物型方程的交替隐方向P-R差分格式的实现
- 【资源免费分享】基于51单片机的函数信号发生器的设计(含源程序+原理图+仿真图+实物图+视频及演示讲解+使用说明+开题报告等)
- Java输出二叉树先序遍历代码
- C&prr111111
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0