First public contribution.
1 // Copyright (c) 2008-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/usb/t_usb_device/include/activecontrol.h
18 #ifndef __ACTIVECONSOLE_H__
19 #define __ACTIVECONSOLE_H__
21 #include "activestallnotifier.h"
22 #include "activedevicestatenotifier.h"
24 static const TInt KSetupPacketSize = 8;
25 static const TInt KMaxControlBufferSize = 256;
26 static const TInt KMaxControlPacketSize = 64;
28 static const TInt KUsb_Ep0RequestTypeOffset = 0;
29 static const TInt KUsb_Ep0RequestOffset = 1;
30 static const TInt KUsb_Ep0wValueOffset = 2;
31 static const TInt KUsb_Ep0wIndexOffset = 4;
32 static const TInt KUsb_Ep0wLengthOffset = 6;
34 static const TUint32 KDeviceVersionMajor = 2; // The version for t_usb_device
35 static const TUint32 KDeviceVersionMinor = 0;
36 static const TUint32 KDeviceVersionMicro = 0;
37 static const TUint8 KHostVersionMajor = 1; // the host version we're compatible with
38 static const TUint8 KHostVersionMinor = 1;
39 static const TUint8 KHostVersionMicro = 0;
41 static const TUint32 KMSFinishedDelay = 5000000; // 5 second delay after mass storage finishing
54 class CActiveControl : public CActive
57 static CActiveControl* NewLC(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
58 static CActiveControl* NewL(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
61 void RequestEp0ControlPacket();
62 void SetMSFinished(TBool aState);
63 void AllocateEndpointDMA(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
64 void AllocateDoubleBuffering(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
65 void DeAllocateEndpointDMA(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
66 void DeAllocateDoubleBuffering(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
69 CActiveControl(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
70 // Defined as pure virtual by CActive;
71 // implementation provided by this class.
72 virtual void DoCancel();
73 // Defined as pure virtual by CActive;
74 // implementation provided by this class,
76 void CActiveControl::ReConnect();
77 void SetupInterface(IFConfigPtr* aIfPtr, TInt aPortNumber);
78 void QueryUsbClientL(LDDConfigPtr aLddPtr,RDEVCLIENT* aPort);
79 void QueryEndpointState(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
81 TInt ProcessEp0ControlPacket();
85 CConsoleBase* iConsole; // a console to read from
86 CActiveStallNotifier* iStallNotifier[KMaxInterfaces];
87 CActiveDeviceStateNotifier* iDeviceStateNotifier[KMaxInterfaces];
88 RDEVCLIENT iPort[KMaxInterfaces];
91 TInt iNumInterfaceSettings[KMaxInterfaces];
93 TBool iSoftwareConnect;
97 TDes * iConfigFileName;
98 TDes * iScriptFileName;
101 TEndpointBuffer iEp0Buf;
106 TBuf8<KSetupPacketSize> iEp0SetUpPacket;
107 TBuf8<KMaxControlBufferSize> iEp0DataBuffer;
108 TUint iEp0PacketSize;
109 RThread iIdleCounterThread;
110 RChunk iIdleCounterChunk;
111 struct TTestIdleCounter* iIdleCounter;
114 #endif // __ACTIVECONTROL_H__