os/kernelhwsrv/kerneltest/e32test/examples/exdriver/exdriver_pio/inc/expio.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     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 expio.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 
    39  by the user. User can open the driver for different units as supported
    40  by the driver.
    41   		
    42  @return	return value of DoCreate(), i.e KErrNone or standard error code
    43  */ 
    44 inline TInt RExDriverChannel::Open()
    45 	{
    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. 	
    50 	//
    51 	return DoCreate(KDriverName,VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);	
    52 	}
    53 
    54 /**
    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.
    58  
    59  @param	aCaps
    60  		Descriptor to be filled with channel capabilities
    61  
    62  @return	return value of DoControl(), i.e KErrNone or standard error code
    63  */
    64 inline TInt RExDriverChannel::Caps(TDes8& aCaps)
    65 	{	
    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
    70 	//
    71 	return DoControl(EControlCaps,(TAny*)&aCaps);
    72 	}
    73 		
    74 /**
    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.
    78  
    79  @param	aConfig
    80  		buffer descriptor with device configuration information
    81  
    82  @return	return value of DoControl(), i.e KErrNone or standard error code
    83  */
    84 inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig)
    85 	{	
    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
    89 	//
    90 	return DoControl(EControlSetConfig,(TAny*)&aConfig);
    91 	}
    92 	
    93 /**
    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.
    97  
    98  @param	aData
    99  			buffer holding the data to transmit
   100  
   101  @return	return value of DoControl(), i.e KErrNone or standard error code
   102  */
   103 inline TInt RExDriverChannel::TransmitData(const TDesC8& aData)
   104 	{
   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.
   110 	//
   111 	return DoControl(EControlTransmitData,(TAny*)&aData);
   112 	}
   113 
   114 /**
   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.
   118  
   119  @param	aData
   120  			buffer holding the data received
   121  
   122  @return	return value of DoControl(), i.e KErrNone or standard error code
   123  			KErrArgument in case of zero length buffer
   124  */
   125 inline TInt RExDriverChannel::ReceiveData(TDes8& aData)
   126 	{
   127 	TInt length=aData.MaxLength();
   128 	if (!length)
   129 		return KErrArgument;
   130 									
   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.
   136 	//
   137 	return DoControl(EControlReceiveData,&aData,&length);
   138 	}
   139 
   140 //
   141 // End of expio.inl