os/kernelhwsrv/kerneltest/e32utils/testusbcldd/inc/testusbc.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2004-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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\testusbcldd\inc\testusbc.h
    15 // Test USB Client API.
    16 // 
    17 // WARNING: This file contains some APIs which are internal and are subject
    18 //          to change without notice. Such APIs should therefore not be used
    19 //          outside the Kernel and Hardware Services package.
    20 //
    21 
    22 /**
    23  @file
    24  @internalTechnology
    25 */
    26 
    27 #ifndef __TESTUSBC_H__
    28 #define __TESTUSBC_H__
    29 
    30 #include <e32ver.h>
    31 #include <d32usbc.h>
    32 
    33 
    34 	
    35 class RDevTestUsbcClient : public RDevUsbcClient
    36 	{
    37 	public:
    38 	
    39 	enum TControl
    40 		{
    41 		ETestControlReqEndpointStatusNotify = 100,
    42 		ETestControlClearEndpoint
    43 		};
    44 	
    45 	enum TRequest
    46 		{
    47 		ETestRequestNotifyEndpointStatus = 100
    48 		};
    49 		
    50 	inline TInt Open(TInt aUnit)
    51 		{
    52 		_LIT(KUsbDevName, "Usbc");
    53 		return (DoCreate(KUsbDevName, TVersion(0, 1, 1), aUnit, NULL, NULL, EOwnerThread));
    54 		}
    55 		
    56 	inline void HostRead(TRequestStatus &aStatus, TEndpointNumber aEndpoint, TDes8 &aDes, TInt aLen)
    57 		{
    58 		TInt ep = (aEndpoint < 0 || aEndpoint>KMaxEndpointsPerClient) ? KInvalidEndpointNumber : aEndpoint;
    59 		TEndpointTransferInfo info = { &aDes, ETransferTypeReadData, aLen };
    60 		DoRequest(ep, aStatus, &info, (void*)ETrue);
    61 		}
    62 		
    63 	inline void HostWrite(TRequestStatus &aStatus, TEndpointNumber aEndpoint, const TDesC8& aDes,
    64 						  TInt aLen, TBool aZlpRequired = EFalse)
    65 		{
    66 		TInt ep = (aEndpoint < 0 || aEndpoint > KMaxEndpointsPerClient) ? KInvalidEndpointNumber : aEndpoint;
    67 		TEndpointTransferInfo info = { const_cast<TDesC8*>(&aDes), ETransferTypeWrite, aLen, aZlpRequired };
    68 		DoRequest(ep, aStatus, &info, (void*)ETrue);
    69 		}
    70 	
    71 	inline void HostEndpointStatusNotify(TRequestStatus &aStatus, TEndpointNumber aEndpoint)
    72 		{
    73 		TInt ep = (aEndpoint < 0 || aEndpoint > KMaxEndpointsPerClient) ? KInvalidEndpointNumber : aEndpoint;
    74 		DoRequest(ETestRequestNotifyEndpointStatus, aStatus, (void*)ep, (void*)ETrue);
    75 		}
    76 	
    77 	inline void HostClearEndpoint(TEndpointNumber aEndpoint)
    78 		{
    79 		TInt ep = (aEndpoint < 0 || aEndpoint > KMaxEndpointsPerClient) ? KInvalidEndpointNumber : aEndpoint;
    80 		DoControl(ETestControlClearEndpoint, (void*)ep, (void*)NULL);
    81 		}
    82 	};
    83 	
    84 #endif //__TESTUSBC_H__