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.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    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
    18 // 
    19 //
    20 
    21 /**
    22  
    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.
    26  
    27  @return	initialized TVersion object
    28  
    29 */
    30 inline TVersion RExDriverChannel::VersionRequired()
    31 	{
    32 	return (TVersion(EUartMajorVersionNumber,
    33 					EUartMinorVersionNumber,
    34 					EUartBuildVersionNumber));
    35 	}
    36 
    37 /**
    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
    40  by the driver.
    41 
    42  @param	aUnit
    43  		device unit number
    44 
    45  @return	return value of DoCreate(), i.e KErrNone or standard error code
    46  */
    47 inline TInt RExDriverChannel::Open(TInt aUnit)
    48 	{
    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.
    52 	//
    53 	return DoCreate(KDriverName,VersionRequired(),aUnit,NULL,NULL,EOwnerProcess);
    54 	}
    55 
    56 /**
    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.
    60 
    61  @param	aCaps
    62  		Descriptor to be filled with channel capabilities
    63 
    64  @return	return value of DoControl(), i.e KErrNone or standard error code
    65  */
    66 inline TInt RExDriverChannel::Caps(TDes8& aCaps)
    67 	{
    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
    72 	//
    73 	return DoControl(EControlCaps,(TAny*)&aCaps);
    74 	}
    75 
    76 /**
    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.
    80 
    81  @param		aMode
    82 			Holds the loopback enable and disable option
    83 			KLoopbackEnable for enable and KLoopbackDisable for disable
    84 
    85  @return	return value of DoControl(), i.e KErrNone or standard error code
    86  */
    87 inline TInt RExDriverChannel::SetIntLoopback(const TInt aMode)
    88 	{
    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
    92 	//
    93 	return DoControl(EControlSetIntLoopback,(TAny*)&aMode);
    94 	}
    95 
    96 /**
    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.
   100 
   101  @param	aConfig
   102  		buffer descriptor with device configuration information
   103 
   104  @return	return value of DoControl(), i.e KErrNone or standard error code
   105  */
   106 inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
   107 	{
   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
   111 	//
   112 	return DoControl(EControlSetConfig,(TAny*)&aConfig);
   113 	}
   114 
   115 /**
   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.
   119 
   120  @param		aData
   121  			buffer holding the data to transmit
   122 
   123  @return	KErrNone on success or KErrArgument on invalid length
   124  */
   125 inline TInt RExDriverChannel::TransmitData(const TDesC8& aData)
   126 	{
   127 	// Read the length of the data using TDesC8::Length(). It gives 8-bit data
   128 	// items represented by the descriptor
   129 	//
   130 	TInt len = aData.Length();
   131 	if (!len)
   132 		return KErrArgument;
   133 
   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.
   138 	//
   139 	
   140 	return DoControl(ERequestTransmitData,(TAny*)&aData);;
   141 	}
   142 
   143 /**
   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.
   147 
   148  @param		aData
   149  			buffer holding the data received
   150 
   151  @return	KErrNone on success or KErrArgument on invalid length
   152  */
   153 inline TInt RExDriverChannel::ReceiveData(TDes8 &aData)
   154 	{
   155 	// Read the length of the data using TDesC8::Length(). It gives 8-bit data
   156 	// items represented by the descriptor
   157 	//
   158 	TInt len = aData.MaxLength();
   159 	if (!len)
   160 		return KErrArgument;
   161 
   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.	
   165 
   166 	return DoControl(ERequestReceiveData,&aData);
   167 	}
   168 
   169 // End of exsync.inl