35
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 - 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: Takes control over the EP0 vendor specific messages, and process requests
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CUSBDEVCON_H
|
|
20 |
#define CUSBDEVCON_H
|
|
21 |
|
|
22 |
#include <e32std.h>
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <d32usbc.h>
|
|
25 |
#include <usbman.h>
|
|
26 |
#include <usbwatcher.h>
|
|
27 |
|
|
28 |
class CUsbStateWatcher; // watches device's USB states
|
|
29 |
class CStateMachine; // state-machine
|
|
30 |
class CRequestsHandler; // contains actual requests handlers
|
|
31 |
|
|
32 |
static const TUint KSetupPacketLength = 8; // 8 bytes, always
|
|
33 |
static const TUint KInactiveTimeForShutDown = 10000000; // microseconds
|
|
34 |
|
|
35 |
/**
|
|
36 |
* USB Device Controller
|
|
37 |
* Contains all needed subclasses, to
|
|
38 |
* take control over EP0 vendor specific messages
|
|
39 |
* and processing requests
|
|
40 |
*
|
|
41 |
*
|
|
42 |
* @lib usbdevcon.lib
|
|
43 |
* @since S60 v.5.0
|
|
44 |
*/
|
|
45 |
|
|
46 |
class CUsbDevCon : public CActive
|
|
47 |
{
|
|
48 |
|
|
49 |
public:
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Two-phased constructor.
|
|
53 |
*
|
|
54 |
* @since S60 v.5.0
|
|
55 |
* @return Constructed instance
|
|
56 |
*/
|
|
57 |
static CUsbDevCon* NewL();
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Two-phased constructor.
|
|
61 |
*
|
|
62 |
* @since S60 v.5.0
|
|
63 |
* @return Constructed instance
|
|
64 |
*/
|
|
65 |
static CUsbDevCon* NewLC();
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Destructor.
|
|
69 |
*
|
|
70 |
* @since S60 v.5.0
|
|
71 |
*/
|
|
72 |
virtual ~CUsbDevCon();
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Performs action needed by specific usb state
|
|
76 |
*
|
|
77 |
* @since S60 v.5.0
|
|
78 |
* @param aUsbState USB state
|
|
79 |
*/
|
|
80 |
void ActAccordinglyToUsbStateL(TUsbcDeviceState aUsbState);
|
|
81 |
|
|
82 |
private:
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Default construction
|
|
86 |
*
|
|
87 |
* @since S60 v.5.0
|
|
88 |
*/
|
|
89 |
CUsbDevCon();
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Two-phased constructor.
|
|
93 |
*
|
|
94 |
* @since S60 v.5.0
|
|
95 |
*/
|
|
96 |
void ConstructL();
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Take needed actions on starting services
|
|
100 |
*
|
|
101 |
* @since S60 v.5.0
|
|
102 |
*/
|
|
103 |
void StartL();
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Take needed actions on stopping services
|
|
107 |
*
|
|
108 |
* @since S60 v.5.0
|
|
109 |
*/
|
|
110 |
void StopL();
|
|
111 |
|
|
112 |
// from CActive
|
|
113 |
|
|
114 |
/**
|
|
115 |
* From CActive
|
|
116 |
*
|
|
117 |
*/
|
|
118 |
void RunL();
|
|
119 |
|
|
120 |
/**
|
|
121 |
* From CActive
|
|
122 |
*
|
|
123 |
*/
|
|
124 |
void DoCancel();
|
|
125 |
|
|
126 |
/**
|
|
127 |
* From CActive.
|
|
128 |
*
|
|
129 |
*/
|
|
130 |
TInt RunError( TInt /*aError*/ );
|
|
131 |
|
|
132 |
private: // data
|
|
133 |
|
|
134 |
/**
|
|
135 |
* USB state watcher
|
|
136 |
* Own
|
|
137 |
*/
|
|
138 |
CUsbStateWatcher* iUsbStateWatcher;
|
|
139 |
|
|
140 |
/**
|
|
141 |
* CStateMachine
|
|
142 |
* Own
|
|
143 |
*/
|
|
144 |
CStateMachine* iStateMachine;
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Requests handler
|
|
148 |
* Own
|
|
149 |
*/
|
|
150 |
CRequestsHandler* iRequestsHandler;
|
|
151 |
|
|
152 |
/**
|
|
153 |
* USB client
|
|
154 |
* Need to take control over EP0
|
|
155 |
* Also reference to it will be provided to handlers
|
|
156 |
*/
|
|
157 |
RDevUsbcClient iLdd;
|
|
158 |
|
|
159 |
/**
|
|
160 |
* USB Watcher
|
|
161 |
* Need to handle some requests (like GetPersonalities)
|
|
162 |
* Reference to it will be provided to handlers
|
|
163 |
*/
|
|
164 |
RUsbWatcher iUsbWatcher;
|
|
165 |
|
|
166 |
/**
|
|
167 |
* USB Manager
|
|
168 |
* Need to handle some requests (like SetPersonality)
|
|
169 |
* Reference to it will be provided to handlers
|
|
170 |
*/
|
|
171 |
RUsb iUsbManager;
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Previous USB state
|
|
175 |
*/
|
|
176 |
TInt iPrevUsbState;
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Shuts down if USB inactive for specified period of time
|
|
180 |
*/
|
|
181 |
RTimer iShutdownTimer;
|
|
182 |
|
|
183 |
};
|
|
184 |
|
|
185 |
#endif // USBDEVCON_H
|