author | mikek |
Wed, 16 Jun 2010 12:59:18 +0100 | |
branch | GCC_SURGE |
changeset 160 | 30e086416910 |
parent 90 | 947f0dc9f7a8 |
child 199 | 189ece41fa29 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test/iic/iic_psl/I2c.cpp |
|
15 |
// |
|
16 |
||
17 |
#include "i2c.h" |
|
18 |
||
19 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
20 |
#include <drivers/iic_trace.h> |
|
21 |
#endif |
|
22 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
23 |
#ifndef STANDALONE_CHANNEL |
0 | 24 |
#if defined(MASTER_MODE) && !defined(SLAVE_MODE) |
25 |
const TInt KChannelTypeArray[NUM_CHANNELS] = {DIicBusChannel::EMaster, DIicBusChannel::EMaster, DIicBusChannel::EMaster}; |
|
26 |
#elif defined(MASTER_MODE) && defined(SLAVE_MODE) |
|
27 |
const TInt KChannelTypeArray[NUM_CHANNELS] = {DIicBusChannel::EMaster, DIicBusChannel::ESlave, DIicBusChannel::EMasterSlave}; |
|
28 |
#else |
|
29 |
const TInt KChannelTypeArray[NUM_CHANNELS] = {DIicBusChannel::ESlave, DIicBusChannel::ESlave, DIicBusChannel::ESlave}; |
|
30 |
#endif |
|
31 |
#define CHANNEL_TYPE(n) (KChannelTypeArray[n]) |
|
32 |
#define CHANNEL_DUPLEX(n) (DIicBusChannel::EHalfDuplex) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
33 |
#endif/*STANDALONE_CHANNEL*/ |
0 | 34 |
|
35 |
#ifdef STANDALONE_CHANNEL |
|
36 |
_LIT(KPddNameI2c,"i2c_ctrless.pdd"); |
|
37 |
#else |
|
38 |
_LIT(KPddNameI2c,"i2c.pdd"); |
|
39 |
#endif |
|
40 |
||
41 |
#ifndef STANDALONE_CHANNEL |
|
42 |
LOCAL_C TInt8 AssignChanNum() |
|
43 |
{ |
|
44 |
static TInt8 iBaseChanNum = KI2cChannelNumBase; |
|
45 |
I2C_PRINT(("I2C AssignChanNum - on entry, iBaseChanNum = 0x%x\n",iBaseChanNum)); |
|
46 |
return iBaseChanNum++; // Arbitrary, for illustration |
|
47 |
} |
|
48 |
#endif/*STANDALONE_CHANNEL*/ |
|
49 |
||
50 |
#ifdef SLAVE_MODE |
|
51 |
LOCAL_C TInt16 AssignSlaveChanId() |
|
52 |
{ |
|
53 |
static TInt16 iBaseSlaveChanId = KI2cSlaveChannelIdBase; |
|
54 |
I2C_PRINT(("I2C AssignSlaveChanId - on entry, iBaseSlaveChanId = 0x%x\n",iBaseSlaveChanId)); |
|
55 |
return iBaseSlaveChanId++; // Arbitrary, for illustration |
|
56 |
} |
|
57 |
#endif/*SLAVE_MODE*/ |
|
58 |
||
59 |
NONSHARABLE_CLASS(DSimulatedI2cDevice) : public DPhysicalDevice |
|
60 |
{ |
|
61 |
// Class to faciliate loading of the IIC classes |
|
62 |
public: |
|
63 |
class TCaps |
|
64 |
{ |
|
65 |
public: |
|
66 |
TVersion iVersion; |
|
67 |
}; |
|
68 |
public: |
|
69 |
DSimulatedI2cDevice(); |
|
70 |
virtual TInt Install(); |
|
71 |
virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
72 |
virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
73 |
virtual void GetCaps(TDes8& aDes) const; |
|
74 |
inline static TVersion VersionRequired(); |
|
75 |
}; |
|
76 |
||
77 |
TVersion DSimulatedI2cDevice::VersionRequired() |
|
78 |
{ |
|
79 |
I2C_PRINT(("DSimulatedI2cDevice::VersionRequired\n")); |
|
80 |
return TVersion(KIicClientMajorVersionNumber,KIicClientMinorVersionNumber,KIicClientBuildVersionNumber); |
|
81 |
} |
|
82 |
||
83 |
/** Factory class constructor */ |
|
84 |
DSimulatedI2cDevice::DSimulatedI2cDevice() |
|
85 |
{ |
|
86 |
I2C_PRINT(("DSimulatedI2cDevice::DSimulatedI2cDevice\n")); |
|
87 |
iVersion = DSimulatedI2cDevice::VersionRequired(); |
|
88 |
} |
|
89 |
||
90 |
TInt DSimulatedI2cDevice::Install() |
|
91 |
{ |
|
92 |
I2C_PRINT(("DSimulatedI2cDevice::Install\n")); |
|
93 |
return(SetName(&KPddNameI2c)); |
|
94 |
} |
|
95 |
||
96 |
/** Called by the kernel's device driver framework to create a Physical Channel. */ |
|
97 |
TInt DSimulatedI2cDevice::Create(DBase*& /*aChannel*/, TInt /*aUint*/, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/) |
|
98 |
{ |
|
99 |
I2C_PRINT(("DSimulatedI2cDevice::Create\n")); |
|
100 |
return KErrNone; |
|
101 |
} |
|
102 |
||
103 |
/** Called by the kernel's device driver framework to check if this PDD is suitable for use with a Logical Channel.*/ |
|
104 |
TInt DSimulatedI2cDevice::Validate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer) |
|
105 |
{ |
|
106 |
I2C_PRINT(("DSimulatedI2cDevice::Validate\n")); |
|
107 |
if (!Kern::QueryVersionSupported(DSimulatedI2cDevice::VersionRequired(),aVer)) |
|
108 |
return(KErrNotSupported); |
|
109 |
return KErrNone; |
|
110 |
} |
|
111 |
||
112 |
/** Return the driver capabilities */ |
|
113 |
void DSimulatedI2cDevice::GetCaps(TDes8& aDes) const |
|
114 |
{ |
|
115 |
I2C_PRINT(("DSimulatedI2cDevice::GetCaps\n")); |
|
116 |
// Create a capabilities object |
|
117 |
TCaps caps; |
|
118 |
caps.iVersion = iVersion; |
|
119 |
// Zero the buffer |
|
120 |
TInt maxLen = aDes.MaxLength(); |
|
121 |
aDes.FillZ(maxLen); |
|
122 |
// Copy capabilities |
|
123 |
TInt size=sizeof(caps); |
|
124 |
if(size>maxLen) |
|
125 |
size=maxLen; |
|
126 |
aDes.Copy((TUint8*)&caps,size); |
|
127 |
} |
|
128 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
129 |
#ifndef STANDALONE_CHANNEL |
0 | 130 |
// supported channels for this implementation |
131 |
static DIicBusChannel* ChannelPtrArray[NUM_CHANNELS]; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
132 |
#endif |
0 | 133 |
|
134 |
//DECLARE_EXTENSION_WITH_PRIORITY(BUS_IMPLMENTATION_PRIORITY) |
|
135 |
DECLARE_STANDARD_PDD() // I2c test driver to be explicitly loaded as an LDD, not kernel extension |
|
136 |
{ |
|
137 |
#ifndef STANDALONE_CHANNEL |
|
138 |
DIicBusChannel* chan=NULL; |
|
139 |
for(TInt i=0; i<NUM_CHANNELS; i++) |
|
140 |
{ |
|
141 |
I2C_PRINT(("\n")); |
|
142 |
#if defined(MASTER_MODE) |
|
143 |
if(CHANNEL_TYPE(i) == (DIicBusChannel::EMaster)) |
|
144 |
{ |
|
145 |
chan=new DSimulatedIicBusChannelMasterI2c(BUS_TYPE,CHANNEL_DUPLEX(i)); |
|
146 |
if(!chan) |
|
147 |
return NULL; |
|
148 |
I2C_PRINT(("I2C chan created at 0x%x\n",chan)); |
|
149 |
if(((DSimulatedIicBusChannelMasterI2c*)chan)->Create()!=KErrNone) |
|
150 |
{ |
|
151 |
delete chan; |
|
152 |
return NULL; |
|
153 |
} |
|
154 |
} |
|
155 |
#endif |
|
156 |
#if defined(MASTER_MODE) && defined(SLAVE_MODE) |
|
157 |
if(CHANNEL_TYPE(i) == DIicBusChannel::EMasterSlave) |
|
158 |
{ |
|
159 |
DIicBusChannel* chanM=new DSimulatedIicBusChannelMasterI2c(BUS_TYPE,CHANNEL_DUPLEX(i)); |
|
160 |
if(!chanM) |
|
161 |
return NULL; |
|
162 |
DIicBusChannel* chanS=new DSimulatedIicBusChannelSlaveI2c(BUS_TYPE,CHANNEL_DUPLEX(i)); |
|
163 |
if(!chanS) |
|
164 |
{ |
|
165 |
delete chanM; |
|
166 |
return NULL; |
|
167 |
} |
|
168 |
// For MasterSlave channel, the channel number for both the Master and Slave channels must be the same |
|
169 |
TInt8 msChanNum = ((DSimulatedIicBusChannelMasterI2c*)chanM)->GetChanNum(); |
|
170 |
((DSimulatedIicBusChannelSlaveI2c*)chanS)->SetChanNum(msChanNum); |
|
171 |
||
172 |
chan=new DSimulatedIicBusChannelMasterSlaveI2c(BUS_TYPE,CHANNEL_DUPLEX(i),(DSimulatedIicBusChannelMasterI2c*)chanM,(DSimulatedIicBusChannelSlaveI2c*)chanS); // Generic implementation |
|
173 |
if(!chan) |
|
174 |
{ |
|
175 |
delete chanM; |
|
176 |
delete chanS; |
|
177 |
return NULL; |
|
178 |
} |
|
179 |
I2C_PRINT(("I2C chan created at 0x%x\n",chan)); |
|
180 |
if(((DIicBusChannelMasterSlave*)chan)->DoCreate()!=KErrNone) |
|
181 |
{ |
|
182 |
delete chanM; |
|
183 |
delete chanS; |
|
184 |
delete chan; |
|
185 |
return NULL; |
|
186 |
} |
|
187 |
} |
|
188 |
#endif |
|
189 |
#if defined(SLAVE_MODE) |
|
190 |
if(CHANNEL_TYPE(i) == (DIicBusChannel::ESlave)) |
|
191 |
{ |
|
192 |
chan=new DSimulatedIicBusChannelSlaveI2c(BUS_TYPE,CHANNEL_DUPLEX(i)); |
|
193 |
if(!chan) |
|
194 |
return NULL; |
|
195 |
I2C_PRINT(("I2C chan created at 0x%x\n",chan)); |
|
196 |
if(((DSimulatedIicBusChannelSlaveI2c*)chan)->Create()!=KErrNone) |
|
197 |
{ |
|
198 |
delete chan; |
|
199 |
return NULL; |
|
200 |
} |
|
201 |
} |
|
202 |
#endif |
|
203 |
#if !defined(MASTER_MODE) && !defined(SLAVE_MODE) |
|
204 |
#error I2C mode not defined as Master, Slave nor Master-Slave |
|
205 |
#endif |
|
206 |
if(chan == NULL) |
|
207 |
{ |
|
208 |
I2C_PRINT(("\n\nI2C: Channel of type (%d) not created for index %d\n\n",CHANNEL_TYPE(i),i)); |
|
209 |
return NULL; |
|
210 |
} |
|
211 |
ChannelPtrArray[i]=chan; |
|
212 |
} |
|
213 |
I2C_PRINT(("\nI2C PDD, channel creation loop done- about to invoke RegisterChannels\n\n")); |
|
214 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
215 |
IIC_REGISTERCHANS_START_PSL_TRACE; |
|
216 |
#endif |
|
217 |
||
218 |
TInt r=DIicBusController::RegisterChannels(ChannelPtrArray,NUM_CHANNELS); |
|
219 |
||
220 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
221 |
IIC_REGISTERCHANS_END_PSL_TRACE; |
|
222 |
#endif |
|
223 |
I2C_PRINT(("\nI2C - returned from RegisterChannels with r=%d\n",r)); |
|
224 |
if(r!=KErrNone) |
|
225 |
{ |
|
226 |
delete chan; |
|
227 |
return NULL; |
|
228 |
} |
|
229 |
#endif |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
return new DSimulatedI2cDevice; |
0 | 231 |
} |
232 |
||
233 |
||
234 |
#ifdef MASTER_MODE |
|
235 |
#ifdef STANDALONE_CHANNEL |
|
236 |
EXPORT_C |
|
237 |
#endif |
|
238 |
DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(const TBusType aBusType, const TChannelDuplex aChanDuplex) |
|
239 |
: DIicBusChannelMaster(aBusType,aChanDuplex) |
|
240 |
{ |
|
241 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c, aBusType=%d,aChanDuplex=%d\n",aBusType,aChanDuplex)); |
|
242 |
#ifndef STANDALONE_CHANNEL |
|
243 |
iChannelNumber = AssignChanNum(); |
|
244 |
#endif |
|
245 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c, iChannelNumber=%d\n",iChannelNumber)); |
|
246 |
} |
|
247 |
||
248 |
TInt DSimulatedIicBusChannelMasterI2c::DoCreate() |
|
249 |
{ |
|
250 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoCreate\n")); |
|
251 |
TInt r=Init(); // PIL Base class initialisation |
|
252 |
r=Kern::DynamicDfcQCreate(iDynamicDfcQ,KI2cThreadPriority,KI2cThreadName); |
|
253 |
if(r == KErrNone) |
|
254 |
SetDfcQ((TDfcQue*)iDynamicDfcQ); |
|
255 |
DSimulatedIicBusChannelMasterI2c::SetRequestDelayed(this,EFalse); |
|
256 |
return r; |
|
257 |
} |
|
258 |
||
259 |
TInt DSimulatedIicBusChannelMasterI2c::CheckHdr(TDes8* aHdr) |
|
260 |
{ |
|
261 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::CheckHdr\n")); |
|
262 |
||
263 |
TConfigI2cBufV01* i2cBuf = (TConfigI2cBufV01*)aHdr; |
|
264 |
TConfigI2cV01* i2cPtr = &((*i2cBuf)()); |
|
265 |
||
266 |
// Check that the values for address type, clock speed, user operation and endianness are recognised |
|
267 |
if((i2cPtr->iAddrType < 0) || (i2cPtr->iAddrType > EI2cAddr10Bit)) |
|
268 |
{ |
|
269 |
I2C_PRINT(("ERROR: DSimulatedIicBusChannelMasterI2c::CheckHdr unrecognised address type identifier %d\n",i2cPtr->iAddrType)); |
|
270 |
return KErrArgument; |
|
271 |
} |
|
272 |
if(i2cPtr->iClkSpeedHz < 0) |
|
273 |
{ |
|
274 |
I2C_PRINT(("ERROR: DSimulatedIicBusChannelMasterI2c::CheckHdr negative clock speed specified %d\n",i2cPtr->iClkSpeedHz)); |
|
275 |
return KErrArgument; |
|
276 |
} |
|
277 |
if((i2cPtr->iEndianness < 0) || (i2cPtr->iEndianness > ELittleEndian)) |
|
278 |
{ |
|
279 |
I2C_PRINT(("ERROR: DSimulatedIicBusChannelMasterI2c::CheckHdr unrecognised endianness identifier %d\n",i2cPtr->iEndianness)); |
|
280 |
return KErrArgument; |
|
281 |
} |
|
282 |
// Values for the timeout period are arbitrary - can only check it is not a negative value |
|
283 |
if(i2cPtr->iTimeoutPeriod < 0) |
|
284 |
{ |
|
285 |
I2C_PRINT(("ERROR: DSimulatedIicBusChannelMasterI2c::CheckHdr negative timeout period %d\n",i2cPtr->iTimeoutPeriod)); |
|
286 |
return KErrArgument; |
|
287 |
} |
|
288 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::CheckHdr address type = %d\n",i2cPtr->iAddrType)); |
|
289 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::CheckHdr clock speed ID = %d\n",i2cPtr->iClkSpeedHz)); |
|
290 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::CheckHdr iEndianness ID = %d\n",i2cPtr->iEndianness)); |
|
291 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::CheckHdr iTimeoutPeriod = %d\n",i2cPtr->iTimeoutPeriod)); |
|
292 |
return KErrNone; |
|
293 |
} |
|
294 |
||
295 |
// Gateway function for PSL implementation, invoked for DFC processing |
|
296 |
TInt DSimulatedIicBusChannelMasterI2c::DoRequest(TIicBusTransaction* aTransaction) |
|
297 |
{ |
|
298 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoRequest invoked with aTransaction=0x%x\n",aTransaction)); |
|
299 |
TInt r = KErrNone; |
|
300 |
||
301 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
302 |
IIC_MPROCESSTRANS_START_PSL_TRACE; |
|
303 |
#endif |
|
304 |
||
305 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans aTransaction->iHeader=0x%x\n",GetTransactionHeader(aTransaction))); |
|
306 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans aTransaction->iHalfDuplexTrans=0x%x\n",GetTransHalfDuplexTferPtr(aTransaction))); |
|
307 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans aTransaction->iFullDuplexTrans=0x%x\n",GetTransFullDuplexTferPtr(aTransaction))); |
|
308 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans aTransaction->iCallback=0x%x\n",GetTransCallback(aTransaction))); |
|
309 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans aTransaction->iFlags=0x%x\n",GetTransFlags(aTransaction))); |
|
310 |
||
311 |
I2C_PRINT(("\nDSimulatedIicBusChannelMasterI2c::DoRequest, iHeader info \n")); |
|
312 |
TDes8* bufPtr = GetTransactionHeader(aTransaction); |
|
313 |
if(bufPtr == NULL) |
|
314 |
{ |
|
315 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoRequest ERROR - NULL header\n")); |
|
316 |
return KErrCorrupt; |
|
317 |
} |
|
318 |
TConfigI2cV01 *buf = (TConfigI2cV01 *)(bufPtr->Ptr()); |
|
319 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoRequest, header address type=0x%x\n",buf->iAddrType)); |
|
320 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoRequest, header clock speed=0x%x\n",buf->iClkSpeedHz)); |
|
321 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoRequest, header endianness=0x%x\n",buf->iEndianness)); |
|
322 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::DoRequest, header timeout period=0x%x\n",buf->iTimeoutPeriod)); |
|
323 |
(void)buf; // Silence compiler when I2C_PRINT not used |
|
324 |
||
325 |
TInt aTime=1000000/NKern::TickPeriod(); |
|
326 |
r = StartSlaveTimeOutTimer(aTime); |
|
327 |
I2C_PRINT(("\nDSimulatedIicBusChannelMasterI2c::ProcessTrans, iHalfDuplexTrans info \n")); |
|
328 |
TIicBusTransfer* halfDuplexPtr=GetTransHalfDuplexTferPtr(aTransaction); |
|
329 |
while(halfDuplexPtr != NULL) |
|
330 |
{ |
|
331 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans transfer type=0x%x\n",GetTferType(halfDuplexPtr))); |
|
332 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans granularity=0x%x\n",GetTferBufGranularity(halfDuplexPtr))); |
|
333 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans transfer buffer=0x%x\n",GetTferBuffer(halfDuplexPtr))); |
|
334 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans next transfer =0x%x\n",GetTferNextTfer(halfDuplexPtr))); |
|
335 |
halfDuplexPtr=GetTferNextTfer(halfDuplexPtr); |
|
336 |
} |
|
337 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans - End of iHalfDuplexTrans info")); |
|
338 |
||
339 |
while(IsRequestDelayed(this)) |
|
340 |
{ |
|
341 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans - starting Sleep...\n")); |
|
342 |
NKern::Sleep(1000); // 1000 is arbitrary |
|
343 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans - completed Sleep, check if still delayed\n")); |
|
344 |
}; |
|
345 |
||
346 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::ProcessTrans - exiting\n")); |
|
347 |
||
348 |
return r; |
|
349 |
} |
|
350 |
||
351 |
||
352 |
TBool DSimulatedIicBusChannelMasterI2c::IsRequestDelayed(DSimulatedIicBusChannelMasterI2c* aChan) |
|
353 |
{ |
|
354 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::IsRequestDelayed invoked for aChan=0x%x\n",aChan)); |
|
355 |
return aChan->iReqDelayed; |
|
356 |
} |
|
357 |
||
358 |
void DSimulatedIicBusChannelMasterI2c::SetRequestDelayed(DSimulatedIicBusChannelMasterI2c* aChan,TBool aDelay) |
|
359 |
{ |
|
360 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::SetRequestDelayed invoked for aChan=0x%x, with aDelay=0x%d\n",aChan,aDelay)); |
|
361 |
aChan->iReqDelayed=aDelay; |
|
362 |
} |
|
363 |
||
364 |
TInt DSimulatedIicBusChannelMasterI2c::HandleSlaveTimeout() |
|
365 |
{ |
|
366 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::HandleSlaveTimeout invoked for this=0x%x\n",this)); |
|
367 |
return KErrTimedOut; |
|
368 |
} |
|
369 |
||
370 |
TInt DSimulatedIicBusChannelMasterI2c::StaticExtension(TUint aFunction, TAny* aParam1, TAny* aParam2) |
|
371 |
{ |
|
372 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::StaticExtension\n")); |
|
373 |
TInt r = KErrNone; |
|
374 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
375 |
IIC_MSTATEXT_START_PSL_TRACE; |
|
376 |
#endif |
|
377 |
(void)aParam1; |
|
378 |
(void)aParam2; |
|
379 |
||
380 |
// Test values of aFunction were shifted left one place by the (test) client driver |
|
381 |
// Return to its original value. |
|
382 |
if(aFunction>KTestControlIoPilOffset) |
|
383 |
aFunction >>= 1; |
|
384 |
switch(aFunction) |
|
385 |
{ |
|
386 |
case(RBusDevIicClient::ECtlIoDumpChan): |
|
387 |
{ |
|
388 |
#ifdef _DEBUG |
|
389 |
DumpChannel(); |
|
390 |
#endif |
|
391 |
break; |
|
392 |
} |
|
393 |
case(RBusDevIicClient::ECtlIoBlockReqCompletion): |
|
394 |
{ |
|
395 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::Blocking request completion\n")); |
|
396 |
SetRequestDelayed(this, ETrue); |
|
397 |
break; |
|
398 |
} |
|
399 |
case(RBusDevIicClient::ECtlIoUnblockReqCompletion): |
|
400 |
{ |
|
401 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c::Unlocking request completion\n")); |
|
402 |
SetRequestDelayed(this, EFalse); |
|
403 |
break; |
|
404 |
} |
|
405 |
case(RBusDevIicClient::ECtlIoDeRegChan): |
|
406 |
{ |
|
407 |
#ifndef STANDALONE_CHANNEL |
|
408 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
409 |
IIC_DEREGISTERCHAN_START_PSL_TRACE; |
|
410 |
#endif |
|
411 |
I2C_PRINT(("DSimulatedIicBusChannelMasterI2c: deregister channel\n")); |
|
412 |
r=DIicBusController::DeRegisterChannel(this); |
|
413 |
||
414 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
415 |
IIC_DEREGISTERCHAN_END_PSL_TRACE; |
|
416 |
#endif/*IIC_INSTRUMENTATION_MACRO*/ |
|
417 |
||
418 |
#else/*STANDALONE_CHANNEL*/ |
|
419 |
r = KErrNotSupported; |
|
420 |
#endif/*STANDALONE_CHANNEL*/ |
|
421 |
break; |
|
422 |
} |
|
423 |
default: |
|
424 |
{ |
|
425 |
Kern::Printf("aFunction %d is not recognised \n",aFunction); |
|
426 |
r=KErrNotSupported; |
|
427 |
} |
|
428 |
} |
|
429 |
||
430 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
431 |
IIC_MSTATEXT_END_PSL_TRACE; |
|
432 |
#endif |
|
433 |
return r; |
|
434 |
} |
|
435 |
||
436 |
//#ifdef MASTER_MODE |
|
437 |
#endif |
|
438 |
||
439 |
#ifdef SLAVE_MODE |
|
440 |
||
441 |
void DSimulatedIicBusChannelSlaveI2c::SlaveAsyncSimCallback(TAny* aPtr) |
|
442 |
{ |
|
443 |
// To support simulating an asynchronous capture operation |
|
444 |
I2C_PRINT(("SlaveAsyncSimCallback\n")); |
|
445 |
DSimulatedIicBusChannelSlaveI2c* channel = (DSimulatedIicBusChannelSlaveI2c*)aPtr; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
446 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
447 |
// This will be invoked in the context of DfcThread1, so require |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
448 |
// synchronised access to iAsyncEvent and iRxTxTrigger |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
449 |
// Use local variables to enable early release of the spin lock |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
450 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
451 |
// If DfcThread1 runs on a separate core to the simulated I2C bus, the other core |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
452 |
// will have updated values, and since this core may cached copies, memory access |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
453 |
// should be observed. The spin lock mechanism is expected to incorpoate this. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
454 |
TInt intState=__SPIN_LOCK_IRQSAVE(channel->iEventSpinLock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
455 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
456 |
TAsyncEvent asyncEvent = channel->iAsyncEvent; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
457 |
TInt rxTxTrigger = channel->iRxTxTrigger; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
458 |
channel->iAsyncEvent = ENoEvent; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
459 |
channel->iRxTxTrigger = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
460 |
__SPIN_UNLOCK_IRQRESTORE(channel->iEventSpinLock,intState); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
461 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
462 |
switch(asyncEvent) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
463 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
464 |
case (EAsyncChanCapture): |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
465 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
466 |
TInt r=KErrNone;// Just simulate successful capture |
0 | 467 |
#ifdef IIC_INSTRUMENTATION_MACRO |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
468 |
IIC_SCAPTCHANASYNC_END_PSL_TRACE; |
0 | 469 |
#endif |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
470 |
channel->ChanCaptureCb(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
471 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
472 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
473 |
case (ERxWords): |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
474 |
case (ETxWords): |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
475 |
case (ERxTxWords): |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
476 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
477 |
channel->ChanNotifyClient(rxTxTrigger); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
478 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
479 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
480 |
default: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
481 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
482 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
483 |
} |
0 | 484 |
} |
485 |
||
486 |
#ifdef STANDALONE_CHANNEL |
|
487 |
EXPORT_C |
|
488 |
#endif |
|
489 |
DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c(const DIicBusChannel::TBusType aBusType, const DIicBusChannel::TChannelDuplex aChanDuplex) |
|
490 |
: DIicBusChannelSlave(aBusType,aChanDuplex,0), // 0 to be ignored by base class |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
491 |
iBlockedTrigger(0),iBlockNotification(EFalse),iAsyncEvent(ENoEvent),iRxTxTrigger(0), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
492 |
iSlaveTimer(DSimulatedIicBusChannelSlaveI2c::SlaveAsyncSimCallback,this), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
493 |
iEventSpinLock(TSpinLock::EOrderGenericIrqHigh2) // Semi-arbitrary, high priority value (NTimer used) |
0 | 494 |
{ |
495 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c, aBusType=%d,aChanDuplex=%d\n",aBusType,aChanDuplex)); |
|
496 |
#ifndef STANDALONE_CHANNEL |
|
497 |
iChannelNumber = AssignChanNum(); |
|
498 |
#endif |
|
499 |
iChannelId = AssignSlaveChanId(); |
|
500 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c, iChannelNumber=%d, iChannelId=0x%x\n",iChannelNumber,iChannelId)); |
|
501 |
} |
|
502 |
||
503 |
DSimulatedIicBusChannelSlaveI2c::~DSimulatedIicBusChannelSlaveI2c() |
|
504 |
{ |
|
505 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::~DSimulatedIicBusChannelSlaveI2c\n")); |
|
506 |
} |
|
507 |
||
508 |
TInt DSimulatedIicBusChannelSlaveI2c::DoCreate() |
|
509 |
{ |
|
510 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::DoCreate\n")); |
|
511 |
TInt r=Init(); // PIL Base class initialisation |
|
512 |
return r; |
|
513 |
} |
|
514 |
||
515 |
||
516 |
TInt DSimulatedIicBusChannelSlaveI2c::CaptureChannelPsl(TBool aAsynch) |
|
517 |
{ |
|
518 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::CaptureChannelPsl\n")); |
|
519 |
TInt r = KErrNone; |
|
520 |
if(aAsynch) |
|
521 |
{ |
|
522 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
523 |
IIC_SCAPTCHANASYNC_START_PSL_TRACE; |
|
524 |
#endif |
|
525 |
// To simulate an asynchronous capture operation, just set a timer to expire |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
526 |
TInt intState=__SPIN_LOCK_IRQSAVE(iEventSpinLock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
527 |
iAsyncEvent = EAsyncChanCapture; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
528 |
__SPIN_UNLOCK_IRQRESTORE(iEventSpinLock,intState); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
529 |
iSlaveTimer.OneShot(KI2cSlaveAsyncDelaySim, ETrue); // Arbitrary timeout - expiry executes callback in context of DfcThread1 |
0 | 530 |
} |
531 |
else |
|
532 |
{ |
|
533 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
534 |
IIC_SCAPTCHANSYNC_START_PSL_TRACE; |
|
535 |
#endif |
|
536 |
// PSL processing would happen here ... |
|
537 |
// Expected to include implementation of the header configuration information |
|
538 |
||
539 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::CaptureChannelPsl (synchronous) ... no real processing to do \n")); |
|
540 |
||
541 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
542 |
IIC_SCAPTCHANSYNC_END_PSL_TRACE; |
|
543 |
#endif |
|
544 |
} |
|
545 |
||
546 |
return r; |
|
547 |
} |
|
548 |
||
549 |
TInt DSimulatedIicBusChannelSlaveI2c::ReleaseChannelPsl() |
|
550 |
{ |
|
551 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::ReleaseChannelPsl\n")); |
|
552 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
553 |
IIC_SRELCHAN_START_PSL_TRACE; |
|
554 |
#endif |
|
555 |
TInt r = KErrNone; |
|
556 |
||
557 |
// PSL-specific processing would happen here ... |
|
558 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::ReleaseChannelPsl ... no real processing to do \n")); |
|
559 |
||
560 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
561 |
IIC_SRELCHAN_END_PSL_TRACE; |
|
562 |
#endif |
|
563 |
||
564 |
return r; |
|
565 |
} |
|
566 |
||
567 |
||
568 |
TInt DSimulatedIicBusChannelSlaveI2c::PrepareTrigger(TInt aTrigger) |
|
569 |
{ |
|
570 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::PrepareTrigger\n")); |
|
571 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
572 |
// IIC_SNOTIFTRIG_START_PSL; |
|
573 |
#endif |
|
574 |
TInt r=KErrNotSupported; |
|
575 |
if(aTrigger&EReceive) |
|
576 |
{ |
|
577 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::PrepareTrigger - prepare hardware for Rx\n")); |
|
578 |
r=KErrNone; |
|
579 |
} |
|
580 |
if(aTrigger&ETransmit) |
|
581 |
{ |
|
582 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::PrepareTrigger - prepare hardware for Tx\n")); |
|
583 |
r=KErrNone; |
|
584 |
} |
|
585 |
// Check for any additional triggers and make the necessary preparation |
|
586 |
// ... do nothing in simulated PSL |
|
587 |
r=KErrNone; |
|
588 |
||
589 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
590 |
// IIC_SNOTIFTRIG_END_PSL; |
|
591 |
#endif |
|
592 |
return r; |
|
593 |
} |
|
594 |
||
595 |
TInt DSimulatedIicBusChannelSlaveI2c::CheckHdr(TDes8* /*aHdr*/) |
|
596 |
{ |
|
597 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::CheckHdr\n")); |
|
598 |
return KErrNone; |
|
599 |
} |
|
600 |
||
601 |
TInt DSimulatedIicBusChannelSlaveI2c::DoRequest(TInt aOperation) |
|
602 |
{ |
|
603 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::DoRequest\n")); |
|
604 |
TInt r = KErrNone; |
|
605 |
||
606 |
switch(aOperation) |
|
607 |
{ |
|
608 |
case(ESyncConfigPwrUp): |
|
609 |
{ |
|
610 |
r=CaptureChannelPsl(EFalse); |
|
611 |
break; |
|
612 |
}; |
|
613 |
case(EAsyncConfigPwrUp): |
|
614 |
{ |
|
615 |
r=CaptureChannelPsl(ETrue); |
|
616 |
break; |
|
617 |
}; |
|
618 |
case(EPowerDown): |
|
619 |
{ |
|
620 |
r=ReleaseChannelPsl(); |
|
621 |
break; |
|
622 |
}; |
|
623 |
case(EAbort): |
|
624 |
{ |
|
625 |
break; |
|
626 |
}; |
|
627 |
default: |
|
628 |
{ |
|
629 |
// The remaining operations are to instigate an Rx, Tx or just prepare for |
|
630 |
// overrun/underrun/bus error notifications. |
|
631 |
// Handle all these, and any unsupported operation in the following function |
|
632 |
r=PrepareTrigger(aOperation); |
|
633 |
break; |
|
634 |
}; |
|
635 |
} |
|
636 |
return r; |
|
637 |
} |
|
638 |
||
639 |
void DSimulatedIicBusChannelSlaveI2c::ProcessData(TInt aTrigger, TIicBusSlaveCallback* aCb) |
|
640 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
641 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::ProcessData trigger=0x%x\n",aTrigger)); |
0 | 642 |
// fills in iReturn, iRxWords and/or iTxWords |
643 |
// |
|
644 |
if(aTrigger & ERxAllBytes) |
|
645 |
{ |
|
646 |
aCb->SetRxWords(iNumWordsWereRx); |
|
647 |
if(iRxTxUnderOverRun & ERxUnderrun) |
|
648 |
{ |
|
649 |
aTrigger|=ERxUnderrun; |
|
650 |
iRxTxUnderOverRun&= ~ERxUnderrun; |
|
651 |
} |
|
652 |
if(iRxTxUnderOverRun & ERxOverrun) |
|
653 |
{ |
|
654 |
aTrigger|=ERxOverrun; |
|
655 |
iRxTxUnderOverRun&= ~ERxOverrun; |
|
656 |
} |
|
657 |
} |
|
658 |
if(aTrigger & ETxAllBytes) |
|
659 |
{ |
|
660 |
aCb->SetTxWords(iNumWordsWereTx); |
|
661 |
if(iRxTxUnderOverRun & ETxUnderrun) |
|
662 |
{ |
|
663 |
aTrigger|=ETxUnderrun; |
|
664 |
iRxTxUnderOverRun&= ~ETxUnderrun; |
|
665 |
} |
|
666 |
if(iRxTxUnderOverRun & ETxOverrun) |
|
667 |
{ |
|
668 |
aTrigger|=ETxOverrun; |
|
669 |
iRxTxUnderOverRun&= ~ETxOverrun; |
|
670 |
} |
|
671 |
} |
|
672 |
aCb->SetTrigger(aTrigger); |
|
673 |
} |
|
674 |
||
675 |
TInt DSimulatedIicBusChannelSlaveI2c::StaticExtension(TUint aFunction, TAny* aParam1, TAny* aParam2) |
|
676 |
{ |
|
677 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c::StaticExtension\n")); |
|
678 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
679 |
IIC_SSTATEXT_START_PSL_TRACE; |
|
680 |
#endif |
|
681 |
// Test values of aFunction were shifted left one place by the (test) client driver |
|
682 |
// and for Slave values the two msb were cleared |
|
683 |
// Return to its original value. |
|
684 |
if(aFunction>KTestControlIoPilOffset) |
|
685 |
{ |
|
686 |
aFunction |= 0xC0000000; |
|
687 |
aFunction >>= 1; |
|
688 |
} |
|
689 |
TInt r = KErrNone; |
|
690 |
switch(aFunction) |
|
691 |
{ |
|
692 |
case(RBusDevIicClient::ECtlIoDumpChan): |
|
693 |
{ |
|
694 |
#ifdef _DEBUG |
|
695 |
DumpChannel(); |
|
696 |
#endif |
|
697 |
break; |
|
698 |
} |
|
699 |
case(RBusDevIicClient::ECtlIoDeRegChan): |
|
700 |
{ |
|
701 |
#ifndef STANDALONE_CHANNEL |
|
702 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: deregister channel\n")); |
|
703 |
// DIicBusController::DeRegisterChannel just removes the channel from the array of channels available |
|
704 |
r=DIicBusController::DeRegisterChannel(this); |
|
705 |
#else |
|
706 |
r = KErrNotSupported; |
|
707 |
#endif |
|
708 |
break; |
|
709 |
} |
|
710 |
||
711 |
case(RBusDevIicClient::ECtrlIoRxWords): |
|
712 |
{ |
|
713 |
// Simulate receipt of a number of bytes |
|
714 |
// aParam1 represents the ChannelId |
|
715 |
// aParam2 specifies the number of bytes |
|
716 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoRxWords, channelId=0x%x, numBytes=0x%x\n",aParam1,aParam2)); |
|
717 |
||
718 |
// Load the buffer with simulated data |
|
719 |
if(iRxBuf == NULL) |
|
720 |
{ |
|
721 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoRxWords, ERROR, iRxBuf == NULL\n")); |
|
722 |
r=KErrGeneral; |
|
723 |
break; |
|
724 |
} |
|
725 |
// Check for overrun-underrun conditions |
|
726 |
TInt trigger=ERxAllBytes; |
|
727 |
iNumWordsWereRx=(TInt8)((TInt)aParam2); |
|
728 |
iDeltaWordsToRx = (TInt8)(iNumWordsWereRx - iNumRxWords); |
|
729 |
if(iDeltaWordsToRx>0) |
|
730 |
{ |
|
731 |
iNumWordsWereRx=iNumRxWords; |
|
732 |
iRxTxUnderOverRun |= ERxOverrun; |
|
733 |
} |
|
734 |
if(iDeltaWordsToRx<0) |
|
735 |
iRxTxUnderOverRun |= ERxUnderrun; |
|
736 |
||
737 |
TInt8* ptr=(TInt8*)(iRxBuf+iRxOffset); |
|
738 |
TInt8 startVal=0x10; |
|
739 |
for(TInt8 numWords=0; numWords<iNumWordsWereRx; numWords++,startVal++) |
|
740 |
{ |
|
741 |
for(TInt wordByte=0; wordByte<iRxGranularity; wordByte++,ptr++) |
|
742 |
{ |
|
743 |
*ptr=startVal; |
|
744 |
} |
|
745 |
} |
|
746 |
if(iBlockNotification == EFalse) |
|
747 |
{ |
|
748 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
749 |
// Use a timer for asynchronous call to NotifyClient - this will invoke ProcessData and invoke the client callback |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
750 |
TInt intState=__SPIN_LOCK_IRQSAVE(iEventSpinLock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
751 |
// Tx may already have been requested, to add to the existing flags set in iRxTxTrigger |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
752 |
iRxTxTrigger |= trigger; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
753 |
iAsyncEvent = ERxWords; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
754 |
__SPIN_UNLOCK_IRQRESTORE(iEventSpinLock,intState); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
755 |
iSlaveTimer.OneShot(KI2cSlaveAsyncDelaySim, ETrue); // Arbitrary timeout - expiry executes callback in context of DfcThread1 |
0 | 756 |
} |
757 |
else |
|
758 |
{ |
|
759 |
// Save the trigger value to notify when prompted. |
|
760 |
iBlockedTrigger=trigger; |
|
761 |
} |
|
762 |
break; |
|
763 |
||
764 |
} |
|
765 |
||
766 |
case(RBusDevIicClient::ECtrlIoUnblockNotification): |
|
767 |
{ |
|
768 |
iBlockNotification=EFalse; |
|
769 |
NotifyClient(iBlockedTrigger); |
|
770 |
iBlockedTrigger=0; |
|
771 |
break; |
|
772 |
} |
|
773 |
||
774 |
case(RBusDevIicClient::ECtrlIoBlockNotification): |
|
775 |
{ |
|
776 |
iBlockNotification=ETrue; |
|
777 |
break; |
|
778 |
} |
|
779 |
||
780 |
case(RBusDevIicClient::ECtrlIoTxWords): |
|
781 |
{ |
|
782 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoTxWords, aParam1=0x%x, aParam2=0x%x\n",aParam1,aParam2)); |
|
783 |
// Simulate transmission of a number of bytes |
|
784 |
// aParam1 represents the ChannelId |
|
785 |
// aParam2 specifies the number of bytes |
|
786 |
// Load the buffer with simulated data |
|
787 |
if(iTxBuf == NULL) |
|
788 |
{ |
|
789 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoTxWords, ERROR, iTxBuf==NULL\n")); |
|
790 |
r=KErrGeneral; |
|
791 |
break; |
|
792 |
} |
|
793 |
// Check for overrun-underrun conditions |
|
794 |
TInt trigger=ETxAllBytes; |
|
795 |
iNumWordsWereTx=(TInt8)((TInt)aParam2); |
|
796 |
iDeltaWordsToTx = (TInt8)(iNumWordsWereTx - iNumTxWords); |
|
797 |
if(iDeltaWordsToTx>0) |
|
798 |
{ |
|
799 |
iNumWordsWereTx=iNumTxWords; |
|
800 |
iRxTxUnderOverRun |= ETxUnderrun; |
|
801 |
} |
|
802 |
if(iDeltaWordsToTx<0) |
|
803 |
iRxTxUnderOverRun |= ETxOverrun; |
|
804 |
||
805 |
// Initialise the check buffer |
|
806 |
if(iTxCheckBuf!=NULL) |
|
807 |
delete iTxCheckBuf; |
|
808 |
// iTxCheckBuf is a member of class DSimulatedIicBusChannelSlaveI2c, which |
|
809 |
// is created here, and deleted not in ~DSimulatedIicBusChannelSlaveI2c() |
|
810 |
// but from client side. This is because in t_iic, |
|
811 |
// we put a memory leak checking macro __KHEAP_MARKEND before |
|
812 |
// the pdd gets unloaded which will call ~DSimulatedIicBusChannelSlaveI2c(). |
|
813 |
// If we delete iTxCheckBuf in ~DSimulatedIicBusChannelSlaveI2c(), |
|
814 |
// we will get a memory leak panic in __KHEAP_MARKEND. |
|
815 |
// To support the test code, we moved iTxCheckBuf deletion to the client side. |
|
816 |
iTxCheckBuf = new TInt8[iNumTxWords*iTxGranularity]; |
|
817 |
memset(iTxCheckBuf,0,(iNumTxWords*iTxGranularity)); |
|
818 |
||
819 |
TInt8* srcPtr=(TInt8*)(iTxBuf+iTxOffset); |
|
820 |
TInt8* dstPtr=iTxCheckBuf; |
|
821 |
for(TInt8 numWords=0; numWords<iNumWordsWereTx; numWords++) |
|
822 |
{ |
|
823 |
for(TInt wordByte=0; wordByte<iTxGranularity; wordByte++) |
|
824 |
*dstPtr++=*srcPtr++; |
|
825 |
} |
|
826 |
if(iBlockNotification == EFalse) |
|
827 |
{ |
|
828 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
829 |
// Use a timer for asynchronous call to NotifyClient - this will invoke ProcessData and invoke the client callback |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
830 |
TInt intState=__SPIN_LOCK_IRQSAVE(iEventSpinLock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
831 |
// Rx may already have been requested, to add to the existing flags set in iRxTxTrigger |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
832 |
iRxTxTrigger |= trigger; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
833 |
iAsyncEvent = ETxWords; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
834 |
__SPIN_UNLOCK_IRQRESTORE(iEventSpinLock,intState); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
835 |
iSlaveTimer.OneShot(KI2cSlaveAsyncDelaySim, ETrue); // Arbitrary timeout - expiry executes callback in context of DfcThread1 |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
836 |
// No effect if OneShot already invoked |
0 | 837 |
} |
838 |
else |
|
839 |
{ |
|
840 |
// Save the trigger value to notify when prompted. |
|
841 |
iBlockedTrigger=trigger; |
|
842 |
} |
|
843 |
break; |
|
844 |
} |
|
845 |
||
846 |
case(RBusDevIicClient::ECtrlIoRxTxWords): |
|
847 |
{ |
|
848 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoRxTxWords, aParam1=0x%x, aParam2=0x%x\n",aParam1,aParam2)); |
|
849 |
// Simulate transmission of a number of bytes |
|
850 |
// aParam1 represents the ChannelId |
|
851 |
// aParam2 represents a pointer to the two numbers of bytes |
|
852 |
// Check the buffers are available |
|
853 |
if(iTxBuf == NULL) |
|
854 |
{ |
|
855 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoRxTxWords, ERROR, iTxBuf==NULL\n")); |
|
856 |
r=KErrGeneral; |
|
857 |
break; |
|
858 |
} |
|
859 |
if(iRxBuf == NULL) |
|
860 |
{ |
|
861 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoRxTxWords, ERROR, iRxBuf==NULL\n")); |
|
862 |
r=KErrGeneral; |
|
863 |
break; |
|
864 |
} |
|
865 |
// Check for overrun-underrun conditions |
|
866 |
TInt trigger=ETxAllBytes|ERxAllBytes; |
|
867 |
iNumWordsWereRx=(TInt8)(*(TInt*)aParam2); |
|
868 |
TInt* tempPtr=((TInt*)(aParam2)); |
|
869 |
iNumWordsWereTx=(TInt8)(*(++tempPtr)); |
|
870 |
||
871 |
iDeltaWordsToTx = (TInt8)(iNumWordsWereTx - iNumTxWords); |
|
872 |
if(iDeltaWordsToTx>0) |
|
873 |
{ |
|
874 |
iNumWordsWereTx=iNumTxWords; |
|
875 |
iRxTxUnderOverRun |= ETxUnderrun; |
|
876 |
} |
|
877 |
if(iDeltaWordsToTx<0) |
|
878 |
iRxTxUnderOverRun |= ETxOverrun; |
|
879 |
||
880 |
||
881 |
iDeltaWordsToRx = (TInt8)(iNumWordsWereRx - iNumRxWords); |
|
882 |
if(iDeltaWordsToRx>0) |
|
883 |
{ |
|
884 |
iNumWordsWereRx=iNumRxWords; |
|
885 |
iRxTxUnderOverRun |= ERxOverrun; |
|
886 |
} |
|
887 |
if(iDeltaWordsToRx<0) |
|
888 |
iRxTxUnderOverRun |= ERxUnderrun; |
|
889 |
||
890 |
||
891 |
// Initialise the buffers |
|
892 |
if(iTxCheckBuf!=NULL) |
|
893 |
delete iTxCheckBuf; |
|
894 |
iTxCheckBuf = new TInt8[iNumTxWords*iTxGranularity]; |
|
895 |
memset(iTxCheckBuf,0,(iNumTxWords*iTxGranularity)); |
|
896 |
||
897 |
TInt8* srcPtr=(TInt8*)(iTxBuf+iTxOffset); |
|
898 |
TInt8* dstPtr=iTxCheckBuf; |
|
899 |
TInt8 numWords=0; |
|
900 |
for(numWords=0; numWords<iNumWordsWereTx; numWords++) |
|
901 |
{ |
|
902 |
for(TInt wordByte=0; wordByte<iTxGranularity; wordByte++) |
|
903 |
*dstPtr++=*srcPtr++; |
|
904 |
} |
|
905 |
||
906 |
TInt8* ptr=(TInt8*)(iRxBuf+iRxOffset); |
|
907 |
TInt8 startVal=0x10; |
|
908 |
for(numWords=0; numWords<iNumWordsWereRx; numWords++,startVal++) |
|
909 |
{ |
|
910 |
for(TInt wordByte=0; wordByte<iRxGranularity; wordByte++,ptr++) |
|
911 |
{ |
|
912 |
*ptr=startVal; |
|
913 |
} |
|
914 |
} |
|
915 |
||
916 |
if(iBlockNotification == EFalse) |
|
917 |
{ |
|
918 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
919 |
// Use a timer for asynchronous call to NotifyClient - this will invoke ProcessData and invoke the client callback |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
920 |
TInt intState=__SPIN_LOCK_IRQSAVE(iEventSpinLock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
921 |
// Rx or Tx may already have been requested, to add to the existing flags set in iRxTxTrigger |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
922 |
iRxTxTrigger |= trigger; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
923 |
iAsyncEvent = ERxTxWords; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
924 |
__SPIN_UNLOCK_IRQRESTORE(iEventSpinLock,intState); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
925 |
iSlaveTimer.OneShot(KI2cSlaveAsyncDelaySim, ETrue); // Arbitrary timeout - expiry executes callback in context of DfcThread1 |
0 | 926 |
} |
927 |
else |
|
928 |
{ |
|
929 |
// Save the trigger value to notify when prompted. |
|
930 |
iBlockedTrigger=trigger; |
|
931 |
} |
|
932 |
break; |
|
933 |
} |
|
934 |
||
935 |
case(RBusDevIicClient::ECtrlIoTxChkBuf): |
|
936 |
{ |
|
937 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtrlIoTxChkBuf, aParam1=0x%x, aParam2=0x%x\n",aParam1,aParam2)); |
|
938 |
// Return the address of iTxCheckBuf to the address pointed to by a1 |
|
939 |
// Both the simulated bus channel and the slave client are resident in the client process |
|
940 |
// so the client can use the pointer value for direct access |
|
941 |
TInt8** ptr = (TInt8**)aParam1; |
|
942 |
*ptr=iTxCheckBuf; |
|
943 |
break; |
|
944 |
} |
|
945 |
||
946 |
case(RBusDevIicClient::ECtlIoBusError): |
|
947 |
{ |
|
948 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c: ECtlIoBusError\n")); |
|
949 |
NotifyClient(EGeneralBusError); |
|
950 |
break; |
|
951 |
} |
|
952 |
||
953 |
case(RBusDevIicClient::ECtrlIoUpdTimeout): |
|
954 |
{ |
|
955 |
// For this test, do the following for the Master and Client timeout values: |
|
956 |
// (1) Read the current timeout value and check that it is set to the default |
|
957 |
// (2) Check setting to a neagtive value fails |
|
958 |
// (3) Set it to a new, different value |
|
959 |
// (4) Read it back to check success |
|
960 |
// (5) Return to the original value, and readback to confirm |
|
961 |
I2C_PRINT(("DSimulatedIicBusChannelSlaveI2c ECtrlIoUpdTimeout \n")); |
|
962 |
||
963 |
TInt timeout = 0; |
|
964 |
TInt r=KErrNone; |
|
965 |
// Master timeout |
|
966 |
timeout=GetMasterWaitTime(); |
|
967 |
if(timeout!=KSlaveDefMWaitTime) |
|
968 |
{ |
|
969 |
I2C_PRINT(("ERROR: Initial Master Wait time != KSlaveDefMWaitTime (=%d) \n",timeout)); |
|
970 |
return KErrGeneral; |
|
971 |
} |
|
972 |
r=SetMasterWaitTime(-1); |
|
973 |
if(r!=KErrArgument) |
|
974 |
{ |
|
975 |
I2C_PRINT(("ERROR: Attempt to set negative Master wait time not rejected\n")); |
|
976 |
return KErrGeneral; |
|
977 |
} |
|
978 |
r=SetMasterWaitTime(KSlaveDefCWaitTime); |
|
979 |
if(r!=KErrNone) |
|
980 |
{ |
|
981 |
I2C_PRINT(("ERROR: Attempt to set new valid Master wait time (%d) rejected\n",KSlaveDefCWaitTime)); |
|
982 |
return KErrGeneral; |
|
983 |
} |
|
984 |
timeout=GetMasterWaitTime(); |
|
985 |
if(timeout!=KSlaveDefCWaitTime) |
|
986 |
{ |
|
987 |
I2C_PRINT(("ERROR: Master Wait time read back has unexpected value (=%d) \n",timeout)); |
|
988 |
return KErrGeneral; |
|
989 |
} |
|
990 |
r=SetMasterWaitTime(KSlaveDefMWaitTime); |
|
991 |
if(r!=KErrNone) |
|
992 |
{ |
|
993 |
I2C_PRINT(("ERROR: Attempt to set reset Master wait time (%d) rejected\n",KSlaveDefMWaitTime)); |
|
994 |
return KErrGeneral; |
|
995 |
} |
|
996 |
timeout=GetMasterWaitTime(); |
|
997 |
if(timeout!=KSlaveDefMWaitTime) |
|
998 |
{ |
|
999 |
I2C_PRINT(("ERROR: Master Wait time read back of reset time has unexpected value (=%d) \n",timeout)); |
|
1000 |
return KErrGeneral; |
|
1001 |
} |
|
1002 |
// Client timeout |
|
1003 |
timeout=GetClientWaitTime(); |
|
1004 |
if(timeout!=KSlaveDefCWaitTime) |
|
1005 |
{ |
|
1006 |
I2C_PRINT(("ERROR: Initial Client Wait time != KSlaveDefCWaitTime (=%d) \n",timeout)); |
|
1007 |
return KErrGeneral; |
|
1008 |
} |
|
1009 |
r=SetClientWaitTime(-1); |
|
1010 |
if(r!=KErrArgument) |
|
1011 |
{ |
|
1012 |
I2C_PRINT(("ERROR: Attempt to set negative Client wait time not rejected\n")); |
|
1013 |
return KErrGeneral; |
|
1014 |
} |
|
1015 |
r=SetClientWaitTime(KSlaveDefMWaitTime+1); |
|
1016 |
if(r!=KErrNone) |
|
1017 |
{ |
|
1018 |
I2C_PRINT(("ERROR: Attempt to set new valid Client wait time (%d) rejected\n",KSlaveDefMWaitTime)); |
|
1019 |
return KErrGeneral; |
|
1020 |
} |
|
1021 |
timeout=GetClientWaitTime(); |
|
1022 |
if(timeout!=KSlaveDefMWaitTime+1) |
|
1023 |
{ |
|
1024 |
I2C_PRINT(("ERROR: Client Wait time read back has unexpected value (=%d) \n",timeout)); |
|
1025 |
return KErrGeneral; |
|
1026 |
} |
|
1027 |
r=SetClientWaitTime(KSlaveDefCWaitTime); |
|
1028 |
if(r!=KErrNone) |
|
1029 |
{ |
|
1030 |
I2C_PRINT(("ERROR: Attempt to set reset Client wait time (%d) rejected\n",KSlaveDefCWaitTime)); |
|
1031 |
return KErrGeneral; |
|
1032 |
} |
|
1033 |
timeout=GetClientWaitTime(); |
|
1034 |
if(timeout!=KSlaveDefCWaitTime) |
|
1035 |
{ |
|
1036 |
I2C_PRINT(("ERROR: Client Wait time read back of reset time has unexpected value (=%d) \n",timeout)); |
|
1037 |
return KErrGeneral; |
|
1038 |
} |
|
1039 |
break; |
|
1040 |
} |
|
1041 |
||
1042 |
default: |
|
1043 |
{ |
|
1044 |
Kern::Printf("aFunction %d is not recognised \n",aFunction); |
|
1045 |
r=KErrNotSupported; |
|
1046 |
} |
|
1047 |
} |
|
1048 |
#ifdef IIC_INSTRUMENTATION_MACRO |
|
1049 |
IIC_SSTATEXT_END_PSL_TRACE; |
|
1050 |
#endif |
|
1051 |
return r; |
|
1052 |
} |
|
1053 |
||
1054 |
||
1055 |
||
1056 |
//#ifdef MASTER_MODE |
|
1057 |
#endif |
|
1058 |
||
1059 |
#if defined(MASTER_MODE) && defined(SLAVE_MODE) |
|
1060 |
#ifdef STANDALONE_CHANNEL |
|
1061 |
EXPORT_C |
|
1062 |
#endif |
|
1063 |
DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(TBusType /*aBusType*/, TChannelDuplex aChanDuplex, DSimulatedIicBusChannelMasterI2c* aMasterChan, DSimulatedIicBusChannelSlaveI2c* aSlaveChan) |
|
1064 |
: DIicBusChannelMasterSlave(EI2c, aChanDuplex, aMasterChan, aSlaveChan) |
|
1065 |
{} |
|
1066 |
||
1067 |
TInt DSimulatedIicBusChannelMasterSlaveI2c::StaticExtension(TUint aFunction, TAny* /*aParam1*/, TAny* /*aParam2*/) |
|
1068 |
{ |
|
1069 |
I2C_PRINT(("DSimulatedIicBusChannelMasterSlaveI2c::StaticExtension, aFunction=0x%x\n",aFunction)); |
|
1070 |
TInt r = KErrNone; |
|
1071 |
||
1072 |
// Test values of aFunction were shifted left one place by the (test) client driver |
|
1073 |
// Return to its original value. |
|
1074 |
if(aFunction>KTestControlIoPilOffset) |
|
1075 |
aFunction >>= 1; |
|
1076 |
switch(aFunction) |
|
1077 |
{ |
|
1078 |
case(RBusDevIicClient::ECtlIoDumpChan): |
|
1079 |
{ |
|
1080 |
#ifdef _DEBUG |
|
1081 |
DumpChannel(); |
|
1082 |
#endif |
|
1083 |
break; |
|
1084 |
} |
|
1085 |
case(RBusDevIicClient::ECtlIoDeRegChan): |
|
1086 |
{ |
|
1087 |
I2C_PRINT(("DSimulatedIicBusChannelMasterSlaveI2c: deregister channel\n")); |
|
1088 |
#ifndef STANDALONE_CHANNEL |
|
1089 |
r=DIicBusController::DeRegisterChannel(this); |
|
1090 |
#else |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1091 |
r = KErrNotSupported; |
0 | 1092 |
#endif |
1093 |
break; |
|
1094 |
} |
|
1095 |
case(RBusDevIicClient::ECtlIoBlockReqCompletion): |
|
1096 |
{ |
|
1097 |
I2C_PRINT(("DSimulatedIicBusChannelMasterSlaveI2c::Blocking request completion\n")); |
|
1098 |
((DSimulatedIicBusChannelMasterI2c*)iMasterChannel)->SetRequestDelayed(((DSimulatedIicBusChannelMasterI2c*)iMasterChannel), ETrue); |
|
1099 |
break; |
|
1100 |
} |
|
1101 |
case(RBusDevIicClient::ECtlIoUnblockReqCompletion): |
|
1102 |
{ |
|
1103 |
I2C_PRINT(("DSimulatedIicBusChannelMasterSlaveI2c::Unlocking request completion\n")); |
|
1104 |
((DSimulatedIicBusChannelMasterI2c*)iMasterChannel)->SetRequestDelayed(((DSimulatedIicBusChannelMasterI2c*)iMasterChannel), EFalse); |
|
1105 |
break; |
|
1106 |
} |
|
1107 |
default: |
|
1108 |
{ |
|
1109 |
Kern::Printf("aFunction %d is not recognised \n",aFunction); |
|
1110 |
r=KErrNotSupported; |
|
1111 |
} |
|
1112 |
} |
|
1113 |
return r; |
|
1114 |
} |
|
1115 |
||
1116 |
||
1117 |
//#if defined(MASTER_MODE) && defined(SLAVE_MODE) |
|
1118 |
#endif |
|
1119 |
||
1120 |
||
1121 |