sl@0: /* sl@0: * Copyright (c) 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: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #ifndef __IIC_MASTER_H_ sl@0: #define __IIC_MASTER_H_ sl@0: sl@0: #include sl@0: // #include platform specific header files here ... sl@0: sl@0: _LIT(KIicPslThreadName,"IicPslChannelThread_"); sl@0: sl@0: const TInt KIicPslDfcPriority = 0; // Arbitrary, can be 0-7, 7 highest sl@0: const TInt KIicPslThreadPriority = 24; sl@0: sl@0: // DIicBusChannelMasterPsl class declaration: sl@0: class DIicBusChannelMasterPsl: public DIicBusChannelMaster sl@0: { sl@0: public: sl@0: // Method to create a channel sl@0: static DIicBusChannelMasterPsl* New(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex); sl@0: sl@0: // Gateway function for PSL implementation sl@0: virtual TInt DoRequest(TIicBusTransaction* aTransaction); sl@0: sl@0: // Overloaded constructor sl@0: DIicBusChannelMasterPsl(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex); sl@0: sl@0: private: sl@0: // Override base-class pure virtual methods sl@0: virtual TInt DoCreate(); // 2nd stage construction. sl@0: virtual TInt CheckHdr(TDes8* aHdr); sl@0: virtual TInt HandleSlaveTimeout(); sl@0: sl@0: // Internal methods sl@0: TInt ConfigureInterface(); sl@0: TBool TransConfigDiffersFromPrev(); // Optional method - potentially saving hardware re-configuration sl@0: TInt DoTransfer(TInt8 *aBuff, TUint aNumOfBytes, TUint8 aType); sl@0: TInt StartTransfer(TIicBusTransfer* aTransferPtr, TUint8 aType); sl@0: TInt ProcessNextTransfers(); sl@0: void ExitComplete(TInt aErr, TBool aComplete = ETrue); sl@0: sl@0: // Dfc and timeout Callback functions sl@0: static void TransferEndDfc(TAny* aPtr); sl@0: static void TransferTimeoutDfc(TAny* aPtr); sl@0: static void TimeoutCallback(TAny* aPtr); sl@0: sl@0: // ISR handler. sl@0: static void IicIsr(TAny* aPtr); sl@0: sl@0: // DFC for handling transfer completion sl@0: TDfc iTransferEndDfc; sl@0: sl@0: // Flags indicating the current Rx/Tx activity sl@0: TIicOperationType iOperation; sl@0: sl@0: // Granularity of data transmitted sl@0: TUint8 iWordSize; sl@0: sl@0: // Current state of the channel. The channel shuould not accept requests for new sl@0: // transactions until the current one is complete. The following enumeration and sl@0: // state variable are used to control this. sl@0: enum TMyState sl@0: { sl@0: EIdle, sl@0: EBusy sl@0: }; sl@0: TUint8 iState; sl@0: sl@0: // Register base for the Master channel sl@0: TUint iMasterChanBase; sl@0: sl@0: // Interrupt ID for the Master channel sl@0: TInt iMasterIntId; sl@0: sl@0: // Pointers used to store current transfers information sl@0: TIicBusTransfer* iHalfDTransfer; sl@0: TIicBusTransfer* iFullDTransfer; sl@0: sl@0: // Pointer to the current transaction. sl@0: TIicBusTransaction* iCurrTransaction; sl@0: sl@0: // Pointers to buffers used for Rx and Tx transfers sl@0: TInt8 *iTxData; sl@0: TInt8 *iRxData; sl@0: TInt8 *iTxDataEnd; sl@0: TInt8 *iRxDataEnd; sl@0: sl@0: // Timer to guard against hardware timeout sl@0: NTimer iHwGuardTimer; sl@0: sl@0: // Status of the transaction sl@0: volatile TInt iTransactionStatus; sl@0: sl@0: // Optional - pointers to the previous, and newly-requested transaction's headers sl@0: // These would be of a type that is speific to the bus type supported by the channel. sl@0: // Here, they are of a fictional bus type, 'Abc', and so are commented-out sl@0: // TConfigAbcBufV01* iPrevHeader; sl@0: // TConfigAbcBufV01* iCurrHeader sl@0: }; sl@0: sl@0: #endif //__IIC_MASTER_H_