os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/inc/controlendpointreader.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 #ifndef __CONTROL_ENDPOINT_READER_H
     2 #define __CONTROL_ENDPOINT_READER_H
     3 
     4 /*
     5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     6 * All rights reserved.
     7 * This component and the accompanying materials are made available
     8 * under the terms of the License "Eclipse Public License v1.0"
     9 * which accompanies this distribution, and is available
    10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    11 *
    12 * Initial Contributors:
    13 * Nokia Corporation - initial contribution.
    14 *
    15 * Contributors:
    16 *
    17 * Description:
    18 * @file controlendpointreader.h
    19 * @internalComponent
    20 * 
    21 *
    22 */
    23 
    24 
    25 
    26 #include "endpointreader.h"
    27 
    28 namespace NUnitTesting_USBDI
    29 	{
    30 
    31 /**
    32 */
    33 class MRequestHandler
    34 	{
    35 public:
    36 	/**
    37 	Called when a control vendor request from the host is received and does not require data being
    38 	sent back to the host.
    39 	@param aRequest the control request value
    40 	@param aValue a parameter value for the request
    41 	@param aIndex an index parameter for the request
    42 	@param aDataReqLength the length of the data to be returned to the host
    43 	@param aPayload the data payload sent to the device by the host in a data phase
    44 	*/
    45 	
    46 	virtual TInt ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,TUint16 aDataReqLength,
    47 					const TDesC8& aPayload) = 0;
    48 	};
    49 
    50 
    51 	
    52 /**
    53 This class describes a entity that reads control requests from endpoint 0
    54 */
    55 class CControlEndpointReader : public CEndpointReader, public MEndpointDataHandler
    56 	{
    57 public:
    58 
    59 	/**
    60 	Constructor, build a reader of requests from endpoint zero
    61 	@param aClientDriver the channel to the USB client driver
    62 	@param aRequestHandler the handler of control requests
    63 	*/
    64 	
    65 	CControlEndpointReader(RDevUsbcClient& aClientDriver,MRequestHandler& aRequestHandler);
    66 	
    67 	/**
    68 	Destructor
    69 	*/
    70 	
    71 	virtual ~CControlEndpointReader();
    72 
    73 	/**
    74 	Reads requests sent by the host on endpoint 0.  This includes any data from the data phase
    75 	of the transfer
    76 	*/
    77 	
    78 	void ReadRequestsL();
    79 
    80 public: // From MEndpointDataHandler
    81 
    82 	/**
    83 	Interprets the data received as a control request on endpoint 0
    84 	@param aEndpointNumber the number of the endpoint read from
    85 	@param aData the data successfully read from the endpoint
    86 	*/
    87 	
    88 	virtual void DataReceivedFromEndpointL(TEndpointNumber aEndpointNumber,const TDesC8& aData);	
    89 	
    90 	/**
    91 	Notified when an error occurs on a read from the endpoint
    92 	@param aEndpointNumber the number of the endpoint read from
    93 	@param aErrorCode the read operation completion error
    94 	*/
    95 	
    96 	void EndpointReadError(TEndpointNumber aEndpointNumber,TInt aErrorCode);
    97 	
    98 private:
    99 
   100 	// Flag to indicate
   101 	TBool iDeviceToHost;
   102 	TBool iDataPhase;
   103 	
   104 	/**
   105 	The request status of the entity processing requests
   106 	*/
   107 	MRequestHandler& iRequestHandler;
   108 	
   109 	/**
   110 	The fields of the control transfer request
   111 	*/
   112 	TUint8 ibRequestType;
   113 	TUint8 ibRequest;
   114 	TUint16 iwValue;
   115 	TUint16 iwIndex;
   116 	TUint16 iwLength;
   117 	};
   118 	
   119 	}
   120 
   121 
   122 #endif
   123 
   124