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 expio.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
39 by the user. User can open the driver for different units as supported
42 @return return value of DoCreate(), i.e KErrNone or standard error code
44 inline TInt RExDriverChannel::Open()
46 // Call DoCreate() API of RBusLogicalChannel with driver name,
47 // version, unit number and owner. This will result in creating the
48 // logical channel by invoking Create() and DoCreate() of Logical Channel.
49 // KNullUnit is used if unit numbers are not permitted.
51 return DoCreate(KDriverName,VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
55 Gets the capabilities of a channel opened on the driver. User can use the
56 retrieved capabilities to configure different channels (if supported by
57 driver) with supported configuration.
60 Descriptor to be filled with channel capabilities
62 @return return value of DoControl(), i.e KErrNone or standard error code
64 inline TInt RExDriverChannel::Caps(TDes8& aCaps)
66 // Call DoControl() API of RBusLogicalChannel with the request number
67 // and the caps buffer(structure) that has to be filled by the driver.
68 // This is a synchronous message and will be handled in driver/LDD
69 // DoControl() function
71 return DoControl(EControlCaps,(TAny*)&aCaps);
75 Configure the device (uart) for the specified settings. User initializes the
76 configuration buffer, and passes this to the device driver. The config data
77 structure is packaged as a buffer and passes as an argument.
80 buffer descriptor with device configuration information
82 @return return value of DoControl(), i.e KErrNone or standard error code
84 inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
86 // Call DoControl() API of RBusLogicalChannel with the request number
87 // and the config buffer(structure). This is a synchronous message
88 // and will be handled in driver/LDD DoControl() function
90 return DoControl(EControlSetConfig,(TAny*)&aConfig);
94 Transmit the data to the device. User initializes the buffer and sends the
95 the buffer descriptor as an argument. It returns only after the completion
96 of operation on the device.
99 buffer holding the data to transmit
101 @return return value of DoControl(), i.e KErrNone or standard error code
103 inline TInt RExDriverChannel::TransmitData(const TDesC8& aData)
105 // Call DoControl() API of RBusLogicalChannel with the request number
106 // and the transmit buffer. This is a implemented as a synchronous
107 // message and will be handled in driver/LDD DoControl() function.
108 // Here the transmit buffer, aData is filled by user and sent to the
109 // driver for writing to device.
111 return DoControl(EControlTransmitData,(TAny*)&aData);
115 Receive the data from the device. User sends an empty buffer and reads the
116 data after the call. This function returns only after the completion of the
117 read operation on the device.
120 buffer holding the data received
122 @return return value of DoControl(), i.e KErrNone or standard error code
123 KErrArgument in case of zero length buffer
125 inline TInt RExDriverChannel::ReceiveData(TDes8& aData)
127 TInt length=aData.MaxLength();
131 // Call DoControl() API of RBusLogicalChannel with the request number
132 // and the transmit buffer. This is a implemented as a synchronous
133 // message and will be handled in driver/LDD DoControl() function
134 // Here, the receive buffer, aData will be filled and returned with
135 // the received data by the driver read from the device.
137 return DoControl(EControlReceiveData,&aData,&length);