|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test/iic/iic_psl/iic_testpsl.cpp |
|
15 // |
|
16 |
|
17 #include <drivers/iic.h> |
|
18 #include "iic_testpsl.h" |
|
19 |
|
20 // Global Controller pointer |
|
21 extern DIicBusController*& gTheController; |
|
22 |
|
23 #ifndef IIC_SIMULATED_PSL |
|
24 |
|
25 #error iic_testpsl.cpp being built when IIC_SIMULATED_PSL is not defined |
|
26 |
|
27 #else |
|
28 |
|
29 TVersion DIicPdd::VersionRequired() |
|
30 { |
|
31 const TInt KIicMajorVersionNumber=1; |
|
32 const TInt KIicMinorVersionNumber=0; |
|
33 const TInt KIicBuildVersionNumber=KE32BuildVersionNumber; |
|
34 return TVersion(KIicMajorVersionNumber,KIicMinorVersionNumber,KIicBuildVersionNumber); |
|
35 } |
|
36 |
|
37 /** Factory class constructor */ |
|
38 DIicPdd::DIicPdd() |
|
39 { |
|
40 iVersion = DIicPdd::VersionRequired(); |
|
41 } |
|
42 |
|
43 DIicPdd::~DIicPdd() |
|
44 { |
|
45 delete gTheController; |
|
46 } |
|
47 |
|
48 TInt DIicPdd::Install() |
|
49 { |
|
50 return(SetName(&KPddName)); |
|
51 } |
|
52 |
|
53 /** Called by the kernel's device driver framework to create a Physical Channel. */ |
|
54 TInt DIicPdd::Create(DBase*& /*aChannel*/, TInt /*aUint*/, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/) |
|
55 { |
|
56 return KErrNone; |
|
57 } |
|
58 |
|
59 /** Called by the kernel's device driver framework to check if this PDD is suitable for use with a Logical Channel.*/ |
|
60 TInt DIicPdd::Validate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer) |
|
61 { |
|
62 if (!Kern::QueryVersionSupported(DIicPdd::VersionRequired(),aVer)) |
|
63 return(KErrNotSupported); |
|
64 return KErrNone; |
|
65 } |
|
66 |
|
67 /** Return the driver capabilities */ |
|
68 void DIicPdd::GetCaps(TDes8& aDes) const |
|
69 { |
|
70 // Create a capabilities object |
|
71 TCaps caps; |
|
72 caps.iVersion = iVersion; |
|
73 // Zero the buffer |
|
74 TInt maxLen = aDes.MaxLength(); |
|
75 aDes.FillZ(maxLen); |
|
76 // Copy cpabilities |
|
77 TInt size=sizeof(caps); |
|
78 if(size>maxLen) |
|
79 size=maxLen; |
|
80 aDes.Copy((TUint8*)&caps,size); |
|
81 } |
|
82 |
|
83 static DIicPdd* TheIicPdd; |
|
84 |
|
85 DECLARE_STANDARD_PDD() |
|
86 { |
|
87 gTheController = new DIicBusController; |
|
88 if(!gTheController) |
|
89 return NULL; |
|
90 TInt r = gTheController->Create(); |
|
91 if(r == KErrNone) |
|
92 { |
|
93 TheIicPdd = new DIicPdd; |
|
94 if(TheIicPdd) |
|
95 return TheIicPdd; |
|
96 } |
|
97 |
|
98 delete gTheController; |
|
99 return NULL; |
|
100 } |
|
101 |
|
102 #endif/*IIC_SIMULATED_PSL*/ |
|
103 |
|
104 |
|
105 |
|
106 |