sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// This is an inline file and has the implementation of RExDriverChannel
|
sl@0
|
15 |
// derived from RBusLogicalChannel class. The member functions will
|
sl@0
|
16 |
// basically be wrappers of RBusLogicalChannel API.
|
sl@0
|
17 |
// This file is included in expio.h
|
sl@0
|
18 |
//
|
sl@0
|
19 |
//
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
|
sl@0
|
23 |
VersionRequired() inline function to initialize TVersion object with
|
sl@0
|
24 |
driver Major number, Minor number and Build version number. This function
|
sl@0
|
25 |
is provided just as a utility function to easily get the version details.
|
sl@0
|
26 |
|
sl@0
|
27 |
@return initialized TVersion object
|
sl@0
|
28 |
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
inline TVersion RExDriverChannel::VersionRequired()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
return (TVersion(EUartMajorVersionNumber,
|
sl@0
|
33 |
EUartMinorVersionNumber,
|
sl@0
|
34 |
EUartBuildVersionNumber));
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
/**
|
sl@0
|
38 |
Open the driver for the specified unit. Unit information is passed
|
sl@0
|
39 |
by the user. User can open the driver for different units as supported
|
sl@0
|
40 |
by the driver.
|
sl@0
|
41 |
|
sl@0
|
42 |
@return return value of DoCreate(), i.e KErrNone or standard error code
|
sl@0
|
43 |
*/
|
sl@0
|
44 |
inline TInt RExDriverChannel::Open()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
// Call DoCreate() API of RBusLogicalChannel with driver name,
|
sl@0
|
47 |
// version, unit number and owner. This will result in creating the
|
sl@0
|
48 |
// logical channel by invoking Create() and DoCreate() of Logical Channel.
|
sl@0
|
49 |
// KNullUnit is used if unit numbers are not permitted.
|
sl@0
|
50 |
//
|
sl@0
|
51 |
return DoCreate(KDriverName,VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
/**
|
sl@0
|
55 |
Gets the capabilities of a channel opened on the driver. User can use the
|
sl@0
|
56 |
retrieved capabilities to configure different channels (if supported by
|
sl@0
|
57 |
driver) with supported configuration.
|
sl@0
|
58 |
|
sl@0
|
59 |
@param aCaps
|
sl@0
|
60 |
Descriptor to be filled with channel capabilities
|
sl@0
|
61 |
|
sl@0
|
62 |
@return return value of DoControl(), i.e KErrNone or standard error code
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
inline TInt RExDriverChannel::Caps(TDes8& aCaps)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
// Call DoControl() API of RBusLogicalChannel with the request number
|
sl@0
|
67 |
// and the caps buffer(structure) that has to be filled by the driver.
|
sl@0
|
68 |
// This is a synchronous message and will be handled in driver/LDD
|
sl@0
|
69 |
// DoControl() function
|
sl@0
|
70 |
//
|
sl@0
|
71 |
return DoControl(EControlCaps,(TAny*)&aCaps);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
Configure the device (uart) for the specified settings. User initializes the
|
sl@0
|
76 |
configuration buffer, and passes this to the device driver. The config data
|
sl@0
|
77 |
structure is packaged as a buffer and passes as an argument.
|
sl@0
|
78 |
|
sl@0
|
79 |
@param aConfig
|
sl@0
|
80 |
buffer descriptor with device configuration information
|
sl@0
|
81 |
|
sl@0
|
82 |
@return return value of DoControl(), i.e KErrNone or standard error code
|
sl@0
|
83 |
*/
|
sl@0
|
84 |
inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
// Call DoControl() API of RBusLogicalChannel with the request number
|
sl@0
|
87 |
// and the config buffer(structure). This is a synchronous message
|
sl@0
|
88 |
// and will be handled in driver/LDD DoControl() function
|
sl@0
|
89 |
//
|
sl@0
|
90 |
return DoControl(EControlSetConfig,(TAny*)&aConfig);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
Transmit the data to the device. User initializes the buffer and sends the
|
sl@0
|
95 |
the buffer descriptor as an argument. It returns only after the completion
|
sl@0
|
96 |
of operation on the device.
|
sl@0
|
97 |
|
sl@0
|
98 |
@param aData
|
sl@0
|
99 |
buffer holding the data to transmit
|
sl@0
|
100 |
|
sl@0
|
101 |
@return return value of DoControl(), i.e KErrNone or standard error code
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
inline TInt RExDriverChannel::TransmitData(const TDesC8& aData)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
// Call DoControl() API of RBusLogicalChannel with the request number
|
sl@0
|
106 |
// and the transmit buffer. This is a implemented as a synchronous
|
sl@0
|
107 |
// message and will be handled in driver/LDD DoControl() function.
|
sl@0
|
108 |
// Here the transmit buffer, aData is filled by user and sent to the
|
sl@0
|
109 |
// driver for writing to device.
|
sl@0
|
110 |
//
|
sl@0
|
111 |
return DoControl(EControlTransmitData,(TAny*)&aData);
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
/**
|
sl@0
|
115 |
Receive the data from the device. User sends an empty buffer and reads the
|
sl@0
|
116 |
data after the call. This function returns only after the completion of the
|
sl@0
|
117 |
read operation on the device.
|
sl@0
|
118 |
|
sl@0
|
119 |
@param aData
|
sl@0
|
120 |
buffer holding the data received
|
sl@0
|
121 |
|
sl@0
|
122 |
@return return value of DoControl(), i.e KErrNone or standard error code
|
sl@0
|
123 |
KErrArgument in case of zero length buffer
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
inline TInt RExDriverChannel::ReceiveData(TDes8& aData)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TInt length=aData.MaxLength();
|
sl@0
|
128 |
if (!length)
|
sl@0
|
129 |
return KErrArgument;
|
sl@0
|
130 |
|
sl@0
|
131 |
// Call DoControl() API of RBusLogicalChannel with the request number
|
sl@0
|
132 |
// and the transmit buffer. This is a implemented as a synchronous
|
sl@0
|
133 |
// message and will be handled in driver/LDD DoControl() function
|
sl@0
|
134 |
// Here, the receive buffer, aData will be filled and returned with
|
sl@0
|
135 |
// the received data by the driver read from the device.
|
sl@0
|
136 |
//
|
sl@0
|
137 |
return DoControl(EControlReceiveData,&aData,&length);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
//
|
sl@0
|
141 |
// End of expio.inl
|