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