Summary |
#include <file_config.h>
BOOL SetDma ( /* Optional, NULL for local or non DMA */
U32 mode, /* DMA mode read or write */
U8* buf, /* Buffer location with/for the data */
U32 cnt); /* Number of blocks to read or write */
|
Description |
The function SetDma function sets the DMA mode for sending
or receiving data.
The parameter mode specifies the requested DMA
mode:
Mode |
Description |
DMA_READ |
Setup DMA for reading from SD Memory Card. |
DMA_WRITE |
Setup DMA for writing to SD Memory Card. |
The parameter buf is a pointer to the buffer
that holds the data. The parameter cnt specifies
the number of block to be read or written.
The function is part of the MCI
Driver. The prototype is defined in the file
File_Config.h. Developers must customize the function.
The MCI Driver functions are called in the following sequence to
read or write data:
-
SetDma - sets the DMA to write or read data.
This can be used if DMA must be set prior to sending an SD
command.
-
Command - sends a write or read command to SD Memory
Card.
-
WriteBlock - writes a block of data to SD Memory Card
or
ReadBlock - reads a block of data from SD Memory Card.
|
Example |
/* MCI Device Driver Control Block */
MCI_DRV mci0_drv = {
Init,
UnInit,
Delay,
BusMode,
BusWidth,
BusSpeed,
Command,
ReadBlock,
WriteBlock,
SetDma,
CheckMedia
};
/* Configure DMA for read or write. */
static BOOL SetDma (U32 mode, U8 *buf, U32 cnt) {
pMCI->MCI_CR = AT91C_MCI_MCIDIS;
pMCI->MCI_PTCR = AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS;
pMCI->MCI_BLKR = (512 << 16) | cnt;
if (mode == DMA_READ) { /* Transfer data from card to memory. */
pMCI->MCI_RPR = (U32)buf;
pMCI->MCI_RCR = (512 >> 2) * cnt;
pMCI->MCI_PTCR = AT91C_PDC_RXTEN;
}
else { /* Transfer data from memory to card. */
pMCI->MCI_TPR = (U32)buf;
pMCI->MCI_TCR = (512 >> 2) * cnt;
}
return (__TRUE);
}
/* MCI Device Driver Control Block omitting SetDma*/
MCI_DRV mci0_drv = {
Init,
UnInit,
Delay,
BusMode,
BusWidth,
BusSpeed,
Command,
ReadBlock,
WriteBlock,
NULL,
CheckMedia
};
|