1、简介
MMC卡: MultiMedia card,有 7 个触点( 引脚),分为两种操作模式,分别为 MMC模式与SPI 模式,两种模式对引脚的定义是不同的。SPI 模式只有 Host 具有SPI 接口时才能使用。MMC只具有存储功能,不像SD卡还具有加密功能。
SD卡: Security Digtial card,共有9 个触点( 引脚),多余的 2 个引脚为数据线,但使用与 MMC卡兼容的模式时,这两个多余的引脚没有起到作用。SD卡除了存储功能外,还有一种加密功能,但加密功能是收费的(所以开源的linux中只包含mmc的驱动目录),因为当初SD卡联盟中(索尼)就是发明这种卡就是用来存储音乐(淘汰卡带),并使用加密特性,防止拷贝。
TF卡:软件上SD卡一致,只是在硬件的体积上比SD卡西小,所以市场上很多的TF卡的SD外形卡套
SDIO卡:
3、SD卡协议
1.x:小于2GB的卡(但通过相关的软件,可以模拟实现大于2GB)
2.0: 2<SD卡<32 GB
3.0: >32GB
4、SD卡通信接口
SD卡有9个pin:1个VDD,2个VSS(GND),CLK,CMD,DATA0-DATA3, 【DATA3可以作为卡检测脚】
SD卡可以使用SD总线接口,也可以使用SPI通信接口;
SD总线接口描述:
CMD:Command is a bi-directional signal. (Host and card drivers are operating in push pull mode.) 【命令与响应都是走这条线】
DAT0-3:Data lines are bi-directional signals. (Host and card drivers are operating in push pull
CLK:Clock is a host to cards signal. (CLK operates in push pull mode.)
VDD:VDD is the power supply line for all cards.
VSS[1:2]:VSS are two ground lines.
SPI接口描述:
CS:Host to card Chip Select signal.
CLK:Host to card clock signal.
DataIn:Host to card data signal.
DataOut:Card to host data signal.
5、SD卡内部结构
上电初始化需要1ms或者74 CLOCK(SD卡的clock,400KHZ)两者大致,SD卡的电压上到2.0V,SD卡开始工作,此时支持的命令非常有限(其中最主要支持ACMD41命令,sd host问卡的操作电压时多少? 卡就会从它的OCR寄存器里面读出SD卡出厂就烧录在里面的卡的操作电压值返回给sd host),当电压调整到它要求的VDD时候(SD卡的工作电压在2.7~3.6V,常见3.3V),同时SD的CLK从400KHZ调整到更高频率(比如25MHZ),这时卡就完全正常的工作了。接下来可以去获取卡的生产厂家,容量等信息。
最多支持64个命令: CMD0~CMD63,(其中CMD57~63是保留的)
ACMD: Application Sepcific command:
ACMD41 =cmd55 + cmd41,组合命令,CMD55是前导命令,提醒卡后面的CMD41是一个特殊的命令
命令的类型
广播命令(bc,bcr)——广播命令发送给所有SD卡,有些命令需要响应。
寻址(点对点)命令
(ac,adtc)
——
寻址命令只发送给具有相应地址的卡,并
需要从卡返回一个响应。
R1 (standard response): response length 48 bit
R1b is identical to R1 with an optional busy signal transmitted on the data line
R2 (CID, CSD register): response length 136 bits. The content of the CID register is sent as a response to CMD2 and CMD10. The content of the CSD register is sentas a response to CMD9.
R3 (OCR register): response length 48 bits. The contents of the OCR register are sent as a response to ACMD41.
R4~R5: responses are not supported.
R6:(Published RCA response): code length 48-bit, response to CMD3
