diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-9986DCC6-EE73-59FB-BDAC-9B09DC64FBCE.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-9986DCC6-EE73-59FB-BDAC-9B09DC64FBCE.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,44 @@ + + + + + +Client of IIC Master Channel Implementation Tutorial

This document describes a simple implementation of an IIC client using the master channel functionality.

Purpose

This tutorial explains how to use the IIC master side API to communicate with a peripheral using half-duplex.

Intended Audience

Device driver writers.

Required Background

Before you start, you must:

  • Have installed the platform specific implementation of IIC channels that is required to support the IIC API.

  • The IIC.dll has been included in the kernel.iby file.

  • Include the iic.h and iic_channel.h header files.

Note: The code example fragments are for synchronous operation. For asynchronous operation, the buffers must be allocated on the heap.

Implementing IIC user-side

The Following tasks will be covered in this tutorial:

  • Performing read/write operations.

Basic Procedure

The high level steps to performing read/write operations are shown here:

  1. First set the bus type, the channel number and the slave address.

    An example of this, is :

    // Configure the port. + busId.SetBusType(DIicBusChannel::ESpi); // Specify which multi-wire bus is to be used. in this example, SPI. + busId.SetChanNum(0); // Set the channel number. + busId.SetSlaveAddr(13); // Set the slave address.
  2. Configure the channel.

    An example of which, is :

    // create header - this configures a SPI port. + const TConfigSpiV01 TestHeader = + { + ESpiWordWidth_8, // Set the word width. In this example, 8 bits. + 260000, // Set the clock speed of the port. In this example, 260KHz. + ESpiPolarityLowRisingEdge, // Set the clock mode value. In this example, Active high, odd edges. + 500, // Set the timeout period. In this example, 500msec. + EBigEndian, // Set which endian is to be used. In this example, BigEndian is used. + EMsbFirst, // Set which bit order is to be used. In this example, the Msb is first. + 0, // Set the number of transaction wait cycles. In this example, 0. + ESpiCSPinActiveLow // Set the Chip select active mode. In this example, chip select is active low. + };
  3. Make linked lists of the transfers that are to be carried out.

    An example of this, is :

    // Set the transaction header. + TPckgBuf<TConfigSpiV01> header(TestHeader); + + // Set up a transmit transaction. + // This txTransfer buffer acts as the start of the transaction linked list. + TIicBusTransfer txTransfer(TIicBusTransfer::EMasterWrite, 8, &txTransferBuf); + + // Set up a receive transaction. + TIicBusTransfer rxTransfer(TIicBusTransfer::EMasterRead, 8, &rxTransferBuf); + + // Add to the receive transaction to the transaction linked list. + txTransfer.LinkAfter(&rxTransfer); + + // Create a transaction using header and the transaction linked list. + TIicBusTransaction transaction(&header, &txTransfer);
  4. 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.

    An example of this, is :

    // Queue the transaction. + // Once this command has been executed, the value of r should be KErrNone. + r = IicBus::QueueTransaction(busId.GetConfig(), &transaction);
Client + of Slave User Side Tutorial IIC + Implementation Tutorial IIC Guide SPI Technology Guide I2C Technology Guide
\ No newline at end of file