Update contrib.
1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\device\t_usb.h
30 static const TInt KMaxBufSize = 1024 * 1024; // max data buffer size: 1MB
31 static const TInt KPreambleLength = 8; // length of preamble data (bytes)
45 class CActiveStallNotifier;
46 class CActiveDeviceStateNotifier;
48 class CActiveConsole : public CActive
51 static CActiveConsole* NewLC(CConsoleBase* aConsole, TBool aVerboseOutput);
52 static CActiveConsole* NewL(CConsoleBase* aConsole, TBool aVerboseOutput);
55 TInt SetupInterface();
56 void RequestCharacter();
59 CActiveConsole(CConsoleBase* aConsole, TBool aVerboseOutput);
60 // Defined as pure virtual by CActive;
61 // implementation provided by this class.
62 virtual void DoCancel();
63 // Defined as pure virtual by CActive;
64 // implementation provided by this class,
66 void ProcessKeyPressL(TChar aChar);
67 TInt QueryUsbClientL();
68 void AllocateEndpointDMA(TEndpointNumber aEndpoint);
69 void AllocateDoubleBuffering(TEndpointNumber aEndpoint);
70 void DeAllocateEndpointDMA(TEndpointNumber aEndpoint);
71 void DeAllocateDoubleBuffering(TEndpointNumber aEndpoint);
72 void QueryEndpointState(TEndpointNumber aEndpoint);
73 #ifdef WITH_DUMP_OPTION
76 TInt SetupDescriptors();
80 CConsoleBase* iConsole; // a console to read from
81 CActiveRW* iRW; // the USB read/write active object
82 CActiveStallNotifier* iStallNotifier;
83 CActiveDeviceStateNotifier* iDeviceStateNotifier;
85 RUsbOtgDriver iOtgPort;
86 TBool iBufferSizeChosen;
87 TBool iBandwidthPriorityChosen;
89 TBool iDoubleBufferingChosen;
90 TUint32 iBandwidthPriority;
91 TBool iSoftwareConnect;
100 class CActiveRW : public CActive
110 static CActiveRW* NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
112 TInt ExchangeVersions();
117 void SetMaxBufSize(TInt aBufSz);
118 void SetMaxPacketSize(TInt aPktSz);
119 TInt MaxBufSize() const;
120 void SetTransferMode(TXferMode aMode);
121 TInt WriteToDisk(TBool aEnable);
122 TInt ReadFromDisk(TBool aEnable);
125 CActiveRW(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
128 virtual void DoCancel();
130 TInt ReceiveVersion();
131 TBool CompareBuffers(TInt aLen);
133 void WriteBufferToDisk(TDes8& aBuffer, TInt aLen);
134 void ReadBufferFromDisk(TDes8& aBuffer, TInt aLen);
137 TBuf8<KPreambleLength> iPreambleBuf; // 2 bytes transfer length + stuffing
138 TBuf8<KMaxBufSize> iWriteBuf;
139 TBuf8<KMaxBufSize> iReadBuf;
140 CConsoleBase* iConsole;
141 RDevUsbcClient* iPort;
142 CActiveTimer* iTimeoutTimer;
146 TXferType iCurrentXfer;
151 TBool iDiskAccessEnabled;
159 class CActiveStallNotifier : public CActive
162 static CActiveStallNotifier* NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
163 ~CActiveStallNotifier();
167 CActiveStallNotifier(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
169 virtual void DoCancel();
173 CConsoleBase* iConsole;
174 RDevUsbcClient* iPort;
175 TUint iEndpointState;
180 class CActiveDeviceStateNotifier : public CActive
183 static CActiveDeviceStateNotifier* NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
184 ~CActiveDeviceStateNotifier();
188 CActiveDeviceStateNotifier(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
190 virtual void DoCancel();
194 CConsoleBase* iConsole;
195 RDevUsbcClient* iPort;
201 class CActiveTimer : public CActive
204 static CActiveTimer* NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
206 void Activate(TTimeIntervalMicroSeconds32 aDelay);
209 CActiveTimer(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput);
211 virtual void DoCancel();
215 CConsoleBase* iConsole;
216 RDevUsbcClient* iPort;
226 #define TUSB_PRINT(string) \
228 iConsole->Printf(_L(string)); \
229 iConsole->Printf(_L("\n")); \
230 RDebug::Print(_L(string)); \
233 #define TUSB_PRINT1(string, a) \
235 iConsole->Printf(_L(string), (a)); \
236 iConsole->Printf(_L("\n")); \
237 RDebug::Print(_L(string), (a)); \
240 #define TUSB_PRINT2(string, a, b) \
242 iConsole->Printf(_L(string), (a), (b)); \
243 iConsole->Printf(_L("\n")); \
244 RDebug::Print(_L(string), (a), (b)); \
247 #define TUSB_PRINT3(string, a, b, c) \
249 iConsole->Printf(_L(string), (a), (b), (c)); \
250 iConsole->Printf(_L("\n")); \
251 RDebug::Print(_L(string), (a), (b), (c)); \
254 #define TUSB_PRINT5(string, a, b, c, d, e) \
256 iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \
257 iConsole->Printf(_L("\n")); \
258 RDebug::Print(_L(string), (a), (b), (c), (d), (e)); \
261 #define TUSB_PRINT6(string, a, b, c, d, e, f) \
263 iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \
264 iConsole->Printf(_L("\n")); \
265 RDebug::Print(_L(string), (a), (b), (c), (d), (e), (f)); \
268 #define TUSB_VERBOSE_PRINT(string) \
272 TUSB_PRINT(string); \
276 #define TUSB_VERBOSE_PRINT1(string, a) \
280 TUSB_PRINT1(string, a); \
284 #define TUSB_VERBOSE_PRINT2(string, a, b) \
288 TUSB_PRINT2(string, a, b); \
293 #endif // __T_USB_H__