00001 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // Interface to example Logical Device Driver 00015 // 00016 00017 00018 00023 #ifndef __DRIVER1_H__ 00024 #define __DRIVER1_H__ 00025 00026 #include <e32cmn.h> 00027 #include <e32ver.h> 00028 #ifndef __KERNEL_MODE__ 00029 #include <e32std.h> 00030 #endif 00031 00035 class RDriver1 : public RBusLogicalChannel 00036 { 00037 public: 00042 class TCaps 00043 { 00044 public: 00045 TVersion iVersion; 00046 }; 00047 00051 class TConfig 00052 { 00053 public: 00054 TInt iSpeed; 00055 TInt iPddBufferSize; 00056 TInt iMaxSendDataSize; 00057 TInt iMaxReceiveDataSize; 00058 }; 00059 typedef TPckgBuf<TConfig> TConfigBuf; 00060 00061 public: 00062 inline TInt Open(); 00063 inline TInt GetConfig(TConfigBuf& aConfig); 00064 inline TInt SetConfig(const TConfigBuf& aConfig); 00065 inline void SendData(TRequestStatus &aStatus,const TDesC8& aData); 00066 inline void SendDataCancel(); 00067 inline void ReceiveData(TRequestStatus &aStatus,TDes8& aBuffer); 00068 inline void ReceiveDataCancel(); 00069 inline static const TDesC& Name(); 00070 inline static TVersion VersionRequired(); 00071 private: 00075 enum TControl 00076 { 00077 EGetConfig, 00078 ESetConfig 00079 }; 00080 00084 enum TRequest 00085 { 00086 ESendData, 00087 EReceiveData, 00088 ENumRequests, 00089 EAllRequests = (1<<ENumRequests)-1 00090 }; 00091 00092 // Kernel side LDD channel is a friend 00093 friend class DDriver1Channel; 00094 }; 00095 00100 inline const TDesC& RDriver1::Name() 00101 { 00102 _LIT(KDriver1Name,"DRIVER1"); 00103 return KDriver1Name; 00104 } 00105 00110 inline TVersion RDriver1::VersionRequired() 00111 { 00112 const TInt KMajorVersionNumber=1; 00113 const TInt KMinorVersionNumber=0; 00114 const TInt KBuildVersionNumber=KE32BuildVersionNumber; 00115 return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); 00116 } 00117 00118 /* 00119 NOTE: The following methods would normally be exported from a seperate client DLL 00120 but are included in this header file for convenience. 00121 */ 00122 00123 #ifndef __KERNEL_MODE__ 00124 00129 inline TInt RDriver1::Open() 00130 { 00131 return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread); 00132 } 00133 00139 inline TInt RDriver1::GetConfig(TConfigBuf& aConfig) 00140 { 00141 return DoControl(EGetConfig,(TAny*)&aConfig); 00142 } 00143 00151 inline TInt RDriver1::SetConfig(const TConfigBuf& aConfig) 00152 { 00153 return DoControl(ESetConfig,(TAny*)&aConfig); 00154 } 00155 00164 inline void RDriver1::SendData(TRequestStatus &aStatus,const TDesC8& aData) 00165 { 00166 DoRequest(ESendData,aStatus,(TAny*)&aData); 00167 } 00168 00172 inline void RDriver1::SendDataCancel() 00173 { 00174 DoCancel(1<<ESendData); 00175 } 00176 00185 inline void RDriver1::ReceiveData(TRequestStatus &aStatus,TDes8& aBuffer) 00186 { 00187 DoRequest(EReceiveData,aStatus,(TAny*)&aBuffer); 00188 } 00189 00193 inline void RDriver1::ReceiveDataCancel() 00194 { 00195 DoCancel(1<<EReceiveData); 00196 } 00197 00198 #endif // !__KERNEL_MODE__ 00199 00200 #endif // __DRIVER1_H__ 00201
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.