os/kernelhwsrv/kerneltest/e32test/examples/exdriver/exdriver_int/inc/exint.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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 exint.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 as an 
sl@0
    39
 argument 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
 @param	aUnit
sl@0
    43
 		device unit number
sl@0
    44
 		
sl@0
    45
 @return	return value of DoCreate(), i.e KErrNone or standard error code
sl@0
    46
 */ 
sl@0
    47
inline TInt RExDriverChannel::Open(TInt aUnit)
sl@0
    48
	{
sl@0
    49
	// Call DoCreate() API of RBusLogicalChannel with driver name, 
sl@0
    50
	// version, unit number and owner. This will result in creating the 
sl@0
    51
	// logical channel by invoking Create() and DoCreate() of Logical Channel. 	
sl@0
    52
	//
sl@0
    53
	return DoCreate(KDriverName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
sl@0
    54
	}
sl@0
    55
sl@0
    56
/**
sl@0
    57
 Gets the capabilities of a channel opened on the driver. User can use the
sl@0
    58
 retrieved capabilities to configure different channels (if supported by 
sl@0
    59
 driver) with supported configuration.
sl@0
    60
 
sl@0
    61
 @param	aCaps
sl@0
    62
 		Descriptor to be filled with channel capabilities
sl@0
    63
 
sl@0
    64
 @return	return value of DoControl(), i.e KErrNone or standard error code
sl@0
    65
 */
sl@0
    66
inline TInt RExDriverChannel::Caps(TDes8& aCaps)
sl@0
    67
	{	
sl@0
    68
	// Call DoControl() API of RBusLogicalChannel with the request number 
sl@0
    69
	// and the caps buffer(structure) that has to be filled by the driver. 
sl@0
    70
	// This is a synchronous message and will be handled in driver/LDD 
sl@0
    71
	// DoControl() function
sl@0
    72
	//
sl@0
    73
	return DoControl(EControlCaps,(TAny*)&aCaps);
sl@0
    74
	}
sl@0
    75
		
sl@0
    76
/**
sl@0
    77
 Configure the device (uart) internal loopback mode. User can configure the
sl@0
    78
 device for internal loopback mode using this API. Loopback mode can be enabled 
sl@0
    79
 or disabled by passing the mode as a parameter to this API.
sl@0
    80
sl@0
    81
 @param		aMode
sl@0
    82
			Holds the loopback enable and disable option
sl@0
    83
			KLoopbackEnable for enable and KLoopbackDisable for disable
sl@0
    84
 
sl@0
    85
 @return	return value of DoControl(), i.e KErrNone or standard error code
sl@0
    86
 */
sl@0
    87
inline TInt RExDriverChannel::SetIntLoopback(const TInt aMode)
sl@0
    88
	{	
sl@0
    89
	// Call DoControl() API of RBusLogicalChannel with the request number 
sl@0
    90
	// and the loopback mode. This is a synchronous message
sl@0
    91
	// and will be handled in driver/LDD DoControl() function
sl@0
    92
	//
sl@0
    93
	return DoControl(EControlSetIntLoopback,(TAny*)&aMode);
sl@0
    94
	}
sl@0
    95
	
sl@0
    96
/**
sl@0
    97
 Configure the device (uart) for the specified settings. User initializes the 
sl@0
    98
 configuration buffer, and passes this to the device driver. The config data 
sl@0
    99
 structure is packaged as a buffer and passes as an argument.
sl@0
   100
 
sl@0
   101
 @param	aConfig
sl@0
   102
 		buffer descriptor with device configuration information
sl@0
   103
 
sl@0
   104
 @return	return value of DoControl(), i.e KErrNone or standard error code
sl@0
   105
 */
sl@0
   106
inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
sl@0
   107
	{	
sl@0
   108
	// Call DoControl() API of RBusLogicalChannel with the request number 
sl@0
   109
	// and the config buffer(structure). This is a synchronous message
sl@0
   110
	// and will be handled in driver/LDD DoControl() function
sl@0
   111
	//
sl@0
   112
	return DoControl(EControlSetConfig,(TAny*)&aConfig);
sl@0
   113
	}
sl@0
   114
	
sl@0
   115
/**
sl@0
   116
 Transmit the data to the device. User initializes the buffer and sends the 
sl@0
   117
 the buffer descriptor as an argument. It returns immediately after initiating
sl@0
   118
 the transmit. The actual request completes asynchronously after the completion 
sl@0
   119
 of the operation on the device and is notified then.
sl@0
   120
 
sl@0
   121
 @param		aStatus
sl@0
   122
 			TRequestStatus object to hold the asynchronous request status
sl@0
   123
 @param		aData
sl@0
   124
 			buffer holding the data to transmit
sl@0
   125
 
sl@0
   126
 @return	KErrNone on success or KErrArgument on invalid length
sl@0
   127
 */
sl@0
   128
inline TInt RExDriverChannel::TransmitData(TRequestStatus& aStatus, const TDesC8& aData)
sl@0
   129
	{
sl@0
   130
	// Read the length of the data using TDesC8::Length(). It gives 8-bit data 
sl@0
   131
	// items represented by the descriptor
sl@0
   132
	//
sl@0
   133
	TInt len = aData.Length();
sl@0
   134
	if (!len)
sl@0
   135
		return KErrArgument;	
sl@0
   136
sl@0
   137
	// Call DoRequest() API of RBusLogicalChannel with the request number,
sl@0
   138
	// TRequestStatus object to hold asynchronous request status, transmit buffer
sl@0
   139
	// and data length. This is a implemented as asynchronous message and will be
sl@0
   140
	// handled in driver/LDD DoRequest() function.Here the transmit buffer, aData
sl@0
   141
	// is filled by user and sent to the driver for writing to device.
sl@0
   142
	//
sl@0
   143
	DoRequest(ERequestTransmitData,aStatus,(TAny*)&aData);
sl@0
   144
	
sl@0
   145
	return KErrNone;
sl@0
   146
	}
sl@0
   147
	
sl@0
   148
/** 
sl@0
   149
 Receive the data from the device. User sends an empty buffer and reads the
sl@0
   150
 data after the call. It returns immediately after initiating the receive. 
sl@0
   151
 The actual request completes asynchronously after the completion of the 
sl@0
   152
 operation on the device and is notified then.
sl@0
   153
 
sl@0
   154
 @param		aData
sl@0
   155
 			buffer holding the data received
sl@0
   156
 
sl@0
   157
 @return	KErrNone on success or KErrArgument on invalid length
sl@0
   158
 */
sl@0
   159
inline TInt RExDriverChannel::ReceiveData(TRequestStatus& aStatus, TDes8 &aData)
sl@0
   160
	{	
sl@0
   161
	// Read the length of the data using TDesC8::Length(). It gives 8-bit data 
sl@0
   162
	// items represented by the descriptor
sl@0
   163
	//
sl@0
   164
	TInt len = aData.MaxLength();
sl@0
   165
	if (!len)
sl@0
   166
		return KErrArgument;	
sl@0
   167
	
sl@0
   168
	// Call DoRequest() API of RBusLogicalChannel with the request number,
sl@0
   169
	// TRequestStatus object to hold asynchronous request status, receive buffer
sl@0
   170
	// and data length. This is a implemented as asynchronous message and will be
sl@0
   171
	// handled in driver/LDD DoRequest() function. Here, the receive buffer, aData
sl@0
   172
	// will be filled and returned with the received data by the driver read from 
sl@0
   173
	// the device.
sl@0
   174
	//
sl@0
   175
	DoRequest(ERequestReceiveData,aStatus,&aData);
sl@0
   176
	
sl@0
   177
	return KErrNone;
sl@0
   178
	}
sl@0
   179
sl@0
   180
/** 
sl@0
   181
 Cancel Transmit request on the device. User can request to cancel any outstanding 
sl@0
   182
 transmit requests. This request is handled by calling DoCancel() with appropriate
sl@0
   183
 request mask
sl@0
   184
  
sl@0
   185
 @param		none
sl@0
   186
 
sl@0
   187
 @return	void
sl@0
   188
 */
sl@0
   189
inline void RExDriverChannel::CancelTransmit()
sl@0
   190
	{
sl@0
   191
	// Call DoCancel() API of RBusLogicalChannel with the request number. This is 
sl@0
   192
	// handled in driver/LDD DoCancel() function. It will cancel the operation and 
sl@0
   193
	// also tidy up the request specific resources.
sl@0
   194
	//
sl@0
   195
	DoCancel(1<<ERequestTransmitData);
sl@0
   196
	}
sl@0
   197
sl@0
   198
sl@0
   199
/** 
sl@0
   200
 Cancel Receive request on the device. User can request to cancel any outstanding 
sl@0
   201
 receive requests. This request is handled by calling DoCancel() with appropriate 
sl@0
   202
 request mask. 
sl@0
   203
  
sl@0
   204
 @param		none
sl@0
   205
 
sl@0
   206
 @return	void
sl@0
   207
 */
sl@0
   208
inline void RExDriverChannel::CancelReceive()
sl@0
   209
	{
sl@0
   210
	// Call DoCancel() API of RBusLogicalChannel with the request number. This is 
sl@0
   211
	// handled in driver/LDD DoCancel() function. It will cancel the operation and 
sl@0
   212
	// also tidy up the request specific resources.
sl@0
   213
	//
sl@0
   214
	DoCancel(1<<ERequestReceiveData);
sl@0
   215
	}
sl@0
   216
sl@0
   217
//
sl@0
   218
// End of exint.inl