diff -r 578be2adaf3e -r 307f4279f433 Adaptation/GUID-9986DCC6-EE73-59FB-BDAC-9B09DC64FBCE.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adaptation/GUID-9986DCC6-EE73-59FB-BDAC-9B09DC64FBCE.dita Fri Oct 15 14:32:18 2010 +0100 @@ -0,0 +1,84 @@ + + + + + +Client of Master Channel TutorialDescribes a simple implementation of a client using the +master channel functionality. +

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

+
Purpose

This tutorial explains how to use the IIC platform service API +as a master and 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 platform service API.

  • +
  • Include the IIC.dll in the kernel.iby file.

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

  • +

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

+
Implementing +the IIC platform service

The Following tasks will be covered +in this tutorial:

    +
  • Performing read/write +operations.

  • +

Basic Procedure

The implementation +on which the following code examples are based is implemented IIC +via a SPI bus. On hardware with dedicated IIC ports, the IIC port +would be specified and the header data type would be TConfigIICV01.

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. +
  3. 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. + };
  4. +
  5. 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);
  6. +
  7. Use the IicBus::QueueTransaction() method, specifying the configuration +of the port and the start location of the transaction linked lists. +This queues the transactions on to 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);
  8. +
+
+Client + of Slave Channel Tutorial +IIC +Concepts +I2C +Technology Guide +
\ No newline at end of file