|
1 // Copyright (c) 1995-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 "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 // |
|
15 |
|
16 |
|
17 #if !defined(D_COMM_H) |
|
18 #define D_COMM_H |
|
19 |
|
20 #include "DParams.h" |
|
21 |
|
22 // |
|
23 const TInt KCommsMajorVersionNumber=1; |
|
24 const TInt KCommsMinorVersionNumber=0; |
|
25 const TInt KCommsBuildVersionNumber=KE32BuildVersionNumber; |
|
26 // |
|
27 const TInt KDefaultRxBufferSize=0x400; |
|
28 const TInt KTxBufferSize=0x400; |
|
29 const TInt KMaxHighWaterMark=0x080; |
|
30 // |
|
31 const TUint KReceiveIsrParityError=0x10000000; |
|
32 const TUint KReceiveIsrFrameError=0x20000000; |
|
33 const TUint KReceiveIsrOverrunError=0x40000000; |
|
34 const TUint KReceiveIsrMaskError=0x70000000; |
|
35 // |
|
36 const TInt KTransmitIrqEmpty=KErrGeneral; |
|
37 // |
|
38 const TUint KReceiveIsrTermChar=0x80000000; |
|
39 const TUint KReceiveIsrMaskComplete=0xf0000000; |
|
40 const TUint KReceiveIsrShift=24; |
|
41 const TUint KReceiveIsrShiftedMask=0x0f; |
|
42 // |
|
43 // |
|
44 enum TStopMode {EStopNormal,EStopPwrDown,EStopEmergency}; |
|
45 // |
|
46 // |
|
47 |
|
48 #ifdef __MARM__ |
|
49 const TInt KDummyTimerGranularity = 31000; |
|
50 #else |
|
51 const TInt KDummyTimerGranularity = 80000; |
|
52 #endif |
|
53 |
|
54 const TInt KDummyTimeOut=200000; // 0.2 seconds |
|
55 |
|
56 |
|
57 class DChannelComm; |
|
58 class DComm : public CBase |
|
59 { |
|
60 public: |
|
61 virtual TInt Start() =0; |
|
62 virtual void Stop(TStopMode aMode) =0; |
|
63 virtual void Break(TBool aState) =0; |
|
64 virtual void EnableTransmit() =0; |
|
65 virtual TUint Signals() const =0; |
|
66 virtual void SetSignals(TUint aSetMask,TUint aClearMask) =0; |
|
67 virtual TInt Validate(const TCommConfigV01 &aConfig) const =0; |
|
68 virtual void Configure(TCommConfigV01 &aConfig) =0; |
|
69 virtual void Caps(TDes8 &aCaps) const =0; |
|
70 virtual void CheckConfig(TCommConfigV01& aConfig)=0; |
|
71 virtual void EnableInterrupts() =0; |
|
72 virtual void DisableInterrupts() =0; |
|
73 virtual TInt CompleteSlowOpen(DThread *aThread,TRequestStatus *aReqStat) =0; |
|
74 inline DChannelComm &Comm() {return(*iComm);} |
|
75 inline void SetComm(DChannelComm *aComm) {iComm=aComm;} |
|
76 private: |
|
77 DChannelComm *iComm; |
|
78 #ifdef _DEBUG_DEVCOMM |
|
79 public: |
|
80 TInt iRxIntCount; |
|
81 TInt iTxIntCount; |
|
82 TInt iRxErrCount; |
|
83 TInt iTxErrCount; |
|
84 #endif |
|
85 }; |
|
86 |
|
87 // |
|
88 class DDeviceComm : public DLogicalDevice |
|
89 { |
|
90 public: |
|
91 DDeviceComm(); |
|
92 virtual TInt Install(); |
|
93 virtual void GetCaps(TDes8 &aDes) const; |
|
94 virtual DLogicalChannel *CreateL(); |
|
95 }; |
|
96 // |
|
97 |
|
98 class DChannelComm : public DLogicalChannel |
|
99 { |
|
100 public: |
|
101 DChannelComm(DLogicalDevice *aDevice); |
|
102 ~DChannelComm(); |
|
103 void CompleteReq(TInt aReqNo); |
|
104 void SetSignals(); |
|
105 void ChangeConfig(); |
|
106 protected: |
|
107 virtual void DoCreateL(TInt aUnit,CBase *aDriver,const TDesC *anInfo,const TVersion &aVer); |
|
108 virtual void DoCancel(TInt aReqNo); |
|
109 virtual void DoRequest(TInt aReqNo,TAny *a1,TAny *a2); |
|
110 virtual TInt DoControl(TInt aFunction,TAny *a1,TAny *a2); |
|
111 private: |
|
112 static void SignalChangeCompleted(TAny*,TInt); |
|
113 static void ConfigChangeCompleted(TAny*,TInt); |
|
114 static void RxDataAvailableCompleted(TAny*,TInt); |
|
115 static void FlowControlChangeCompleted(TAny*,TInt); |
|
116 static void WriteCompleted(TAny*,TInt); |
|
117 public: |
|
118 TCommNotificationV01 iConfig; |
|
119 private: |
|
120 DComm *iDriver; |
|
121 |
|
122 TTickLink iQueuedRxDataAvailable; |
|
123 TTickLink iQueuedSignalNotify; |
|
124 TTickLink iQueuedConfigChange; |
|
125 TTickLink iQueuedFlowControl; |
|
126 TTickLink iQueuedWrite; |
|
127 |
|
128 TUint* iSignals; |
|
129 TUint iSignalMask; |
|
130 TFlowControl iFlowControl; |
|
131 TCommNotificationPckg* iConfigPointer; |
|
132 |
|
133 TBool iRxDataAvailablePending; |
|
134 TBool iSignalNotifyPending; |
|
135 TBool iConfigChangePending; |
|
136 TBool iFlowControlChangePending; |
|
137 TBool iWritePending; |
|
138 |
|
139 TInt iSignalCount; |
|
140 |
|
141 #ifdef _DEBUG_DEVCOMM |
|
142 TInt iDoDrainSeq; |
|
143 TInt iTxChars, iRxChars; |
|
144 TInt iTxXon, iTxXoff, iRxXon, iRxXoff; |
|
145 #endif |
|
146 }; |
|
147 |
|
148 #endif |
|
149 |