os/kernelhwsrv/kerneltest/e32test/examples/exdriver/exdriver_sync/inc/exsync.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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 exsync.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,EOwnerProcess);
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 after complete data transfer.
sl@0
   118
 It completes synchronously.
sl@0
   119
sl@0
   120
 @param		aData
sl@0
   121
 			buffer holding the data to transmit
sl@0
   122
sl@0
   123
 @return	KErrNone on success or KErrArgument on invalid length
sl@0
   124
 */
sl@0
   125
inline TInt RExDriverChannel::TransmitData(const TDesC8& aData)
sl@0
   126
	{
sl@0
   127
	// Read the length of the data using TDesC8::Length(). It gives 8-bit data
sl@0
   128
	// items represented by the descriptor
sl@0
   129
	//
sl@0
   130
	TInt len = aData.Length();
sl@0
   131
	if (!len)
sl@0
   132
		return KErrArgument;
sl@0
   133
sl@0
   134
	// Calls DoControl() API of RBusLogicalChannel with the request number
sl@0
   135
	// and transmit buffer. This is a implemented as synchronous message and will be
sl@0
   136
	// handled in driver/LDD DoControl() function.Here the transmit buffer, aData
sl@0
   137
	// is filled by user and sent to the driver for writing to device.
sl@0
   138
	//
sl@0
   139
	
sl@0
   140
	return DoControl(ERequestTransmitData,(TAny*)&aData);;
sl@0
   141
	}
sl@0
   142
sl@0
   143
/**
sl@0
   144
 Receive the data from the device. User sends an empty buffer and reads the
sl@0
   145
 data after the call. It returns after reading the complete data.
sl@0
   146
 The request completes synchronously.
sl@0
   147
sl@0
   148
 @param		aData
sl@0
   149
 			buffer holding the data received
sl@0
   150
sl@0
   151
 @return	KErrNone on success or KErrArgument on invalid length
sl@0
   152
 */
sl@0
   153
inline TInt RExDriverChannel::ReceiveData(TDes8 &aData)
sl@0
   154
	{
sl@0
   155
	// Read the length of the data using TDesC8::Length(). It gives 8-bit data
sl@0
   156
	// items represented by the descriptor
sl@0
   157
	//
sl@0
   158
	TInt len = aData.MaxLength();
sl@0
   159
	if (!len)
sl@0
   160
		return KErrArgument;
sl@0
   161
sl@0
   162
	// Calls DoControl() API of RBusLogicalChannel with the request number
sl@0
   163
	// and receive buffer. This is a implemented as synchronous message and will be
sl@0
   164
	// handled in driver/LDD DoControl() function.	
sl@0
   165
sl@0
   166
	return DoControl(ERequestReceiveData,&aData);
sl@0
   167
	}
sl@0
   168
sl@0
   169
// End of exsync.inl