Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test/iic/iic_psl/spi.h
20 #include <drivers/iic_channel.h>
24 #define SPI_PRINT(str) Kern::Printf str
26 #define SPI_PRINT(str)
29 #ifndef STANDALONE_CHANNEL
30 const TInt8 KSpiChannelNumBase = 1; // Arbitrary, real platform may consult the Configuration Repository
31 // Note limit of 5 bit representation (0-31)
34 class THwDoneCallBack : public TDfc
37 inline THwDoneCallBack(THwDoneCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority) : TDfc(DfcFn, this, aQue, aPriority),iCbFn(aFn),iParam(aPtr) {}
38 inline ~THwDoneCallBack(){}
41 inline static void DfcFn(TAny* aPtr)
43 THwDoneCallBack* pCb = (THwDoneCallBack*) aPtr;
44 pCb -> iCbFn(pCb->iParam);
52 class DSimulatedIicBusChannelMasterSpi : public DIicBusChannelMaster
54 // platform specific implementation
59 ETestWaitPriorityTest,
77 #ifdef STANDALONE_CHANNEL
80 DSimulatedIicBusChannelMasterSpi(const TBusType aBusType, const TChannelDuplex aChanDuplex);
81 ~DSimulatedIicBusChannelMasterSpi(){iDynamicDfcQ->Destroy();};
82 inline TInt Create() {return DoCreate();}
84 TInt ReleaseChanArray();
85 void CompleteReq(TInt aResult);
88 TInt CheckHdr(TDes8* aHdr); // Check the header is valid for this channel
89 virtual TInt StaticExtension(TUint aFunction, TAny* aParam1, TAny* aParam2);
91 TInt CompareTransactionOne(TIicBusTransaction* aTransaction);
94 // gateway function for PSL implementation
95 TInt DoRequest(TIicBusTransaction* aTransaction);
96 TInt HandleSlaveTimeout();
97 // Test functions to allow simulating delayed processing of requests
98 static TBool IsRequestDelayed(DSimulatedIicBusChannelMasterSpi* aChan);
99 static void SetRequestDelayed(DSimulatedIicBusChannelMasterSpi* aChan,TBool aDelay);
101 TInt ProcessTrans(TIicBusTransaction* aTransaction); // Accessed by callback
102 TInt AsynchStateMachine(TInt aReason);
103 TInt DoSimulatedTransaction();
104 TInt DoHwPreparation();
105 static void TransactionTimerCallBack(TAny*);
107 inline TInt8 GetChanNum() {return iChannelNumber;};
109 TDynamicDfcQue* iDynamicDfcQ; // Use TDynamicDfcQue since will want to DeRegister channels
111 TIicBusTransaction* iCurrTrans;
113 static TInt8 iCurrentChanNum;
119 THwDoneCallBack *iCb;
120 TInt iPriorityTestResult[KPriorityTestNum];
121 TBool iPriorityTestDone;
123 #ifndef STANDALONE_CHANNEL
124 TInt8 DSimulatedIicBusChannelMasterSpi::iCurrentChanNum = KSpiChannelNumBase; // Initialise static member of DSimulatedIicBusChannelMasterSpi
126 class DSimulatedIicBusChannelSlaveSpi : public DIicBusChannelSlave
129 // platform specific implementation
130 #ifdef STANDALONE_CHANNEL
133 DSimulatedIicBusChannelSlaveSpi(const DIicBusChannel::TBusType aBusType, const DIicBusChannel::TChannelDuplex aChanDuplex);
134 inline TInt Create() {return DoCreate();}
136 // gateway function for PSL implementation
137 TInt DoRequest(TInt aTrigger);
138 void ProcessData(TInt aTrigger, TIicBusSlaveCallback* aCb);
139 virtual TInt StaticExtension(TUint aFunction, TAny* aParam1, TAny* aParam2);
140 static void SlaveAsyncSimCallback(TAny* aPtr);
141 inline void ChanCaptureCb(TInt aResult) {ChanCaptureCallback(aResult);}
142 inline void SetChanNum(TInt8 aChanNum) {iChannelNumber = aChanNum;};
144 virtual void SendBusErrorAndReturn() {return;} // Not implemented in simulated PSL
147 TInt CheckHdr(TDes8* aHdr); // Check the header is valid for this channel
148 virtual TInt CaptureChannelPsl(TDes8* aConfigHdr, TBool aAsynch);