Symbian3/PDK/Source/GUID-9986DCC6-EE73-59FB-BDAC-9B09DC64FBCE.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     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 xml:lang="en" id="GUID-9986DCC6-EE73-59FB-BDAC-9B09DC64FBCE"><title>Client of IIC Master Channel Implementation Tutorial</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This document describes a simple implementation of an IIC client using the master channel functionality. </p> <section><title>Purpose</title> <p>This tutorial explains how to use the IIC master side API to communicate with a peripheral using half-duplex. </p> <p><b>Intended Audience</b> </p> <p>Device driver writers. </p> <p><b>Required Background</b> </p> <p>Before you start, you must: </p> <ul><li id="GUID-E339C63B-A5B2-535A-9EEB-E42F5913695F"><p>Have installed the platform specific implementation of IIC channels that is required to support the IIC API. </p> </li> <li id="GUID-BF87DA07-52AD-5B46-BA69-61AB6E23CA38"><p>The IIC.dll has been included in the kernel.iby file. </p> </li> <li id="GUID-DE66833F-6DE6-5068-BE7B-A748ABFE9915"><p>Include the iic.h and iic_channel.h header files. </p> </li> </ul> <p> <note>Note:</note> The code example fragments are for synchronous operation. For asynchronous operation, the buffers must be allocated on the heap. </p> </section> <section><title>Implementing IIC user-side</title> <p>The Following tasks will be covered in this tutorial: </p> <ul><li id="GUID-FF0DF82E-6D88-5C58-844C-2E1036816FAD"><p>Performing read/write operations. </p> </li> </ul> <p><b>Basic Procedure</b> </p> <p>The high level steps to performing read/write operations are shown here: </p> <ol id="GUID-0080AB2C-6DC5-5128-B2FB-7E1D81859F7B"><li id="GUID-3C607C4B-20B8-5ED7-8A82-BF75CC2C5286"><p>First set the bus type, the channel number and the slave address. </p> <p>An example of this, is : </p> <codeblock id="GUID-A66F8DD0-A870-5210-9AAB-D3B837D0E831" xml:space="preserve">// Configure the port.
       
    13     busId.SetBusType(DIicBusChannel::ESpi);        // Specify which multi-wire bus is to be used. in this example, SPI.
       
    14     busId.SetChanNum(0);                                                                                    // Set the channel number.
       
    15     busId.SetSlaveAddr(13);                                                                     // Set the slave address. </codeblock> </li> <li id="GUID-27D5A0ED-818B-51AE-BB48-32929DB3E134"><p>Configure the channel. </p> <p>An example of which, is : </p> <codeblock id="GUID-43A34CF2-6324-5026-BC9E-28CE4B8D95A6" xml:space="preserve">// create header - this configures a SPI port.
       
    16     const TConfigSpiV01 TestHeader =
       
    17         {
       
    18         ESpiWordWidth_8,                                                 // Set the word width. In this example, 8 bits.
       
    19         260000,                                                                                     // Set the clock speed of the port. In this example, 260KHz.
       
    20         ESpiPolarityLowRisingEdge,         // Set the clock mode value. In this example, Active high, odd edges.
       
    21         500,                                                                                                 // Set the timeout period. In this example, 500msec.
       
    22         EBigEndian,                                                                     // Set which endian is to be used. In this example, BigEndian is used.
       
    23         EMsbFirst,                                                                         // Set which bit order is to be used. In this example, the Msb is first.
       
    24         0,                                                                                                         // Set the number of transaction wait cycles. In this example, 0.
       
    25         ESpiCSPinActiveLow                                         // Set the Chip select active mode. In this example, chip select is active low.
       
    26         };</codeblock> </li> <li id="GUID-6748A0B1-6A37-50AB-9D93-A230F419059A"><p>Make linked lists of the transfers that are to be carried out. </p> <p>An example of this, is : </p> <codeblock id="GUID-C112BD53-C69C-595B-8452-82826AEC37B3" xml:space="preserve">// Set the transaction header.
       
    27     TPckgBuf&lt;TConfigSpiV01&gt; header(TestHeader);
       
    28 
       
    29     // Set up a transmit transaction.
       
    30     // This txTransfer buffer acts as the start of the transaction linked list.
       
    31     TIicBusTransfer txTransfer(TIicBusTransfer::EMasterWrite, 8, &amp;txTransferBuf);
       
    32 
       
    33     // Set up a receive transaction.
       
    34     TIicBusTransfer rxTransfer(TIicBusTransfer::EMasterRead, 8, &amp;rxTransferBuf);
       
    35 
       
    36     // Add to the receive transaction to the transaction linked list.
       
    37     txTransfer.LinkAfter(&amp;rxTransfer);
       
    38 
       
    39     // Create a transaction using header and the transaction linked list.
       
    40     TIicBusTransaction transaction(&amp;header, &amp;txTransfer);</codeblock> </li> <li id="GUID-B750A2D0-CFE2-584F-B2CF-5F19293B88BC"><p>Use the QueueTransaction method, specifying the configuration of the port and the start location of the transaction linked lists. This queues the transactions onto the selected IIC channel. </p> <p>An example of this, is : </p> <codeblock id="GUID-5F929F5F-D8B3-5471-B65A-86D5D9DC8D7C" xml:space="preserve">// Queue the transaction.
       
    41  // Once this command has been executed, the value of r should be KErrNone.
       
    42     r = IicBus::QueueTransaction(busId.GetConfig(), &amp;transaction);</codeblock> </li> </ol> </section> </conbody><related-links><link href="GUID-F461CBB3-F8D1-5961-AD51-5741143A1CB1.dita"><linktext>Client
       
    43                 of Slave User Side Tutorial</linktext> </link> <link href="GUID-C0803997-F111-52C8-9F18-9138F02BCED5.dita"><linktext>IIC
       
    44                 Implementation Tutorial</linktext> </link> <link href="GUID-B2F86F54-EF50-56DB-ADF7-15325AC9324D.dita"><linktext>IIC Guide</linktext> </link> <link href="GUID-99FC067C-0AED-5373-AF63-8DB7FF5C1F7E.dita"><linktext>SPI Technology Guide</linktext> </link> <link href="GUID-3A30DA16-ECA8-5639-A9DC-6BE2AD55420B.dita"><linktext>I2C Technology Guide</linktext> </link> </related-links></concept>