epoc32/include/assp/omap3530_assp/omap3530_i2c.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/assp/omap3530_assp/omap3530_i2c.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,114 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// omap3530/omap3530_drivers/i2c/omap3530_i2c.h
    1.18 +// I2C driver interface.
    1.19 +// This file is part of the Beagle Base port
    1.20 +//
    1.21 +
    1.22 +#ifndef OMAP3530_I2C_H_
    1.23 +#define OMAP3530_I2C_H_
    1.24 +
    1.25 +#include <e32def.h>
    1.26 +
    1.27 +#define I2C_VERSION 0 // update if TConfigPb or TTransferPb change
    1.28 +
    1.29 +class TDfc;
    1.30 +class TDfcQue;
    1.31 +
    1.32 +namespace I2c
    1.33 +{
    1.34 +class TDeviceControl;
    1.35 +
    1.36 +enum TUnit
    1.37 +	{
    1.38 +	E1, // EMaster, ESlave
    1.39 +	E2, // EMaster, ESlave, ESccb
    1.40 +	E3 // EMaster, ESlave, ESccb
    1.41 +	};
    1.42 +enum TRole
    1.43 +	{
    1.44 +	EMaster
    1.45 +//	ESlave - TBI
    1.46 +	};
    1.47 +enum TMode
    1.48 +	{
    1.49 +	E7Bit
    1.50 +//	E10Bit  - TBI
    1.51 +//	EHs - TBI
    1.52 +//	ESccb - TBI
    1.53 +	};
    1.54 +enum TRate
    1.55 +	{
    1.56 +	E100K,
    1.57 +	E400K
    1.58 +//	E3M31 - TBI
    1.59 +	};
    1.60 +typedef TInt TDeviceAddress; // range 0..1023 or 0..128
    1.61 +struct TVersion
    1.62 +	{
    1.63 +	inline TVersion() : iVersion(I2C_VERSION){}
    1.64 +	TInt iVersion;
    1.65 +	};
    1.66 +struct TConfigPb : TVersion // the parameter block used by Open()
    1.67 +	{
    1.68 +	IMPORT_C TConfigPb();
    1.69 +
    1.70 +	TUnit iUnit;
    1.71 +	TRole iRole;
    1.72 +	TMode iMode;
    1.73 +	void* iExclusiveClient; // Clients magic number - zero if the client doesn't require exclusive access otherwise use an owned object, code, stack or data address.
    1.74 +	TRate iRate;
    1.75 +	TDeviceAddress iOwnAddress;
    1.76 +	TDeviceAddress iDeviceAddress; // if role is master
    1.77 +	TDfcQue* iDfcQueue; // clients thread
    1.78 +	};
    1.79 +typedef TInt THandle; // returned from Open()
    1.80 +struct TTransferPb // the parameter block used by Transfer*()
    1.81 +	{
    1.82 +	IMPORT_C TTransferPb();
    1.83 +
    1.84 +	enum
    1.85 +		{
    1.86 +		ERead,
    1.87 +		EWrite
    1.88 +		} iType;
    1.89 +
    1.90 +	TInt iLength; // in bytes.
    1.91 +	const TUint8* iData; // only truly const for writes, i.e. *iData is modified bye Read transfers
    1.92 +
    1.93 +	TTransferPb* iNextPhase; // zero if a full transfer or last phase of a multiphase transfer
    1.94 +
    1.95 +	// only for asynchronous transfers i.e. WriteA() or ReadA();
    1.96 +	TDfc* iCompletionDfc;
    1.97 +	TInt iResult;
    1.98 +
    1.99 +	// reserved for use by I2C driver
   1.100 +	TTransferPb* iNextTransfer;
   1.101 +	TDeviceControl* iDcb;
   1.102 +	};
   1.103 +
   1.104 +// call Open() for each slave device.
   1.105 +// returns:
   1.106 +// KErrArgument if a combination of iUnit, iRole, iMode or iRate are not supported
   1.107 +// KErrInUse if already open exclusively, the configuration doesn't match or the device is already open.
   1.108 +// KErrTooBig if there are already KMaxDevicesPerUnit (currently 8) slave devices open
   1.109 +// a positive value if successful
   1.110 +IMPORT_C THandle Open(const TConfigPb&); 
   1.111 +IMPORT_C void Close(THandle&);
   1.112 +IMPORT_C TInt TransferS(THandle, TTransferPb&);
   1.113 +IMPORT_C void TransferA(THandle, TTransferPb&); // TBI
   1.114 +IMPORT_C void CancelATransfer(THandle); // TBI
   1.115 +}
   1.116 +
   1.117 +#endif // !OMAP3530_I2C_H_