|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __TIMESTAMPTEST_H__ |
|
21 #define __TIMESTAMPTEST_H__ |
|
22 |
|
23 #include <e32cmn.h> |
|
24 #include <e32ver.h> |
|
25 #ifndef __KERNEL_MODE__ |
|
26 #include <e32std.h> |
|
27 #endif |
|
28 |
|
29 /* |
|
30 * Update by driver when a every time NTimer expires |
|
31 */ |
|
32 |
|
33 struct STimestampResult |
|
34 { |
|
35 TUint64 iDelta; // difference in timestamp value between this and the last run |
|
36 TBool iLPMEntered; // true if low power modes wich restored timestamp was entered |
|
37 // since last NTimer expiry |
|
38 }; |
|
39 |
|
40 /* |
|
41 * Hold time stamp information, for now just freq |
|
42 */ |
|
43 |
|
44 struct STimestampTestConfig |
|
45 { |
|
46 TUint32 iFreq; |
|
47 TUint iIterations; |
|
48 TUint iRetries; |
|
49 TUint iTimerDurationS; |
|
50 TUint iErrorPercent; |
|
51 }; |
|
52 |
|
53 |
|
54 /** |
|
55 User interface for 'TimestampTest' |
|
56 */ |
|
57 class RTimestampTest : public RBusLogicalChannel |
|
58 { |
|
59 public: |
|
60 /** |
|
61 Structure for holding driver capabilities information |
|
62 (Just a version number in this example.) |
|
63 */ |
|
64 class TCaps |
|
65 { |
|
66 public: |
|
67 TVersion iVersion; |
|
68 }; |
|
69 static TVersion VersionRequired(); |
|
70 static const TDesC& Name(); |
|
71 |
|
72 public: |
|
73 TInt Open(); |
|
74 void Start(TRequestStatus& aStatus, TInt aNTicks); |
|
75 void WaitOnTimer(TRequestStatus& aStatus, STimestampResult& aResult); |
|
76 TInt Config(STimestampTestConfig& aConfig); |
|
77 private: |
|
78 /** |
|
79 Enumeration of Control messages. |
|
80 */ |
|
81 enum TControl |
|
82 { |
|
83 EConfig |
|
84 }; |
|
85 |
|
86 /** |
|
87 Enumeration of Request messages. |
|
88 */ |
|
89 enum TRequest |
|
90 { |
|
91 EStart, |
|
92 EWaitOnTimer, |
|
93 EAllRequests=-1 |
|
94 }; |
|
95 |
|
96 // Kernel side LDD channel is a friend |
|
97 friend class DTimestampTestChannel; |
|
98 }; |
|
99 |
|
100 /** |
|
101 The driver's name |
|
102 |
|
103 @return The name of the driver |
|
104 |
|
105 @internalComponent |
|
106 */ |
|
107 inline const TDesC& RTimestampTest::Name() |
|
108 { |
|
109 _LIT(KTimestampTestName,"TIMESTAMPTEST"); |
|
110 return KTimestampTestName; |
|
111 } |
|
112 |
|
113 /** |
|
114 The driver's version |
|
115 |
|
116 @return The version number of the driver |
|
117 |
|
118 @internalComponent |
|
119 */ |
|
120 inline TVersion RTimestampTest::VersionRequired() |
|
121 { |
|
122 const TInt KMajorVersionNumber=1; |
|
123 const TInt KMinorVersionNumber=0; |
|
124 const TInt KBuildVersionNumber=KE32BuildVersionNumber; |
|
125 return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
126 } |
|
127 |
|
128 /* |
|
129 NOTE: The following methods would normally be exported from a seperate client DLL |
|
130 but are included inline in this header file for convenience. |
|
131 */ |
|
132 |
|
133 #ifndef __KERNEL_MODE__ |
|
134 |
|
135 /** |
|
136 Open a logical channel to the driver |
|
137 @return One of the system wide error codes. |
|
138 */ |
|
139 TInt RTimestampTest::Open() |
|
140 { |
|
141 return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread); |
|
142 } |
|
143 |
|
144 |
|
145 /** |
|
146 Start measuring timestamp intervals in the timer |
|
147 @param aStatus request status for aync request |
|
148 @param aNTicks number of ticks used with the NTimer in the driver |
|
149 */ |
|
150 void RTimestampTest::Start(TRequestStatus& aStatus, TInt aNTicks) |
|
151 { |
|
152 DoRequest(EStart,aStatus,(TAny*) aNTicks); |
|
153 } |
|
154 |
|
155 |
|
156 /** |
|
157 Wait for next timer expiry of aNTicks used in Start function |
|
158 @param aStatus request status for aync request |
|
159 @param aStatus request status for aync request |
|
160 |
|
161 */ |
|
162 void RTimestampTest::WaitOnTimer(TRequestStatus& aStatus, STimestampResult& aResult) |
|
163 { |
|
164 DoRequest(EWaitOnTimer,aStatus,(TAny*) &aResult); |
|
165 } |
|
166 |
|
167 |
|
168 /** |
|
169 Open a logical channel to the driver |
|
170 @return One of the system wide error codes. |
|
171 */ |
|
172 TInt RTimestampTest::Config(STimestampTestConfig& aConfig) |
|
173 { |
|
174 return DoControl(EConfig,(TAny*) &aConfig); |
|
175 } |
|
176 |
|
177 |
|
178 #endif // !__KERNEL_MODE__ |
|
179 |
|
180 #endif |
|
181 |