- Main Page
- Modules
- Data Structures
- Files

Functions
DMA Functions
DMA

## Functions
CSL_Status | DMA_init (void)
CSL_DMA_Handle | DMA_open (CSL_DMAChanNum chanNum, CSL_DMA_ChannelObj *pDmaChanObj, CSL_Status *status)
CSL_Status | DMA_close (CSL_DMA_Handle hDMA)
CSL_Status | DMA_config (CSL_DMA_Handle hDMA, CSL_DMA_Config *pConfig)
CSL_Status | DMA_getConfig (CSL_DMA_Handle hDMA, CSL_DMA_Config *pConfig)
CSL_Status | DMA_start (CSL_DMA_Handle hDMA)
CSL_Status | DMA_stop (CSL_DMA_Handle hDMA)
CSL_Status | DMA_reset (CSL_DMA_Handle hDMA)
CSL_Status | DMA_swapWords (Uint16 *dataBuffer, Uint32 dataLength)
Bool | DMA_getLastTransferType (CSL_DMA_Handle hDMA, CSL_Status *status)

## Function Documentation

CSL_Status DMA_close | ( | CSL_DMA_Handle | hDMA | ) |

===========================================================================
DMA_close

Description
This function closes the specified handle to DMA.

Arguments

                hDMA            Handle to the DMA

Return Value CSL_Status

- CSL_SOK - Close successful
- CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
DMA_open() must be called before this function call.

Post Condition
After calling this function no other API should be call for the same dma Handle.

Modifies
1. The DMA register will assigned to reset values for this handle.
2. CSL_DMA_ChannelObj object structure

Example

                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj
                CSL_DMA_Handle       hDMA;
                ...

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);

                status = DMA_Close(hDMA);

===========================================================================

References CSL_DMA_CHANNEL_FREE, CSL_DMA_ChannelObj::dmaRegs, and CSL_DMA_ChannelObj::isChanFree.

Referenced by MMC_close().

CSL_Status DMA_config | ( | CSL_DMA_Handle | hDMA,
|  | CSL_DMA_Config * | pConfig
| ) |  |

===========================================================================
DMA_config

Description
It configures the DMA Controller registers of particular handle as per the values passed in the DMA config structure.

Arguments

                hDMA            Handle to the DMA.
                Config          Pointer to DMA Config structure.

Return Value CSL_Status

- CSL_SOK - Hardware setup successful
- CSL_ESYS_BADHANDLE - Invalid handle
- CSL_ESYS_INVPARAMS - Congig Parameter is invalid.

Pre Condition
DMA_open() must be called successfully before this function call.

Post Condition
None

Modifies
1. DMA registers will be updated as per config parameter
2. CSL_DMA_ChannelObj Object will be updated to store some info as passed config parameter.

Example

            #define CSL_DMA_BUFFER_SIZE 1024

                CSL_DMA_Handle       hDMA;
                CSL_DMA_Config       pConfig;
                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj

                Uint16 dmaSRCBuff[CSL_DMA_BUFFER_SIZE];
                Uint16 dmaDESTBuff[CSL_DMA_BUFFER_SIZE];
                ...

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);

    #if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514))
                pConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE;
    #endif

                pConfig.autoMode     = CSL_DMA_AUTORELOAD_DISABLE;
                pConfig.burstLen     = CSL_DMA_TXBURST_8WORD;
                pConfig.trigger      = CSL_DMA_SOFTWARE_TRIGGER;
                pConfig.dmaEvt       = CSL_DMA_EVT_NONE;
                pConfig.dmaInt       = CSL_DMA_INTERRUPT_DISABLE;
                pConfig.chanDir      = CSL_DMA_READ;
                pConfig.trfType      = CSL_DMA_TRANSFER_MEMORY;
                pConfig.dataLen      = CSL_DMA_BUFFER_SIZE * 2;
                pConfig.srcAddr      = (Uint32)dmaSRCBuff;
                pConfig.destAddr     = (Uint32)dmaDESTBuff;

                status = DMA_Config(hDMA, &pConfig);
                ...

===========================================================================

References CSL_DMA_Config::autoMode, CSL_DMA_Config::burstLen, CSL_DMA_Config::chanDir, CSL_DMA_ChannelObj::chanDir, CSL_DMA_ChannelObj::chanNum, CSL_DMA_ADDR_MODE_FIXED, CSL_DMA_ADDR_MODE_INCREMENT, CSL_DMA_ADDR_SHIFT, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN10, CSL_DMA_CHAN11, CSL_DMA_CHAN12, CSL_DMA_CHAN13, CSL_DMA_CHAN14, CSL_DMA_CHAN15, CSL_DMA_CHAN2, CSL_DMA_CHAN3, CSL_DMA_CHAN4, CSL_DMA_CHAN5, CSL_DMA_CHAN6, CSL_DMA_CHAN7, CSL_DMA_CHAN8, CSL_DMA_CHAN9, CSL_DMA_DARAM_ADDR_OFFSET, CSL_DMA_DARAM_END_ADDR, CSL_DMA_DARAM_START_ADDR, CSL_DMA_DMATCR2_DMASTART_SYNC_MASK, CSL_DMA_PING_PONG_ENABLE, CSL_DMA_READ, CSL_DMA_SARAM_ADDR_OFFSET, CSL_DMA_SARAM_END_ADDR, CSL_DMA_SARAM_START_ADDR, CSL_DMA_TRANSFER_MEMORY, CSL_DMA_UINT16_MASK, CSL_DMA_UINT16_NUMBER_BITS, CSL_DMA_WRITE, CSL_DMA_Config::dataLen, CSL_DMA_Config::destAddr, CSL_DMA_Config::dmaEvt, CSL_DMA_Config::dmaInt, CSL_DMA_ChannelObj::dmaInt, CSL_DMA_ChannelObj::dmaRegs, CSL_DMA_ChannelObj::pingPongEnabled, CSL_DMA_Config::pingPongMode, CSL_DMA_Config::srcAddr, CSL_DMA_Config::trfType, CSL_DMA_ChannelObj::trfType, CSL_DMA_Config::trigger, and CSL_DMA_ChannelObj::trigger.

Referenced by MMC_read(), and MMC_write().

CSL_Status DMA_getConfig | ( | CSL_DMA_Handle | hDMA,
|  | CSL_DMA_Config * | pConfig
| ) |  |

===========================================================================
DMA_getConfig

Description
Gets the config information for the different operations of DMA.

Arguments

                hDMA            Handle to the DMA
                Config          Pointer to DMA Config structure

Return Value CSL_Status

- CSL_SOK - Both Parametrs are valid.
- CSL_ESYS_BADHANDLE - Invalid handle
- CSL_ESYS_INVPARAMS - invalid Congig Pointer.

Pre Condition
DMA_open() must be called successfully before this function call.

Post Condition
None

Modifies
1. The Config pointer will be updated to store the DMA Register information as per DMA Handle passed.

Example

                CSL_DMA_Handle       hDMA;
                CSL_DMA_Config       pConfig;
                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);

                status = DMA_getConfig(hDMA, &pConfig);

===========================================================================

References CSL_DMA_Config::autoMode, CSL_DMA_Config::burstLen, CSL_DMA_ChannelObj::chanDir, CSL_DMA_Config::chanDir, CSL_DMA_ChannelObj::chanNum, CSL_DMA_ADDR_SHIFT, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN10, CSL_DMA_CHAN11, CSL_DMA_CHAN12, CSL_DMA_CHAN13, CSL_DMA_CHAN14, CSL_DMA_CHAN15, CSL_DMA_CHAN2, CSL_DMA_CHAN3, CSL_DMA_CHAN4, CSL_DMA_CHAN5, CSL_DMA_CHAN6, CSL_DMA_CHAN7, CSL_DMA_CHAN8, CSL_DMA_CHAN9, CSL_DMA_DARAM_ADDR_OFFSET, CSL_DMA_READ, CSL_DMA_SARAM_ADDR_OFFSET, CSL_DMA_TRANSFER_MEMORY, CSL_DMA_UINT16_NUMBER_BITS, CSL_DMA_WRITE, CSL_DMA_Config::dataLen, CSL_DMA_Config::destAddr, CSL_DMA_Config::dmaEvt, CSL_DMA_Config::dmaInt, CSL_DMA_ChannelObj::dmaRegs, CSL_DMA_Config::pingPongMode, CSL_DMA_Config::srcAddr, CSL_DMA_ChannelObj::trfType, CSL_DMA_Config::trfType, CSL_DMA_ChannelObj::trigger, and CSL_DMA_Config::trigger.

Bool DMA_getLastTransferType | ( | CSL_DMA_Handle | hDMA,
|  | CSL_Status * | status
| ) |  |

===========================================================================
DMA_getLastTransferType

Description
This function returns type of the last trasfer during Ping-Pong buffer mode. This function will return a 1 or 0. In ping-pong buffer mode with reload enabled, DMA data transfer keeps switching between Ping and Pong data buffers. This function is used to know which buffer is transferred by DMA in the last transfer. 0 - Ping Set Transfer completed 1 - Pong Set Transfer completed

Arguments

                hDMA      Handle to the DMA
                status    Status variable to update function Success/Failure status

Return Value CSL_Status

- 0 - Ping Set Transfer completed
- 1 - Pong Set Transfer completed

Pre Condition
DMA_start() must be called successfully before this function call

Post Condition
Returns last transfer status

Modifies
none

Example

                CSL_DMA_Handle    hDMA;
                CSL_Status        status;
                Bool              txStatus;

                status = DMA_start(hDMA);

                status = DMA_getLastTransferType(hDMA, &status);

===========================================================================

===========================================================================
DMA_getLastTransferStatus

Description
This function returns status of the last trasfer during Ping-Pong buffer mode. This function will return a 1 or 0. In ping-pong buffer mode with reload enabled, DMA data transfer keeps switching between Ping and Pong data buffers. This function is used to know which buffer is transferred by DMA in the last transfer. 0 - Ping Set Transfer completed 1 - Pong Set Transfer completed

Arguments

                hDMA      Handle to the DMA
                status    Status variable to update function Success/Failure status

Return Value CSL_Status

- 0 - Ping Set Transfer completed
- 1 - Pong Set Transfer completed

Pre Condition
DMA_start() must be called successfully before this function call

Post Condition
Returns last transfer status

Modifies
none

Example

                CSL_DMA_Handle    hDMA;
                CSL_Status        status;
                Bool              txStatus;

                status = DMA_start(hDMA);

                status = DMA_getLastTransferStatus(hDMA, &status);

===========================================================================

References CSL_DMA_ChannelObj::chanNum, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN2, CSL_DMA_CHAN3, and CSL_DMA_ChannelObj::dmaRegs.

CSL_Status DMA_init | ( | void |  | ) |

===========================================================================
DMA_init

Description
This is the initialization function for the DMA CSL. The function must be called before calling any other API from this CSL. This function is for enabling the clock to the DMA Controller. Currently, the function just return status CSL_SOK. This function should be called only once during system initialization time. This function gates the clock for all the four DMA modules. Application programs may disable the clocks for DMA modules which are are not in use.

Arguments

Return Value CSL_Status

- CSL_SOK - Always returns

Pre Condition
This should be call first before calling any other DMA Function.

Post Condition
None

Modifies
None

Example

                CSL_status       status;

                status = DMA_init();

===========================================================================

References CSL_DMA_RESET_CLOCK_CYCLE.

CSL_DMA_Handle DMA_open | ( | CSL_DMAChanNum | chanNum,
|  | CSL_DMA_ChannelObj * | pDmaChanObj,
|  | CSL_Status * | status
| ) |  |

===========================================================================
DMA_open

Description
This function returns the handle to the DMA instance. This handle is passed to all other CSL APIs.

Arguments

                chanNum     channel number to use.
                pDmaChanObj pointer to dma channel object.
                status      Status of the function call

Return Value CSL_DMA_Handle
Valid DMA handle will be returned if status value is equal to CSL_SOK.

Pre Condition
DMA_init() API should be called before DMA_open().

Post Condition
1. The status is updated in the status variable. If status returned is

- CSL_SOK - Valid DMA handle is returned
- CSL_ESYS_INVPARAMS - Invalid parameter
  2. CSL_DMA_ChannelObj object structure is populated

Modifies
1. The status variable
2. CSL_DMA_ChannelObj object structure

Example

                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj
                CSL_DMA_Handle       hDMA;
                ...

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);
                ...

===========================================================================

References CSL_DMA_ChannelObj::chanDir, CSL_DMA_ChannelObj::chanNum, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN10, CSL_DMA_CHAN11, CSL_DMA_CHAN12, CSL_DMA_CHAN13, CSL_DMA_CHAN14, CSL_DMA_CHAN15, CSL_DMA_CHAN2, CSL_DMA_CHAN3, CSL_DMA_CHAN4, CSL_DMA_CHAN5, CSL_DMA_CHAN6, CSL_DMA_CHAN7, CSL_DMA_CHAN8, CSL_DMA_CHAN9, CSL_DMA_CHAN_INV, CSL_DMA_CHANNEL_BUSY, CSL_DMA_ENGINE0, CSL_DMA_ENGINE1, CSL_DMA_ENGINE2, CSL_DMA_ENGINE3, CSL_DMA_READ, CSL_DMA_SOFTWARE_TRIGGER, CSL_DMA_TRANSFER_MEMORY, CSL_DMA_ChannelObj::dmaInstNum, CSL_DMA_ChannelObj::dmaRegs, CSL_DMA_ChannelObj::isChanFree, CSL_DMA_ChannelObj::trfType, and CSL_DMA_ChannelObj::trigger.

CSL_Status DMA_reset | ( | CSL_DMA_Handle | hDMA | ) |

===========================================================================
DMA_reset

Description
Function reset all the register as per passed handle.

Arguments

                hDMA            Handle to the DMA

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
1. DMA_open() must be called successfully before this function call

Post Condition
None

Modifies
DMA Register will be populated with the reset values.

Example

                CSL_DMA_Handle       hDMA;
                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);

                status = DMA_reset(hDMA);

===========================================================================

References CSL_DMA_ChannelObj::chanNum, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN10, CSL_DMA_CHAN11, CSL_DMA_CHAN12, CSL_DMA_CHAN13, CSL_DMA_CHAN14, CSL_DMA_CHAN15, CSL_DMA_CHAN2, CSL_DMA_CHAN3, CSL_DMA_CHAN4, CSL_DMA_CHAN5, CSL_DMA_CHAN6, CSL_DMA_CHAN7, CSL_DMA_CHAN8, CSL_DMA_CHAN9, and CSL_DMA_ChannelObj::dmaRegs.

CSL_Status DMA_start | ( | CSL_DMA_Handle | hDMA | ) |

===========================================================================
DMA_start

Description
This function trigger to DMA for data transfer.

Arguments

                hDMA            Handle to the DMA

Return Value CSL_Status

- CSL_SOK - Start successful
- CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
DMA_config API must be called before calling this API for same handle.

Post Condition
None

Modifies
Destination buffer will be modified after this call.

Example

            #define CSL_DMA_BUFFER_SIZE 1024

                CSL_DMA_Handle       hDMA;
                CSL_DMA_Config       pConfig;
                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj

            Uint16 dmaSRCBuff[CSL_DMA_BUFFER_SIZE];
            Uint16 dmaDESTBuff[CSL_DMA_BUFFER_SIZE];

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);

    #if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514))
                pConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE;
    #endif

                pConfig.autoMode     = CSL_DMA_AUTORELOAD_DISABLE;
                pConfig.burstLen     = CSL_DMA_TXBURST_8WORD;
                pConfig.trigger      = CSL_DMA_SOFTWARE_TRIGGER;
                pConfig.dmaEvt       = CSL_DMA_EVT_NONE;
                pConfig.dmaInt       = CSL_DMA_INTERRUPT_DISABLE;
                pConfig.chanDir      = CSL_DMA_READ;
                pConfig.trfType      = CSL_DMA_TRANSFER_MEMORY;
                pConfig.dataLen      = CSL_DMA_BUFFER_SIZE * 2;
                pConfig.srcAddr      = (Uint32)dmaSRCBuff;
                pConfig.destAddr     = (Uint32)dmaDESTBuff;

                status = DMA_Config(hDMA, &pConfig);

                status = DMA_start (hDMA);

===========================================================================

Parameters:

  hDMA | Pointer to the object that holds reference to the DMA handle object.

References CSL_DMA_ChannelObj::chanNum, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN2, CSL_DMA_CHAN3, CSL_DMA_CHANNEL_ENABLE, CSL_DMA_DMATCR2_DMASTART_SYNC_MASK, CSL_DMA_EVENT_TRIGGER, CSL_DMA_ChannelObj::dmaRegs, and CSL_DMA_ChannelObj::trigger.

Referenced by MMC_read(), and MMC_write().

CSL_Status DMA_stop | ( | CSL_DMA_Handle | hDMA | ) |

===========================================================================
DMA_stop

Description
This function set the DMA controller for not transfering the data.

Arguments

                hDMA            Handle to the DMA

Return Value CSL_Status

- CSL_SOK - Stop successful
- CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
1. DMA_open() must be called successfully before this function call 2. Call DMA_config() for the handle return by DMA_open() 3. call DMA_start() and in the mean while call DMA_stop() if transfer is not required.

Post Condition
None

Modifies
None

Example

            #define CSL_DMA_BUFFER_SIZE 1024

                CSL_DMA_Handle       hDMA;
                CSL_DMA_Config       pConfig;
                CSL_status           status;
                CSL_DMAChanNum       chanNum;
                CSL_DMA_ChannelObj   pDmaChanObj

            Uint16 dmaSRCBuff[CSL_DMA_BUFFER_SIZE];
            Uint16 dmaDESTBuff[CSL_DMA_BUFFER_SIZE];

                chanNum = CSL_DMA_CHAN0;
                hDMA = DMA_open(chanNum, &pDmaChanObj, &status);

    #if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514))
                pConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE;
    #endif

                pConfig.autoMode     = CSL_DMA_AUTORELOAD_DISABLE;
                pConfig.burstLen     = CSL_DMA_TXBURST_8WORD;
                pConfig.trigger      = CSL_DMA_SOFTWARE_TRIGGER;
                pConfig.dmaEvt       = CSL_DMA_EVT_NONE;
                pConfig.dmaInt       = CSL_DMA_INTERRUPT_DISABLE;
                pConfig.chanDir      = CSL_DMA_READ;
                pConfig.trfType      = CSL_DMA_TRANSFER_MEMORY;
                pConfig.dataLen      = CSL_DMA_BUFFER_SIZE * 2;
                pConfig.srcAddr      = (Uint32)dmaSRCBuff;
                pConfig.destAddr     = (Uint32)dmaDESTBuff;

                status = DMA_Config(hDMA, &pConfig);

                status = DMA_start (hDMA);

                status = DMA_stop (hDMA);

===========================================================================

Parameters:

  hDMA | Pointer to the object that holds reference to the DMA handle object.

References CSL_DMA_ChannelObj::chanNum, CSL_DMA_CHAN0, CSL_DMA_CHAN1, CSL_DMA_CHAN2, CSL_DMA_CHAN3, CSL_DMA_CHANNEL_DISABLE, CSL_DMA_DMATCR2_DMASTART_SYNC_MASK, CSL_DMA_EVENT_TRIGGER, CSL_DMA_ChannelObj::dmaRegs, and CSL_DMA_ChannelObj::trigger.

Referenced by MMC_read(), and MMC_write().

CSL_Status DMA_swapWords | ( | Uint16 * | dataBuffer,
|  | Uint32 | dataLength
| ) |  |

===========================================================================
DMA_swapWords

Description
This function swaps words in a given buffer

Arguments

                dataBuffer    Pointer to the buffer which words needs to be swaped
                dataLength    Length of the valid data buffer in the buffer

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_INVPARAMS - Invalid parameters

Pre Condition
None

Post Condition
Swaps the words in the given buffer

Modifies
Order of data in the given buffer

Example

                #define DMA_BUF_SIZE (256)

                Uint16        dmaBuf [DMA_BUF_SIZE];
                CSL_Status    status;

                status = DMA_swapWords (dmaBuf, DMA_BUF_SIZE);

===========================================================================

Referenced by MMC_read(), and MMC_write().