os/kernelhwsrv/kerneltest/e32test/examples/exdriver/exdriver_chnk/inc/exchnk.h
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 file defines the interface provided by the driver to the user. 
sl@0
    15
// It will be included both in the application (user) and the driver (kernel). 
sl@0
    16
// This file typically defines the RBusLogicalChannel derived class that will 
sl@0
    17
// inturn provide the driver API to the user application.
sl@0
    18
// ifndef __EXCHNK_H__ will resolve the multiple inclusion of this header 
sl@0
    19
// file in different source files. If the file is already included, then the 
sl@0
    20
// following switch will not re-include the file.
sl@0
    21
// 
sl@0
    22
//
sl@0
    23
sl@0
    24
#ifndef __EXCHNK_H__
sl@0
    25
#define __EXCHNK_H__
sl@0
    26
sl@0
    27
// include files
sl@0
    28
// 
sl@0
    29
// e32ver.h (for KE32BuildVersionNumber), e32cmn.h and e32std.h are already
sl@0
    30
// included in d32comm.h and hence not repeating here.
sl@0
    31
//
sl@0
    32
#include <d32comm.h>
sl@0
    33
sl@0
    34
// Literal string descriptor constants for driver name. These descriptors 
sl@0
    35
// are used by the driver to associate a name for registering to the 
sl@0
    36
// Symbian OS. LDD will have a name to associate with.
sl@0
    37
//
sl@0
    38
sl@0
    39
_LIT(KDriverName, "d_exchnk");
sl@0
    40
sl@0
    41
// Internal loopback modes
sl@0
    42
const TInt KIntLoopbackDisable=0;
sl@0
    43
const TInt KIntLoopbackEnable=1;
sl@0
    44
sl@0
    45
/**
sl@0
    46
 User interface for tutorial driver
sl@0
    47
 
sl@0
    48
 RExDriverChannel class is derived from the RBusLogicalChannel and provides 
sl@0
    49
 the interface for user. User application accesses the driver functionality
sl@0
    50
 using only these API.
sl@0
    51
 */
sl@0
    52
class RExDriverChannel:public RBusLogicalChannel
sl@0
    53
	{
sl@0
    54
public:
sl@0
    55
	// TVer is an enumeration for the version related information. Driver will 
sl@0
    56
	// need to set and validate version related information while installing.
sl@0
    57
	// Version numbers are validated to check if this version of driver as 
sl@0
    58
	// expected by the client/user application
sl@0
    59
	//
sl@0
    60
	enum TVer
sl@0
    61
		{
sl@0
    62
		EUartMajorVersionNumber=1,						// Major number for driver
sl@0
    63
		EUartMinorVersionNumber=0,						// Minor number for device
sl@0
    64
		EUartBuildVersionNumber=KE32BuildVersionNumber	// Build version number for driver
sl@0
    65
		};
sl@0
    66
	// TControl is the enumeration for control and synchronous messages 
sl@0
    67
	// supported by the driver. User application can request for any of
sl@0
    68
	// the following control messages to the driver through DoControl() 
sl@0
    69
	// API provided by the RBusLogicalChannel class.
sl@0
    70
	//
sl@0
    71
	enum TControl							// Synchronous control messages used with DoControl()					
sl@0
    72
		{
sl@0
    73
		EControlCaps,						// Get the channel capabilities on uart
sl@0
    74
		EControlSetConfig,					// Configure the device (uart)
sl@0
    75
		EControlSetIntLoopback,				// Configure the device's internal looback mode
sl@0
    76
		EGetTxChunkHandle,					// Get handle to transmit chunk
sl@0
    77
		EGetRxChunkHandle,					// Get handle to Receive chunk
sl@0
    78
		EPassTxChunkHandle,					// Pass handle to transmit chunk from user side.
sl@0
    79
		EPassRxChunkHandle					// Pass handle to Receive chunk from user side.
sl@0
    80
		};
sl@0
    81
	// TRequest is the enumeration for asynchronous requests supported
sl@0
    82
	// by the driver. User application can request for any of the 
sl@0
    83
	// following messages to the driver through DoRequest() API provided
sl@0
    84
	// by the RBusLogicalChannel class.
sl@0
    85
	//
sl@0
    86
	enum TRequest							// Asynchronous request messages used with DoRequest()	
sl@0
    87
		{
sl@0
    88
		ERequestTransmitData,				// Transmit data over the device (uart)	
sl@0
    89
		ERequestReceiveData,				// Receive the data from the device (uart)
sl@0
    90
		ENumRequests,						// Total number of supported asynchrnous requests
sl@0
    91
		EAllRequests = (1<<ENumRequests)-1
sl@0
    92
		};		
sl@0
    93
public:
sl@0
    94
	// VersionRequired() will provide the version of the driver. This is made inline
sl@0
    95
	// function to initialize the TVersion object with driver's Major,Minor and Build
sl@0
    96
	// version numbers. This is later used to validate the driver version.
sl@0
    97
	//
sl@0
    98
#ifndef __KERNEL_MODE__	
sl@0
    99
	inline static TVersion VersionRequired();		
sl@0
   100
	
sl@0
   101
	// These functions are wrappers to the RBusLogicalChannel API and are inline.
sl@0
   102
	//
sl@0
   103
	inline TInt Open(TInt aUnit);					// Open the channel to the driver
sl@0
   104
	inline TInt Caps(TDes8& aCaps);					// Get the channel capabilities
sl@0
   105
	inline TInt SetIntLoopback(const TInt aMode);	// Configure the device's internal loopback
sl@0
   106
	inline TInt SetConfig(const TDesC8& aConfig);	// Configure device (UART)	
sl@0
   107
	inline TInt TransmitData(TRequestStatus& aStatus,TInt aSize,TInt aOffset=0);		// Send data on device (UART)	
sl@0
   108
	inline TInt ReceiveData(TRequestStatus& aStatus,TInt aSize,TInt aOffset=0);		// Receive data on device (UART)		
sl@0
   109
	inline void CancelTransmit();			// Cancel pending asynchronous Tx requests
sl@0
   110
	inline void CancelReceive();			// Cancel pending asynchronous Rx requests
sl@0
   111
	inline TInt GetTxChunkHandle(RChunk& aChunk);
sl@0
   112
	inline TInt GetRxChunkHandle(RChunk& aChunk);
sl@0
   113
	inline TInt PassTxChunkHandle(RChunk& aChunk);
sl@0
   114
	inline TInt PassRxChunkHandle(RChunk& aChunk);
sl@0
   115
#endif	
sl@0
   116
	};
sl@0
   117
sl@0
   118
// All inline functions implementation is provided in a seperate inline file. This file
sl@0
   119
// is included here to add the inline implementations. Note:these inline functions 
sl@0
   120
// implementaion is also available only in user space.
sl@0
   121
// 
sl@0
   122
sl@0
   123
sl@0
   124
sl@0
   125
#include "exchnk.inl"
sl@0
   126
sl@0
   127
sl@0
   128
sl@0
   129
#endif  // __EXCHNK_H__
sl@0
   130
sl@0
   131
//
sl@0
   132
// End of exchnk.h