epoc32/include/assp/omap3530_assp/omap3530_i2c.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // omap3530/omap3530_drivers/i2c/omap3530_i2c.h
    15 // I2C driver interface.
    16 // This file is part of the Beagle Base port
    17 //
    18 
    19 #ifndef OMAP3530_I2C_H_
    20 #define OMAP3530_I2C_H_
    21 
    22 #include <e32def.h>
    23 
    24 #define I2C_VERSION 0 // update if TConfigPb or TTransferPb change
    25 
    26 class TDfc;
    27 class TDfcQue;
    28 
    29 namespace I2c
    30 {
    31 class TDeviceControl;
    32 
    33 enum TUnit
    34 	{
    35 	E1, // EMaster, ESlave
    36 	E2, // EMaster, ESlave, ESccb
    37 	E3 // EMaster, ESlave, ESccb
    38 	};
    39 enum TRole
    40 	{
    41 	EMaster
    42 //	ESlave - TBI
    43 	};
    44 enum TMode
    45 	{
    46 	E7Bit
    47 //	E10Bit  - TBI
    48 //	EHs - TBI
    49 //	ESccb - TBI
    50 	};
    51 enum TRate
    52 	{
    53 	E100K,
    54 	E400K
    55 //	E3M31 - TBI
    56 	};
    57 typedef TInt TDeviceAddress; // range 0..1023 or 0..128
    58 struct TVersion
    59 	{
    60 	inline TVersion() : iVersion(I2C_VERSION){}
    61 	TInt iVersion;
    62 	};
    63 struct TConfigPb : TVersion // the parameter block used by Open()
    64 	{
    65 	IMPORT_C TConfigPb();
    66 
    67 	TUnit iUnit;
    68 	TRole iRole;
    69 	TMode iMode;
    70 	void* iExclusiveClient; // Clients magic number - zero if the client doesn't require exclusive access otherwise use an owned object, code, stack or data address.
    71 	TRate iRate;
    72 	TDeviceAddress iOwnAddress;
    73 	TDeviceAddress iDeviceAddress; // if role is master
    74 	TDfcQue* iDfcQueue; // clients thread
    75 	};
    76 typedef TInt THandle; // returned from Open()
    77 struct TTransferPb // the parameter block used by Transfer*()
    78 	{
    79 	IMPORT_C TTransferPb();
    80 
    81 	enum
    82 		{
    83 		ERead,
    84 		EWrite
    85 		} iType;
    86 
    87 	TInt iLength; // in bytes.
    88 	const TUint8* iData; // only truly const for writes, i.e. *iData is modified bye Read transfers
    89 
    90 	TTransferPb* iNextPhase; // zero if a full transfer or last phase of a multiphase transfer
    91 
    92 	// only for asynchronous transfers i.e. WriteA() or ReadA();
    93 	TDfc* iCompletionDfc;
    94 	TInt iResult;
    95 
    96 	// reserved for use by I2C driver
    97 	TTransferPb* iNextTransfer;
    98 	TDeviceControl* iDcb;
    99 	};
   100 
   101 // call Open() for each slave device.
   102 // returns:
   103 // KErrArgument if a combination of iUnit, iRole, iMode or iRate are not supported
   104 // KErrInUse if already open exclusively, the configuration doesn't match or the device is already open.
   105 // KErrTooBig if there are already KMaxDevicesPerUnit (currently 8) slave devices open
   106 // a positive value if successful
   107 IMPORT_C THandle Open(const TConfigPb&); 
   108 IMPORT_C void Close(THandle&);
   109 IMPORT_C TInt TransferS(THandle, TTransferPb&);
   110 IMPORT_C void TransferA(THandle, TTransferPb&); // TBI
   111 IMPORT_C void CancelATransfer(THandle); // TBI
   112 }
   113 
   114 #endif // !OMAP3530_I2C_H_