author | hgs |
Mon, 11 Oct 2010 17:54:41 +0100 | |
changeset 286 | 48e57fb1237e |
parent 199 | 189ece41fa29 |
child 293 | 0659d0e1a03c |
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/t_iic.cpp |
|
15 |
// |
|
16 |
||
17 |
// This file interacts with test-specific LDD to instigate tests of functionality |
|
18 |
// that would normally be invoked by kernel-side device driver clients of the IIC. |
|
19 |
#include <e32test.h> |
|
20 |
#include <e32cmn.h> |
|
21 |
#include <e32cmn_private.h> |
|
22 |
#include <e32def.h> |
|
23 |
#include <e32def_private.h> |
|
24 |
#include "t_iic.h" |
|
25 |
||
26 |
//for memory leak checking |
|
27 |
#include <e32svr.h> |
|
28 |
#include <u32hal.h> |
|
29 |
||
30 |
_LIT(testName,"t_iic"); |
|
31 |
||
32 |
_LIT(KIicProxyFileNameCtrlLess, "iic_client_ctrless.ldd"); // Kernel-side proxy LDD acting as a client of the IIC |
|
33 |
_LIT(KIicProxyFileNameRootCtrlLess, "iic_client_ctrless"); |
|
34 |
_LIT(KIicProxySlaveFileNameCtrlLess, "iic_slaveclient_ctrless.ldd"); // Kernel-side proxy LDD acting as a slave client of the IIC |
|
35 |
_LIT(KIicProxySlaveFileNameRootCtrlLess, "iic_slaveclient_ctrless"); |
|
36 |
_LIT(KIicProxyFileName, "iic_client.ldd"); // Kernel-side proxy LDD acting as a client of the IIC |
|
37 |
_LIT(KIicProxyFileNameRoot, "iic_client"); |
|
38 |
_LIT(KIicProxySlaveFileName, "iic_slaveclient.ldd"); // Kernel-side proxy LDD acting as a slave client of the IIC |
|
39 |
_LIT(KIicProxySlaveFileNameRoot, "iic_slaveclient"); |
|
199 | 40 |
//These are used to exercise stub functions. |
41 |
_LIT(KIicProxyFileNameStubs, "iic_client_stubs.ldd"); |
|
42 |
_LIT(KIicProxyFileNameRootStubs, "iic_client_stubs"); |
|
43 |
_LIT(KIicProxySlaveFileNameStubs, "iic_slaveclient_stubs.ldd"); |
|
44 |
_LIT(KIicProxySlaveFileNameRootStubs, "iic_slaveclient_stubs"); |
|
45 |
||
0 | 46 |
|
47 |
#ifdef IIC_SIMULATED_PSL |
|
48 |
_LIT(KSpiFileNameCtrlLess, "spi_ctrless.pdd"); // Simulated PSL bus implementation |
|
199 | 49 |
_LIT(KI2cFileNameCtrlLess, "i2c_ctrless.pdd"); // Simulated PSL bus implementation |
0 | 50 |
_LIT(KIicPslFileName, "iic_testpsl.pdd"); // Simulated PSL implementation |
51 |
_LIT(KSpiFileName, "spi.pdd"); // Simulated PSL bus implementation |
|
199 | 52 |
_LIT(KI2cFileName, "i2c.pdd"); // Simulated PSL bus implementation |
53 |
//These are used to exercise stubs. The I2C pdd to use for stub tests will depend on |
|
54 |
//whether Master, Slave mode has been selected. |
|
55 |
#if defined(MASTER_MODE)&&!defined(SLAVE_MODE) |
|
56 |
_LIT(KI2cFileNameStubs, "i2c_slavestubs_ctrless.pdd"); |
|
57 |
#elif !defined(MASTER_MODE)&& defined(SLAVE_MODE) |
|
58 |
_LIT(KI2cFileNameStubs, "i2c_masterstubs_ctrless.pdd"); |
|
59 |
#else |
|
60 |
_LIT(KI2cFileNameStubs, "i2c_ctrless.pdd"); |
|
61 |
#endif |
|
0 | 62 |
#endif |
63 |
||
64 |
_LIT(KIicPslFileNameRoot, "iic.pdd"); |
|
65 |
||
66 |
// Specify a stand-alone channel |
|
67 |
GLDEF_D TBool aStandAloneChan; |
|
68 |
||
69 |
GLDEF_D RTest gTest(testName); |
|
70 |
||
71 |
||
72 |
// SPI has Master channel numbers 1,2 and 4, Slave channel number 3 |
|
73 |
GLDEF_D RBusDevIicClient gChanMasterSpi; |
|
74 |
GLDEF_D RBusDevIicClient gChanSlaveSpi; |
|
75 |
||
76 |
// I2C has Master channel numbers 10 and 11, if built with MASTER_MODE, only |
|
77 |
// I2C has Slave channel numbers 12 and 13, if built with SLAVE_MODE, only |
|
78 |
// I2C has Master channel number 10 and Slave channel number 11 if built with both MASTER_MODE and SLAVE_MODE |
|
79 |
GLDEF_D RBusDevIicClient gChanMasterI2c; |
|
80 |
GLDEF_D RBusDevIicClient gChanSlaveI2c; |
|
81 |
||
82 |
LOCAL_C TInt CreateSingleUserSideTransfer(TUsideTferDesc*& aTfer, TInt8 aType, TInt8 aBufGran, TDes8* aBuf, TUsideTferDesc* aNext) |
|
83 |
// Utility function to create a single transfer |
|
84 |
{ |
|
85 |
aTfer = new TUsideTferDesc(); |
|
86 |
if(aTfer==NULL) |
|
87 |
return KErrNoMemory; |
|
88 |
aTfer->iType=aType; |
|
89 |
aTfer->iBufGranularity=aBufGran; |
|
90 |
aTfer->iBuffer = aBuf; |
|
91 |
aTfer->iNext = aNext; |
|
92 |
return KErrNone; |
|
93 |
} |
|
94 |
||
95 |
LOCAL_C TInt CreateSingleUserSideTransaction(TUsideTracnDesc*& aTracn, TBusType aType, TDes8* aHdr, TUsideTferDesc* aHalfDupTrans, TUsideTferDesc* aFullDupTrans, TUint8 aFlags, TAny* aPreambleArg, TAny* aMultiTranscArg) |
|
96 |
// Utility function to create a single transaction |
|
97 |
{ |
|
98 |
aTracn = new TUsideTracnDesc(); |
|
99 |
if(aTracn==NULL) |
|
100 |
return KErrNoMemory; |
|
101 |
aTracn->iType=aType; |
|
102 |
aTracn->iHeader=aHdr; |
|
103 |
aTracn->iHalfDuplexTrans=aHalfDupTrans; |
|
104 |
aTracn->iFullDuplexTrans=aFullDupTrans; |
|
105 |
aTracn->iFlags=aFlags; |
|
106 |
aTracn->iPreambleArg = aPreambleArg; |
|
107 |
aTracn->iMultiTranscArg = aMultiTranscArg; |
|
108 |
return KErrNone; |
|
109 |
} |
|
110 |
||
111 |
||
112 |
//---------------------------------------------------------------------------------------------- |
|
113 |
//! @SYMTestCaseID KBASE-T_IIC-2402 |
|
114 |
//! @SYMTestType UT |
|
115 |
//! @SYMPREQ PREQ2128,2129 |
|
116 |
//! @SYMTestCaseDesc This test case test the Master channel basic functionality |
|
117 |
//! @SYMTestActions 0) Create a transaction and invoke the synchronous Queue Transaction API |
|
118 |
//! |
|
119 |
//! 1) Re-use the transaction and invoke asynchronous Queue Transaction API. Wait for |
|
120 |
//| the TRequestStatus to be completed. |
|
121 |
//! |
|
122 |
//! 2) Instruct the Kernel-side proxy client to instigate testing of priority queuing. |
|
123 |
//! The proxy uses controlIO to block the transaction queue, then queues 5 transactions in reverse |
|
124 |
//! priority order. The proxy then uses controlIO to unblock the transaction queue and checks that |
|
125 |
//! the transactions complete in priority order. |
|
126 |
//! |
|
127 |
//! 3) Attempt to cancel a previously-completed asynchronous request for a queued transaction |
|
128 |
//! |
|
129 |
//! 4) Use controlio to block request completion. Issue two asynchronous Queue Transaction requests. |
|
130 |
//! Request cancellation of the second transaction. Wait for completion of the TRequestStatus for |
|
131 |
//! the second request. Attempt to de-register the channel. Use controlio to unblock request completion. |
|
132 |
//! Wait for completion of the TRequestStatus for the first request. |
|
133 |
//! |
|
134 |
//! 5) Attempt to de-register a channel that is not busy. |
|
135 |
//! |
|
136 |
//! 6) Attempt to queue a transaction on an invalid (de-registered) channel |
|
137 |
//! |
|
138 |
//! 7) Instruct the Kernel-side proxy client to instigate construction of a valid full duplex transaction. |
|
139 |
//! |
|
140 |
//! 8) Instruct the Kernel-side proxy client to instigate construction of a invalid full duplex transaction, |
|
141 |
//! where both transfer in same direction |
|
142 |
//! |
|
143 |
//! 9) Instruct the Kernel-side proxy client to instigate construction of a invalid full duplex transaction, |
|
144 |
//! where with different node length (not the number of node on opposite linklist ) at the same |
|
145 |
//! position on the opposite transfer linklist |
|
146 |
//! |
|
147 |
//! 10) Instruct the Kernel-side proxy client to instigate construction of a valid full duplex transaction, |
|
148 |
//! with different size for the last node |
|
149 |
//! |
|
150 |
//! 11) Instruct the Kernel-side proxy client to instigate construction of a valid full duplex transaction, |
|
151 |
//! with different number of transfer |
|
152 |
//! |
|
153 |
//! |
|
154 |
//! @SYMTestExpectedResults 0) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
155 |
//! 1) Kernel-side proxy client should return with KErrNone, exits otherwise. TRequestStatus should |
|
156 |
//! be set to KErrNone, exits otherwise. |
|
157 |
//! 2) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
158 |
//! 3) Kernel-side proxy client should return with KErrNone, exits otherwise.TRequestStatus should |
|
159 |
//! be set to KErrNone, exits otherwise. |
|
160 |
//! 4) The TRequestStatus for the cancelled request should be set to KErrCancel, exits otherwise. |
|
161 |
//! The attempt to de-register the channel should return KErrInUse, exits otherwise. The |
|
162 |
//! TRequestStatus for the first request should be set to KErrNone, exits otherwise. |
|
163 |
//! 5) Kernel-side proxy client should return with KErrNone or KErrArgument, exits otherwise. |
|
164 |
//! 6) Kernel-side proxy client should return with KErrArgument, exits otherwise. |
|
165 |
//! 7) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
166 |
//! 8) Kernel-side proxy client should return with KErrNotSupported, exits otherwise. |
|
167 |
//! 9) Kernel-side proxy client should return with KErrNotSupported, exits otherwise. |
|
168 |
//! 10) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
169 |
//! 11) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
170 |
//! |
|
171 |
//! @SYMTestPriority High |
|
172 |
//! @SYMTestStatus Implemented |
|
173 |
//---------------------------------------------------------------------------------------------- |
|
174 |
LOCAL_C TInt MasterBasicTests() |
|
175 |
// |
|
176 |
// Exercise the Master Channel API with trivial data |
|
177 |
// |
|
178 |
{ |
|
179 |
gTest.Printf(_L("\n\nStarting MasterBasicTests\n")); |
|
180 |
||
181 |
TInt r=KErrNone; |
|
182 |
||
183 |
TUint32 busIdSpi = 0; |
|
184 |
||
185 |
// Use the SPI bus |
|
186 |
// SPI uses channel numbers 1,2,3 and 4 |
|
187 |
SET_BUS_TYPE(busIdSpi,ESpi); |
|
188 |
SET_CHAN_NUM(busIdSpi,2); |
|
189 |
TConfigSpiBufV01* spiBuf = NULL; |
|
190 |
// aDeviceId=1 ... 100kHz ... aTimeoutPeriod=100 ... aTransactionWaitCycles=10 - arbitrary paarmeters. |
|
191 |
r = CreateSpiBuf(spiBuf, ESpiWordWidth_8, 100000, ESpiPolarityLowRisingEdge, 100 ,ELittleEndian, EMsbFirst, 10, ESpiCSPinActiveLow); |
|
192 |
gTest(r==KErrNone); |
|
193 |
||
194 |
// Use a single transfer |
|
195 |
_LIT(halfDuplexText,"Half Duplex Text"); |
|
196 |
TBuf8<17> halfDuplexBuf_8; |
|
197 |
halfDuplexBuf_8.Copy(halfDuplexText); |
|
198 |
TUsideTferDesc* tfer = NULL; |
|
199 |
r = CreateSingleUserSideTransfer(tfer, EMasterWrite, 8, &halfDuplexBuf_8, NULL); |
|
200 |
gTest(r==KErrNone); |
|
201 |
||
202 |
// Create the transaction object |
|
203 |
TUsideTracnDesc* tracn = NULL; |
|
204 |
r = CreateSingleUserSideTransaction(tracn, ESpi, spiBuf, tfer, NULL, 0, NULL, NULL); |
|
205 |
gTest(r==KErrNone); |
|
206 |
||
207 |
// Test basic queueing operations |
|
208 |
// inline TInt QueueTransaction(TInt aBusId, TUsideTracnDesc* aTransaction) |
|
209 |
gTest.Printf(_L("\n\nStarting synchronous QueueTransaction \n")); |
|
210 |
r = gChanMasterSpi.QueueTransaction(busIdSpi, tracn); |
|
211 |
gTest.Printf(_L("Synchronous QueueTransaction returned = %d\n"),r); |
|
212 |
gTest(r==KErrNone); |
|
213 |
// inline void QueueTransaction(TRequestStatus& aStatus, TInt aBusId, TUsideTracnDesc* aTransaction) |
|
214 |
gTest.Printf(_L("\n\nStarting asynchronous QueueTransaction \n")); |
|
215 |
TRequestStatus status; |
|
216 |
||
217 |
gChanMasterSpi.QueueTransaction(status, busIdSpi, tracn); |
|
218 |
User::WaitForRequest(status); |
|
219 |
if(status != KErrNone) |
|
220 |
{ |
|
221 |
gTest.Printf(_L("TRequestStatus value after queue = %d\n"), status.Int()); |
|
222 |
gTest(EFalse); |
|
223 |
} |
|
224 |
||
225 |
// Test message with priorities |
|
226 |
gTest.Printf(_L("\n\nStarting test for message with priorities\n\n"),r); |
|
227 |
r = gChanMasterSpi.TestPriority(busIdSpi); |
|
228 |
gTest(r==KErrNone); |
|
229 |
||
230 |
// Test cancel operation (on previously completed request) |
|
231 |
||
232 |
// inline void CancelAsyncOperation(TRequestStatus* aStatus, TInt aBusId) {TInt* parms[2]; parms[0]=(TInt*)aStatus; parms[1]=(TInt*)aBusId;DoCancel((TInt)&parms[0]);} |
|
233 |
gTest.Printf(_L("\n\nStarting CancelAsyncOperation \n")); |
|
234 |
gChanMasterSpi.CancelAsyncOperation(&status, busIdSpi); |
|
235 |
if(status == KRequestPending) |
|
236 |
User::WaitForRequest(status); |
|
237 |
if(status != KErrNone) |
|
238 |
{ |
|
239 |
gTest.Printf(_L("TRequestStatus value after (belated) cancel = %d\n"), status.Int()); |
|
240 |
gTest(EFalse); |
|
241 |
} |
|
242 |
||
243 |
// Test cancel operation (on pending request) |
|
244 |
// Also test that a channel with a transaction queued can not be de-registered. |
|
245 |
// For this: |
|
246 |
// (1) create a second transaction object |
|
247 |
// (2) use controlio/StaticExtension to block request completion |
|
248 |
// (3) use asynchronous queue transaction for the two transaction objects |
|
249 |
// (4) request cancellation of the second request |
|
250 |
// (5) check that the TRequestStatus object associated with the second request is completed with KErrCancel |
|
251 |
// (6) check that attempt to de-register the channel fails with KErrInUse |
|
252 |
// (7) use controlio/StaticExtension to unblock request completion |
|
253 |
// (8) check that the TRequestStatus object associated with the first request is completed with KErrNone |
|
254 |
// |
|
255 |
gTest.Printf(_L("\n\nStarting (successful) cancellation test\n\n"),r); |
|
256 |
_LIT(halfDuplexText2,"2 Half Duplex Text 2"); |
|
257 |
TBuf8<21> halfDuplexBuf2_8; |
|
258 |
halfDuplexBuf2_8.Copy(halfDuplexText2); |
|
259 |
TUsideTferDesc* tfer2 = NULL; |
|
260 |
r = CreateSingleUserSideTransfer(tfer2, EMasterRead, 16, &halfDuplexBuf2_8, NULL); |
|
261 |
gTest(r == KErrNone); |
|
262 |
||
263 |
TUsideTracnDesc* tracn2 = NULL; |
|
264 |
delete spiBuf; |
|
265 |
spiBuf = NULL; |
|
266 |
||
267 |
// aDeviceId=1 ... 100kHz ... aTimeoutPeriod=100 ... aTransactionWaitCycles=10 - arbitrary paarmeters. |
|
268 |
r = CreateSpiBuf(spiBuf, ESpiWordWidth_8, 100000, ESpiPolarityLowRisingEdge, 100 ,ELittleEndian, EMsbFirst, 10, ESpiCSPinActiveLow); |
|
269 |
gTest(r == KErrNone); |
|
270 |
||
271 |
r = CreateSingleUserSideTransaction(tracn2, ESpi, spiBuf, tfer2, NULL, 0, NULL, NULL); |
|
272 |
gTest(r == KErrNone); |
|
273 |
||
274 |
// |
|
275 |
gTest.Printf(_L("Invoking BlockReqCompletion\n")); |
|
276 |
r = gChanMasterSpi.BlockReqCompletion(busIdSpi); |
|
277 |
gTest.Printf(_L("BlockReqCompletion returned = %d\n"),r); |
|
278 |
gTest(r == KErrNone); |
|
279 |
||
280 |
// |
|
281 |
gTest.Printf(_L("Queueing first transaction \n")); |
|
282 |
gChanMasterSpi.QueueTransaction(status, busIdSpi, tracn); |
|
283 |
TRequestStatus status2; |
|
284 |
||
285 |
gTest.Printf(_L("Queueing second transaction \n")); |
|
286 |
gChanMasterSpi.QueueTransaction(status2, busIdSpi, tracn2); |
|
287 |
// |
|
288 |
User::After(50000); |
|
289 |
// |
|
290 |
gTest.Printf(_L("Issuing Cancel for second transaction\n")); |
|
291 |
gChanMasterSpi.CancelAsyncOperation(&status2, busIdSpi); |
|
292 |
gTest.Printf(_L("Returned from Cancel for second transaction\n")); |
|
293 |
if(status2 == KRequestPending) |
|
294 |
User::WaitForRequest(status2); |
|
295 |
if(status2 != KErrCancel) |
|
296 |
{ |
|
297 |
gTest.Printf(_L("TRequestStatus (2) value after cancel = %d\n"), status2.Int()); |
|
298 |
gTest(EFalse); |
|
299 |
} |
|
300 |
||
301 |
// If it is stand-alone channel, the client is reponsible for channel creation. |
|
302 |
// So the RegisterChan and DeRegisterChan are not needed. |
|
303 |
if (aStandAloneChan == 0) |
|
304 |
{ |
|
305 |
gTest.Printf(_L("Invoking DeRegisterChan\n")); |
|
306 |
r = gChanMasterSpi.DeRegisterChan(busIdSpi); |
|
307 |
||
308 |
gTest.Printf(_L("DeRegisterChan returned = %d\n"),r); |
|
309 |
gTest(r==KErrInUse); |
|
310 |
} |
|
311 |
// |
|
312 |
gTest.Printf(_L("Invoking UnlockReqCompletion\n")); |
|
313 |
r = gChanMasterSpi.UnblockReqCompletion(busIdSpi); |
|
314 |
gTest.Printf(_L("UnblockReqCompletion returned = %d\n"),r); |
|
315 |
// |
|
316 |
User::After(50000); |
|
317 |
// |
|
318 |
User::WaitForRequest(status); |
|
319 |
if(status != KErrNone) |
|
320 |
{ |
|
321 |
gTest.Printf(_L("TRequestStatus value after queue = %d\n"), status.Int()); |
|
322 |
gTest(EFalse); |
|
323 |
} |
|
324 |
||
325 |
// Clean up |
|
326 |
delete spiBuf; |
|
327 |
delete tfer; |
|
328 |
delete tracn; |
|
329 |
delete tfer2; |
|
330 |
delete tracn2; |
|
331 |
||
332 |
gTest.Printf(_L("\n\nStarting full duplex transaction creation test\n\n"),r); |
|
333 |
||
334 |
TUint32 busIdSpiFd = 0; |
|
335 |
||
336 |
// Use the SPI bus |
|
337 |
// SPI uses channel numbers 1,2,3 and 4 |
|
338 |
SET_BUS_TYPE(busIdSpi,ESpi); |
|
339 |
SET_CHAN_NUM(busIdSpi,4); |
|
340 |
||
341 |
// Test creating a valid full duplex transaction |
|
342 |
gTest.Printf(_L("\n\nStarting valid full duplex transaction test\n\n"),r); |
|
343 |
r = gChanMasterSpi.TestValidFullDuplexTrans(busIdSpiFd); |
|
344 |
gTest(r==KErrNone); |
|
345 |
||
346 |
// Test creating a full duplex transaction with both transfer in same direction (invalid) |
|
347 |
gTest.Printf(_L("\n\nStarting invalid direction full duplex transaction test\n\n"),r); |
|
348 |
r = gChanMasterSpi.TestInvalidFullDuplexTrans1(busIdSpiFd); |
|
349 |
gTest.Printf(_L("Full duplex transaction with invalid direction returned = %d\n"),r); |
|
350 |
gTest(r==KErrNotSupported); |
|
351 |
||
352 |
// Test creating a full duplex transaction with different node length (not the number of node on opposite linklist ) |
|
353 |
// at the same position on the opposite transfer linklist |
|
354 |
gTest.Printf(_L("\n\nStarting invalid transfer length full duplex transaction test\n\n"),r); |
|
355 |
r = gChanMasterSpi.TestInvalidFullDuplexTrans2(busIdSpiFd); |
|
356 |
gTest(r==KErrNotSupported); |
|
357 |
||
358 |
// Test creating a valid full duplex transaction with different size for the last node |
|
359 |
gTest.Printf(_L("\n\nStarting valid full duplex transaction test with diff size last node\n\n"),r); |
|
360 |
r = gChanMasterSpi.TestLastNodeFullDuplexTrans(busIdSpiFd); |
|
361 |
gTest(r==KErrNone); |
|
362 |
||
363 |
// Test creating a valid full duplex transaction with different number of transfer |
|
364 |
gTest.Printf(_L("\n\nStarting valid full duplex transaction test with diff number of transfer\n\n"),r); |
|
365 |
r = gChanMasterSpi.TestDiffNodeNumFullDuplexTrans(busIdSpiFd); |
|
366 |
gTest(r==KErrNone); |
|
367 |
||
368 |
return KErrNone; |
|
369 |
} |
|
370 |
||
371 |
||
372 |
//---------------------------------------------------------------------------------------------- |
|
373 |
//! @SYMTestCaseID KBASE-T_IIC-2403 |
|
374 |
//! @SYMTestType UT |
|
375 |
//! @SYMPREQ PREQ2128,2129 |
|
376 |
//! @SYMTestCaseDesc This test case tests the Master channel data handling for transactions |
|
377 |
//! @SYMTestActions 0) Instruct the kernel-side proxy to construct a transaction of pre-defined data |
|
378 |
//! and inform the simulated bus to expect to receive this data. Then the proxy invokes |
|
379 |
//! the synchronous Queue Transaction API. On receipt of the transaction, the simulated bus |
|
380 |
//! checks the header and transafer content of the transaction to confirm that it is correct. |
|
381 |
//! |
|
382 |
//! @SYMTestExpectedResults 0) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
383 |
//! |
|
384 |
//! @SYMTestPriority High |
|
385 |
//! @SYMTestStatus Implemented |
|
386 |
//---------------------------------------------------------------------------------------------- |
|
387 |
LOCAL_C TInt MasterTransactionTests() |
|
388 |
// |
|
389 |
// Exercise the Master Channel API with trivial data |
|
390 |
// |
|
391 |
{ |
|
392 |
gTest.Printf(_L("\n\nStarting MasterTransactionTests\n")); |
|
393 |
||
394 |
TInt r = KErrNone; |
|
395 |
||
396 |
// Prove that the simulated bus can access the transfer data contained within a transaction |
|
397 |
// Do this by instructing the proxy client to: |
|
398 |
// (1) Inform the bus of the test about to be informed |
|
399 |
// (2) Send a transaction with a known number of transfers with known data |
|
400 |
// (3) Check the result announced by the bus. |
|
401 |
// |
|
402 |
// Use the SPI bus |
|
403 |
// SPI uses channel numbers 1,2,3 and 4 |
|
404 |
TUint32 busIdSpi = 0; |
|
405 |
SET_BUS_TYPE(busIdSpi,ESpi); |
|
406 |
SET_CHAN_NUM(busIdSpi,4); // Master, Full-duplex - required by TestBufferReUse |
|
407 |
r = gChanMasterSpi.TestTracnOne(busIdSpi); |
|
408 |
gTest.Printf(_L("TestTracnOne returned = %d\n"),r); |
|
409 |
gTest(r==KErrNone); |
|
410 |
||
411 |
// Test that transfer and transaction buffers can be modifed for re-use |
|
412 |
// This test modifies the content of a full-duplex transaction - so a full-duplex channel must be used |
|
413 |
TRequestStatus status; |
|
414 |
gChanMasterSpi.TestBufferReUse(busIdSpi, status); |
|
415 |
User::WaitForRequest(status); |
|
416 |
r=status.Int(); |
|
417 |
if(r != KErrNone) |
|
418 |
{ |
|
419 |
gTest.Printf(_L("TRequestStatus value after CaptureChannel = %d\n"),r); |
|
420 |
gTest(r==KErrCompletion); |
|
421 |
} |
|
422 |
||
423 |
return KErrNone; |
|
424 |
} |
|
425 |
||
426 |
//---------------------------------------------------------------------------------------------- |
|
427 |
//! @SYMTestCaseID KBASE-T_IIC-2401 |
|
428 |
//! @SYMTestType UT |
|
429 |
//! @SYMPREQ PREQ2128,2129 |
|
430 |
//! @SYMTestCaseDesc This test case test the Master channel preamble and multi-transaction functionality. |
|
431 |
//! @SYMTestActions 0) Create a transaction that requires preamble support, and queue it for processing |
|
432 |
//! |
|
433 |
//! 1) If the test has been invoked for preamble testing, wait for the preamble-specific |
|
434 |
//! TRequestStatus to be completed. |
|
435 |
//! |
|
436 |
//! 2) If the test has been invoked for multi-transaction testing, wait for the multi-transaction |
|
437 |
//! -specific TRequestStatus to be completed. |
|
438 |
//! |
|
439 |
//! |
|
440 |
//! @SYMTestExpectedResults 0) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
441 |
//! 1) If waiting on the preamble-specific TRequestStatus, it should be set to KErrNone, exists otherwise. |
|
442 |
//! 2) If waiting on the multi-transaction-specific TRequestStatus, it should be set to KErrNone, exists otherwise. |
|
443 |
//! |
|
444 |
//! @SYMTestPriority High |
|
445 |
//! @SYMTestStatus Implemented |
|
446 |
//---------------------------------------------------------------------------------------------- |
|
447 |
LOCAL_C TInt MasterExtTests(TUint8 aFlags) |
|
448 |
// |
|
449 |
// Exercise the Master Channel API for Preamble functionality |
|
450 |
// |
|
451 |
||
452 |
// For the multi-transaction test, a bus Master might not know |
|
453 |
// how much data to write to a Slave until it performs a single read on it. |
|
454 |
// However, specifying a read separately from the subsequent write |
|
455 |
// introduces the risk of allowing another transaction to go ahead of the |
|
456 |
// following write and thus invalidating it. The multi-transaction feature of IIC |
|
457 |
// allows a callback to be called(in the context of the bus channel) after |
|
458 |
// the transfers of a preliminary transaction have taken place |
|
459 |
// (could be a single read), without completing the overall transaction, |
|
460 |
// then extend the delayed transaction by inserting more transfers |
|
461 |
// |
|
462 |
{ |
|
463 |
gTest.Printf(_L("\n\nStarting MasterExtTests\n")); |
|
464 |
||
465 |
TInt r = KErrNone; |
|
466 |
||
467 |
// Create a transaction that requires preamble support |
|
468 |
// To prove required operation has executed, make callback complete a TRequestStatus object |
|
469 |
TRequestStatus preamblestatus; |
|
470 |
TRequestStatus multitranscstatus; |
|
471 |
||
472 |
// Use the SPI bus |
|
473 |
// SPI uses channel numbers 1,2,3 and 4 |
|
474 |
TUint32 busIdSpi = 0; |
|
475 |
SET_BUS_TYPE(busIdSpi, ESpi); |
|
476 |
SET_CHAN_NUM(busIdSpi, 1); |
|
477 |
TConfigSpiBufV01* spiBuf = NULL; |
|
478 |
// aDeviceId=1 ... 100kHz ... aTimeoutPeriod=100 ... aTransactionWaitCycles=10 - arbitrary paarmeters. |
|
479 |
r = CreateSpiBuf(spiBuf, ESpiWordWidth_8, 100000, |
|
480 |
ESpiPolarityLowRisingEdge, 100, ELittleEndian, EMsbFirst, 10, |
|
481 |
ESpiCSPinActiveLow); |
|
482 |
if (r != KErrNone) |
|
483 |
return r; |
|
484 |
||
485 |
// Use a single transfer |
|
486 |
_LIT(extText, "Ext Text"); |
|
487 |
TBuf8<14> extBuf_8; |
|
488 |
extBuf_8.Copy(extText); |
|
489 |
TUsideTferDesc* tfer = NULL; |
|
490 |
r = CreateSingleUserSideTransfer(tfer, EMasterRead, 8, &extBuf_8, NULL); |
|
491 |
if (r != KErrNone) |
|
492 |
{ |
|
493 |
delete spiBuf; |
|
494 |
return r; |
|
495 |
} |
|
496 |
||
497 |
// Create the transaction object |
|
498 |
TUsideTracnDesc* tracn = NULL; |
|
499 |
r = CreateSingleUserSideTransaction(tracn, ESpi, spiBuf, tfer, NULL, |
|
500 |
aFlags, (TAny*) &preamblestatus, (TAny*) &multitranscstatus); |
|
501 |
||
502 |
if (r != KErrNone) |
|
503 |
{ |
|
504 |
delete spiBuf; |
|
505 |
delete tfer; |
|
506 |
return r; |
|
507 |
} |
|
508 |
||
509 |
// Send the transaction to the kernel-side proxy |
|
510 |
// inline TInt QueueTransaction(TInt aBusId, TUsideTracnDesc* aTransaction) |
|
511 |
gTest.Printf(_L("\nInvoke synchronous QueueTransaction for preamble test %x\n"), tracn); |
|
512 |
||
513 |
r = gChanMasterSpi.QueueTransaction(busIdSpi, tracn); |
|
514 |
gTest.Printf(_L("synchronous QueueTransaction returned = %d\n"), r); |
|
515 |
||
516 |
if (r == KErrNone) |
|
517 |
{ |
|
518 |
// ... and wait for the TRequestStatus object to be completed |
|
519 |
if (aFlags & KTransactionWithPreamble) |
|
520 |
{ |
|
521 |
User::WaitForRequest(preamblestatus); |
|
522 |
r = preamblestatus.Int(); |
|
523 |
if (r != KErrNone) |
|
524 |
{ |
|
525 |
gTest.Printf(_L("MasterPreambleTests: TRequestStatus completed with = %d\n"), r); |
|
526 |
} |
|
527 |
} |
|
528 |
||
529 |
||
530 |
if (aFlags & KTransactionWithMultiTransc) |
|
531 |
{ |
|
532 |
User::WaitForRequest(multitranscstatus); |
|
533 |
if (r != KErrNone) |
|
534 |
{ |
|
535 |
gTest.Printf(_L("MasterMultiTranscTests: TRequestStatus completed with = %d\n"), r); |
|
536 |
} |
|
537 |
} |
|
538 |
} |
|
539 |
||
540 |
delete spiBuf; |
|
541 |
delete tfer; |
|
542 |
delete tracn; |
|
543 |
||
544 |
return r; |
|
545 |
} |
|
546 |
||
547 |
#ifdef SLAVE_MODE |
|
548 |
LOCAL_C TInt CreateSlaveChanI2cConfig(TConfigI2cBufV01*& aI2cBuf, TUint32& aBusIdI2c, TUint8 aChanNum) |
|
549 |
{ |
|
550 |
// Initialise TConfigI2cBufV01 and the Bus Realisation Config for gChanSlaveI2c. |
|
551 |
// Customised: |
|
552 |
// - token containing the bus realisation variability. |
|
553 |
// - pointer to a descriptor containing the device specific configuration option applicable to all transactions. |
|
554 |
// - reference to variable to hold a platform-specific cookie that uniquely identifies the channel instance to be |
|
555 |
// used by this client |
|
556 |
aBusIdI2c = 0; |
|
557 |
SET_BUS_TYPE(aBusIdI2c,EI2c); |
|
558 |
SET_CHAN_NUM(aBusIdI2c,aChanNum); |
|
559 |
// |
|
560 |
// clock speed=36Hz, aTimeoutPeriod=100 - arbitrary parameter |
|
561 |
TInt r=CreateI2cBuf(aI2cBuf, EI2cAddr7Bit, 36, ELittleEndian, 100); |
|
562 |
return r; |
|
563 |
} |
|
564 |
||
565 |
LOCAL_C TInt SyncCaptureGChanSlaveI2c(TInt& aChanId, TConfigI2cBufV01* aI2cBuf, TUint32 aBusIdI2c) |
|
566 |
{ |
|
567 |
// Synchronous capture of a Slave channel. Need to provide: |
|
568 |
// - token containing the bus realisation variability. |
|
569 |
// - pointer to a descriptor containing the device specific configuration option applicable to all transactions. |
|
570 |
// - reference to variable to hold a platform-specific cookie that uniquely identifies the channel instance to be used by this client |
|
571 |
gTest.Printf(_L("\n\nStarting synchronous CaptureChannel \n")); |
|
572 |
TInt r = gChanSlaveI2c.CaptureChannel(aBusIdI2c, aI2cBuf, aChanId ); |
|
573 |
gTest.Printf(_L("Synchronous CaptureChannel returned = %d, aChanId=0x%x\n"),r,aChanId); |
|
574 |
return r; |
|
575 |
} |
|
576 |
||
577 |
||
578 |
LOCAL_C TInt AsyncCaptureGChanSlaveI2c(TInt& aChanId, TConfigI2cBufV01* aI2cBuf, TUint32 aBusIdI2c) |
|
579 |
{ |
|
580 |
// Asynchronous capture of a Slave channel. Need to provide: |
|
581 |
// - token containing the bus realisation variability. |
|
582 |
// - pointer to a descriptor containing the device specific configuration option applicable to all transactions. |
|
583 |
// - reference to variable to hold a platform-specific cookie that uniquely identifies the channel instance to be used by this client |
|
584 |
// - pointer to TRequestStatus used to indicate operation completion |
|
585 |
gTest.Printf(_L("\n\nStarting asynchronous CaptureChannel \n")); |
|
586 |
TRequestStatus status; |
|
587 |
TInt r = gChanSlaveI2c.CaptureChannel(aBusIdI2c, aI2cBuf, aChanId, status ); |
|
588 |
gTest(r==KErrNone); |
|
589 |
User::WaitForRequest(status); |
|
590 |
r=status.Int(); |
|
591 |
if(r != KErrCompletion) |
|
592 |
{ |
|
593 |
gTest.Printf(_L("TRequestStatus value after CaptureChannel = %d\n"),r); |
|
594 |
gTest(r==KErrCompletion); |
|
595 |
} |
|
596 |
gTest.Printf(_L("Asynchronous CaptureChannel gave aChanId=0x%x\n"),aChanId); |
|
597 |
return KErrNone; |
|
598 |
} |
|
599 |
#endif |
|
600 |
//---------------------------------------------------------------------------------------------- |
|
601 |
//! @SYMTestCaseID KBASE-T_IIC-2399 |
|
602 |
//! @SYMTestType UT |
|
603 |
//! @SYMPREQ PREQ2128,2129 |
|
604 |
//! @SYMTestCaseDesc This test case tests Slave channel capture and release APIs. |
|
605 |
//! @SYMTestActions 0) Perform synchronous capture of a channel |
|
606 |
//! |
|
607 |
//! 1) Release the channel |
|
608 |
//! |
|
609 |
//! 2) Perform asynchronous capture of a channel |
|
610 |
//! |
|
611 |
//! 3) Attempt synchronous capture of a channel that is already captured |
|
612 |
//! |
|
613 |
//! 4) Attempt asynchronous capture of a channel that is already captured |
|
614 |
//! |
|
615 |
//! 5) Release the channel |
|
616 |
//! |
|
617 |
//! @SYMTestExpectedResults 0) Kernel-side proxy client should return with KErrCompletion, exits otherwise. |
|
618 |
//! 1) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
619 |
//! 2) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
620 |
//! 3) Kernel-side proxy client should return with KErrInUse, exits otherwise. |
|
621 |
//! 4) Kernel-side proxy client should return with KErrNone, exits otherwise. The associated |
|
622 |
//! TRequestStatus should be set to KErrInUse, exits otherwise. |
|
623 |
//! 5) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
624 |
//! |
|
625 |
//! @SYMTestPriority High |
|
626 |
//! @SYMTestStatus Implemented |
|
627 |
//---------------------------------------------------------------------------------------------- |
|
628 |
LOCAL_C TInt SlaveChannelCaptureReleaseTests() |
|
629 |
// |
|
630 |
// Exercise the Slave Channel API for channel capture and release |
|
631 |
// |
|
632 |
{ |
|
633 |
gTest.Printf(_L("\n\nStarting SlaveChannelCaptureReleaseTests\n")); |
|
634 |
TInt r=KErrNone; |
|
635 |
#ifdef SLAVE_MODE |
|
636 |
||
637 |
// Create a I2C configuration buffer and the configuration data for use in capturing gChanSlaveI2c |
|
638 |
TUint32 busIdI2c = 0; |
|
639 |
TConfigI2cBufV01* i2cBuf=NULL; |
|
640 |
r=CreateSlaveChanI2cConfig(i2cBuf, busIdI2c, 11); // 11 is the Slave channel number |
|
641 |
gTest(r==KErrNone); |
|
642 |
||
643 |
// Synchronous capture of a Slave channel. |
|
644 |
TInt chanId = 0; // Initialise to zero to silence compiler ... |
|
645 |
r=SyncCaptureGChanSlaveI2c(chanId, i2cBuf, busIdI2c); |
|
646 |
gTest(r==KErrNone); |
|
647 |
// |
|
648 |
// Release the channel |
|
649 |
gTest.Printf(_L("\n\nInvoke ReleaseChannel for chanId=0x%x \n"),chanId); |
|
650 |
r = gChanSlaveI2c.ReleaseChannel( chanId ); |
|
651 |
gTest.Printf(_L("ReleaseChannel returned = %d\n"),r); |
|
652 |
gTest(r==KErrNone); |
|
653 |
// |
|
654 |
// Asynchronous capture of a Slave channel. |
|
655 |
chanId = 0; // Re-initialise to zero to silence compiler ... |
|
656 |
r=AsyncCaptureGChanSlaveI2c(chanId, i2cBuf, busIdI2c); |
|
657 |
gTest(r==KErrNone); |
|
658 |
||
659 |
// Try capturing a slave channel that is already captured |
|
660 |
// |
|
661 |
// Create another instance of a client, and use to attempt duplicated capture |
|
662 |
TInt dumChanId = 0; // Initialise to zero to silence compiler ... |
|
663 |
RBusDevIicClient tempChanSlaveI2c; |
|
664 |
TBufC<24> proxySlaveName; |
|
665 |
if(aStandAloneChan == 0) |
|
666 |
proxySlaveName = KIicProxySlaveFileNameRoot; |
|
667 |
else |
|
668 |
proxySlaveName = KIicProxySlaveFileNameRootCtrlLess; |
|
669 |
r = tempChanSlaveI2c.Open(proxySlaveName); |
|
670 |
gTest(r==KErrNone); |
|
671 |
r = tempChanSlaveI2c.InitSlaveClient(); |
|
672 |
gTest(r==KErrNone); |
|
673 |
// |
|
674 |
// Synchronous capture |
|
675 |
gTest.Printf(_L("\n\nStarting attempted synchronous CaptureChannel of previously-captured channel\n")); |
|
676 |
r = tempChanSlaveI2c.CaptureChannel(busIdI2c, i2cBuf, dumChanId ); |
|
677 |
gTest.Printf(_L("Synchronous CaptureChannel returned = %d, dumChanId=0x%x\n"),r,dumChanId); |
|
678 |
gTest(r==KErrInUse); |
|
679 |
// |
|
680 |
// Asynchronous capture |
|
681 |
dumChanId = 0; |
|
682 |
gTest.Printf(_L("\n\nStarting attempted asynchronous CaptureChannel of previously-captured channel\n")); |
|
683 |
TRequestStatus status; |
|
684 |
r = tempChanSlaveI2c.CaptureChannel(busIdI2c, i2cBuf, dumChanId, status ); |
|
685 |
gTest(r==KErrNone); |
|
686 |
User::WaitForRequest(status); |
|
687 |
r=status.Int(); |
|
688 |
if(r != KErrInUse) |
|
689 |
{ |
|
690 |
gTest.Printf(_L("TRequestStatus value after attempted CaptureChannel of previously-captured channel = %d\n"),r); |
|
691 |
gTest(r==KErrInUse); |
|
692 |
} |
|
693 |
gTest.Printf(_L("Asynchronous CaptureChannel gave dumChanId=0x%x\n"),dumChanId); |
|
694 |
||
695 |
tempChanSlaveI2c.Close(); |
|
696 |
// |
|
697 |
// Clean up, release the channel |
|
698 |
r = gChanSlaveI2c.ReleaseChannel( chanId ); |
|
699 |
gTest.Printf(_L("ReleaseChannel returned = %d\n"),r); |
|
700 |
gTest(r==KErrNone); |
|
701 |
||
702 |
delete i2cBuf; |
|
703 |
#else |
|
704 |
gTest.Printf(_L("\nSlaveChannelCaptureReleaseTests only supported when SLAVE_MODE is defined\n")); |
|
705 |
#endif |
|
706 |
return r; |
|
707 |
} |
|
708 |
||
709 |
//---------------------------------------------------------------------------------------------- |
|
710 |
//! @SYMTestCaseID KBASE-T_IIC-2400 |
|
711 |
//! @SYMTestType UT |
|
712 |
//! @SYMPREQ PREQ2128,2129 |
|
713 |
//! @SYMTestCaseDesc This test case tests Slave channel capture operation for receive and transmit of data |
|
714 |
//! @SYMTestActions 0) Check that the timeout threshold values can be updated |
|
715 |
//! |
|
716 |
//! 1) Check that an Rx Buffer can be registered, and that a replacement buffer can be registered in its place |
|
717 |
//! if a notification has not been requested. |
|
718 |
//! |
|
719 |
//! 2) Specify a notification trigger for Rx events |
|
720 |
//! |
|
721 |
//! 3) Attempt to register a replacement Rx buffer |
|
722 |
//! |
|
723 |
//! 4) Use controlIO to instruct the simulated bus to indicate that it has received the required number of words |
|
724 |
//! and wait for the TRequestStatus to be completed. |
|
725 |
//! |
|
726 |
//! 5) Specify a notification trigger for Rx events, use controlIO to instruct the simulated bus to indicate that |
|
727 |
//! it has received less than the required number of words and wait for the TRequestStatus to be completed. |
|
728 |
//! |
|
729 |
//! 6) Specify a notification trigger for Rx events, use controlIO to instruct the simulated bus to indicate that |
|
730 |
//! it has received more than the required number of words and wait for the TRequestStatus to be completed. |
|
731 |
//! |
|
732 |
//! 7) Repeat steps 1-6, but for Tx |
|
733 |
//! |
|
734 |
//! 8) Specify a notification trigger for Rx and Tx events. Use controlIO to instruct the simulated bus to indicate that |
|
735 |
//! it has received the required number of words, then that it has transmitted the required number of words, and wait |
|
736 |
//! for the TRequestStatus to be completed. |
|
737 |
//! |
|
738 |
//! 9) Repeat step 8, but simulate Tx, then Rx. |
|
739 |
//! |
|
740 |
//! 10) Specify a notification trigger for bus error events. Use controlIO to instruct the simulated bus to indicate that |
|
741 |
//! it has encountered a bus error, and wait for the TRequestStatus to be completed. |
|
742 |
//! |
|
743 |
//! 11) Use controlIO to instruct the simulated bus to block Master response. Specify a notification trigger for bus error |
|
744 |
//! events. Use controlIO to instruct the simulated bus to indicate that it has received more than the required number |
|
745 |
//! of words. Wait for the TRequestStatus to be completed (with KErrNone). Specify a notification trigger for Tx and |
|
746 |
//! Tx Overrun, then use controlIO to instruct the simulated bus to unblock Master responses.Wait for the TRequestStatus |
|
747 |
//! to be completed. |
|
199 | 748 |
//! |
749 |
//! 12) Test the PIL behavior for a client timeout: request notification of an event but deliberately delay the client response. |
|
750 |
//! The PIL should return KErrTimedOut when a subsequent request for a notification is made. |
|
0 | 751 |
//! |
752 |
//! @SYMTestExpectedResults 0) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
753 |
//! 1) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
754 |
//! 2) Kernel-side proxy client should return with KErrNone, exits otherwise. |
|
755 |
//! 3) Kernel-side proxy client should return with KErrAlreadyExists, exits otherwise. |
|
756 |
//! 4) Kernel-side proxy client should return with KErrNone, exits otherwise. The associated |
|
757 |
//! TRequestStatus should be set to KErrNone, exits otherwise. |
|
758 |
//! 5) Kernel-side proxy client should return with KErrNone for both API calls, exits otherwise. The associated |
|
759 |
//! TRequestStatus should be set to KErrNone, exits otherwise. |
|
760 |
//! 6) Kernel-side proxy client should return with KErrNone for both API calls, exits otherwise. The associated |
|
761 |
//! TRequestStatus should be set to KErrNone, exits otherwise. |
|
762 |
//! 7) Results should be the same as for steps 1-6. |
|
763 |
//! 8) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated |
|
764 |
//! TRequestStatus should be set to KErrNone, exits otherwise. |
|
765 |
//! 9) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated |
|
766 |
//! TRequestStatus should be set to KErrNone, exits otherwise. |
|
767 |
//! 10) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated |
|
768 |
//! TRequestStatus should be set to KErrNone, exits otherwise. |
|
769 |
//! 11) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated |
|
770 |
//! TRequestStatus should be set to KErrNone in both cases, exits otherwise. |
|
199 | 771 |
//! 12) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated |
772 |
//! TRequestStatus should be set to KErrNone in both cases, exits otherwise, except for when the client response |
|
773 |
//! exceeds the timeout period, and the next request for a notification expects KErrTimedOut. |
|
0 | 774 |
//! |
775 |
//! @SYMTestPriority High |
|
776 |
//! @SYMTestStatus Implemented |
|
777 |
//---------------------------------------------------------------------------------------------- |
|
778 |
||
779 |
LOCAL_C TInt SlaveRxTxNotificationTests() |
|
780 |
// |
|
781 |
// Exercise the Slave channel operation for receive and transmit of data |
|
782 |
// |
|
783 |
||
784 |
// The means to supply a buffer to be filled with data received from the Master, and the number of words expected. |
|
785 |
// It is only after the reception of the number of words specified that the notification should be issued |
|
786 |
// (or on under-run/overrun/timeout/bus specific error). |
|
787 |
// |
|
788 |
// The means to supply a buffer with data to be transmitted to the Master, and the number of words to transmit. |
|
789 |
// It is only after the transmission of the number of words specified that the notification should be issued |
|
790 |
// (or under-run/overrun/timeout/bus specific error). |
|
791 |
// |
|
792 |
// The means to enable and disable the events which will trigger the notification callback. These events are: |
|
793 |
// 1) the complete reception of the number of words specified, |
|
794 |
// 2) the complete transmission of the number of words specified, |
|
795 |
// 3) errors: receive buffer under-run (the Master terminates the transaction or reverts the direction of |
|
796 |
// transfer before all expected data has been received), receive buffer overrun |
|
797 |
// (Master attempts to write more data than this channel expected to receive), transmit buffer overrun |
|
798 |
// (Master attempts to read more data than supplied by client), transmit buffer under-run |
|
799 |
// (the Master terminates the transaction or reverts the direction of transfer before all expected data |
|
800 |
// has been transmitted to it), access timeout(1) error, or bus specific error (e.g. collision, framing). |
|
801 |
{ |
|
802 |
gTest.Printf(_L("\n\nStarting SlaveRxTxNotificationTests\n")); |
|
803 |
TInt r=KErrNone; |
|
804 |
#ifdef SLAVE_MODE |
|
805 |
||
806 |
//Configure and capture a channel |
|
807 |
gTest.Printf(_L("Create and capture channel\n")); |
|
808 |
TUint32 busIdI2c; |
|
809 |
TConfigI2cBufV01* i2cBuf=NULL; |
|
810 |
r=CreateSlaveChanI2cConfig(i2cBuf, busIdI2c, 11); // 11 is the Slave channel number |
|
811 |
gTest(r==KErrNone); |
|
812 |
||
813 |
TInt chanId = 0; // Initialise to zero to silence compiler ... |
|
814 |
r=SyncCaptureGChanSlaveI2c(chanId, i2cBuf, busIdI2c); |
|
815 |
gTest(r==KErrNone); |
|
816 |
||
817 |
// Update wait times for Master and Client |
|
818 |
// Delegate the operation of this test to the proxy client (iic_client). The proxy will read, modify, and reinstate |
|
819 |
// the timeout values. |
|
820 |
gTest.Printf(_L("Starting UpdateTimeoutValues\n")); |
|
821 |
r=gChanSlaveI2c.UpdateTimeoutValues(busIdI2c, chanId); |
|
822 |
gTest(r==KErrNone); |
|
823 |
||
824 |
||
825 |
// Receive and transmit buffers must be created by the client in Kernel heap and remain in their ownership throughout. |
|
826 |
// Therefore, the kernel-side proxy will provide the buffer |
|
827 |
// The buffers are of size KRxBufSizeInBytes and KRxBufSizeInBytes (currently 64) |
|
828 |
||
829 |
// |
|
830 |
// Rx tests |
|
831 |
// |
|
832 |
||
833 |
// For Rx, specify buffer granularity=4 (32-bit words), 8 words to receive, offset of 16 bytes |
|
834 |
// 64 bytes as 16 words: words 0-3 offset, words 4-11 data, words 12-15 unused |
|
835 |
gTest.Printf(_L("Starting RegisterRxBuffer\n")); |
|
836 |
r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16); |
|
837 |
gTest(r==KErrNone); |
|
838 |
// |
|
839 |
// If a buffer is already registered but a notification has not yet been requested the API should return KErrNone |
|
840 |
gTest.Printf(_L("Starting (repeated) RegisterRxBuffer\n")); |
|
841 |
r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16); |
|
842 |
gTest(r==KErrNone); |
|
843 |
// |
|
844 |
// Now set the notification trigger |
|
845 |
TRequestStatus status; |
|
846 |
TInt triggerMask=ERxAllBytes; |
|
847 |
gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes\n")); |
|
848 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
849 |
gTest(r==KErrNone); |
|
850 |
// |
|
851 |
// If a buffer is registered and a notification has been requested the API should return KErrAlreadyExists |
|
852 |
gTest.Printf(_L("Starting RegisterRxBuffer (to be rejected)\n")); |
|
853 |
r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16); |
|
854 |
gTest(r==KErrAlreadyExists); |
|
855 |
// |
|
856 |
// Now instruct the bus implementation to represent receipt of the required number of words from the bus master. |
|
857 |
gTest.Printf(_L("Starting SimulateRxNWords\n")); |
|
858 |
r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 8); |
|
859 |
gTest(r==KErrNone); |
|
860 |
// |
|
861 |
// Wait for the notification |
|
862 |
User::WaitForRequest(status); |
|
863 |
r=status.Int(); |
|
864 |
if(r != KErrNone) |
|
865 |
{ |
|
866 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
867 |
gTest(r==KErrNone); |
|
868 |
} |
|
869 |
gTest.Printf(_L("Starting Rx test completed OK\n")); |
|
870 |
// |
|
871 |
// Repeat for each error condition. Re-use the buffer previously registered. |
|
872 |
// |
|
873 |
// |
|
874 |
triggerMask=ERxAllBytes|ERxUnderrun; |
|
875 |
gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes\n")); |
|
876 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
877 |
gTest(r==KErrNone); |
|
878 |
// Now instruct the bus implementation to represent the bus master transmitting less words than anticipated (Rx Underrun) |
|
879 |
gTest.Printf(_L("Starting SimulateRxNWords for Underrun\n")); |
|
880 |
r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 6); |
|
881 |
gTest(r==KErrNone); |
|
882 |
// |
|
883 |
// Wait for the notification |
|
884 |
User::WaitForRequest(status); |
|
885 |
r=status.Int(); |
|
886 |
if(r != KErrNone) |
|
887 |
{ |
|
888 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
889 |
gTest(r==KErrNone); |
|
890 |
} |
|
891 |
gTest.Printf(_L("Rx Underrun test completed OK\n")); |
|
892 |
// Re-set the notification trigger |
|
893 |
triggerMask=ERxAllBytes|ERxOverrun; |
|
894 |
gTest.Printf(_L("Starting SetNotificationTrigger\n")); |
|
895 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
896 |
gTest(r==KErrNone); |
|
897 |
// Now instruct the bus implementation to represent the bus master attempting to transmit more words than |
|
898 |
// anticipated (Rx Overrun) |
|
899 |
gTest.Printf(_L("Starting SimulateRxNWords for Overrun\n")); |
|
900 |
r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 10); |
|
901 |
gTest(r==KErrNone); |
|
902 |
// |
|
903 |
// Wait for the notification |
|
904 |
User::WaitForRequest(status); |
|
905 |
r=status.Int(); |
|
906 |
if(r != KErrNone) |
|
907 |
{ |
|
908 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
909 |
gTest(r==KErrNone); |
|
910 |
} |
|
911 |
gTest.Printf(_L("Rx Overrun test completed OK\n")); |
|
912 |
||
913 |
// |
|
914 |
// Tx tests |
|
915 |
// |
|
916 |
||
917 |
// For Tx, specify buffer granularity=4 (32-bit words), 12 words to transmit, offset of 8 bytes |
|
918 |
// 64 bytes as 16 words: words 0-1 offset, words 2-13 data, words 14-15 unused |
|
919 |
gTest.Printf(_L("\nStarting RegisterTxBuffer\n")); |
|
920 |
r=gChanSlaveI2c.RegisterTxBuffer(chanId, 4, 12, 8); |
|
921 |
gTest(r==KErrNone); |
|
922 |
// |
|
923 |
// If a buffer is already registered but a notification has not yet been requested the API should return KErrNone |
|
924 |
gTest.Printf(_L("Starting (repeated) RegisterTxBuffer\n")); |
|
925 |
r=gChanSlaveI2c.RegisterTxBuffer(chanId, 4, 12, 8); |
|
926 |
gTest(r==KErrNone); |
|
927 |
// |
|
928 |
||
929 |
// Re-set the notification trigger |
|
930 |
// Now set the notification trigger |
|
931 |
gTest.Printf(_L("Starting SetNotificationTrigger\n")); |
|
932 |
triggerMask=ETxAllBytes; |
|
933 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
934 |
gTest(r==KErrNone); |
|
935 |
// |
|
936 |
// If a buffer is already registered, a subsequent request to do the same should return KErrAlreadyExists |
|
937 |
gTest.Printf(_L("Starting RegisterTxBuffer (to be rejected)\n")); |
|
938 |
r=gChanSlaveI2c.RegisterTxBuffer(chanId, 4, 12, 8); |
|
939 |
gTest(r==KErrAlreadyExists); |
|
940 |
// |
|
941 |
// Now instruct the bus implementation to represent transmission of the required number of words to the bus master. |
|
942 |
gTest.Printf(_L("Starting SimulateTxNWords (to be rejected)\n")); |
|
943 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 12); |
|
944 |
gTest(r==KErrNone); |
|
945 |
// |
|
946 |
// Wait for the notification |
|
947 |
User::WaitForRequest(status); |
|
948 |
r=status.Int(); |
|
949 |
if(r != KErrNone) |
|
950 |
{ |
|
951 |
gTest.Printf(_L("TRequestStatus value after transmitting data = %d\n"),r); |
|
952 |
gTest(r==KErrNone); |
|
953 |
} |
|
954 |
gTest.Printf(_L("Tx test completed OK\n")); |
|
955 |
// |
|
956 |
// Repeat for each error condition. Re-use the buffer previously registered |
|
957 |
// |
|
958 |
// Re-set the notification trigger |
|
959 |
gTest.Printf(_L("Starting SetNotificationTrigger\n")); |
|
960 |
triggerMask=ETxAllBytes|ETxOverrun; |
|
961 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
962 |
gTest(r==KErrNone); |
|
963 |
// Now instruct the bus implementation to represent transmission of less than the required number of words |
|
964 |
// to the bus master (Tx Overrun) |
|
965 |
gTest.Printf(_L("Starting SimulateTxNWords for Tx Overrun\n")); |
|
966 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 10); |
|
967 |
gTest(r==KErrNone); |
|
968 |
// |
|
969 |
// Wait for the notification |
|
970 |
User::WaitForRequest(status); |
|
971 |
r=status.Int(); |
|
972 |
if(r != KErrNone) |
|
973 |
{ |
|
974 |
gTest.Printf(_L("TRequestStatus value after transmitting data = %d\n"),r); |
|
975 |
gTest(r==KErrNone); |
|
976 |
} |
|
977 |
gTest.Printf(_L("Tx Overrun test completed OK\n")); |
|
978 |
// Re-set the notification trigger |
|
979 |
triggerMask=ETxAllBytes|ETxUnderrun; |
|
980 |
gTest.Printf(_L("Starting SetNotificationTrigger\n")); |
|
981 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
982 |
gTest(r==KErrNone); |
|
983 |
// Now instruct the bus implementation to represent the bus master attempting to read more words than |
|
984 |
// anticipated (Tx Underrun) |
|
985 |
gTest.Printf(_L("Starting SimulateTxNWords for Tx Underrun\n")); |
|
986 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 14); |
|
987 |
gTest(r==KErrNone); |
|
988 |
// |
|
989 |
// Wait for the notification |
|
990 |
User::WaitForRequest(status); |
|
991 |
r=status.Int(); |
|
992 |
if(r != KErrNone) |
|
993 |
{ |
|
994 |
gTest.Printf(_L("TRequestStatus value after transmitting data = %d\n"),r); |
|
995 |
gTest(r==KErrNone); |
|
996 |
} |
|
997 |
gTest.Printf(_L("Tx Underrun test completed OK\n")); |
|
998 |
||
999 |
// |
|
1000 |
// Simultaneous Rx,Tx tests |
|
1001 |
// |
|
1002 |
// For these tests, the proxy client (iic_slaveclient) will check that the expected results are witnessed |
|
1003 |
// in the required order, and will complete the TRequestStatus when the sequence is complete (or error occurs). |
|
1004 |
// |
|
1005 |
// Set the notification trigger for both Rx and Tx |
|
1006 |
triggerMask=ERxAllBytes|ETxAllBytes; |
|
1007 |
gTest.Printf(_L("\nStarting SetNotificationTrigger with ERxAllBytes|ETxAllBytes\n")); |
|
1008 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1009 |
gTest(r==KErrNone); |
|
1010 |
// Now instruct the bus implementation to represent receipt of the required number of words from the bus master. |
|
1011 |
gTest.Printf(_L("Starting SimulateRxNWords\n")); |
|
1012 |
r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 8); |
|
1013 |
gTest(r==KErrNone); |
|
1014 |
// Now instruct the bus implementation to represent transmission of the required number of words to the bus master. |
|
1015 |
gTest.Printf(_L("Starting SimulateTxNWords\n")); |
|
1016 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 12); |
|
1017 |
gTest(r==KErrNone); |
|
1018 |
// |
|
1019 |
// Wait for the notification |
|
1020 |
User::WaitForRequest(status); |
|
1021 |
r=status.Int(); |
|
1022 |
if(r != KErrNone) |
|
1023 |
{ |
|
1024 |
gTest.Printf(_L("TRequestStatus value after receiving and transmitting data = %d\n"),r); |
|
1025 |
gTest(r==KErrNone); |
|
1026 |
} |
|
1027 |
gTest.Printf(_L("Rx, Tx test completed OK\n")); |
|
1028 |
// |
|
1029 |
// Set the notification trigger for both Rx and Tx |
|
1030 |
gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes|ETxAllBytes\n")); |
|
1031 |
triggerMask=ERxAllBytes|ETxAllBytes; |
|
1032 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1033 |
gTest(r==KErrNone); |
|
1034 |
// Now instruct the bus implementation to represent transmission of the required number of words to the bus master. |
|
1035 |
gTest.Printf(_L("Starting SimulateTxNWords\n")); |
|
1036 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 12); |
|
1037 |
gTest(r==KErrNone); |
|
1038 |
// Now instruct the bus implementation to represent receipt of the required number of words from the bus master. |
|
1039 |
gTest.Printf(_L("Starting SimulateRxNWords\n")); |
|
1040 |
r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 8); |
|
1041 |
gTest(r==KErrNone); |
|
1042 |
// |
|
1043 |
// Wait for the notification |
|
1044 |
User::WaitForRequest(status); |
|
1045 |
r=status.Int(); |
|
1046 |
if(r != KErrNone) |
|
1047 |
{ |
|
1048 |
gTest.Printf(_L("TRequestStatus value after receiving and transmitting data = %d\n"),r); |
|
1049 |
gTest(r==KErrNone); |
|
1050 |
} |
|
1051 |
gTest.Printf(_L("Tx, Rx test completed OK\n")); |
|
1052 |
// |
|
1053 |
// Set the notification trigger for both Rx and Tx |
|
1054 |
gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes|ETxAllBytes\n")); |
|
1055 |
triggerMask=ERxAllBytes|ETxAllBytes; |
|
1056 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1057 |
gTest(r==KErrNone); |
|
1058 |
// Now instruct the bus implementation to represent simultaneous transmission of the required number of words (12) |
|
1059 |
// to the bus master and receipt of the required number of words (8) from the bus master |
|
1060 |
gTest.Printf(_L("Starting SimulateRxTxNWords\n")); |
|
1061 |
r=gChanSlaveI2c.SimulateRxTxNWords(busIdI2c, chanId, 8, 12); |
|
1062 |
gTest(r==KErrNone); |
|
1063 |
// |
|
1064 |
// Wait for the notification |
|
1065 |
User::WaitForRequest(status); |
|
1066 |
r=status.Int(); |
|
1067 |
if(r != KErrNone) |
|
1068 |
{ |
|
1069 |
gTest.Printf(_L("TRequestStatus value after receiving and transmitting data = %d\n"),r); |
|
1070 |
gTest(r==KErrNone); |
|
1071 |
} |
|
1072 |
gTest.Printf(_L("Tx with Rx test completed OK\n")); |
|
1073 |
||
1074 |
// Clear the trigger mask - this is just invoking SetNotificationTrigger with a zero trigger |
|
1075 |
// so that no subsequent triggers are expected (and so no TRequestStatus is provided) |
|
1076 |
gTest.Printf(_L("Starting SetNotificationTrigger with 0\n")); |
|
1077 |
triggerMask=0; |
|
1078 |
r=gChanSlaveI2c.SetNotifNoTrigger(chanId,triggerMask); |
|
1079 |
gTest(r==KErrNone); |
|
1080 |
||
1081 |
// |
|
1082 |
// Rx Overrun and Tx Underrun when both Rx and Tx notifications are requested |
|
1083 |
// |
|
1084 |
gTest.Printf(_L("Starting RxOverrun-TxUnderrun with simultaneous Rx,Tx notification requests\n")); |
|
1085 |
gChanSlaveI2c.TestOverrunUnderrun(busIdI2c,chanId,status); |
|
1086 |
// |
|
1087 |
// Wait for the notification |
|
1088 |
User::WaitForRequest(status); |
|
1089 |
r=status.Int(); |
|
1090 |
if(r != KErrNone) |
|
1091 |
{ |
|
1092 |
gTest.Printf(_L("TRequestStatus value after RxOverrun-TxUnderrun with simultaneous Rx,Tx notification requests= %d\n"),r); |
|
1093 |
gTest(r==KErrNone); |
|
1094 |
} |
|
1095 |
gTest.Printf(_L("RxOverrun-TxUnderrun with simultaneous Rx,Tx notification requests test completed OK\n")); |
|
1096 |
||
1097 |
||
1098 |
// |
|
1099 |
// Bus Error tests |
|
1100 |
// |
|
1101 |
||
1102 |
// Simulate a bus error |
|
1103 |
// A bus error will cause all pending bus activity to be aborted. |
|
1104 |
// Request a notification, then simulate a bus error |
|
1105 |
triggerMask=ERxAllBytes|ETxAllBytes; |
|
1106 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1107 |
gTest(r==KErrNone); |
|
1108 |
gTest.Printf(_L("Starting SimulateBusErr\n")); |
|
1109 |
r = gChanSlaveI2c.SimulateBusErr(busIdI2c,chanId); |
|
1110 |
gTest(r==KErrNone); |
|
1111 |
// |
|
1112 |
// Wait for the notification |
|
1113 |
User::WaitForRequest(status); |
|
1114 |
r=status.Int(); |
|
1115 |
if(r != KErrNone) |
|
1116 |
{ |
|
1117 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
1118 |
gTest(r==KErrNone); |
|
1119 |
} |
|
1120 |
gTest.Printf(_L("Bus error test completed OK\n")); |
|
1121 |
||
1122 |
// Clear the trigger mask and prepare for the next test |
|
1123 |
// This is unnecessary if the SetNotificationTrigger for the following test |
|
1124 |
// is called within the timeout period applied for Client responses ... |
|
1125 |
// but it represents a Client ending a transaction cleanly, and so is |
|
1126 |
// left here as an example |
|
1127 |
gTest.Printf(_L("\nStarting SetNotificationTrigger with 0\n")); |
|
1128 |
triggerMask=0; |
|
1129 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1130 |
gTest(r==KErrNone); |
|
1131 |
||
1132 |
// Simulate Master timeout |
|
1133 |
// Do this by: |
|
1134 |
// - Requesting a trigger for Tx |
|
1135 |
// - simulating the Master performing a read (ie the PSL indicates a Tx event) to start the transaction |
|
1136 |
// - provide a buffer for Tx, and request notification of Tx events, ie wait for Master response |
|
1137 |
// - block the PSL Tx notification to the PIL, so that the PIL timeout timer expires when a simulated Tx event |
|
1138 |
// is next requested |
|
1139 |
// |
|
1140 |
// Indicate the test to be performed |
|
1141 |
gTest.Printf(_L("\nStarting BlockNotification\n")); |
|
1142 |
// Register a buffer for Tx, then set the notification trigger |
|
1143 |
gTest.Printf(_L("RegisterTxBuffer - for Master to start the transaction\n")); |
|
1144 |
r=gChanSlaveI2c.RegisterTxBuffer(chanId, 4, 12, 8); |
|
1145 |
gTest(r==KErrNone); |
|
1146 |
gTest.Printf(_L("SetNotificationTrigger - for Master to start the transaction\n")); |
|
1147 |
triggerMask=ETxAllBytes; |
|
1148 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1149 |
gTest(r==KErrNone); |
|
1150 |
// Now instruct the bus implementation to simulate the Master reading the expected number of words |
|
1151 |
gTest.Printf(_L("Starting SimulateTxNWords\n")); |
|
1152 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 12); |
|
1153 |
gTest(r==KErrNone); |
|
1154 |
// Wait for the notification |
|
1155 |
User::WaitForRequest(status); |
|
1156 |
gTest.Printf(_L("Status request completed\n")); |
|
1157 |
r=status.Int(); |
|
1158 |
if(r != KErrNone) |
|
1159 |
{ |
|
1160 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
1161 |
gTest(r==KErrNone); |
|
1162 |
} |
|
1163 |
// Client is now expected to perform its part of the transaction - so pretend we need another Tx |
|
1164 |
// - but block completion of the Tx so that we generate a bus error |
|
1165 |
gTest.Printf(_L("SetNotificationTrigger - for second part of the transaction\n")); |
|
1166 |
triggerMask=ETxAllBytes; |
|
1167 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1168 |
gTest(r==KErrNone); |
|
1169 |
gTest.Printf(_L("BlockNotification\n")); |
|
1170 |
r=gChanSlaveI2c.BlockNotification(busIdI2c, chanId); |
|
1171 |
gTest(r==KErrNone); |
|
1172 |
// |
|
1173 |
// Wait for the notification |
|
1174 |
User::WaitForRequest(status); |
|
1175 |
r=status.Int(); |
|
1176 |
if(r != KErrNone) |
|
1177 |
{ |
|
1178 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
1179 |
gTest(r==KErrNone); |
|
1180 |
} |
|
1181 |
gTest.Printf(_L("Blocked notification test completed OK\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1182 |
// Now instruct the bus implementation to represent the bus master attempting to read the required number of words |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1183 |
gTest.Printf(_L("\nStarting SimulateTxNWords\n")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1184 |
r=gChanSlaveI2c.SimulateTxNWords(busIdI2c, chanId, 12); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1185 |
gTest(r==KErrNone); |
0 | 1186 |
// Re-set the notification trigger - for the 'blocked' Tx |
1187 |
// This is required because, in the event of a bus error, the set of requested Rx,Tx |
|
1188 |
// flags are cleared |
|
1189 |
gTest.Printf(_L("Starting SetNotificationTrigger with ETxAllBytes\n")); |
|
1190 |
triggerMask=ETxAllBytes; |
|
1191 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1192 |
gTest(r==KErrNone); |
|
1193 |
// Remove the block |
|
1194 |
gTest.Printf(_L("Starting UnblockNotification\n")); |
|
1195 |
r=gChanSlaveI2c.UnblockNotification(busIdI2c, chanId); |
|
1196 |
gTest(r==KErrNone); |
|
1197 |
// |
|
1198 |
// Wait for the notification |
|
1199 |
User::WaitForRequest(status); |
|
1200 |
r=status.Int(); |
|
1201 |
if(r != KErrNone) |
|
1202 |
{ |
|
1203 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
1204 |
gTest(r==KErrNone); |
|
1205 |
} |
|
1206 |
gTest.Printf(_L("UnBlocked notification test completed OK\n")); |
|
1207 |
// Clear the trigger mask |
|
1208 |
gTest.Printf(_L("Starting SetNotificationTrigger with 0\n")); |
|
1209 |
triggerMask=0; |
|
1210 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1211 |
gTest(r==KErrNone); |
|
1212 |
||
199 | 1213 |
//Test the PIL behavior for a client timeout: request notification of an event |
1214 |
//but deliberately delay the client response. The PIL should return KErrTimedOut |
|
1215 |
//when a subsequent request for a notification is made. |
|
1216 |
gTest.Printf(_L("Starting test for SendBusErrorAndReturn.\n")); |
|
1217 |
||
1218 |
// For Rx, specify buffer granularity=4 (32-bit words), 8 words to receive, offset of 16 bytes |
|
1219 |
// 64 bytes as 16 words: words 0-3 offset, words 4-11 data, words 12-15 unused |
|
1220 |
gTest.Printf(_L("Starting RegisterRxBuffer\n")); |
|
1221 |
r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16); |
|
1222 |
gTest(r==KErrNone); |
|
1223 |
||
1224 |
// Now set the notification trigger |
|
1225 |
//TRequestStatus status; |
|
1226 |
triggerMask=ERxAllBytes; |
|
1227 |
||
1228 |
gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes\n")); |
|
1229 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1230 |
gTest(r==KErrNone); |
|
1231 |
// Now instruct the bus implementation to represent receipt of the required number of words from the bus master. |
|
1232 |
gTest.Printf(_L("Starting SimulateRxNWords\n")); |
|
1233 |
r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 8); |
|
1234 |
gTest(r==KErrNone); |
|
1235 |
// |
|
1236 |
// Wait for the notification |
|
1237 |
User::WaitForRequest(status); |
|
1238 |
r=status.Int(); |
|
1239 |
if(r != KErrNone) |
|
1240 |
{ |
|
1241 |
gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r); |
|
1242 |
gTest(r==KErrNone); |
|
1243 |
} |
|
1244 |
//Delay the client response to exceed the timeout period, and check that the next |
|
1245 |
//request for a notification encounters the expected error code. |
|
1246 |
User::After(1000 * 1000); |
|
1247 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1248 |
gTest(r==KErrNone); |
|
1249 |
User::WaitForRequest(status); |
|
1250 |
r = status.Int(); |
|
1251 |
if(r!=KErrTimedOut) |
|
1252 |
{ |
|
1253 |
gTest.Printf(_L("TRequestStatus value = %d\n"),status.Int()); |
|
1254 |
gTest(r==KErrTimedOut); |
|
1255 |
} |
|
1256 |
gTest.Printf(_L("The test for SendBusErrorAndReturn is completed OK\n")); |
|
0 | 1257 |
// Release the channel |
1258 |
r = gChanSlaveI2c.ReleaseChannel( chanId ); |
|
1259 |
gTest(r==KErrNone); |
|
1260 |
||
1261 |
delete i2cBuf; |
|
1262 |
#else |
|
1263 |
gTest.Printf(_L("\nSlaveRxTxNotificationTests only supported when SLAVE_MODE is defined\n")); |
|
1264 |
#endif |
|
1265 |
||
1266 |
return r; |
|
1267 |
} |
|
1268 |
||
1269 |
//---------------------------------------------------------------------------------------------- |
|
1270 |
//! @SYMTestCaseID KBASE-T_IIC-2404 |
|
1271 |
//! @SYMTestType UT |
|
1272 |
//! @SYMPREQ PREQ2128,2129 |
|
1273 |
//! @SYMTestCaseDesc This test case tests that MasterSlave channels can only be used in one mode at a time, and that |
|
1274 |
//! if captured for Slave operation or with transactions queued for Master operation the channel can |
|
1275 |
//! not be de-registered. |
|
1276 |
//! @SYMTestActions 0) Capture the channel for Slave operation. Attempt to synchronously queue a transaction |
|
1277 |
//! on the channel. Attempt to asynchronously queue a transaction on the channel. Attempt |
|
1278 |
//! to de-register the channel.Release the Slave channel |
|
1279 |
//! |
|
1280 |
//! 1) Use controlio to block completion of queued transactions. Request asynchronous queue |
|
1281 |
//! transaction. Attempt to capture the channel for Slave operation. Attempt to de-register |
|
1282 |
//! the channel. Unblock completion of transactions and wait for the TRequestStatus for the |
|
1283 |
//! transaction to be completed. |
|
1284 |
//! |
|
1285 |
//! @SYMTestExpectedResults 0) Once captured for Slave operation, attempts to queue a transaction or de-register the channel |
|
1286 |
//! return KErrInUse, exits otherwise. |
|
1287 |
//! 1) With a transaction queued, attempt to capture the channel returns KErrInUse, exits otherwise. |
|
1288 |
//! Attempt to de-register channel returns KErrInUse, exits otherwise. The TRequestStatus should |
|
1289 |
//! be set to KErrTimedOut, exits otherwise. |
|
1290 |
//! |
|
1291 |
//! |
|
1292 |
//! @SYMTestPriority High |
|
1293 |
//! @SYMTestStatus Implemented |
|
1294 |
//---------------------------------------------------------------------------------------------- |
|
1295 |
LOCAL_C TInt MasterSlaveAcquisitionTests() |
|
1296 |
// |
|
1297 |
// Test to check that: |
|
1298 |
// (1) A Master-Slave channel that has been captured for use in Slave mode will not allow requests for |
|
1299 |
// queing transactions to be accepted |
|
1300 |
// (2) A Master-Slave channel that has been captured for use in Slave mode can not be de-registered |
|
1301 |
// (3) A Master-Slave channel that has one or more transactions queued in its Master channel transaction queue |
|
1302 |
// can not be captured for use in Slave Made |
|
1303 |
// (4) A Master-Slave channel that has one or more transactions queued in its Master channel transaction queue |
|
1304 |
// can not be de-registered |
|
1305 |
// |
|
1306 |
{ |
|
1307 |
gTest.Printf(_L("\n\nStarting MasterSlaveAcquisitionTests\n")); |
|
1308 |
TInt r=KErrNone; |
|
1309 |
||
1310 |
#if defined(MASTER_MODE) && defined(SLAVE_MODE) |
|
1311 |
// Create a Master-Slave channel |
|
1312 |
RBusDevIicClient chanMasterSlaveI2c; |
|
1313 |
TBufC<18> proxyName; |
|
1314 |
if(!aStandAloneChan) |
|
1315 |
proxyName = KIicProxyFileNameRoot; |
|
1316 |
else |
|
1317 |
proxyName = KIicProxyFileNameRootCtrlLess; |
|
1318 |
r = chanMasterSlaveI2c.Open(proxyName); |
|
1319 |
gTest(r==KErrNone); |
|
1320 |
r = chanMasterSlaveI2c.InitSlaveClient(); // Initialise callback used for Slave processing |
|
1321 |
gTest(r==KErrNone); |
|
1322 |
// |
|
1323 |
// Capture the channel for Slave operation |
|
1324 |
// Attempt to synchronously queue a transaction on the channel - expect KErrInUse as a response |
|
1325 |
// Attempt to asynchronously queue a transaction on the channel - expect KErrInUse as a response |
|
1326 |
// Attempt to de-register the channel - expect KErrInUse as a response |
|
1327 |
// Release the Slave channel |
|
1328 |
// |
|
1329 |
// Create a I2C configuration buffer and the configuration data for use in capturing gChanSlaveI2c |
|
1330 |
TUint32 busIdI2c = 0; |
|
1331 |
TConfigI2cBufV01* i2cBuf=NULL; |
|
1332 |
r=CreateSlaveChanI2cConfig(i2cBuf, busIdI2c, 12); // 12 is the MasterSlave channel number |
|
1333 |
gTest(r==KErrNone); |
|
1334 |
TInt chanId; |
|
1335 |
||
1336 |
gTest.Printf(_L("\nStarting synchronous CaptureChannel \n")); |
|
1337 |
r = chanMasterSlaveI2c.CaptureChannel(busIdI2c, i2cBuf, chanId ); |
|
1338 |
gTest.Printf(_L("Synchronous CaptureChannel returned = %d, chanId=0x%x\n"),r,chanId); |
|
1339 |
gTest(r==KErrNone); |
|
1340 |
// |
|
1341 |
_LIT(halfDuplexText,"Half Duplex Text"); |
|
1342 |
TBuf8<17> halfDuplexBuf_8; |
|
1343 |
halfDuplexBuf_8.Copy(halfDuplexText); |
|
1344 |
TUsideTferDesc* tfer = NULL; |
|
1345 |
r=CreateSingleUserSideTransfer(tfer, EMasterWrite, 8, &halfDuplexBuf_8, NULL); |
|
1346 |
if(r!=KErrNone) |
|
1347 |
return r; |
|
1348 |
if(tfer==NULL) |
|
1349 |
return KErrGeneral; |
|
1350 |
// |
|
1351 |
TUsideTracnDesc* tracn = NULL; |
|
1352 |
r = CreateSingleUserSideTransaction(tracn, EI2c, i2cBuf, tfer, NULL, 0, NULL, NULL); |
|
1353 |
if(r!=KErrNone) |
|
1354 |
return r; |
|
1355 |
if(tracn==NULL) |
|
1356 |
return KErrGeneral; |
|
1357 |
||
1358 |
||
1359 |
gTest.Printf(_L("\nStarting synchronous QueueTransaction \n")); |
|
1360 |
r = chanMasterSlaveI2c.QueueTransaction(busIdI2c, tracn); |
|
1361 |
gTest.Printf(_L("Synchronous QueueTransaction returned = %d\n"),r); |
|
1362 |
gTest(r==KErrInUse); |
|
1363 |
gTest.Printf(_L("\nStarting asynchronous QueueTransaction \n")); |
|
1364 |
TRequestStatus status; |
|
1365 |
chanMasterSlaveI2c.QueueTransaction(status, busIdI2c, tracn); |
|
1366 |
User::WaitForRequest(status); |
|
1367 |
if(status != KErrInUse) |
|
1368 |
{ |
|
1369 |
gTest.Printf(_L("TRequestStatus value after queue = %d\n"),status.Int()); |
|
1370 |
gTest(r==KErrInUse); |
|
1371 |
} |
|
1372 |
// |
|
1373 |
// // If it is stand-alone channel, the client is responsible for channel creation. |
|
1374 |
// // So the RegisterChan and DeRegisterChan are not needed. |
|
1375 |
if(aStandAloneChan == 0) |
|
1376 |
{ |
|
1377 |
gTest.Printf(_L("\nStarting deregistration of captured channel\n")); |
|
1378 |
r = chanMasterSlaveI2c.DeRegisterChan(busIdI2c); |
|
1379 |
gTest.Printf(_L("DeRegisterChan returned = %d\n"),r); |
|
1380 |
gTest(r==KErrInUse); |
|
1381 |
} |
|
1382 |
||
1383 |
gTest.Printf(_L("\nInvoke ReleaseChannel for chanId=0x%x \n"),chanId); |
|
1384 |
r = chanMasterSlaveI2c.ReleaseChannel( chanId ); |
|
1385 |
gTest.Printf(_L("ReleaseChannel returned = %d\n"),r); |
|
1386 |
gTest(r==KErrNone); |
|
1387 |
||
1388 |
// |
|
1389 |
// Use ControlIO/StaticExtension to block transactions on the Master Channel |
|
1390 |
// Queue an asynchronous transaction on the channel |
|
1391 |
// Attempt to capture the channel for Slave operation - expect KErrInUse as a response |
|
1392 |
// Attempt to de-register the channel - expect KErrInUse as a response |
|
1393 |
// Unblock the channel |
|
1394 |
// Check for (timed out) completion of the transaction |
|
1395 |
// |
|
1396 |
gTest.Printf(_L("Invoking BlockReqCompletion\n")); |
|
1397 |
r = chanMasterSlaveI2c.BlockReqCompletion(busIdI2c); |
|
1398 |
gTest.Printf(_L("BlockReqCompletion returned = %d\n"),r); |
|
1399 |
// |
|
1400 |
gTest.Printf(_L("Queueing first transaction \n")); |
|
1401 |
chanMasterSlaveI2c.QueueTransaction(status, busIdI2c, tracn); |
|
1402 |
// |
|
1403 |
User::After(50000); |
|
1404 |
// |
|
1405 |
gTest.Printf(_L("\nStarting synchronous CaptureChannel \n")); |
|
1406 |
r = chanMasterSlaveI2c.CaptureChannel(busIdI2c, i2cBuf, chanId ); |
|
1407 |
gTest.Printf(_L("Synchronous CaptureChannel returned = %d, chanId=0x%x\n"),r,chanId); |
|
1408 |
gTest(r==KErrInUse); |
|
1409 |
||
1410 |
// If it is stand-alone channel, the client is responsible for channel creation. |
|
1411 |
// So the RegisterChan and DeRegisterChan are not needed. |
|
1412 |
if(aStandAloneChan == 0) |
|
1413 |
{ |
|
1414 |
gTest.Printf(_L("\nStarting deregistration of channel\n")); |
|
1415 |
r = chanMasterSlaveI2c.DeRegisterChan(busIdI2c); |
|
1416 |
gTest.Printf(_L("DeRegisterChan returned = %d\n"),r); |
|
1417 |
gTest(r==KErrInUse); |
|
1418 |
} |
|
1419 |
gTest.Printf(_L("Invoking UnlockReqCompletion\n")); |
|
1420 |
r = chanMasterSlaveI2c.UnblockReqCompletion(busIdI2c); |
|
1421 |
gTest.Printf(_L("UnblockReqCompletion returned = %d\n"),r); |
|
1422 |
// |
|
1423 |
User::After(50000); |
|
1424 |
// |
|
1425 |
User::WaitForRequest(status); |
|
1426 |
r=status.Int(); |
|
1427 |
if(r != KErrTimedOut) |
|
1428 |
{ |
|
1429 |
gTest.Printf(_L("TRequestStatus value after queue = %d\n"),r); |
|
1430 |
gTest(r==KErrTimedOut); |
|
1431 |
} |
|
1432 |
r=KErrNone; // Ensure error code is not propagated |
|
1433 |
||
1434 |
delete i2cBuf; |
|
1435 |
delete tfer; |
|
1436 |
delete tracn; |
|
1437 |
chanMasterSlaveI2c.Close(); |
|
1438 |
#else |
|
1439 |
gTest.Printf(_L("\nMasterSlaveAcquisitionTests only supported when both MASTER_MODE and SLAVE_MODE are defined\n")); |
|
1440 |
#endif |
|
1441 |
||
1442 |
return r; |
|
1443 |
} |
|
1444 |
||
1445 |
//---------------------------------------------------------------------------------------------- |
|
1446 |
//! @SYMTestCaseID KBASE-T_IIC-2404 |
|
1447 |
//! @SYMTestType UT |
|
1448 |
//! @SYMDEF DEF141732 |
|
1449 |
//! @SYMTestCaseDesc This test case tests the inline functions of DIicBusChannel interface. |
|
1450 |
//! @SYMTestActions Call Kernel-side proxy client function to perform interface tests. |
|
1451 |
//! @SYMTestExpectedResults Kernel-side proxy client should return with KErrNone. |
|
1452 |
//! @SYMTestPriority Medium |
|
1453 |
//! @SYMTestStatus Implemented |
|
1454 |
//---------------------------------------------------------------------------------------------- |
|
1455 |
LOCAL_C TInt IicInterfaceInlineTests() |
|
1456 |
{ |
|
1457 |
if(aStandAloneChan == 1) |
|
1458 |
{ |
|
1459 |
gTest.Printf(_L("\n\nStarting IicInterfaceInlineTests\n")); |
|
1460 |
TInt r=KErrNone; |
|
1461 |
r = gChanMasterSpi.TestIiicChannelInlineFunc(); |
|
1462 |
return r; |
|
1463 |
} |
|
1464 |
else |
|
1465 |
{ |
|
1466 |
gTest.Printf(_L("\nIicInterfaceInlineTests can only be run in Standalone mode\n")); |
|
1467 |
return KErrNone; |
|
1468 |
} |
|
1469 |
} |
|
1470 |
||
199 | 1471 |
//Only get called in stand alone mode |
1472 |
LOCAL_C TInt IicTestStubs() |
|
1473 |
{ |
|
1474 |
//Function to call the stub methods for Master and slave channels |
|
1475 |
//when Master and Slave functionality has not been built. The stubs |
|
1476 |
//return KErrNotSupported. |
|
1477 |
TInt r=KErrNone; |
|
1478 |
||
1479 |
TUint32 busIdI2c = 0; |
|
1480 |
TConfigI2cBufV01* i2cBuf=NULL; |
|
1481 |
TRequestStatus status; |
|
1482 |
||
1483 |
//Starting master channel stubs test. |
|
1484 |
//a valid transaction is required when calling the Master QueueTransaction stub. |
|
1485 |
//Use I2C channel here. In MASTER_MODE, channelId starting from 10, |
|
1486 |
//and 10 is a master channel |
|
1487 |
SET_BUS_TYPE(busIdI2c,EI2c); |
|
1488 |
SET_CHAN_NUM(busIdI2c,10); |
|
1489 |
// aDeviceId=1 ... 100kHz ... aTimeoutPeriod=100 ... aTransactionWaitCycles=10 - arbitrary paarmeters. |
|
1490 |
r=CreateI2cBuf(i2cBuf, EI2cAddr7Bit, 36, ELittleEndian, 100); |
|
1491 |
gTest(r==KErrNone); |
|
1492 |
||
1493 |
// Use a single transfer |
|
1494 |
_LIT(halfDuplexText,"Half Duplex Text"); |
|
1495 |
TBuf8<17> halfDuplexBuf_8; |
|
1496 |
halfDuplexBuf_8.Copy(halfDuplexText); |
|
1497 |
TUsideTferDesc* tfer = NULL; |
|
1498 |
r = CreateSingleUserSideTransfer(tfer, EMasterWrite, 8, &halfDuplexBuf_8, NULL); |
|
1499 |
gTest(r==KErrNone); |
|
1500 |
||
1501 |
// Create the transaction object |
|
1502 |
TUsideTracnDesc* tracn = NULL; |
|
1503 |
r = CreateSingleUserSideTransaction(tracn, EI2c, i2cBuf, tfer, NULL, 0, NULL, NULL); |
|
1504 |
gTest(r==KErrNone); |
|
1505 |
||
1506 |
// queue a synchronous transaction |
|
1507 |
gTest.Printf(_L("\n\nStarting synchronous QueueTransaction \n")); |
|
1508 |
r = gChanMasterI2c.QueueTransaction(busIdI2c, tracn); |
|
1509 |
gTest.Printf(_L("Synchronous QueueTransaction returned = %d\n"),r); |
|
1510 |
//Queueing a transaction in SLAVE_MODE should return KErrNotSupported |
|
1511 |
gTest(r==KErrNotSupported); |
|
1512 |
||
1513 |
// queue an asynchronous transaction and cancel the trasnaction |
|
1514 |
// QueueTransaction actually completes before CancelAsyncOperation with KErrNotSupported |
|
1515 |
// In test driver, we pretend the request is still in the queue and then cancel it. |
|
1516 |
gChanMasterI2c.QueueTransaction(status, busIdI2c, tracn); |
|
1517 |
gChanMasterI2c.CancelAsyncOperation(&status, busIdI2c); |
|
1518 |
User::WaitForRequest(status); |
|
1519 |
if(status != KErrNotSupported) |
|
1520 |
{ |
|
1521 |
gTest.Printf(_L("TRequestStatus value after queue = %d\n"),status.Int()); |
|
1522 |
gTest(r==KErrNotSupported); |
|
1523 |
} |
|
1524 |
//spare1 is an unused method that is present to provide for future extension, |
|
1525 |
//which just returns KErrNotSupported. |
|
1526 |
r = gChanMasterI2c.TestSpare1(busIdI2c); |
|
1527 |
gTest(r == KErrNotSupported); |
|
1528 |
//StaticExtension is present for PSL implementations to override, the default |
|
1529 |
//implementation just returns KErrNotSupported |
|
1530 |
r = gChanMasterI2c.TestStaticExtension(busIdI2c); |
|
1531 |
gTest(r == KErrNotSupported); |
|
1532 |
//free the memory |
|
1533 |
delete i2cBuf; |
|
1534 |
delete tfer; |
|
1535 |
delete tracn; |
|
1536 |
||
1537 |
//Start to test slave channel operations |
|
1538 |
SET_BUS_TYPE(busIdI2c,EI2c); |
|
1539 |
SET_CHAN_NUM(busIdI2c,11); // 11 is the Slave channel number |
|
1540 |
// |
|
1541 |
// clock speed=36Hz, aTimeoutPeriod=100 - arbitrary parameter |
|
1542 |
r=CreateI2cBuf(i2cBuf, EI2cAddr7Bit, 36, ELittleEndian, 100); |
|
1543 |
gTest(r==KErrNone); |
|
1544 |
||
1545 |
// Synchronous capture of a Slave channel. |
|
1546 |
TInt chanId = 0; // Initialise to zero to silence compiler ... |
|
1547 |
gTest.Printf(_L("\n\nStarting synchronous CaptureChannel \n")); |
|
1548 |
r = gChanSlaveI2c.CaptureChannel(busIdI2c, i2cBuf, chanId ); |
|
1549 |
gTest.Printf(_L("Synchronous CaptureChannel returned = %d, aChanId=0x%x\n"),r,chanId); |
|
1550 |
gTest(r==KErrNotSupported); |
|
1551 |
||
1552 |
gTest.Printf(_L("Starting RegisterRxBuffer\n")); |
|
1553 |
r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16); |
|
1554 |
gTest(r==KErrNotSupported); |
|
1555 |
||
1556 |
gTest.Printf(_L("\nStarting RegisterTxBuffer\n")); |
|
1557 |
r=gChanSlaveI2c.RegisterTxBuffer(chanId, 4, 12, 8); |
|
1558 |
gTest(r==KErrNotSupported); |
|
1559 |
// |
|
1560 |
// Now set the notification trigger |
|
1561 |
TInt triggerMask=ERxAllBytes; |
|
1562 |
||
1563 |
gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes\n")); |
|
1564 |
r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status); |
|
1565 |
gTest(r==KErrNotSupported); |
|
1566 |
||
1567 |
r = gChanSlaveI2c.TestSpare1(busIdI2c); |
|
1568 |
gTest(r == KErrNotSupported); |
|
1569 |
r = gChanSlaveI2c.TestStaticExtension(busIdI2c); |
|
1570 |
gTest(r == KErrNotSupported); |
|
1571 |
delete i2cBuf; |
|
1572 |
||
1573 |
//Start to test MasterSlave channel operations |
|
1574 |
//Create a Master-Slave channel |
|
1575 |
RBusDevIicClient chanMasterSlaveI2c; |
|
1576 |
TBufC<18> proxyName; |
|
1577 |
proxyName = KIicProxyFileNameRootStubs; |
|
1578 |
r = chanMasterSlaveI2c.Open(proxyName); |
|
1579 |
gTest(r==KErrNone); |
|
1580 |
||
1581 |
SET_BUS_TYPE(busIdI2c,EI2c); |
|
1582 |
SET_CHAN_NUM(busIdI2c,12); // 12 is the MasterSlave channel number |
|
1583 |
r = chanMasterSlaveI2c.TestStaticExtension(busIdI2c); |
|
1584 |
gTest(r==KErrNotSupported); |
|
1585 |
chanMasterSlaveI2c.Close(); |
|
1586 |
||
1587 |
return KErrNone; |
|
1588 |
} |
|
1589 |
||
0 | 1590 |
LOCAL_C TInt RunTests() |
1591 |
// |
|
1592 |
// Utility method to invoke the separate tests |
|
1593 |
// |
|
1594 |
{ |
|
1595 |
TInt r =KErrNone; |
|
1596 |
r = IicInterfaceInlineTests(); |
|
1597 |
if(r!=KErrNone) |
|
1598 |
return r; |
|
1599 |
||
1600 |
r = MasterBasicTests(); |
|
1601 |
if(r!=KErrNone) |
|
1602 |
return r; |
|
1603 |
||
1604 |
r = SlaveRxTxNotificationTests(); |
|
1605 |
if(r!=KErrNone) |
|
1606 |
return r; |
|
1607 |
||
1608 |
r = SlaveChannelCaptureReleaseTests(); |
|
1609 |
if(r!=KErrNone) |
|
1610 |
return r; |
|
1611 |
||
1612 |
r = MasterExtTests(KTransactionWithPreamble); |
|
1613 |
if(r!=KErrNone) |
|
1614 |
return r; |
|
1615 |
||
1616 |
r = MasterExtTests(KTransactionWithMultiTransc); |
|
1617 |
if(r!=KErrNone) |
|
1618 |
return r; |
|
1619 |
||
1620 |
r = MasterExtTests(KTransactionWithMultiTransc|KTransactionWithPreamble); |
|
1621 |
if(r!=KErrNone) |
|
1622 |
return r; |
|
1623 |
||
1624 |
r = MasterTransactionTests(); |
|
1625 |
if(r!=KErrNone) |
|
1626 |
return r; |
|
1627 |
||
1628 |
r = MasterSlaveAcquisitionTests(); |
|
1629 |
if(r!=KErrNone) |
|
1630 |
return r; |
|
1631 |
||
1632 |
return KErrNone; |
|
1633 |
} |
|
1634 |
||
1635 |
GLDEF_C TInt E32Main() |
|
1636 |
// |
|
1637 |
// Main |
|
1638 |
// |
|
1639 |
{ |
|
1640 |
gTest.Title(); |
|
1641 |
gTest.Start(_L("Test IIC API\n")); |
|
1642 |
||
1643 |
TInt r = KErrNone; |
|
1644 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1645 |
// Turn off lazy dll unloading |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1646 |
RLoader l; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1647 |
gTest(l.Connect()==KErrNone); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1648 |
gTest(l.CancelLazyDllUnload()==KErrNone); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1649 |
l.Close(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1650 |
|
0 | 1651 |
#ifdef IIC_SIMULATED_PSL |
1652 |
gTest.Next(_L("Start the IIC with controller test\n")); |
|
1653 |
aStandAloneChan = 0; |
|
1654 |
gTest.Next(_L("Load Simulated IIC PSL bus driver")); |
|
1655 |
r = User::LoadPhysicalDevice(KIicPslFileName); |
|
1656 |
gTest.Printf(_L("return value r=%d"),r); |
|
1657 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1658 |
||
1659 |
gTest.Next(_L("Load Simulated PSL SPI bus driver")); |
|
1660 |
r = User::LoadPhysicalDevice(KSpiFileName); |
|
1661 |
gTest.Printf(_L("return value r=%d"),r); |
|
1662 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1663 |
||
1664 |
gTest.Next(_L("Load Simulated PSL I2C bus driver")); |
|
1665 |
r = User::LoadPhysicalDevice(KI2cFileName); |
|
1666 |
gTest.Printf(_L("return value r=%d"),r); |
|
1667 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1668 |
||
1669 |
gTest.Next(_L("Load kernel-side proxy IIC client")); |
|
1670 |
r = User::LoadLogicalDevice(KIicProxyFileName); |
|
1671 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1672 |
||
1673 |
gTest.Next(_L("Load kernel-side proxy IIC slave client")); |
|
1674 |
r = User::LoadLogicalDevice(KIicProxySlaveFileName); |
|
1675 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1676 |
||
1677 |
__KHEAP_MARK; |
|
1678 |
// First ascertain what bus options are available. |
|
1679 |
||
1680 |
// SPI has Master channel numbers 1,2 and 4, Slave channel number 3 |
|
1681 |
// Open a Master SPI channel to the kernel side proxy |
|
1682 |
TBufC<30> proxyName(KIicProxyFileNameRoot); |
|
1683 |
r = gChanMasterSpi.Open(proxyName); |
|
1684 |
gTest(r==KErrNone); |
|
1685 |
||
1686 |
// I2C has Master channel numbers 10 and 11, if built with MASTER_MODE, only |
|
1687 |
// I2C has Slave channel numbers 12 and 13, if built with SLAVE_MODE, only |
|
1688 |
// I2C has Master channel number 10 and Slave channel numer 11 if built with both MASTER_MODE and SLAVE_MODE |
|
1689 |
// Open a Master I2C channel to the kernel side proxy |
|
1690 |
r = gChanMasterI2c.Open(proxyName); |
|
1691 |
gTest(r==KErrNone); |
|
1692 |
TBufC<15> proxySlaveName(KIicProxySlaveFileNameRoot); |
|
1693 |
r = gChanSlaveI2c.Open(proxySlaveName); |
|
1694 |
gTest(r==KErrNone); |
|
1695 |
r = gChanSlaveI2c.InitSlaveClient(); |
|
1696 |
gTest(r==KErrNone); |
|
1697 |
||
1698 |
// Instigate tests |
|
1699 |
r = RunTests(); |
|
1700 |
gTest(r==KErrNone); |
|
1701 |
||
1702 |
gTest.Printf(_L("Tests completed OK, about to close channel\n")); |
|
1703 |
||
1704 |
gChanMasterSpi.Close(); |
|
1705 |
gChanMasterI2c.Close(); |
|
1706 |
gChanSlaveI2c.Close(); |
|
1707 |
||
1708 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
123 | 1709 |
// Not safe to assume that heap clean-up has completed for the channels just closed, so insert a delay.(DEF145202) |
1710 |
User::After(20 * 1000); |
|
0 | 1711 |
__KHEAP_MARKEND; |
1712 |
||
1713 |
gTest.Next(_L("Free kernel-side proxy IIC client")); |
|
1714 |
TInt err = User::FreeLogicalDevice(KIicProxyFileNameRoot); |
|
1715 |
gTest(err==KErrNone || err==KErrAlreadyExists); |
|
1716 |
||
1717 |
gTest.Next(_L("Free kernel-side proxy IIC slave client")); |
|
1718 |
err = User::FreeLogicalDevice(KIicProxySlaveFileNameRoot); |
|
1719 |
gTest(err==KErrNone || err==KErrAlreadyExists); |
|
1720 |
||
1721 |
gTest.Next(_L("Free Simulated PSL I2C bus driver")); |
|
1722 |
err = User::FreePhysicalDevice(KI2cFileName); |
|
1723 |
gTest(err==KErrNone); |
|
1724 |
||
1725 |
gTest.Next(_L("Free Simulated PSL SPI bus driver")); |
|
1726 |
err = User::FreePhysicalDevice(KSpiFileName); |
|
1727 |
gTest(err==KErrNone); |
|
1728 |
||
1729 |
gTest.Next(_L("Free Simulated IIC PSL bus driver")); |
|
1730 |
err = User::FreePhysicalDevice(KIicPslFileNameRoot); |
|
1731 |
gTest(err==KErrNone); |
|
1732 |
||
1733 |
gTest.Next(_L("Start the controller-less IIC test\n")); |
|
1734 |
aStandAloneChan = 1; |
|
1735 |
||
1736 |
gTest.Next(_L("Load Simulated PSL SPI bus driver")); |
|
1737 |
r = User::LoadPhysicalDevice(KSpiFileNameCtrlLess); |
|
1738 |
gTest.Printf(_L("return value r=%d"),r); |
|
1739 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1740 |
||
1741 |
gTest.Next(_L("Load Simulated PSL I2C bus driver")); |
|
1742 |
r = User::LoadPhysicalDevice(KI2cFileNameCtrlLess); |
|
1743 |
gTest.Printf(_L("return value r=%d"),r); |
|
1744 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1745 |
||
1746 |
gTest.Next(_L("Load kernel-side proxy IIC client")); |
|
1747 |
r = User::LoadLogicalDevice(KIicProxyFileNameCtrlLess); |
|
1748 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1749 |
||
1750 |
gTest.Next(_L("Load kernel-side proxy IIC slave client")); |
|
1751 |
r = User::LoadLogicalDevice(KIicProxySlaveFileNameCtrlLess); |
|
1752 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1753 |
||
1754 |
// First ascertain what bus options are available. |
|
1755 |
__KHEAP_MARK; |
|
1756 |
// SPI has Master channel numbers 1,2 and 4, Slave channel number 3 |
|
1757 |
// Open a Master SPI channel to the kernel side proxy |
|
1758 |
TBufC<30> proxyNameCtrlLess(KIicProxyFileNameRootCtrlLess); |
|
1759 |
r = gChanMasterSpi.Open(proxyNameCtrlLess); |
|
1760 |
gTest(r==KErrNone); |
|
1761 |
||
1762 |
// I2C has Master channel numbers 10 and 11, if built with MASTER_MODE, only |
|
1763 |
// I2C has Slave channel numbers 12 and 13, if built with SLAVE_MODE, only |
|
1764 |
// I2C has Master channel number 10 and Slave channel numer 11 if built with both MASTER_MODE and SLAVE_MODE |
|
1765 |
// Open a Master I2C channel to the kernel side proxy |
|
1766 |
r = gChanMasterI2c.Open(proxyNameCtrlLess); |
|
1767 |
||
1768 |
gTest(r==KErrNone); |
|
1769 |
TBufC<35> proxySlaveNameCtrlLess(KIicProxySlaveFileNameRootCtrlLess); |
|
1770 |
||
1771 |
r = gChanSlaveI2c.Open(proxySlaveNameCtrlLess); |
|
1772 |
gTest(r==KErrNone); |
|
1773 |
r = gChanSlaveI2c.InitSlaveClient(); |
|
1774 |
gTest(r==KErrNone); |
|
1775 |
||
1776 |
// Instigate tests |
|
1777 |
r = RunTests(); |
|
1778 |
gTest(r==KErrNone); |
|
1779 |
||
1780 |
gTest.Printf(_L("Tests completed OK, about to close channel\n")); |
|
1781 |
||
1782 |
gChanMasterSpi.Close(); |
|
1783 |
gChanMasterI2c.Close(); |
|
1784 |
gChanSlaveI2c.Close(); |
|
1785 |
||
1786 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
123 | 1787 |
// Not safe to assume that heap clean-up has completed for the channels just closed, so insert a delay.(DEF145202) |
1788 |
User::After(20 * 1000); |
|
0 | 1789 |
__KHEAP_MARKEND; |
1790 |
||
1791 |
gTest.Next(_L("Free kernel-side proxy IIC client")); |
|
1792 |
||
1793 |
err = User::FreeLogicalDevice(KIicProxyFileNameRootCtrlLess); |
|
1794 |
gTest(err==KErrNone || err==KErrAlreadyExists); |
|
1795 |
gTest.Next(_L("Free kernel-side proxy IIC slave client")); |
|
1796 |
err = User::FreeLogicalDevice(KIicProxySlaveFileNameRootCtrlLess); |
|
1797 |
gTest(err==KErrNone || err==KErrAlreadyExists); |
|
1798 |
||
1799 |
gTest.Next(_L("Free Simulated PSL I2C bus driver")); |
|
1800 |
err = User::FreePhysicalDevice(KI2cFileNameCtrlLess); |
|
1801 |
gTest(err==KErrNone); |
|
1802 |
||
1803 |
gTest.Next(_L("Free Simulated PSL SPI bus driver")); |
|
1804 |
err = User::FreePhysicalDevice(KSpiFileNameCtrlLess); |
|
1805 |
gTest(err==KErrNone); |
|
199 | 1806 |
|
1807 |
//For simplicity, the code coverage tests are executed in STANDALONE_CHANNEL mode |
|
1808 |
//All the changes are made in test code, and not affect PIL. |
|
1809 |
gTest.Next(_L("Start the code coverage tests")); |
|
1810 |
||
1811 |
gTest.Next(_L("Load Simulated PSL I2C bus driver")); |
|
1812 |
r = User::LoadPhysicalDevice(KI2cFileNameStubs); |
|
1813 |
gTest.Printf(_L("return value r=%d"),r); |
|
1814 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1815 |
||
1816 |
gTest.Next(_L("Load kernel-side proxy IIC client")); |
|
1817 |
r = User::LoadLogicalDevice(KIicProxyFileNameStubs); |
|
1818 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1819 |
||
1820 |
gTest.Next(_L("Load kernel-side proxy IIC slave client")); |
|
1821 |
r = User::LoadLogicalDevice(KIicProxySlaveFileNameStubs); |
|
1822 |
gTest(r==KErrNone || r==KErrAlreadyExists); |
|
1823 |
||
1824 |
__KHEAP_MARK; |
|
1825 |
TBufC<30> proxyNameStubs(KIicProxyFileNameRootStubs); |
|
1826 |
// Open a Master I2C channel to the kernel side proxy |
|
1827 |
r = gChanMasterI2c.Open(proxyNameStubs); |
|
1828 |
||
1829 |
gTest(r==KErrNone); |
|
1830 |
TBufC<35> proxySlaveNameStubs(KIicProxySlaveFileNameRootStubs); |
|
1831 |
||
1832 |
r = gChanSlaveI2c.Open(proxySlaveNameStubs); |
|
1833 |
gTest(r==KErrNone); |
|
1834 |
r = gChanSlaveI2c.InitSlaveClient(); |
|
1835 |
gTest(r==KErrNone); |
|
1836 |
||
1837 |
// Instigate tests |
|
1838 |
r = IicTestStubs(); |
|
1839 |
gTest(r==KErrNone); |
|
1840 |
||
1841 |
gTest.Printf(_L("Tests completed OK, about to close channel\n")); |
|
1842 |
gChanMasterI2c.Close(); |
|
1843 |
gChanSlaveI2c.Close(); |
|
1844 |
||
1845 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
1846 |
// Not safe to assume that heap clean-up has completed for the channels just closed, so insert a delay.(DEF145202) |
|
1847 |
User::After(20 * 1000); |
|
1848 |
__KHEAP_MARKEND; |
|
1849 |
||
1850 |
gTest.Next(_L("Free kernel-side proxy IIC client")); |
|
1851 |
||
1852 |
err = User::FreeLogicalDevice(KIicProxyFileNameRootStubs); |
|
1853 |
gTest(err==KErrNone || err==KErrAlreadyExists); |
|
1854 |
gTest.Next(_L("Free kernel-side proxy IIC slave client")); |
|
1855 |
err = User::FreeLogicalDevice(KIicProxySlaveFileNameRootStubs); |
|
1856 |
gTest(err==KErrNone || err==KErrAlreadyExists); |
|
1857 |
||
1858 |
gTest.Next(_L("Free Simulated PSL I2C bus driver")); |
|
1859 |
err = User::FreePhysicalDevice(KI2cFileNameStubs); |
|
1860 |
gTest(err==KErrNone); |
|
1861 |
||
1862 |
gTest.Next(_L("End the code coverage tests")); |
|
0 | 1863 |
#else |
1864 |
gTest.Printf(_L("Don't do the test if it is not IIC_SIMULATED_PSL")); |
|
1865 |
#endif |
|
1866 |
gTest.End(); |
|
1867 |
return r; |
|
1868 |
} |
|
1869 |