Update contrib.
1 // Copyright (c) 2007-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.
14 // This is an inline file and has the implementation of RExDriverChannel
15 // derived from RBusLogicalChannel class. The member functions will
16 // basically be wrappers of RBusLogicalChannel API.
17 // This file is included in exchnk.h
21 #ifndef __KERNEL_MODE__
23 VersionRequired() inline function to initialize TVersion object with
24 driver Major number, Minor number and Build version number. This function
25 is provided just as a utility function to easily get the version details.
27 @return initialized TVersion object
29 inline TVersion RExDriverChannel::VersionRequired()
31 return (TVersion(EUartMajorVersionNumber,
32 EUartMinorVersionNumber,
33 EUartBuildVersionNumber));
37 Open the driver for the specified unit. Unit information is passed as an
38 argument by the user. User can open the driver for different units as supported
44 @return return value of DoCreate(), i.e KErrNone or standard error code
46 inline TInt RExDriverChannel::Open(TInt aUnit)
48 // Call DoCreate() API of RBusLogicalChannel with driver name,
49 // version, unit number and owner. This will result in creating the
50 // logical channel by invoking Create() and DoCreate() of Logical Channel.
52 return DoCreate(KDriverName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
56 Gets the capabilities of a channel opened on the driver. User can use the
57 retrieved capabilities to configure different channels (if supported by
58 driver) with supported configuration.
61 Descriptor to be filled with channel capabilities
63 @return return value of DoControl(), i.e KErrNone or standard error code
65 inline TInt RExDriverChannel::Caps(TDes8& aCaps)
67 // Call DoControl() API of RBusLogicalChannel with the request number
68 // and the caps buffer(structure) that has to be filled by the driver.
69 // This is a synchronous message and will be handled in driver/LDD
70 // DoControl() function
72 return DoControl(EControlCaps,(TAny*)&aCaps);
76 Configure the device (uart) internal loopback mode. User can configure the
77 device for internal loopback mode using this API. Loopback mode can be enabled
78 or disabled by passing the mode as a parameter to this API.
81 Holds the loopback enable and disable option
82 KLoopbackEnable for enable and KLoopbackDisable for disable
84 @return return value of DoControl(), i.e KErrNone or standard error code
86 inline TInt RExDriverChannel::SetIntLoopback(const TInt aMode)
88 // Call DoControl() API of RBusLogicalChannel with the request number
89 // and the loopback mode. This is a synchronous message
90 // and will be handled in driver/LDD DoControl() function
92 return DoControl(EControlSetIntLoopback,(TAny*)&aMode);
96 Configure the device (uart) for the specified settings. User initializes the
97 configuration buffer, and passes this to the device driver. The config data
98 structure is packaged as a buffer and passes as an argument.
101 buffer descriptor with device configuration information
103 @return return value of DoControl(), i.e KErrNone or standard error code
105 inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
107 // Call DoControl() API of RBusLogicalChannel with the request number
108 // and the config buffer(structure). This is a synchronous message
109 // and will be handled in driver/LDD DoControl() function
111 return DoControl(EControlSetConfig,(TAny*)&aConfig);
115 Transmit the data to the device.It returns immediately after initiating
116 the transmit. The actual request completes asynchronously after the completion
117 of the operation on the device and is notified then.
120 TRequestStatus object to hold the asynchronous request status
122 Size of data to be transmitted
124 @return KErrNone on success or KErrArgument on invalid length or offset.
126 inline TInt RExDriverChannel::TransmitData(TRequestStatus& aStatus, const TInt aSize,TInt aOffset)
129 // Invalid length or offset, return error
130 if (aSize<=0 || aOffset<0)
133 // Call DoRequest() API of RBusLogicalChannel with the request number,
134 // TRequestStatus object to hold asynchronous request status, transmit buffer
135 // and data length. This is a implemented as asynchronous message and will be
136 // handled in driver/LDD DoRequest() function.Here the transmit buffer, aData
137 // is filled by user and sent to the driver for writing to device.
139 DoRequest(ERequestTransmitData,aStatus,(TAny*)aOffset,(TAny*)aSize);
145 Receive the data from the device. User sends an empty buffer and reads the
146 data after the call. It returns immediately after initiating the receive.
147 The actual request completes asynchronously after the completion of the
148 operation on the device and is notified then.
151 TRequestStatus object to hold the asynchronous request status
153 @return KErrNone on success or KErrArgument on invalid length
155 inline TInt RExDriverChannel::ReceiveData(TRequestStatus& aStatus,TInt aSize,TInt aOffset)
158 // Invalid length or offset, return error
159 if (aSize<=0 || aOffset<0)
161 // Call DoRequest() API of RBusLogicalChannel with the request number,
162 // TRequestStatus object to hold asynchronous request status, receive buffer
163 // and data length. This is a implemented as asynchronous message and will be
164 // handled in driver/LDD DoRequest() function. Here, the receive buffer, aData
165 // will be filled and returned with the received data by the driver read from
168 DoRequest(ERequestReceiveData,aStatus,(TAny*)aOffset,(TAny*)aSize);
174 Cancel Transmit request on the device. User can request to cancel any outstanding
175 transmit requests. This request is handled by calling DoCancel() with appropriate
182 inline void RExDriverChannel::CancelTransmit()
184 // Call DoCancel() API of RBusLogicalChannel with the request number. This is
185 // handled in driver/LDD DoCancel() function. It will cancel the operation and
186 // also tidy up the request specific resources.
188 DoCancel(1<<ERequestTransmitData);
192 Cancel Receive request on the device. User can request to cancel any outstanding
193 receive requests. This request is handled by calling DoCancel() with appropriate
200 inline void RExDriverChannel::CancelReceive()
202 // Call DoCancel() API of RBusLogicalChannel with the request number. This is
203 // handled in driver/LDD DoCancel() function. It will cancel the operation and
204 // also tidy up the request specific resources.
206 DoCancel(1<<ERequestReceiveData);
211 Get handle for Transmit chunk request on the device. User can request to get the
212 handle to Tx chunk by passing the appropriate aReqMask value. i.e EGetTxChunkHandle
217 @return KErrNone on success, else standard error code
219 inline TInt RExDriverChannel::GetTxChunkHandle(RChunk& aChunk)
224 // Call DoControl() API of RBusLogicalChannel with the request number
225 // and the chunk reference. This is a synchronous message and will be
226 // handled in driver/LDD DoControl() function
228 r = DoControl(EGetTxChunkHandle, (TAny*)&handle);
230 // Set the handle returned by the driver to the chunk. RChunk::SetHandle()
231 // sets the specified handle value to the chunk.
234 aChunk.SetHandle(handle);
240 Get handle for Receive chunk request on the device. User can request to get the
241 handle to Rx chunk by passing the appropriate aReqMask value. i.e EGetTxChunkHandle
246 @return KErrNone on success, else standard error code
248 inline TInt RExDriverChannel::GetRxChunkHandle(RChunk& aChunk)
253 // Call DoControl() API of RBusLogicalChannel with the request number
254 // and the chunk reference. This is a synchronous message and will be
255 // handled in driver/LDD DoControl() function
257 r = DoControl(EGetRxChunkHandle, (TAny*)&handle);
259 // Set the handle returned by the driver to the chunk. RChunk::SetHandle()
260 // sets the specified handle value to the chunk.
263 aChunk.SetHandle(handle);
268 Pass the handle for Transmit chunk to the device. User can request to pass the
269 handle to Rx chunk by passing the appropriate aReqMask value. i.e EPassTxChunkHandle
274 @return KErrNone on success, else standard error code
276 inline TInt RExDriverChannel::PassTxChunkHandle(RChunk& aChunk)
281 // Get the shared chunk handle.
282 handle = aChunk.Handle();
284 // Call DoControl() API of RBusLogicalChannel with the request number
285 // and the chunk reference. This is a synchronous message and will be
286 // handled in driver/LDD DoControl() function
288 r = DoControl(EPassTxChunkHandle, (TAny*)&handle);
294 Pass the handle for Receive chunk to the device. User can request to pass the
295 handle to Rx chunk by passing the appropriate aReqMask value. i.e EPassRxChunkHandle
300 @return KErrNone on success, else standard error code
302 inline TInt RExDriverChannel::PassRxChunkHandle(RChunk& aChunk)
307 // Get the shared chunk handle.
308 handle = aChunk.Handle();
309 // Call DoControl() API of RBusLogicalChannel with the request number
310 // and the chunk reference. This is a synchronous message and will be
311 // handled in driver/LDD DoControl() function
313 r = DoControl(EPassRxChunkHandle, (TAny*)&handle);