s3c2410平台SD卡驱动分析

s3c2410平台SD卡驱动分析

(转自:http://blog.chinaunix.net/u2/79779/showart_1898352.html)

 

 

先了解一下SD卡工作的总体流程

1:  SD Memory Card state diagram (card identification mode)

2:  SD Memory Card state diagram (data transfer mode)

按照S3C2410 datasheet上介绍:

先配置几个SD卡使用的I/O口,看I/O口介绍那章就知道,都要配置成10咯

GPE10 [21:20] 00 = Input 01 = Output 10 = SDDAT3 11 = Reserved

GPE9 [19:18] 00 = Input 01 = Output 10 = SDDAT2 11 = Reserved

GPE8 [17:16] 00 = Input 01 = Output 10 = SDDAT1 11 = Reserved

GPE7 [15:14] 00 = Input 01 = Output 10 = SDDAT0 11 = Reserved

GPE6 [13:12] 00 = Input 01 = Output 10 = SDCMD 11 = Reserved

GPE5 [11:10] 00 = Input 01 = Output 10 = SDCLK 11 = Reserved

然后初始化SD卡控制寄存器

1. Set SDICON to configure properly with clock and interrupt.

2. Set SDIPRE to configure with a proper value.

3. Wait 74 SDCLK clock cycle in order to initialize the card.

要是要给SD卡发命令,就按以下几个步骤来办

1. Write command argument (32-bit) to SDICARG register.

2. Determine command types and start command by setting SDICCON[8].

 3. Confirm the end of SDI command operation when the specific flag of SDICSTA is set. — If the type of command is no-response, the flag is SDICSTA[11]. — If the type of command is with-response, the flag is SDICSTA[9].

4. Clear the corresponding flag of the SDICSTA register by writing one to the flag bit.

跟SD读取和写入数据时,就按照以下几步来

1. Write timeout period to SDIDTIMER register.

2. Write block size (block length) to SDIBSIZE register (normally 0x200 byte).

3. Determine the mode of block, wide bus, DMA, etc. and start data transfer with setting SDIDCON register.

4. Write Tx-data to SDIDAT register while Tx FIFO is available by checking SDIFSTA (available, half or empty) register.

5. Read Rx-data from SDIDAT register while Rx FIFO is available by checking SDIFSTA (available, half or be last data) register.

6. Confirm the end of SDI data operation when the flag of data transfer finish (SDIDSTA[4]) is set.

7. Clear the corresponding flag of SDIDSTA register by writing one to the flag bit.

 

 原文地址 http://sniper167.bokee.com/6023408.html

你可能感兴趣的:(c,command,input,平台,output,Types)