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 exint.h
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
30 inline TVersion RExDriverChannel::VersionRequired()
32 return (TVersion(EUartMajorVersionNumber,
33 EUartMinorVersionNumber,
34 EUartBuildVersionNumber));
38 Open the driver for the specified unit. Unit information is passed as an
39 argument by the user. User can open the driver for different units as supported
45 @return return value of DoCreate(), i.e KErrNone or standard error code
47 inline TInt RExDriverChannel::Open(TInt aUnit)
49 // Call DoCreate() API of RBusLogicalChannel with driver name,
50 // version, unit number and owner. This will result in creating the
51 // logical channel by invoking Create() and DoCreate() of Logical Channel.
53 return DoCreate(KDriverName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
57 Gets the capabilities of a channel opened on the driver. User can use the
58 retrieved capabilities to configure different channels (if supported by
59 driver) with supported configuration.
62 Descriptor to be filled with channel capabilities
64 @return return value of DoControl(), i.e KErrNone or standard error code
66 inline TInt RExDriverChannel::Caps(TDes8& aCaps)
68 // Call DoControl() API of RBusLogicalChannel with the request number
69 // and the caps buffer(structure) that has to be filled by the driver.
70 // This is a synchronous message and will be handled in driver/LDD
71 // DoControl() function
73 return DoControl(EControlCaps,(TAny*)&aCaps);
77 Configure the device (uart) internal loopback mode. User can configure the
78 device for internal loopback mode using this API. Loopback mode can be enabled
79 or disabled by passing the mode as a parameter to this API.
82 Holds the loopback enable and disable option
83 KLoopbackEnable for enable and KLoopbackDisable for disable
85 @return return value of DoControl(), i.e KErrNone or standard error code
87 inline TInt RExDriverChannel::SetIntLoopback(const TInt aMode)
89 // Call DoControl() API of RBusLogicalChannel with the request number
90 // and the loopback mode. This is a synchronous message
91 // and will be handled in driver/LDD DoControl() function
93 return DoControl(EControlSetIntLoopback,(TAny*)&aMode);
97 Configure the device (uart) for the specified settings. User initializes the
98 configuration buffer, and passes this to the device driver. The config data
99 structure is packaged as a buffer and passes as an argument.
102 buffer descriptor with device configuration information
104 @return return value of DoControl(), i.e KErrNone or standard error code
106 inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
108 // Call DoControl() API of RBusLogicalChannel with the request number
109 // and the config buffer(structure). This is a synchronous message
110 // and will be handled in driver/LDD DoControl() function
112 return DoControl(EControlSetConfig,(TAny*)&aConfig);
116 Transmit the data to the device. User initializes the buffer and sends the
117 the buffer descriptor as an argument. It returns immediately after initiating
118 the transmit. The actual request completes asynchronously after the completion
119 of the operation on the device and is notified then.
122 TRequestStatus object to hold the asynchronous request status
124 buffer holding the data to transmit
126 @return KErrNone on success or KErrArgument on invalid length
128 inline TInt RExDriverChannel::TransmitData(TRequestStatus& aStatus, const TDesC8& aData)
130 // Read the length of the data using TDesC8::Length(). It gives 8-bit data
131 // items represented by the descriptor
133 TInt len = aData.Length();
137 // Call DoRequest() API of RBusLogicalChannel with the request number,
138 // TRequestStatus object to hold asynchronous request status, transmit buffer
139 // and data length. This is a implemented as asynchronous message and will be
140 // handled in driver/LDD DoRequest() function.Here the transmit buffer, aData
141 // is filled by user and sent to the driver for writing to device.
143 DoRequest(ERequestTransmitData,aStatus,(TAny*)&aData);
149 Receive the data from the device. User sends an empty buffer and reads the
150 data after the call. It returns immediately after initiating the receive.
151 The actual request completes asynchronously after the completion of the
152 operation on the device and is notified then.
155 buffer holding the data received
157 @return KErrNone on success or KErrArgument on invalid length
159 inline TInt RExDriverChannel::ReceiveData(TRequestStatus& aStatus, TDes8 &aData)
161 // Read the length of the data using TDesC8::Length(). It gives 8-bit data
162 // items represented by the descriptor
164 TInt len = aData.MaxLength();
168 // Call DoRequest() API of RBusLogicalChannel with the request number,
169 // TRequestStatus object to hold asynchronous request status, receive buffer
170 // and data length. This is a implemented as asynchronous message and will be
171 // handled in driver/LDD DoRequest() function. Here, the receive buffer, aData
172 // will be filled and returned with the received data by the driver read from
175 DoRequest(ERequestReceiveData,aStatus,&aData);
181 Cancel Transmit request on the device. User can request to cancel any outstanding
182 transmit requests. This request is handled by calling DoCancel() with appropriate
189 inline void RExDriverChannel::CancelTransmit()
191 // Call DoCancel() API of RBusLogicalChannel with the request number. This is
192 // handled in driver/LDD DoCancel() function. It will cancel the operation and
193 // also tidy up the request specific resources.
195 DoCancel(1<<ERequestTransmitData);
200 Cancel Receive request on the device. User can request to cancel any outstanding
201 receive requests. This request is handled by calling DoCancel() with appropriate
208 inline void RExDriverChannel::CancelReceive()
210 // Call DoCancel() API of RBusLogicalChannel with the request number. This is
211 // handled in driver/LDD DoCancel() function. It will cancel the operation and
212 // also tidy up the request specific resources.
214 DoCancel(1<<ERequestReceiveData);