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_channel.h sl@0: // Include file for channel implementation 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: #ifndef __IIC_CHANNEL_H__ sl@0: #define __IIC_CHANNEL_H__ sl@0: sl@0: #ifdef STANDALONE_CHANNEL sl@0: #include sl@0: #else sl@0: #include sl@0: #endif sl@0: sl@0: static const char KIicChannelPanic[]="Iic Channel PIL"; sl@0: sl@0: const static TInt KChannelTypeMask = 0x03; sl@0: const static TInt KBusTypeShift = 2; sl@0: const static TInt KBusTypeMask = 0x07< KMaxWaitTime sl@0: */ sl@0: TInt SetMasterWaitTime(TInt8 aWaitTime); sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Function invoked by the PSL to get the timeout period to wait for a response from the bus master sl@0: sl@0: @return The wait time, in milliseconds sl@0: */ sl@0: inline TInt8 GetMasterWaitTime(); sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Function invoked by the PSL to set the timeout period to wait for a response from the Client sl@0: sl@0: @param aWaitTime Argument specifying the wait time, in milliseconds (limit=KMaxWaitTime) sl@0: @return KErrNone sl@0: */ sl@0: TInt SetClientWaitTime(TInt8 aWaitTime); sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.6 sl@0: Function invoked by the PSL to get the timeout period to wait for a response from the Client sl@0: sl@0: @return The wait time, in milliseconds sl@0: */ sl@0: inline TInt8 GetClientWaitTime(); sl@0: private: sl@0: //Method to instruct PSL to indicate a bus error to the bus Master, then return sl@0: void SendBusErrorAndReturn(); sl@0: void SetChannelId(TInt& aChannelId); sl@0: sl@0: void CompleteAsynchCapture(TInt aResult); sl@0: void SlaveTimerCallBack(); sl@0: static void SlaveStaticCB(TAny* aDumPtr); sl@0: sl@0: protected: sl@0: TInt8 iRxGranularity; sl@0: TInt8 iTxGranularity; sl@0: TInt8 iNumRxWords; sl@0: TInt8 iNumTxWords; sl@0: TInt8 iRxOffset; sl@0: TInt8 iTxOffset; sl@0: private: sl@0: TInt8 iChannelInUse; sl@0: TInt8 iSpare1; sl@0: protected: sl@0: TInt16 iChannelId; // channel identifier to be returned to client (in aChannelId) sl@0: private: sl@0: TInt16 iInstanceCount; // instance count part of aChannelId sl@0: protected: sl@0: TDes8* iConfigHeader; sl@0: TInt8* iTxBuf; sl@0: TInt8* iRxBuf; sl@0: private: sl@0: TIicBusSlaveCallback* iNotif; sl@0: TDfc* iClientTimeoutDfc; // To be queued on the dfc queue used by iNotif sl@0: DThread* iClient; // stored when client captures channel sl@0: #ifndef STANDALONE_CHANNEL sl@0: DIicBusController* iController; sl@0: #endif sl@0: sl@0: TInt8 iTimerState; sl@0: TInt8 iMasterWaitTime; // 8 bits allows maximum wait time of 0.25 seconds sl@0: TInt8 iClientWaitTime; // 8 bits allows maximum wait time of 0.25 seconds sl@0: TInt8 iSpare2; sl@0: sl@0: TInt8 iReqTrig; // Represents the trigger required by the Client (bitmask from TIicBusSlaveTrigger). sl@0: TInt8 iAccumTrig; // Represents the events accumulated during the current trigger period sl@0: TInt16 iSpare3; sl@0: sl@0: TSpinLock iSpinLock; sl@0: TAny* iReserved1; sl@0: TAny* iReserved2; sl@0: sl@0: friend class DIicBusChannelMasterSlave; sl@0: friend class DIicBusController; // For static method DIicBusController::DeRegisterChannel sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: @prototype 9.6 sl@0: The Master-Slave Channel class (not for derivation) sl@0: */ sl@0: class DIicBusChannelMasterSlave : public DIicBusChannel sl@0: { sl@0: public: sl@0: // constructor sl@0: #ifdef STANDALONE_CHANNEL sl@0: IMPORT_C DIicBusChannelMasterSlave(TBusType aBusType, TChannelDuplex aChanDuplex, DIicBusChannelMaster* aMasterChan, DIicBusChannelSlave* aSlaveChan); sl@0: #else sl@0: inline DIicBusChannelMasterSlave(TBusType aBusType, TChannelDuplex aChanDuplex, DIicBusChannelMaster* aMasterChan, DIicBusChannelSlave* aSlaveChan); sl@0: #endif sl@0: ~DIicBusChannelMasterSlave(){delete iMasterChannel; delete iSlaveChannel; } sl@0: inline TInt DoCreate(); sl@0: // Master side interface to Bus Controller sl@0: virtual TInt QueueTransaction(TIicBusTransaction* aTransaction); sl@0: virtual TInt QueueTransaction(TIicBusTransaction* aTransaction, TIicBusCallback* aCallback); sl@0: inline TInt CancelTransaction(TIicBusTransaction* aTransaction); sl@0: sl@0: // Slave side interface to Bus Controller sl@0: virtual TInt CaptureChannel(TDes8* aConfigHdr, TIicBusSlaveCallback* aCallback, TInt& aChannelId, TBool aAsynch); sl@0: virtual TInt ReleaseChannel(); sl@0: inline TInt RegisterRxBuffer(TPtr8 aRxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset); sl@0: inline TInt RegisterTxBuffer(TPtr8 aTxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset); sl@0: inline TInt SetNotificationTrigger(TInt aTrigger); sl@0: virtual TInt StaticExtension(TUint aFunction, TAny* aParam1, TAny* aParam2); sl@0: sl@0: private: sl@0: // Base class support sl@0: virtual TInt CheckHdr(TDes8* /*aHdr*/){ __ASSERT_DEBUG(0,Kern::Fault("DIicBusChannelMasterSlave::CheckHdr",__LINE__)); \ sl@0: return KErrGeneral;}; // Not accessed. PSL implementation for Master or Slave used. sl@0: protected: sl@0: DIicBusChannelMaster* iMasterChannel; sl@0: DIicBusChannelSlave* iSlaveChannel; sl@0: private: sl@0: sl@0: friend class DIicBusChannelMaster; sl@0: friend class DIicBusChannelSlave; sl@0: friend class DIicBusController; // For static method DIicBusController::DeRegisterChannel sl@0: }; sl@0: sl@0: #include sl@0: sl@0: #endif // #ifndef __IIC_CHANNEL_H__ sl@0: