1.35.5.3 1.36.8.3 MEM2MEM_ChannelTransfer Function

C

bool MEM2MEM_ChannelTransfer(const void *srcAddr, const void *destAddr, size_t blockSize, MEM2MEM_TRANSFER_WIDTH twidth)

Summary

Registers a DMA transfer using MEM2MEM.

Description

This function schedules a DMA transfer and starts the transfer.

The srcAddr parameter specifies the source address from where data will be transferred. Once the transfer is registered the module will transfer blockSize of data from the source address in twidth chunks.

If the requesting client registered a callback function before calling the channel transfer function, this function will be called when the transfer completes. The callback function will be called with a MEM2MEM_TRANSFER_COMPLETE event if the transfer was processed successfully and a MEM2MEM_TRANSFER_ERROR event if the transfer was not processed successfully.

When already a transfer is in progress, this API will return false indicating that transfer request is not accepted.

Precondition

None.

Parameters

Param Description
srcAddr Source address of the MEM2MEM transfer
destAddr Destination address of the MEM2MEM transfer
blockSize Size of the transfer block in bytes
twidth chank size for the transfer

Returns

True - If transfer request is accepted.

False - If previous transfer is in progress and the request is rejected.

Example

// Transfer 10 bytes of data from one buffer to another using MEM2MEM
MY_APP_OBJ myAppObj;
uint8_t buf[10] = {0,1,2,3,4,5,6,7,8,9};
uint8_t buf_sdram[10] = {};
    void *srcAddr = (uint8_t *) buf;
    void *destAddr = (uin8_t*) buf2;
    size_t size = 10;
    
    // User registers an event handler with PLIB. This is done once.
    MEM2MEM_ChannelCallbackRegister(APP_MEM2MEMTransferEventHandler,
    (uintptr_t)&myAppObj);
    
    if(MEM2MEM_ChannelTransfer(srcAddr, destAddr, size, MEM2MEM_TRANSFER_WIDTH_BYTE) == true)
    {
        // do something
    }
    else
    {
        // try again?
    }

Remarks

None.