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