First public contribution.
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 exsync.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,EOwnerProcess);
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 after complete data transfer.
118 It completes synchronously.
121 buffer holding the data to transmit
123 @return KErrNone on success or KErrArgument on invalid length
125 inline TInt RExDriverChannel::TransmitData(const TDesC8& aData)
127 // Read the length of the data using TDesC8::Length(). It gives 8-bit data
128 // items represented by the descriptor
130 TInt len = aData.Length();
134 // Calls DoControl() API of RBusLogicalChannel with the request number
135 // and transmit buffer. This is a implemented as synchronous message and will be
136 // handled in driver/LDD DoControl() function.Here the transmit buffer, aData
137 // is filled by user and sent to the driver for writing to device.
140 return DoControl(ERequestTransmitData,(TAny*)&aData);;
144 Receive the data from the device. User sends an empty buffer and reads the
145 data after the call. It returns after reading the complete data.
146 The request completes synchronously.
149 buffer holding the data received
151 @return KErrNone on success or KErrArgument on invalid length
153 inline TInt RExDriverChannel::ReceiveData(TDes8 &aData)
155 // Read the length of the data using TDesC8::Length(). It gives 8-bit data
156 // items represented by the descriptor
158 TInt len = aData.MaxLength();
162 // Calls DoControl() API of RBusLogicalChannel with the request number
163 // and receive buffer. This is a implemented as synchronous message and will be
164 // handled in driver/LDD DoControl() function.
166 return DoControl(ERequestReceiveData,&aData);