253
|
1 |
// Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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/usb\t_usb_device\src\activetimer.cpp
|
|
15 |
// USB Test Program T_USB_DEVICE, functional part.
|
|
16 |
// Device-side part, to work against T_USB_HOST running on the host.
|
|
17 |
//
|
|
18 |
//
|
|
19 |
|
|
20 |
#include "general.h" // CActiveControl, CActiveRW
|
253
|
21 |
#include "OstTraceDefinitions.h"
|
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
23 |
#include "activetimerTraces.h"
|
|
24 |
#endif
|
0
|
25 |
#include "activetimer.h"
|
|
26 |
|
|
27 |
extern RTest test;
|
|
28 |
extern TBool gVerbose;
|
|
29 |
extern TBool gSkip;
|
|
30 |
extern TBool gStopOnFail;
|
|
31 |
extern TInt gSoakCount;
|
|
32 |
|
|
33 |
//
|
|
34 |
// --- class CActiveTimer ---------------------------------------------------------
|
|
35 |
//
|
|
36 |
|
|
37 |
CActiveTimer::CActiveTimer(CConsoleBase* aConsole, RDEVCLIENT* aPort)
|
|
38 |
: CActive(EPriorityNormal),
|
|
39 |
iConsole(aConsole),
|
|
40 |
iPort(aPort)
|
|
41 |
{
|
|
42 |
CActiveScheduler::Add(this);
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
CActiveTimer* CActiveTimer::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort)
|
|
47 |
{
|
|
48 |
CActiveTimer* self = new (ELeave) CActiveTimer(aConsole, aPort);
|
|
49 |
CleanupStack::PushL(self);
|
|
50 |
self->ConstructL();
|
|
51 |
CleanupStack::Pop(); // self
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
|
|
56 |
void CActiveTimer::ConstructL()
|
|
57 |
{
|
|
58 |
User::LeaveIfError(iTimer.CreateLocal());
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
CActiveTimer::~CActiveTimer()
|
|
63 |
{
|
|
64 |
TUSB_VERBOSE_PRINT("CActiveTimer::~CActiveTimer()");
|
253
|
65 |
if(gVerbose)
|
|
66 |
{
|
|
67 |
OstTrace0(TRACE_VERBOSE, CACTIVETIMER_DCACTIVETIMER, "CActiveTimer::~CActiveTimer()");
|
|
68 |
}
|
0
|
69 |
Cancel(); // base class
|
|
70 |
iTimer.Close();
|
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
void CActiveTimer::DoCancel()
|
|
75 |
{
|
|
76 |
TUSB_VERBOSE_PRINT("CActiveTimer::DoCancel()");
|
253
|
77 |
if(gVerbose)
|
|
78 |
{
|
|
79 |
OstTrace0(TRACE_VERBOSE, CACTIVETIMER_DOCANCEL, "CActiveTimer::DoCancel()");
|
|
80 |
}
|
0
|
81 |
iTimer.Cancel();
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
void CActiveTimer::RunL()
|
|
86 |
{
|
|
87 |
TUSB_VERBOSE_PRINT("CActiveTimer::RunL()");
|
253
|
88 |
if(gVerbose)
|
|
89 |
{
|
|
90 |
OstTrace0(TRACE_VERBOSE, CACTIVETIMER_RUNL, "CActiveTimer::RunL()");
|
|
91 |
}
|
0
|
92 |
// Nothing to do here, as we call ReadCancel() after a manual WaitForRequest()
|
|
93 |
// (in CActiveRW::ReceiveVersion()).
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
void CActiveTimer::Activate(TTimeIntervalMicroSeconds32 aDelay)
|
|
98 |
{
|
|
99 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666));
|
|
100 |
iTimer.After(iStatus, aDelay);
|
|
101 |
SetActive();
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
// -eof-
|