os/kernelhwsrv/bsptemplate/asspandvariant/template_assp/iic/iic_master.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/bsptemplate/asspandvariant/template_assp/iic/iic_master.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,117 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#ifndef __IIC_MASTER_H_
    1.24 +#define __IIC_MASTER_H_
    1.25 +
    1.26 +#include <drivers/iic_channel.h>
    1.27 +// #include platform specific header files here ...
    1.28 +
    1.29 +_LIT(KIicPslThreadName,"IicPslChannelThread_");
    1.30 +
    1.31 +const TInt KIicPslDfcPriority = 0; // Arbitrary, can be 0-7, 7 highest
    1.32 +const TInt KIicPslThreadPriority = 24;
    1.33 +
    1.34 +// DIicBusChannelMasterPsl class declaration:
    1.35 +class DIicBusChannelMasterPsl: public DIicBusChannelMaster
    1.36 +	{
    1.37 +public:
    1.38 +	// Method to create a channel
    1.39 +	static DIicBusChannelMasterPsl* New(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
    1.40 +
    1.41 +	// Gateway function for PSL implementation
    1.42 +	virtual TInt DoRequest(TIicBusTransaction* aTransaction);
    1.43 +
    1.44 +	// Overloaded constructor
    1.45 +	DIicBusChannelMasterPsl(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
    1.46 +
    1.47 +private:
    1.48 +	// Override base-class pure virtual methods
    1.49 +	virtual TInt DoCreate(); // 2nd stage construction.
    1.50 +	virtual TInt CheckHdr(TDes8* aHdr);
    1.51 +	virtual TInt HandleSlaveTimeout();
    1.52 +
    1.53 +	// Internal methods
    1.54 +	TInt ConfigureInterface();
    1.55 +	TBool TransConfigDiffersFromPrev();		// Optional method - potentially saving hardware re-configuration
    1.56 +	TInt DoTransfer(TInt8 *aBuff, TUint aNumOfBytes, TUint8 aType);
    1.57 +	TInt StartTransfer(TIicBusTransfer* aTransferPtr, TUint8 aType);
    1.58 +	TInt ProcessNextTransfers();
    1.59 +	void ExitComplete(TInt aErr, TBool aComplete = ETrue);
    1.60 +
    1.61 +	// Dfc and timeout Callback functions
    1.62 +	static void TransferEndDfc(TAny* aPtr);
    1.63 +	static void TransferTimeoutDfc(TAny* aPtr);
    1.64 +	static void TimeoutCallback(TAny* aPtr);
    1.65 +
    1.66 +	// ISR handler.
    1.67 +	static void IicIsr(TAny* aPtr);
    1.68 +
    1.69 +	// DFC for handling transfer completion
    1.70 +	TDfc iTransferEndDfc;
    1.71 +
    1.72 +	// Flags indicating the current Rx/Tx activity
    1.73 +	TIicOperationType iOperation;
    1.74 +
    1.75 +	// Granularity of data transmitted
    1.76 +	TUint8 iWordSize;
    1.77 +
    1.78 +	// Current state of the channel. The channel shuould not accept requests for new
    1.79 +	// transactions until the current one is complete. The following enumeration and 
    1.80 +	// state variable are used to control this.
    1.81 +	enum TMyState
    1.82 +		{
    1.83 +		EIdle,
    1.84 +		EBusy
    1.85 +		};
    1.86 +	TUint8 iState;
    1.87 +
    1.88 +	// Register base for the Master channel
    1.89 +	TUint iMasterChanBase;
    1.90 +
    1.91 +	// Interrupt ID for the Master channel
    1.92 +	TInt iMasterIntId;
    1.93 +
    1.94 +	// Pointers used to store current transfers information
    1.95 +	TIicBusTransfer* iHalfDTransfer;
    1.96 +	TIicBusTransfer* iFullDTransfer;
    1.97 +
    1.98 +	// Pointer to the current transaction.
    1.99 +	TIicBusTransaction* iCurrTransaction;
   1.100 +
   1.101 +	// Pointers to buffers used for Rx and Tx transfers
   1.102 +	TInt8 *iTxData;
   1.103 +	TInt8 *iRxData;
   1.104 +	TInt8 *iTxDataEnd;
   1.105 +	TInt8 *iRxDataEnd;
   1.106 +
   1.107 +	// Timer to guard against hardware timeout
   1.108 +	NTimer iHwGuardTimer;
   1.109 +
   1.110 +	// Status of the transaction
   1.111 +	volatile TInt iTransactionStatus;
   1.112 +
   1.113 +	// Optional - pointers to the previous, and newly-requested transaction's headers
   1.114 +	// These would be of a type that is speific to the bus type supported by the channel.
   1.115 +	// Here, they are of a fictional bus type, 'Abc', and so are commented-out
   1.116 +	//		TConfigAbcBufV01* iPrevHeader;
   1.117 +	//		TConfigAbcBufV01* iCurrHeader
   1.118 +	};
   1.119 +
   1.120 +#endif //__IIC_MASTER_H_