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
changeset 15 307f4279f433
equal deleted inserted replaced
14:578be2adaf3e 15:307f4279f433
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-58AA7257-0951-42AB-9B6E-AAF63343FEFA-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1" xml:lang="en"><title>DMA Channel Operations</title><shortdesc>Describes how a device driver should open and close a DMA
       
    13 channel.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <section id="GUID-C4241738-D4C3-4171-87B2-5EDFFACE4002-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1-3-1"><title>Open</title><p>To use a DMA channel it has to be opened. <xref href="GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37.dita#GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37/GUID-514BA285-3563-3C24-A067-F360098A6ADF"><apiname>TDmaChannel::Open()</apiname></xref> must be called to open the channel, and the required information
       
    15 provided in a <xref href="GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37.dita#GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37/GUID-6B973278-8BE7-3CE5-97D8-60E8D3F4D473"><apiname>TDmaChannel::SCreateInfo</apiname></xref> structure.
       
    16 The actual DMA channel selection is done by the hardware specific
       
    17 layer. </p> <codeblock id="GUID-A1CA8DBA-1378-502B-8CC8-6D83F13DD151-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1-3-1-3" xml:space="preserve">/**
       
    18  Initializes the DMA for transmit. This function does all the 
       
    19  required generic initialization to use the DMA framework. This 
       
    20  function does not have any variant specific initialization. 
       
    21     
       
    22  @return     KErrNone on success, else standard error code on failure
       
    23  */
       
    24 TInt DExDriverUartTxDma::Init()
       
    25     {
       
    26     ...
       
    27 
       
    28     // Initialize the channel information to select and configure the DMA     
       
    29     // channel
       
    30     TDmaChannel::SCreateInfo info;
       
    31     info.iCookie = (TUint);
       
    32     info.iDesCount = 1; // For single buffered transfers
       
    33     info.iDfcPriority = 4; // Set the priority of this DFC for DMA
       
    34     info.iDfcQ = iUartComm-&gt;DfcQ(); // DFCQ onto which this request
       
    35  // has to be queued    
       
    36 
       
    37     // DMA channel has to be opened before doing any operations on 
       
    38     // the channel. TDmaChannel::Open() opens the DMA channel as 
       
    39     // set by info passed and selected by the hardware-specific layer. 
       
    40    
       
    41     r = TDmaChannel::Open(info, iTxDmaChannel);
       
    42     if (r!=KErrNone)
       
    43         {
       
    44         return r;
       
    45         }
       
    46     ...
       
    47     }</codeblock> </section>
       
    48 <section id="GUID-5E09A55C-A2B9-4E02-9BCF-F23558357B70-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1-3-2"><title>Close</title> <p>A DMA channel has to be closed after completing all the DMA operations.
       
    49 This releases the DMA channel for other resources and peripherals.
       
    50 To close a previously opened channel, the channel should be idle,
       
    51 with no pending requests. So, before closing, call <xref href="GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37.dita#GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37/GUID-0A98D2DC-2A61-3FBD-AB7A-623FE926A183"><apiname>TDmaChannel::CancelAll()</apiname></xref>, which cancels the current request and any pending DMA requests.
       
    52 This should then be followed by closing the channel using <xref href="GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37.dita#GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37/GUID-8204AFBD-2A60-372E-B626-35BD19851FF7"><apiname>TDmaChannel::Close()</apiname></xref>. </p> <codeblock id="GUID-4BA5CDD2-6BD3-5179-89B8-7337ED5809AA-GENID-1-2-1-10-1-5-1-5-1-1-7-1-9-1-5-1-3-2-3" xml:space="preserve">/**
       
    53  Destructor. Deinitializes the member variables, cancels any 
       
    54  requests, closes the channel, deletes the DMA requests, frees the 
       
    55  hardware chunks allocated.
       
    56  */    
       
    57 
       
    58 DExDriverUartTxDma::~DExDriverUarttxDma()
       
    59     {
       
    60     ...
       
    61     // if DMA channel is existing, cancel all requests on it.    
       
    62     //
       
    63     if (iTxDmaChannel)
       
    64         {
       
    65         // TDmaChannel::CancelAll() cancels the current request and 
       
    66         // any pending requests on the DMA channel
       
    67         //     
       
    68         iTxDmaChannel-&gt;CancelAll();
       
    69         }
       
    70     ...
       
    71 
       
    72     if(iTxDmaChannel)
       
    73         {
       
    74         // Close the DMA channel. TDmaChannel::Close() closes a 
       
    75         // previously opened channel. All the requests on this 
       
    76         // channel should have been cancelled prior to this, i.e. 
       
    77         // TDmaChannel::CancelAll() should have been called before 
       
    78         // this call.
       
    79         //
       
    80         iTxDmaChannel-&gt;Close();
       
    81         }
       
    82     ...
       
    83     }</codeblock> <p>To stop DMA without closing the channel, simply
       
    84 cancel the request. </p></section>
       
    85 </conbody><related-links>
       
    86 <link href="GUID-C649DB97-F138-4C90-B177-16590F2E3F19-GENID-1-2-1-9-1-6-1-8-1-7-1-3-1.dita"><linktext>DMA
       
    87 Channels</linktext></link>
       
    88 </related-links></concept>