sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This is an inline file and has the implementation of RExDriverChannel sl@0: // derived from RBusLogicalChannel class. The member functions will sl@0: // basically be wrappers of RBusLogicalChannel API. sl@0: // This file is included in exint.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: sl@0: VersionRequired() inline function to initialize TVersion object with sl@0: driver Major number, Minor number and Build version number. This function sl@0: is provided just as a utility function to easily get the version details. sl@0: sl@0: @return initialized TVersion object sl@0: sl@0: */ sl@0: inline TVersion RExDriverChannel::VersionRequired() sl@0: { sl@0: return (TVersion(EUartMajorVersionNumber, sl@0: EUartMinorVersionNumber, sl@0: EUartBuildVersionNumber)); sl@0: } sl@0: sl@0: /** sl@0: Open the driver for the specified unit. Unit information is passed as an sl@0: argument by the user. User can open the driver for different units as supported sl@0: by the driver. sl@0: sl@0: @param aUnit sl@0: device unit number sl@0: sl@0: @return return value of DoCreate(), i.e KErrNone or standard error code sl@0: */ sl@0: inline TInt RExDriverChannel::Open(TInt aUnit) sl@0: { sl@0: // Call DoCreate() API of RBusLogicalChannel with driver name, sl@0: // version, unit number and owner. This will result in creating the sl@0: // logical channel by invoking Create() and DoCreate() of Logical Channel. sl@0: // sl@0: return DoCreate(KDriverName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread); sl@0: } sl@0: sl@0: /** sl@0: Gets the capabilities of a channel opened on the driver. User can use the sl@0: retrieved capabilities to configure different channels (if supported by sl@0: driver) with supported configuration. sl@0: sl@0: @param aCaps sl@0: Descriptor to be filled with channel capabilities sl@0: sl@0: @return return value of DoControl(), i.e KErrNone or standard error code sl@0: */ sl@0: inline TInt RExDriverChannel::Caps(TDes8& aCaps) sl@0: { sl@0: // Call DoControl() API of RBusLogicalChannel with the request number sl@0: // and the caps buffer(structure) that has to be filled by the driver. sl@0: // This is a synchronous message and will be handled in driver/LDD sl@0: // DoControl() function sl@0: // sl@0: return DoControl(EControlCaps,(TAny*)&aCaps); sl@0: } sl@0: sl@0: /** sl@0: Configure the device (uart) internal loopback mode. User can configure the sl@0: device for internal loopback mode using this API. Loopback mode can be enabled sl@0: or disabled by passing the mode as a parameter to this API. sl@0: sl@0: @param aMode sl@0: Holds the loopback enable and disable option sl@0: KLoopbackEnable for enable and KLoopbackDisable for disable sl@0: sl@0: @return return value of DoControl(), i.e KErrNone or standard error code sl@0: */ sl@0: inline TInt RExDriverChannel::SetIntLoopback(const TInt aMode) sl@0: { sl@0: // Call DoControl() API of RBusLogicalChannel with the request number sl@0: // and the loopback mode. This is a synchronous message sl@0: // and will be handled in driver/LDD DoControl() function sl@0: // sl@0: return DoControl(EControlSetIntLoopback,(TAny*)&aMode); sl@0: } sl@0: sl@0: /** sl@0: Configure the device (uart) for the specified settings. User initializes the sl@0: configuration buffer, and passes this to the device driver. The config data sl@0: structure is packaged as a buffer and passes as an argument. sl@0: sl@0: @param aConfig sl@0: buffer descriptor with device configuration information sl@0: sl@0: @return return value of DoControl(), i.e KErrNone or standard error code sl@0: */ sl@0: inline TInt RExDriverChannel::SetConfig(const TDesC8& aConfig) sl@0: { sl@0: // Call DoControl() API of RBusLogicalChannel with the request number sl@0: // and the config buffer(structure). This is a synchronous message sl@0: // and will be handled in driver/LDD DoControl() function sl@0: // sl@0: return DoControl(EControlSetConfig,(TAny*)&aConfig); sl@0: } sl@0: sl@0: /** sl@0: Transmit the data to the device. User initializes the buffer and sends the sl@0: the buffer descriptor as an argument. It returns immediately after initiating sl@0: the transmit. The actual request completes asynchronously after the completion sl@0: of the operation on the device and is notified then. sl@0: sl@0: @param aStatus sl@0: TRequestStatus object to hold the asynchronous request status sl@0: @param aData sl@0: buffer holding the data to transmit sl@0: sl@0: @return KErrNone on success or KErrArgument on invalid length sl@0: */ sl@0: inline TInt RExDriverChannel::TransmitData(TRequestStatus& aStatus, const TDesC8& aData) sl@0: { sl@0: // Read the length of the data using TDesC8::Length(). It gives 8-bit data sl@0: // items represented by the descriptor sl@0: // sl@0: TInt len = aData.Length(); sl@0: if (!len) sl@0: return KErrArgument; sl@0: sl@0: // Call DoRequest() API of RBusLogicalChannel with the request number, sl@0: // TRequestStatus object to hold asynchronous request status, transmit buffer sl@0: // and data length. This is a implemented as asynchronous message and will be sl@0: // handled in driver/LDD DoRequest() function.Here the transmit buffer, aData sl@0: // is filled by user and sent to the driver for writing to device. sl@0: // sl@0: DoRequest(ERequestTransmitData,aStatus,(TAny*)&aData); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: Receive the data from the device. User sends an empty buffer and reads the sl@0: data after the call. It returns immediately after initiating the receive. sl@0: The actual request completes asynchronously after the completion of the sl@0: operation on the device and is notified then. sl@0: sl@0: @param aData sl@0: buffer holding the data received sl@0: sl@0: @return KErrNone on success or KErrArgument on invalid length sl@0: */ sl@0: inline TInt RExDriverChannel::ReceiveData(TRequestStatus& aStatus, TDes8 &aData) sl@0: { sl@0: // Read the length of the data using TDesC8::Length(). It gives 8-bit data sl@0: // items represented by the descriptor sl@0: // sl@0: TInt len = aData.MaxLength(); sl@0: if (!len) sl@0: return KErrArgument; sl@0: sl@0: // Call DoRequest() API of RBusLogicalChannel with the request number, sl@0: // TRequestStatus object to hold asynchronous request status, receive buffer sl@0: // and data length. This is a implemented as asynchronous message and will be sl@0: // handled in driver/LDD DoRequest() function. Here, the receive buffer, aData sl@0: // will be filled and returned with the received data by the driver read from sl@0: // the device. sl@0: // sl@0: DoRequest(ERequestReceiveData,aStatus,&aData); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: Cancel Transmit request on the device. User can request to cancel any outstanding sl@0: transmit requests. This request is handled by calling DoCancel() with appropriate sl@0: request mask sl@0: sl@0: @param none sl@0: sl@0: @return void sl@0: */ sl@0: inline void RExDriverChannel::CancelTransmit() sl@0: { sl@0: // Call DoCancel() API of RBusLogicalChannel with the request number. This is sl@0: // handled in driver/LDD DoCancel() function. It will cancel the operation and sl@0: // also tidy up the request specific resources. sl@0: // sl@0: DoCancel(1<