sl@0: /* sl@0: * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * e32/include/drivers/iic_transaction.h sl@0: * sl@0: */ sl@0: sl@0: // WARNING: This file contains some APIs which are internal and are subject sl@0: // to change without notice. Such APIs should therefore not be used sl@0: // outside the Kernel and Hardware Services package. sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __IIC_TRANSACTION_H__ sl@0: #define __IIC_TRANSACTION_H__ sl@0: sl@0: #include // for DThread; sl@0: #include sl@0: sl@0: static const char KIicPanic[]="Iic PIL"; sl@0: sl@0: const TInt KNumTrancPriorities=8; sl@0: const TUint8 KTransactionWithPreamble = 0x80; sl@0: const TUint8 KTransactionWithMultiTransc = 0x40; sl@0: sl@0: #ifdef _DEBUG sl@0: static const TUint KCtrlIoDumpChan = 1; // StaticExtension value reserved for printing a channel sl@0: #endif sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: The set of endianness values for use with IIC buses sl@0: sl@0: */ sl@0: enum TEndianness sl@0: { sl@0: EBigEndian, sl@0: ELittleEndian sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: The set of bit-order values for use with IIC buses sl@0: sl@0: */ sl@0: enum TBitOrder sl@0: { sl@0: ELsbFirst, sl@0: EMsbFirst sl@0: }; sl@0: sl@0: // sl@0: // Bus-specific configuration for SPI bus sl@0: // sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: The set of word-width values for use with TConfigSpiV01 sl@0: sl@0: @see TConfigSpiV01 sl@0: sl@0: */ sl@0: enum TSpiWordWidth sl@0: { sl@0: ESpiWordWidth_8, sl@0: ESpiWordWidth_10, sl@0: ESpiWordWidth_12, sl@0: ESpiWordWidth_16 sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: The set of clock mode values for use with TConfigSpiV01 sl@0: sl@0: @see TConfigSpiV01 sl@0: sl@0: */ sl@0: enum TSpiClkMode sl@0: { sl@0: ESpiPolarityLowRisingEdge, // Active high, odd edges sl@0: ESpiPolarityLowFallingEdge, // Active high, even edges sl@0: ESpiPolarityHighFallingEdge, // Active low, odd edges sl@0: ESpiPolarityHighRisingEdge // Active low, even edges sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: The set of values to represent the pin sense when selecting a Slave sl@0: sl@0: @see TConfigSpiV01 sl@0: sl@0: */ sl@0: enum TSpiSsPinMode sl@0: { sl@0: ESpiCSPinActiveLow, // Active low sl@0: ESpiCSPinActiveHigh // Active high sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Class to represent the configuration data for a SPI bus channel registered with IIC sl@0: sl@0: */ sl@0: class TConfigSpiV01 sl@0: { sl@0: public: sl@0: TSpiWordWidth iWordWidth; sl@0: TInt32 iClkSpeedHz; sl@0: TSpiClkMode iClkMode; sl@0: TInt32 iTimeoutPeriod; sl@0: TEndianness iEndianness; sl@0: TBitOrder iBitOrder; sl@0: TUint iTransactionWaitCycles; sl@0: TSpiSsPinMode iSSPinActiveMode; sl@0: }; sl@0: sl@0: typedef TPckgBuf TConfigSpiBufV01; sl@0: sl@0: sl@0: // sl@0: // Bus-specific configuration for I2C bus sl@0: // sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: The set of address types for use with TConfigI2cV01 sl@0: sl@0: @see TConfigI2cV01 sl@0: sl@0: */ sl@0: enum TI2cAddrType sl@0: { sl@0: EI2cAddr7Bit, sl@0: EI2cAddr10Bit sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Class to represent the configuration data for a I2C bus channel registered with IIC sl@0: sl@0: */ sl@0: class TConfigI2cV01 sl@0: { sl@0: public: sl@0: TI2cAddrType iAddrType; // 7 or 10-bit addressing sl@0: TInt32 iClkSpeedHz; sl@0: TEndianness iEndianness; sl@0: TInt32 iTimeoutPeriod; sl@0: }; sl@0: sl@0: typedef TPckgBuf TConfigI2cBufV01; sl@0: sl@0: sl@0: sl@0: // Bus realisation configuration sl@0: // sl@0: // 31 30 29 28 | 27 26 25 24 | 23 22 21 20 | 19 18 17 16 | 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 sl@0: // sl@0: // 31:29 - HS Master address (I2C only) sl@0: // 28 - HS address valid bit sl@0: // 27:23 - Reserved sl@0: // 22:20 - Bus type sl@0: // 19:15 - Channel number sl@0: // 14:10 - Transaction speed sl@0: // 9:0 - Slave address sl@0: #define HS_MASTER_ADDR_SHIFT 29 sl@0: #define HS_MASTER_ADDR_MASK 0x7 sl@0: #define HS_ADDR_VALID_SHIFT 28 sl@0: #define HS_ADDR_VALID_MASK 0x1 sl@0: #define BUS_TYPE_SHIFT 20 sl@0: #define BUS_TYPE_MASK 0x7 sl@0: #define CHANNEL_NO_SHIFT 15 sl@0: #define CHANNEL_NO_MASK 0x1F sl@0: #define TRANS_SPEED_SHIFT 10 sl@0: #define TRANS_SPEED_MASK 0x1F sl@0: #define SLAVE_ADDR_SHIFT 0 sl@0: #define SLAVE_ADDR_MASK 0x3FF sl@0: sl@0: // The SET_CONF_FIELD and GET_CONF_FIELD are for internal use, only. sl@0: // They are to support the set of macros below which access particular fields of the Bus realisation configuration sl@0: #define SET_CONF_FIELD(aBusId,aField,aMask,aShift) aBusId=(aBusId&~(aMask<>(aShift))&(aMask)) sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to get the HS Master address of a Bus realisation configuration sl@0: */ sl@0: #define GET_HS_MASTER_ADDR(aBusId) GET_CONF_FIELD(aBusId,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to set the HS Master address of a Bus realisation configuration sl@0: */ sl@0: #define SET_HS_MASTER_ADDR(aBusId,aHsMasterAddr) SET_CONF_FIELD(aBusId,aHsMasterAddr,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to get the HS address valid bit of a Bus realisation configuration sl@0: */ sl@0: #define GET_HS_VALID(aBusId,aHsValid) GET_CONF_FIELD(aBusId,aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to set the HS address valid bit of a Bus realisation configuration sl@0: */ sl@0: #define SET_HS_VALID(aBusId,aHsValid) SET_CONF_FIELD(aBusId,aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to get the Bus type of a Bus realisation configuration sl@0: */ sl@0: #define GET_BUS_TYPE(aBusId) GET_CONF_FIELD(aBusId,BUS_TYPE_MASK,BUS_TYPE_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to set the Bus type of a Bus realisation configuration sl@0: */ sl@0: #define SET_BUS_TYPE(aBusId,aBusType) SET_CONF_FIELD(aBusId,aBusType,BUS_TYPE_MASK,BUS_TYPE_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to get the Channel number of a Bus realisation configuration sl@0: */ sl@0: #define GET_CHAN_NUM(aBusId) GET_CONF_FIELD(aBusId,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to set the Channel number of a Bus realisation configuration sl@0: */ sl@0: #define SET_CHAN_NUM(aBusId,aChanNum) SET_CONF_FIELD(aBusId,aChanNum,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to set the Transaction speed of a Bus realisation configuration sl@0: */ sl@0: #define SET_TRANS_SPEED(aBusId,aTransSpeed) SET_CONF_FIELD(aBusId,aTransSpeed,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to get the Transaction speed of a Bus realisation configuration sl@0: */ sl@0: #define GET_TRANS_SPEED(aBusId) GET_CONF_FIELD(aBusId,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to set the Slave address of a Bus realisation configuration sl@0: */ sl@0: #define SET_SLAVE_ADDR(aBusId,aSlaveAddr) SET_CONF_FIELD(aBusId,aSlaveAddr,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT) sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Macro to get the Slave address of a Bus realisation configuration sl@0: */ sl@0: #define GET_SLAVE_ADDR(aBusId) GET_CONF_FIELD(aBusId,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT) sl@0: sl@0: sl@0: // The SET_CONFIG_FIELD and GET_CONFIG_FIELD are for internal use, only. sl@0: // They are to support the TIicBusRealisation class sl@0: // These macros should be considered deprecated - they will be removed when the TIicBusRealisation class is removed sl@0: #define SET_CONFIG_FIELD(aField,aMask,aShift) iConfig=(iConfig&~(aMask<>aShift)&aMask) sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @deprecated sl@0: sl@0: Class to represent and provide access to configuration data used on a per-transaction basis with IIC sl@0: sl@0: */ sl@0: class TIicBusRealisationConfig sl@0: { sl@0: public: sl@0: // default constructor - just resets the value.. sl@0: inline TIicBusRealisationConfig() : iConfig(0) {} sl@0: sl@0: inline TIicBusRealisationConfig& operator=(const TIicBusRealisationConfig &aObj){iConfig = aObj.GetConfig(); return *this;} sl@0: sl@0: inline void Clear() {iConfig = 0;} sl@0: inline TUint32 GetConfig() const {return iConfig;} sl@0: inline void SetConfig(TUint32 aConfig) {iConfig = aConfig;} sl@0: sl@0: inline void SetHsMasterAddr(TUint8 aHsMasterAddr) {SET_CONFIG_FIELD(aHsMasterAddr,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT);}; sl@0: inline void GetHsMasterAddr(TUint8& aHsMasterAddr) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT);aHsMasterAddr=(TUint8)tempVar;};}; sl@0: sl@0: inline void SetHsValid(TUint8 aHsValid) {SET_CONFIG_FIELD(aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT);}; sl@0: inline void GetHsValid(TUint8& aHsValid) const{{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT);aHsValid=(TUint8)tempVar;};}; sl@0: sl@0: inline void SetBusType(TUint8 aBusType) {SET_CONFIG_FIELD(aBusType,BUS_TYPE_MASK,BUS_TYPE_SHIFT);}; sl@0: inline void GetBusType(TUint8& aBusType) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,BUS_TYPE_MASK,BUS_TYPE_SHIFT);aBusType=(TUint8)tempVar;};}; sl@0: sl@0: inline void SetChanNum(TUint8 aChanNum) {SET_CONFIG_FIELD(aChanNum,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT);}; sl@0: inline void GetChanNum(TUint8& aChanNum) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT);aChanNum=(TUint8)tempVar;};}; sl@0: sl@0: inline void SetTransSpeed(TUint8 aTransSpeed) {SET_CONFIG_FIELD(aTransSpeed,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT);}; sl@0: inline void GetTransSpeed(TUint8& aTransSpeed) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT);aTransSpeed=(TUint8)tempVar;};}; sl@0: sl@0: inline void SetSlaveAddr(TUint16 aSlaveAddr) {SET_CONFIG_FIELD(aSlaveAddr,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT);}; sl@0: inline void GetSlaveAddr(TUint16& aSlaveAddr) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT);aSlaveAddr=(TUint16)tempVar;};}; sl@0: sl@0: private: sl@0: TUint32 iConfig; sl@0: }; sl@0: sl@0: sl@0: // Forward declarations sl@0: class TIicBusTransaction; sl@0: class DIicBusChannelMaster; sl@0: sl@0: // sl@0: // Master-side items sl@0: // sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Class to represent and provide access to configuration data used on a per-transaction basis with IIC sl@0: sl@0: @see TIicBusTransaction sl@0: sl@0: */ sl@0: class TIicBusTransfer sl@0: { sl@0: public: sl@0: enum TReqType sl@0: { sl@0: EMasterRead, sl@0: EMasterWrite, sl@0: }; sl@0: // the client interface for creating and linking simple requests sl@0: // default constructor.. sl@0: inline TIicBusTransfer(); sl@0: inline TIicBusTransfer(TReqType aType, TInt8 aGranularity, TDes8* aBuffer); sl@0: inline void LinkAfter(TIicBusTransfer* aPrev); sl@0: inline TInt8 WordWidth(); sl@0: inline TReqType Direction(); sl@0: inline TInt Length(); sl@0: inline const TIicBusTransfer* Next(); sl@0: sl@0: inline TInt SetTransferData(TReqType aType, TInt8 aGranularity, TDes8* aBuffer); sl@0: const TDes8* GetBuffer() {return (const TDes8*)iBuffer;} sl@0: sl@0: private: sl@0: TInt8 iType; // as one of TReqType sl@0: TInt8 iBufGranularity; // width of a transfer word in bits sl@0: TInt8 iSpare1; sl@0: TDes8* iBuffer; // the data for this transfer (packed into 8-bit words with padding). Access must be guarded for safety. sl@0: TIicBusTransfer* iNext; sl@0: TIicBusTransaction* iTransaction; // pointer to the TIicBusTransaction owning the list that this transfer has been added to sl@0: sl@0: friend class TIicBusTransaction; sl@0: friend class DIicBusChannelMaster; sl@0: }; sl@0: sl@0: const TInt8 KTransferQueued = 0x01; sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Definition of function prototype for a callback function provided by a client sl@0: for invocation on the after the client transaction has been processed by a Master sl@0: channel. The function will be executed in the context of the client thread. sl@0: sl@0: @see TIicBusTransaction sl@0: sl@0: */ sl@0: typedef void (*TIicBusCbFn)(TIicBusTransaction* /*aTransction*/, sl@0: TInt /*aBusId*/, sl@0: TInt /*aResult*/, sl@0: TAny* /*aParam*/); sl@0: sl@0: class TIicBusCallback; // Forward declaration sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Class to represent a transaction for processing by an IIC Master Channel sl@0: sl@0: @see IicBus sl@0: sl@0: */ sl@0: class TIicBusTransaction : public SOrdQueLink sl@0: { sl@0: public: sl@0: enum TState {EFree,EDelivered,EAccepted}; sl@0: sl@0: //default constuctor. sl@0: inline TIicBusTransaction(); sl@0: sl@0: // the client interface for creating half duplex transactions sl@0: inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TInt aPriority=0); sl@0: inline ~TIicBusTransaction(); sl@0: inline TInt SetHalfDuplexTrans(TDes8* aHeader, TIicBusTransfer* aHdTrans); sl@0: sl@0: // The client interface for setting full duplex transaction: the API checks that it is possible to have the 2 transactions done in parallel. sl@0: // It does not check if the channel supports full duplex, so the transaction may still fail at queuing time. sl@0: inline TInt SetFullDuplexTrans(TIicBusTransfer* aFdTrans); sl@0: inline TInt RemoveTrans(TIicBusTransfer* aTrans); sl@0: // Client interface to explicitly disassociate transfer lists from the transaction, when the sl@0: // transaction is in state EFree. sl@0: // These methods are for optional use. If the transfer list will not be further accessed, sl@0: // then there is no need to explicitly disassociate it from a transaction. However, if sl@0: // it will be accessed again its iTransaction pointer will refer to this object, so should sl@0: // be cleared to prevent corruption - and this is the purpose of these methods. sl@0: inline TInt RemoveHalfDuplexTrans(); sl@0: inline TInt RemoveFullDuplexTrans(); sl@0: sl@0: // Accessor method to allow PSL access to iFlags to determine transaction type sl@0: inline TUint Flags(); sl@0: protected: sl@0: inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TUint8 aFlags, TInt aPriority=0); sl@0: public: sl@0: inline TUint8 State(); sl@0: inline TInt GetBusId(); sl@0: private: sl@0: TDes8* iHeader; sl@0: TUint8 iFlags; // used to indicate if it supports a preamble sl@0: TUint8 iState; sl@0: TInt8 iSpare1; sl@0: TInt8 iSpare2; sl@0: #ifdef STANDALONE_CHANNEL sl@0: //iBusId is needed by client when calling QueueTransaction sl@0: public: sl@0: TInt iBusId; sl@0: #else sl@0: private: sl@0: TInt iBusId; sl@0: #endif sl@0: TIicBusTransfer* iHalfDuplexTrans; sl@0: TIicBusTransfer* iFullDuplexTrans; sl@0: TIicBusCallback* iCallback; sl@0: sl@0: NFastSemaphore iSyncNotification; sl@0: TInt iResult; sl@0: friend class DIicBusChannelMaster; sl@0: #ifndef STANDALONE_CHANNEL sl@0: friend class DIicBusController; sl@0: #endif sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Class to represent a callback object for use with asynchronous transactions processed by IIC Master channels sl@0: sl@0: @see IicBus sl@0: sl@0: */ sl@0: class TIicBusCallback : public TDfc sl@0: { sl@0: public: sl@0: inline TIicBusCallback(TIicBusCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority); sl@0: inline ~TIicBusCallback(); sl@0: private: sl@0: inline static void DfcFunc(TAny* aPtr); sl@0: private: sl@0: TIicBusTransaction* iTransaction; sl@0: TInt iBusId; sl@0: TInt iResult; // the result of this transaction as a system wide error sl@0: TAny* iParam; sl@0: TIicBusCbFn iCallback; sl@0: sl@0: friend class DIicBusChannelMaster; sl@0: }; sl@0: sl@0: // Forward declarations sl@0: class DIicBusChannelSlave; sl@0: class TIicBusSlaveCallback; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Definition of function prototype for a callback function provided by a client sl@0: for invocation when an asynchronous event (such as a notification, or completion sl@0: of the asynchronous capture of a channel) occurs for a Slave channel. sl@0: sl@0: @see IicBus sl@0: sl@0: */ sl@0: typedef void (*TIicBusSlaveCbFn)(TInt /*aChannelId*/, sl@0: TInt /*aReturn*/, sl@0: TInt /*aTrigger*/, sl@0: TInt16 /*aRxWords*/, sl@0: TInt16 /*aTxWords*/, sl@0: TAny* /*aParam*/); sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: A Slave callback notification object. sl@0: It wraps a DFC in client's thread which is queued by the channel generic implementation sl@0: when the transfer are completed asynchronously (e.g. in ISR). sl@0: Alternatively, if the entire transaction is processed synchronously in the client's thread, sl@0: the callback function will be called directly. sl@0: sl@0: @see IicBus sl@0: sl@0: */ sl@0: NONSHARABLE_CLASS(TIicBusSlaveCallback) : public TDfc sl@0: { sl@0: public: sl@0: inline TIicBusSlaveCallback(TIicBusSlaveCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority); sl@0: inline void SetReturn(TInt aRet); // to be used by PSL sl@0: inline void SetTxWords(TInt16 aTxWords); // to be used by PSL sl@0: inline void SetRxWords(TInt16 aRxWords); // to be used by PSL sl@0: sl@0: inline TInt GetTrigger(); // to be used by PSL sl@0: inline void SetTrigger(TInt aTrigger); // to be used by PSL sl@0: sl@0: private: sl@0: IMPORT_C static void DfcFunc(TAny* aPtr); sl@0: sl@0: private: sl@0: TInt iChannelId; sl@0: TInt iReturn; // a system wide error code sl@0: TInt iTrigger; // a bitmask containing the reason(s) why this callback was queued (see TIicBusSlaveTrigger) sl@0: TInt16 iRxWords; // number of words received sl@0: TInt16 iTxWords; // number of words transmitted sl@0: TAny* iParam; sl@0: DIicBusChannelSlave* iChannel; sl@0: TIicBusSlaveCbFn iCallback; sl@0: sl@0: friend class DIicBusChannelSlave; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Prototype function pointer for a client supplied preamble: sl@0: The supplied function shall not: sl@0: - spin sl@0: - block or wait on a fast mutex sl@0: - use any Kernel or base port services that do any of the above (e.g. alloc/free memory, sl@0: signal a DMutex, complete a request, access user side memory) sl@0: sl@0: @see IicBus sl@0: sl@0: */ sl@0: typedef void (*TIicBusPreamble)(TIicBusTransaction* /*aTransaction*/, sl@0: TAny* /*aArg*/); sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Transaction which support preamble sl@0: sl@0: @see TIicBusTransaction sl@0: sl@0: */ sl@0: class TIicBusTransactionPreamble : public TIicBusTransaction sl@0: { sl@0: public: sl@0: // the client interface for creating transactions that support a preamble sl@0: inline TIicBusTransactionPreamble(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusPreamble aPreamble, TAny* aArg, TInt aPriority=0); sl@0: private: sl@0: TIicBusPreamble iPreamble; // preamble function pointer sl@0: TAny* iPreambleArg; // argument to be passed to preamble sl@0: protected: sl@0: inline TIicBusTransactionPreamble(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusPreamble aPreamble, TAny* aArg, TUint8 aFlags, TInt aPriority=0); sl@0: friend class DIicBusChannelMaster; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Prototype function pointer for a client supplied multi transaction callback. sl@0: The function should return a pointer to a new transaction which will be send sl@0: within the same request. The function is called in the channel thread after sl@0: calling channel PSL DoRequest sl@0: sl@0: @see TIicBusTransaction sl@0: sl@0: */ sl@0: typedef TIicBusTransaction* (*TIicBusMultiTranscCbFn) ( sl@0: TIicBusTransaction* /*aTransaction*/, sl@0: TAny* /*aArg*/); sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Transaction which support multi-transaction sl@0: sl@0: @see TIicBusTransaction sl@0: sl@0: */ sl@0: class TIicBusTransactionMultiTransc : public TIicBusTransaction sl@0: { sl@0: public: sl@0: inline TIicBusTransactionMultiTransc(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusMultiTranscCbFn aMultiTransc, TAny* aArg, TInt aPriority=0); sl@0: private: sl@0: TIicBusMultiTranscCbFn iMultiTransc; sl@0: TAny* iMultiTranscArg; sl@0: friend class DIicBusChannelMaster; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Transaction which support both preamble and multi-transaction sl@0: sl@0: @see TIicBusTransactionPreamble sl@0: sl@0: */ sl@0: class TIicBusTransactionPreambleExt : public TIicBusTransactionPreamble sl@0: { sl@0: public: sl@0: inline TIicBusTransactionPreambleExt(TDes8* aHeader, TIicBusTransfer* aHdTrans, sl@0: TIicBusPreamble aPreamble, TAny* aPreambleArg, sl@0: TIicBusMultiTranscCbFn aMultiTransc, TAny* aMultiTranscArg, TInt aPriority=0); sl@0: private: sl@0: TIicBusMultiTranscCbFn iMultiTransc; sl@0: TAny* iMultiTranscArg; sl@0: friend class DIicBusChannelMaster; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: sl@0: Enumeration of IIC Slave channel trigger values sl@0: sl@0: @see IicBus sl@0: */ sl@0: enum TIicBusSlaveTrigger sl@0: { sl@0: ERxAllBytes = 0x01, // Master has written the required number of bytes sl@0: ERxUnderrun = 0x02, // Master has written less than the required number of bytes, and ceased transmitting sl@0: ERxOverrun = 0x04, // Master has written the required number of bytes and is continuing to transmit sl@0: ETxAllBytes = 0x08, // Master has read the required number of bytes sl@0: ETxUnderrun = 0x10, // Master has read the required number of bytes and is continuing to read sl@0: ETxOverrun = 0x20, // Master has read less than the required number of bytes, and ceased reading sl@0: EGeneralBusError = 0x40, // An error has occurred during a transaction sl@0: EAsyncCaptChan = 0x80 // Completion of asynchronous CaptureChannel sl@0: }; sl@0: sl@0: #include sl@0: sl@0: #endif // __IIC_TRANSACTION_H__