diff -r 578be2adaf3e -r 307f4279f433 Adaptation/GUID-58AA7257-0951-42AB-9B6E-AAF63343FEFA-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adaptation/GUID-58AA7257-0951-42AB-9B6E-AAF63343FEFA-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1.dita Fri Oct 15 14:32:18 2010 +0100 @@ -0,0 +1,88 @@ + + + + + +DMA Channel OperationsDescribes how a device driver should open and close a DMA +channel. +
Open

To use a DMA channel it has to be opened. TDmaChannel::Open() must be called to open the channel, and the required information +provided in a TDmaChannel::SCreateInfo structure. +The actual DMA channel selection is done by the hardware specific +layer.

/** + Initializes the DMA for transmit. This function does all the + required generic initialization to use the DMA framework. This + function does not have any variant specific initialization. + + @return KErrNone on success, else standard error code on failure + */ +TInt DExDriverUartTxDma::Init() + { + ... + + // Initialize the channel information to select and configure the DMA + // channel + TDmaChannel::SCreateInfo info; + info.iCookie = (TUint); + info.iDesCount = 1; // For single buffered transfers + info.iDfcPriority = 4; // Set the priority of this DFC for DMA + info.iDfcQ = iUartComm->DfcQ(); // DFCQ onto which this request + // has to be queued + + // DMA channel has to be opened before doing any operations on + // the channel. TDmaChannel::Open() opens the DMA channel as + // set by info passed and selected by the hardware-specific layer. + + r = TDmaChannel::Open(info, iTxDmaChannel); + if (r!=KErrNone) + { + return r; + } + ... + }
+
Close

A DMA channel has to be closed after completing all the DMA operations. +This releases the DMA channel for other resources and peripherals. +To close a previously opened channel, the channel should be idle, +with no pending requests. So, before closing, call TDmaChannel::CancelAll(), which cancels the current request and any pending DMA requests. +This should then be followed by closing the channel using TDmaChannel::Close().

/** + Destructor. Deinitializes the member variables, cancels any + requests, closes the channel, deletes the DMA requests, frees the + hardware chunks allocated. + */ + +DExDriverUartTxDma::~DExDriverUarttxDma() + { + ... + // if DMA channel is existing, cancel all requests on it. + // + if (iTxDmaChannel) + { + // TDmaChannel::CancelAll() cancels the current request and + // any pending requests on the DMA channel + // + iTxDmaChannel->CancelAll(); + } + ... + + if(iTxDmaChannel) + { + // Close the DMA channel. TDmaChannel::Close() closes a + // previously opened channel. All the requests on this + // channel should have been cancelled prior to this, i.e. + // TDmaChannel::CancelAll() should have been called before + // this call. + // + iTxDmaChannel->Close(); + } + ... + }

To stop DMA without closing the channel, simply +cancel the request.

+
+DMA +Channels +
\ No newline at end of file