epoc32/include/wins/winscomm.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/wins/winscomm.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,249 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// wins/specific/winscomm.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __M32COMM_H__
    1.22 +#define __M32COMM_H__
    1.23 +#include <platform.h>
    1.24 +//#include <kpower.h>
    1.25 +#include <d32comm.h>
    1.26 +#include <e32ver.h>
    1.27 +//
    1.28 +const TInt KCommsMajorVersionNumber=1;
    1.29 +const TInt KCommsMinorVersionNumber=1;
    1.30 +const TInt KCommsBuildVersionNumber=KE32BuildVersionNumber;
    1.31 +
    1.32 +//
    1.33 +enum TStopMode {EStopNormal,EStopPwrDown,EStopEmergency};
    1.34 +//
    1.35 +//
    1.36 +class DChannelComm;
    1.37 +class DComm : public DBase
    1.38 +	{
    1.39 +public:
    1.40 +	virtual TInt Start() =0;
    1.41 +	virtual void Stop(TStopMode aMode) =0;
    1.42 +	virtual void Break(TBool aState) =0;
    1.43 +	virtual void Write(DThread*,TAny*,TInt) = 0;
    1.44 +	virtual void Read(DThread*,TAny*,TInt) = 0;
    1.45 +	virtual void NotifySignals(DThread*, TInt) = 0;
    1.46 +	virtual void NotifyDataAvailable() = 0;
    1.47 +	virtual TUint Signals() const =0;
    1.48 +	virtual void SetSignals(TUint aSetMask,TUint aClearMask) =0;
    1.49 +	virtual TInt ValidateConfig(const TCommConfigV01 &aConfig) const =0;
    1.50 +	virtual void Configure(TCommConfigV01 &aConfig) =0;
    1.51 +	virtual void Caps(TDes8 &aCaps) const =0;
    1.52 +	virtual void CheckConfig(TCommConfigV01& aConfig)=0;
    1.53 +	virtual TDfcQue* DfcQ(TInt aUnit)=0;
    1.54 +	inline void SetCurrent(TInt aCurrent);
    1.55 +	inline TBool Transmitting();
    1.56 +	virtual TInt RxCount() =0;
    1.57 +	virtual void ResetBuffers(TBool) = 0;
    1.58 +	virtual TInt SetRxBufferSize(TInt aSize) = 0;
    1.59 +	virtual TInt RxBufferSize() =0;
    1.60 +	virtual TDes8* RxBuffer() =0;
    1.61 +	virtual TBool AreAnyPending() = 0;
    1.62 +	virtual void ReadCancel() = 0;
    1.63 +	virtual void WriteCancel() = 0;
    1.64 +	virtual void SignalChangeCancel() = 0;
    1.65 +	virtual inline TBool LineFail() =0;
    1.66 +
    1.67 +public:
    1.68 +	DChannelComm *iLdd;
    1.69 +	TBool iTransmitting;
    1.70 +	TUint8 * iInBufPtr;
    1.71 +	TUint8 * iOutBufPtr;
    1.72 +	};
    1.73 +
    1.74 +
    1.75 +class DDeviceComm : public DLogicalDevice
    1.76 +	{
    1.77 +public:
    1.78 +	DDeviceComm();
    1.79 +	virtual TInt Install();
    1.80 +	virtual void GetCaps(TDes8 &aDes) const;
    1.81 +	virtual TInt Create(DLogicalChannelBase*& aChannel);
    1.82 +	};
    1.83 +
    1.84 +//class DCommPowerHandler;
    1.85 +class DChannelComm : public DLogicalChannel
    1.86 +	{
    1.87 +public:
    1.88 +	enum TState {EOpen,EActive,EClosed};
    1.89 +	enum TRequest {ERx=1, ETx=2, ESigChg=4, ERxDA=8, EBreak=16, EAll=0xff};
    1.90 +
    1.91 +	DChannelComm();
    1.92 +	~DChannelComm();
    1.93 +	inline void SetStatus(TState aStatus);
    1.94 +	TInt TurnaroundSet(TUint aNewTurnaroundMilliSeconds);
    1.95 +	TBool TurnaroundStopTimer();
    1.96 +	TInt TurnaroundClear();
    1.97 +	static void TurnaroundStartDfc(TAny* aSelf);
    1.98 +	void TurnaroundStartDfcImplementation(TBool inIsr);
    1.99 +	static void TurnaroundTimeout(TAny* aSelf);
   1.100 +	void TurnaroundTimeoutImplementation(void);
   1.101 +
   1.102 +protected:
   1.103 +	virtual TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
   1.104 +	virtual void HandleMsg(TMessageBase* aMsg);
   1.105 +	void DoCancel(TInt aMask);
   1.106 +	TInt DoControl(TInt aId, TAny* a1, TAny* a2);
   1.107 +	TInt DoRequest(TInt aId, TRequestStatus* aStatus, TAny* a1, TAny* a2);
   1.108 +	void Start();
   1.109 +	void Shutdown();
   1.110 +	void BreakOn();
   1.111 +	void BreakOff();
   1.112 +	void ResetBuffers(TBool aResetTx);
   1.113 +	void DoCompleteRx();
   1.114 +	void DoCompleteTx();
   1.115 +	void DoSignalNotify();
   1.116 +	void DoRxDataAvailable();
   1.117 +	void Complete(TInt aMask, TInt aReason);
   1.118 +	inline void CompleteRead()	{ iRxCompleteDfc.Add(); }
   1.119 +	inline void CompleteWrite() { iTxCompleteDfc.Add(); }
   1.120 +protected:
   1.121 +	inline void Write(DThread* aT, TAny* aP, TInt aL) {((DComm*)iPdd)->Write(aT, aP,aL);}
   1.122 +	inline void Read(DThread* aT, TAny* aP, TInt aL) {((DComm*)iPdd)->Read(aT, aP,aL);}
   1.123 +	inline void NotifySignals(DThread* aThread, TInt aMask) {((DComm*)iPdd)->NotifySignals(aThread, aMask);}
   1.124 +	inline void NotifyDataAvailable() {((DComm*)iPdd)->NotifyDataAvailable(); }
   1.125 +	inline TInt PddStart();
   1.126 +	inline void Stop(TStopMode aMode);
   1.127 +	inline void PddBreak(TBool aState);
   1.128 +	inline TUint Signals() const;
   1.129 +	inline void SetSignals(TUint aSetMask,TUint aClearMask);
   1.130 +	inline TInt ValidateConfig(const TCommConfigV01 &aConfig) const;
   1.131 +	inline void PddConfigure(TCommConfigV01 &aConfig);
   1.132 +	inline void PddCaps(TDes8 &aCaps) const;
   1.133 +	inline void PddCheckConfig(TCommConfigV01& aConfig);
   1.134 +	inline TBool Transmitting();
   1.135 +	inline TInt BufferSize();
   1.136 +	inline void ReadCancel();
   1.137 +	inline void WriteCancel();
   1.138 +	inline void SignalChangeCancel();
   1.139 +
   1.140 +	static void FinishBreakDfc(TAny* aSelf);
   1.141 +	void QueueFinishBreakDfc();
   1.142 +	static void FinishBreak(TAny* aSelf);
   1.143 +	void FinishBreakImplementation(TInt aBreakError);
   1.144 +private:
   1.145 +//	static void PowerUpDfc(TAny* aPtr);
   1.146 +//	static void PowerDownDfc(TAny* aPtr);
   1.147 +	static void CompleteRxDfc(TAny* aPtr);
   1.148 +	static void CompleteTxDfc(TAny* aPtr);
   1.149 +	static void SignalNotifyDfc(TAny* aPtr);
   1.150 +	static void RxDataAvailableDfc(TAny* aPtr);
   1.151 +	inline TInt RxCount();
   1.152 +	inline TInt RxBufferSize();
   1.153 +	inline TDes8* RxBuffer();
   1.154 +	inline TInt SetRxBufferSize(TInt aSize);
   1.155 +	inline TBool AreAnyPending() const;
   1.156 +//	void UpdateSignals();
   1.157 +	void UpdateAndProcessSignals();
   1.158 +	void InitiateRead(TAny* aRxDes, TInt aLength);
   1.159 +	void InitiateWrite(TAny* aTxDes, TInt aLength);
   1.160 +	void InitiateNotifySignals(TAny* aResult, TInt aMask);
   1.161 +	void NotifyReadDataAvailable();
   1.162 +//	TUint FailSignals(TUint aHandshake);
   1.163 +//	TUint HoldSignals(TUint aHandshake);
   1.164 +//	TUint FlowControlSignals(TUint aHandshake);
   1.165 +//	TUint AutoSignals(TUint aHandshake);
   1.166 +	TInt SetConfig(TCommConfigV01& aConfig);
   1.167 +//	void CheckOutputHeld();
   1.168 +//	void ReleaseBuffers();
   1.169 +	inline TBool LineFail();
   1.170 +
   1.171 +	// Min Turnaround time between Rx and Tx
   1.172 +	TUint		iTurnaroundMicroSeconds;		// delay after a receive before transmission in us
   1.173 +	TUint		iTurnaroundMinMilliSeconds;		// delay after a receive before transmission in ms
   1.174 +	TUint       iTurnaroundTimerStartTime;      // stores the start time of the turnaround timer.
   1.175 +	TUint8      iTurnaroundTimerStartTimeValid; // stores turnaround timer status 0 after boot, 1 if the timestamp is valid, and 2 if invalid
   1.176 +	TUint8		iTurnaroundTimerRunning;		// a receive has started the timer
   1.177 +	TUint8		iTurnaroundTransmitDelayed;		// a transmission is held until time elapses after a receive
   1.178 +	TUint8		iSpare;
   1.179 +	NTimer		iTurnaroundTimer;				// used to delay transmission after a receive
   1.180 +	TDfc		iTurnaroundDfc;					// used in interrupt space, to trigger a call in user space
   1.181 +
   1.182 +	TAny*		iTurnaroundTxDesPtr;			// client descriptor awaiting transmission
   1.183 +	TInt		iTurnaroundTxDesLength;			// initial size of tx descriptor
   1.184 +
   1.185 +	// Breaks
   1.186 +	TTickLink iBreakTimer;
   1.187 +	TDfc		 iBreakDfc;
   1.188 +	TRequestStatus* iBreakStatus;
   1.189 +	TInt		iBreakTimeMicroSeconds;
   1.190 +	TBool 	iTurnaroundBreakDelayed;
   1.191 +	TAny*		iBreakDelayedTxDesPtr;			// client descriptor awaiting transmission
   1.192 +	TInt		iBreakDelayedTxDesLength;			// initial size of tx descriptor
   1.193 +	TBool		iBreakDelayedTx;
   1.194 +public:
   1.195 +	// Port configuration
   1.196 +	TCommConfigV01 iConfig;
   1.197 +
   1.198 +	// General items
   1.199 +	DThread* iClient;
   1.200 +	TAny* iClientDestPtr;
   1.201 +//	DCommPowerHandler* iPowerHandler;
   1.202 +//	TDfc iPowerUpDfc;
   1.203 +//	TDfc iPowerDownDfc;
   1.204 +//	TUint32 iPowerDownMask;
   1.205 +	TState iStatus;
   1.206 +	TDfc iRxCompleteDfc;
   1.207 +	TDfc iTxCompleteDfc;
   1.208 +	TDfc iRxDataAvailableDfc;
   1.209 +	TDfc iSigNotifyDfc;
   1.210 +	TUint iFlags;				//
   1.211 +	TUint iSignals;				// State of handshake lines
   1.212 +//	TUint iFailSignals;			// 1 bit means line low causes line fail error
   1.213 +//	TUint iHoldSignals;			// 1 bit means line low halts TX
   1.214 +//	TUint iFlowControlSignals;	// 1 bit means signal is used for RX flow control
   1.215 +//	TUint iAutoSignals;			// 1 bit means signal is high when channel is open
   1.216 +	TBool iShutdown;			// ETrue means device is being closed
   1.217 +	TBool iMsgHeld;				// ETrue means a message has been held up waiting power on
   1.218 +
   1.219 +	// RX client related items
   1.220 +	TInt iRxError;
   1.221 +	TRequestStatus* iRxStatus;
   1.222 +
   1.223 +
   1.224 +	// TX client related items
   1.225 +	TInt iTxError;
   1.226 +	TRequestStatus* iTxStatus;
   1.227 +
   1.228 +	// DataAvailable client related items
   1.229 +	TInt iRxDAError;
   1.230 +	TRequestStatus* iRxDAStatus;
   1.231 +
   1.232 +	// Signal change notification
   1.233 +	TInt iSignalError;
   1.234 +	TRequestStatus* iSignalStatus;	
   1.235 +	TUint* iClientSignalResultPtr;	//ptr to uint in client address space
   1.236 +	TUint iSignalResult;			//holds result of the signal (in Symbian OS values)
   1.237 +	};
   1.238 +
   1.239 +//class DCommPowerHandler : public DPowerHandler
   1.240 +//	{
   1.241 +//public:
   1.242 +//	DCommPowerHandler(DChannelComm* aChannel);
   1.243 +//	virtual TInt DoPowerUp();
   1.244 +//	virtual void DoPowerDown(TUint32 aPowerDownMask);
   1.245 +//	virtual void DoEmergencyPowerDown();
   1.246 +//public:
   1.247 +//	DChannelComm* iChannel;
   1.248 +//	};
   1.249 +
   1.250 +#include "winscomm.inl"
   1.251 +
   1.252 +#endif