1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/inc/EndpointStallWatcher.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,153 @@
1.4 +#ifndef __ENDPOINT_STALL_WATCHER_H
1.5 +#define __ENDPOINT_STALL_WATCHER_H
1.6 +
1.7 +/*
1.8 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.9 +* All rights reserved.
1.10 +* This component and the accompanying materials are made available
1.11 +* under the terms of the License "Eclipse Public License v1.0"
1.12 +* which accompanies this distribution, and is available
1.13 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.14 +*
1.15 +* Initial Contributors:
1.16 +* Nokia Corporation - initial contribution.
1.17 +*
1.18 +* Contributors:
1.19 +*
1.20 +* Description:
1.21 +* @file BaseTestCase.h
1.22 +* @internalComponent
1.23 +*
1.24 +*
1.25 +*/
1.26 +
1.27 +
1.28 +
1.29 +#include <d32usbc.h>
1.30 +#include <e32base.h>
1.31 +#include "testdebug.h"
1.32 +
1.33 +
1.34 +namespace NUnitTesting_USBDI
1.35 + {
1.36 +
1.37 +/**
1.38 +*/
1.39 +class CEndpointStallWatcher : public CActive
1.40 + {
1.41 +public:
1.42 + /**
1.43 + C++ constructor
1.44 + */
1.45 + CEndpointStallWatcher(RDevUsbcClient& aClientDriver)
1.46 + : CActive(EPriorityUserInput),
1.47 + iClientDriver(aClientDriver),
1.48 + iEpMask(0)
1.49 + {
1.50 + CActiveScheduler::Add(this);
1.51 + RequestNotification();
1.52 + }
1.53 +
1.54 + /**
1.55 + Destructor
1.56 + */
1.57 + ~CEndpointStallWatcher()
1.58 + {
1.59 + Cancel();
1.60 + }
1.61 +
1.62 +protected:
1.63 + /**
1.64 + */
1.65 + void DoCancel()
1.66 + {
1.67 + LOG_FUNC
1.68 +
1.69 + iClientDriver.EndpointStatusNotifyCancel();
1.70 + }
1.71 +
1.72 + /**
1.73 + */
1.74 + void RunL()
1.75 + /*
1.76 + This is only called if the host alters the stall status of an endpoint.
1.77 + It will NOT be called if the client\peripheral has altered the stall ststus
1.78 + of an endpoint.
1.79 + */
1.80 + {
1.81 + LOG_FUNC
1.82 +
1.83 + TUint epMask = iEpMask;
1.84 +
1.85 + if(iStatus.Int() != KErrNone)
1.86 + /*
1.87 + ...for example a reset has occurred.
1.88 + The EP Mask will not be filled.
1.89 + */
1.90 + {
1.91 + RequestNotification();
1.92 + return;
1.93 + }
1.94 +
1.95 + RDebug::Printf("The HOST has halted or cleared a halt on an endpoint.");
1.96 + if(epMask==0)
1.97 + {
1.98 + RDebug::Printf("Now NO endpoints are stalled!");
1.99 + RequestNotification();
1.100 + return;
1.101 + }
1.102 +
1.103 + _LIT(KStalledEndpoints, "Currently Stalled Endpoints: ");
1.104 + _LIT(KComma, ", ");
1.105 + TUint KLSB = 0x01;
1.106 + TBuf<128> msg(KStalledEndpoints);
1.107 + for(TUint8 count = 1; count <= KMaxEndpointsPerClient; count++)
1.108 + //Notifier does not notify for EP0, so count from EP1
1.109 + //up to max endpoints per interface allowed by the Symbian client
1.110 + {
1.111 + epMask>>=1;
1.112 + if(epMask & KLSB)
1.113 + {
1.114 + msg.AppendNum(count);
1.115 + msg.Append(KComma);
1.116 + }
1.117 + }
1.118 + RDebug::Print(msg);
1.119 + RequestNotification();
1.120 + return;
1.121 + }
1.122 +
1.123 + /**
1.124 + */
1.125 + TInt RunError(TInt aError)
1.126 + {
1.127 + LOG_FUNC
1.128 +
1.129 + return KErrNone;
1.130 + }
1.131 +
1.132 +private:
1.133 + void RequestNotification()
1.134 + {
1.135 + iClientDriver.EndpointStatusNotify(iStatus,iEpMask);
1.136 + SetActive();
1.137 + }
1.138 +private:
1.139 + /**
1.140 + The channel to the client driver
1.141 + */
1.142 + RDevUsbcClient& iClientDriver;
1.143 +
1.144 + /**
1.145 + */
1.146 + TUint iEpMask;
1.147 + };
1.148 +
1.149 +
1.150 + }
1.151 +
1.152 +
1.153 +#endif
1.154 +
1.155 +
1.156 +