Update contrib.
1 // Copyright (c) 2003-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 @file Interface to example Logical Device Driver
27 #ifndef __KERNEL_MODE__
32 User interface for 'Driver1'
34 class RDriver1 : public RBusLogicalChannel
38 Structure for holding driver capabilities information
39 (Just a version number in this example.)
48 Structure for holding driver configuration data
53 TInt iSpeed; /**< Data transfer speed in microseconds/byte */
54 TInt iPddBufferSize; /**< Size of the PDD's data buffer (not modifiable) */
55 TInt iMaxSendDataSize; /**< Maximum size of data which can be sent in one go (not modifiable) */
56 TInt iMaxReceiveDataSize; /**< Maximum size of data which can be received in one go (not modifiable) */
58 typedef TPckgBuf<TConfig> TConfigBuf;
62 TInt GetConfig(TConfigBuf& aConfig);
63 TInt SetConfig(const TConfigBuf& aConfig);
64 void SendData(TRequestStatus &aStatus,const TDesC8& aData);
65 void SendDataCancel();
66 void ReceiveData(TRequestStatus &aStatus,TDes8& aBuffer);
67 void ReceiveDataCancel();
68 inline static const TDesC& Name();
69 inline static TVersion VersionRequired();
72 Enumeration of Control messages.
81 Enumeration of Request messages.
88 EAllRequests = (1<<ENumRequests)-1
91 // Kernel side LDD channel is a friend
92 friend class DDriver1Channel;
98 @return The name of the driver
102 inline const TDesC& RDriver1::Name()
104 _LIT(KDriver1Name,"DRIVER1");
111 @return The version number of the driver
115 inline TVersion RDriver1::VersionRequired()
117 const TInt KMajorVersionNumber=1;
118 const TInt KMinorVersionNumber=0;
119 const TInt KBuildVersionNumber=KE32BuildVersionNumber;
120 return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
124 NOTE: The following methods would normally be exported from a seperate client DLL
125 but are included inline in this header file for convenience.
128 #ifndef __KERNEL_MODE__
131 Open a logical channel to the driver
133 @return One of the system wide error codes.
135 TInt RDriver1::Open()
137 return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
141 Get the current configuration settings.
143 @param aConfig A structure which will be filled with the configuration settings.
147 TInt RDriver1::GetConfig(TConfigBuf& aConfig)
149 return DoControl(EGetConfig,(TAny*)&aConfig);
153 Set the current configuration settings.
155 @param aConfig The new configuration settings to be used.
157 @return KErrInUse if there are outstanding data transfer requests.
158 KErrArgument if any configuration values are invalid.
161 TInt RDriver1::SetConfig(const TConfigBuf& aConfig)
163 return DoControl(ESetConfig,(TAny*)&aConfig);
167 Send data to the device.
168 Only one send request may be pending at any time.
170 @param aStatus The request to be signaled when the data has been sent.
171 The result value will be set to KErrNone on success;
172 or set to one of the system wide error codes when an error occurs.
173 @param aData A descriptor containing the data to send.
175 void RDriver1::SendData(TRequestStatus &aStatus,const TDesC8& aData)
177 DoRequest(ESendData,aStatus,(TAny*)&aData);
181 Cancel a previous SendData request.
183 void RDriver1::SendDataCancel()
185 DoCancel(1<<ESendData);
189 Receive data from the device.
190 Only one receive request may be pending at any time.
192 @param aStatus The request to be signaled when the data has been received.
193 The result value will be set to KErrNone on success;
194 or set to one of the system wide error codes when an error occurs.
195 @param aData A descriptor to which the received data will be written.
197 void RDriver1::ReceiveData(TRequestStatus &aStatus,TDes8& aBuffer)
199 DoRequest(EReceiveData,aStatus,(TAny*)&aBuffer);
203 Cancel a previous ReceiveData request.
205 void RDriver1::ReceiveDataCancel()
207 DoCancel(1<<EReceiveData);
210 #endif // !__KERNEL_MODE__