os/kernelhwsrv/bsptemplate/asspandvariant/template_assp/iic/iic_master.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.
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 #ifndef __IIC_MASTER_H_
    21 #define __IIC_MASTER_H_
    22 
    23 #include <drivers/iic_channel.h>
    24 // #include platform specific header files here ...
    25 
    26 _LIT(KIicPslThreadName,"IicPslChannelThread_");
    27 
    28 const TInt KIicPslDfcPriority = 0; // Arbitrary, can be 0-7, 7 highest
    29 const TInt KIicPslThreadPriority = 24;
    30 
    31 // DIicBusChannelMasterPsl class declaration:
    32 class DIicBusChannelMasterPsl: public DIicBusChannelMaster
    33 	{
    34 public:
    35 	// Method to create a channel
    36 	static DIicBusChannelMasterPsl* New(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
    37 
    38 	// Gateway function for PSL implementation
    39 	virtual TInt DoRequest(TIicBusTransaction* aTransaction);
    40 
    41 	// Overloaded constructor
    42 	DIicBusChannelMasterPsl(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
    43 
    44 private:
    45 	// Override base-class pure virtual methods
    46 	virtual TInt DoCreate(); // 2nd stage construction.
    47 	virtual TInt CheckHdr(TDes8* aHdr);
    48 	virtual TInt HandleSlaveTimeout();
    49 
    50 	// Internal methods
    51 	TInt ConfigureInterface();
    52 	TBool TransConfigDiffersFromPrev();		// Optional method - potentially saving hardware re-configuration
    53 	TInt DoTransfer(TInt8 *aBuff, TUint aNumOfBytes, TUint8 aType);
    54 	TInt StartTransfer(TIicBusTransfer* aTransferPtr, TUint8 aType);
    55 	TInt ProcessNextTransfers();
    56 	void ExitComplete(TInt aErr, TBool aComplete = ETrue);
    57 
    58 	// Dfc and timeout Callback functions
    59 	static void TransferEndDfc(TAny* aPtr);
    60 	static void TransferTimeoutDfc(TAny* aPtr);
    61 	static void TimeoutCallback(TAny* aPtr);
    62 
    63 	// ISR handler.
    64 	static void IicIsr(TAny* aPtr);
    65 
    66 	// DFC for handling transfer completion
    67 	TDfc iTransferEndDfc;
    68 
    69 	// Flags indicating the current Rx/Tx activity
    70 	TIicOperationType iOperation;
    71 
    72 	// Granularity of data transmitted
    73 	TUint8 iWordSize;
    74 
    75 	// Current state of the channel. The channel shuould not accept requests for new
    76 	// transactions until the current one is complete. The following enumeration and 
    77 	// state variable are used to control this.
    78 	enum TMyState
    79 		{
    80 		EIdle,
    81 		EBusy
    82 		};
    83 	TUint8 iState;
    84 
    85 	// Register base for the Master channel
    86 	TUint iMasterChanBase;
    87 
    88 	// Interrupt ID for the Master channel
    89 	TInt iMasterIntId;
    90 
    91 	// Pointers used to store current transfers information
    92 	TIicBusTransfer* iHalfDTransfer;
    93 	TIicBusTransfer* iFullDTransfer;
    94 
    95 	// Pointer to the current transaction.
    96 	TIicBusTransaction* iCurrTransaction;
    97 
    98 	// Pointers to buffers used for Rx and Tx transfers
    99 	TInt8 *iTxData;
   100 	TInt8 *iRxData;
   101 	TInt8 *iTxDataEnd;
   102 	TInt8 *iRxDataEnd;
   103 
   104 	// Timer to guard against hardware timeout
   105 	NTimer iHwGuardTimer;
   106 
   107 	// Status of the transaction
   108 	volatile TInt iTransactionStatus;
   109 
   110 	// Optional - pointers to the previous, and newly-requested transaction's headers
   111 	// These would be of a type that is speific to the bus type supported by the channel.
   112 	// Here, they are of a fictional bus type, 'Abc', and so are commented-out
   113 	//		TConfigAbcBufV01* iPrevHeader;
   114 	//		TConfigAbcBufV01* iCurrHeader
   115 	};
   116 
   117 #endif //__IIC_MASTER_H_