Пример #1
0
//------------------------------------------------------------------------------
/// Configure the DMA transfer control infomation.
/// \param channel Particular channel number.
/// \param bufSize Buffer transfer size in byte.
/// \param sourceWidth Source transfer width.
/// \param destWidth Destination transfer width.
/// \param sourceAddress Destination transfer width.
/// \param destAddress Destination transfer width.
//------------------------------------------------------------------------------
unsigned char DMAD_Configure_TransferController(unsigned char channel,
                                      unsigned int bufSize,
                                      unsigned char sourceWidth,
                                      unsigned char destWidth,
                                      unsigned int sourceAddress,
                                      unsigned int destAddress)
{
    DmaTransfer *pTransfer = &(dmad.transfers[channel]);
    // Check that no transfer is pending on the channel
    if (pTransfer-> transferSize > 0 ) {
        TRACE_ERROR("DAM transfer is already pending\n\r");
        return DMAD_ERROR_BUSY;
    }
    pTransfer->bufSize = bufSize; 
    
    // Set up the transfer width and transfer size.
    DMA_SetSourceBufferSize(channel, bufSize, sourceWidth, destWidth, 0);

    if(sourceAddress) {
        // Write the starting source address.
        DMA_SetSourceAddr(channel, sourceAddress);
    }
    if(destAddress){
        // Write the starting destination address.
        DMA_SetDestinationAddr(channel, destAddress);
    }
    return 0;
}                                 
Пример #2
0
//------------------------------------------------------------------------------
/// Configure the DMA transfer control infomation.
/// \param channel Particular channel number.
/// \param bufSize Buffer transfer size in byte.
/// \param sourceWidth Source transfer width.
/// \param destWidth Destination transfer width.
/// \param sourceAddress Destination transfer width.
/// \param destAddress Destination transfer width.
//------------------------------------------------------------------------------
U8 DMAD_Configure_TransferController(U8 channel, U32 bufSize, U8 sourceWidth, U8 destWidth, U32 sourceAddress, U32 destAddress)
{
	DmaTransfer *pTransfer = &(dmad.transfers[channel]);
	
	if(pTransfer-> transferSize > 0) // Check that no transfer is pending on the channel
	{
		DEBUG_MSG("DAM transfer is already pending");
		return DMAD_ERROR_BUSY;
	}
	pTransfer->bufSize = bufSize; 
	DMA_SetSourceBufferSize(channel, bufSize, sourceWidth, destWidth, 0); // Set up the transfer width and transfer size.
	if(sourceAddress)
	{
		DMA_SetSourceAddr(channel, sourceAddress); // Write the starting source address.
	}
	if(destAddress)
	{
		DMA_SetDestinationAddr(channel, destAddress); // Write the starting destination address.
	}
	return 0;
}