os/kernelhwsrv/kernel/eka/include/drivers/iic_channel.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-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
// e32/include/iic_channel.inl
sl@0
    15
// Channel
sl@0
    16
//
sl@0
    17
// WARNING: This file contains some APIs which are internal and are subject
sl@0
    18
//          to change without noticed. Such APIs should therefore not be used
sl@0
    19
//          outside the Kernel and Hardware Services package.
sl@0
    20
//
sl@0
    21
sl@0
    22
inline DIicBusChannel::DIicBusChannel(TChannelType aChanType, TBusType aBusType, TChannelDuplex aChanDuplex)
sl@0
    23
	{
sl@0
    24
	__KTRACE_OPT(KIIC, Kern::Printf("DIicBusChannel::DIicBusChannel, aChanType=%d, aBusType=%d, aChanDuplex=%d\n",aChanType,aBusType,aChanDuplex));
sl@0
    25
sl@0
    26
	// Arbitary ...
sl@0
    27
	iFlags=(TUint8)((aChanType&KChannelTypeMask) | ((aBusType<<KBusTypeShift)&KBusTypeMask) | ((aChanDuplex<<KChannelDuplexShift)&(KChannelDuplexMask)));
sl@0
    28
	}
sl@0
    29
sl@0
    30
inline DIicBusChannel::TChannelType DIicBusChannel::ChannelType() 
sl@0
    31
	{return((TChannelType)(iFlags&KChannelTypeMask));}
sl@0
    32
sl@0
    33
inline void DIicBusChannel::SetChannelType(TChannelType aChanType) 
sl@0
    34
	{
sl@0
    35
	iFlags &= ~KChannelTypeMask;
sl@0
    36
	iFlags |= (aChanType & KChannelTypeMask);
sl@0
    37
	};
sl@0
    38
sl@0
    39
inline DIicBusChannel::TBusType DIicBusChannel::BusType() 
sl@0
    40
	{return((TBusType)((iFlags & KBusTypeMask) >> KBusTypeShift));};
sl@0
    41
sl@0
    42
inline void DIicBusChannel::SetBusType(TBusType aBusType) 
sl@0
    43
	{
sl@0
    44
	iFlags &= ~KBusTypeMask;
sl@0
    45
	iFlags |= ((aBusType << KBusTypeShift) & KBusTypeMask);
sl@0
    46
	};
sl@0
    47
sl@0
    48
inline DIicBusChannel::TChannelDuplex DIicBusChannel::ChannelDuplex() 
sl@0
    49
	{return((TChannelDuplex)((iFlags & KChannelDuplexMask) >> KChannelDuplexShift));};
sl@0
    50
sl@0
    51
inline void DIicBusChannel::SetChannelType(TChannelDuplex aChanDuplex) 
sl@0
    52
	{
sl@0
    53
	iFlags &= ~KChannelDuplexMask;
sl@0
    54
	iFlags |= ((aChanDuplex << KChannelDuplexShift) & KChannelDuplexMask);
sl@0
    55
	};
sl@0
    56
sl@0
    57
inline TInt8 DIicBusChannel::ChannelNumber() const 
sl@0
    58
	{return iChannelNumber;};
sl@0
    59
sl@0
    60
//
sl@0
    61
//		Master Channel
sl@0
    62
//
sl@0
    63
sl@0
    64
sl@0
    65
// Methods to make private data of TIicBusTransfer object accessible to derivatives of this class
sl@0
    66
inline TIicBusTransfer* DIicBusChannelMaster::GetTferNextTfer(const TIicBusTransfer* aTransfer) 
sl@0
    67
	{return aTransfer->iNext;};
sl@0
    68
sl@0
    69
inline TInt8 DIicBusChannelMaster::GetTferType(const TIicBusTransfer* aTransfer) 
sl@0
    70
	{return aTransfer->iType;};
sl@0
    71
sl@0
    72
inline TInt8 DIicBusChannelMaster::GetTferBufGranularity(const TIicBusTransfer* aTransfer) 
sl@0
    73
	{return aTransfer->iBufGranularity;};
sl@0
    74
sl@0
    75
inline const TDes8* DIicBusChannelMaster::GetTferBuffer(const TIicBusTransfer* aTransfer) 
sl@0
    76
	{return aTransfer->iBuffer;};
sl@0
    77
sl@0
    78
// Methods to make private data of TIicBusTransaction object accessible to derivatives of this class
sl@0
    79
inline TDes8* DIicBusChannelMaster::GetTransactionHeader(const TIicBusTransaction* aTransaction) 
sl@0
    80
	{return aTransaction->iHeader;};
sl@0
    81
sl@0
    82
inline TIicBusTransfer* DIicBusChannelMaster::GetTransHalfDuplexTferPtr(const TIicBusTransaction* aTransaction)
sl@0
    83
	{return aTransaction->iHalfDuplexTrans;};
sl@0
    84
sl@0
    85
inline TIicBusTransfer* DIicBusChannelMaster::GetTransFullDuplexTferPtr(const TIicBusTransaction* aTransaction) 
sl@0
    86
	{return aTransaction->iFullDuplexTrans;};
sl@0
    87
sl@0
    88
inline TIicBusCallback* DIicBusChannelMaster::GetTransCallback(const TIicBusTransaction* aTransaction) 
sl@0
    89
	{return aTransaction->iCallback;};
sl@0
    90
sl@0
    91
inline TUint8 DIicBusChannelMaster::GetTransFlags(const TIicBusTransaction* aTransaction) 
sl@0
    92
	{return aTransaction->iFlags;};
sl@0
    93
sl@0
    94
sl@0
    95
// Methods to make private data of TIicBusTransactionPreamble object accessible to derivatives of this class
sl@0
    96
inline TIicBusPreamble  DIicBusChannelMaster::GetPreambleFuncPtr(const TIicBusTransactionPreamble* aTransfer)
sl@0
    97
	{return aTransfer->iPreamble;};
sl@0
    98
sl@0
    99
inline TAny* DIicBusChannelMaster::GetPreambleFuncArg(const TIicBusTransactionPreamble* aTransfer)
sl@0
   100
	{return aTransfer->iPreambleArg;};
sl@0
   101
sl@0
   102
inline TIicBusMultiTranscCbFn  DIicBusChannelMaster::GetMultiTranscFuncPtr(const TIicBusTransactionMultiTransc* aTransfer)
sl@0
   103
	{return aTransfer->iMultiTransc;};
sl@0
   104
sl@0
   105
inline TAny* DIicBusChannelMaster::GetMultiTranscFuncArg(const TIicBusTransactionMultiTransc* aTransfer)
sl@0
   106
	{return aTransfer->iMultiTranscArg;};
sl@0
   107
sl@0
   108
inline TIicBusMultiTranscCbFn  DIicBusChannelMaster::GetExtTranscFuncPtr(const TIicBusTransactionPreambleExt* aTransfer)
sl@0
   109
	{return aTransfer->iMultiTransc;};
sl@0
   110
sl@0
   111
inline TAny* DIicBusChannelMaster::GetExtTranscFuncArg(const TIicBusTransactionPreambleExt* aTransfer)
sl@0
   112
	{return aTransfer->iMultiTranscArg;};
sl@0
   113
sl@0
   114
inline TInt8 DIicBusChannelSlave::GetMasterWaitTime() 
sl@0
   115
	{return iMasterWaitTime;}
sl@0
   116
sl@0
   117
inline TInt8 DIicBusChannelSlave::GetClientWaitTime() 
sl@0
   118
	{return iClientWaitTime;};
sl@0
   119
sl@0
   120
#ifndef STANDALONE_CHANNEL
sl@0
   121
inline DIicBusChannelMasterSlave::DIicBusChannelMasterSlave(TBusType aBusType, TChannelDuplex aChanDuplex, DIicBusChannelMaster* aMasterChan, DIicBusChannelSlave* aSlaveChan)
sl@0
   122
	: DIicBusChannel(DIicBusChannel::EMasterSlave, aBusType, aChanDuplex),
sl@0
   123
	iMasterChannel(aMasterChan),
sl@0
   124
	iSlaveChannel(aSlaveChan)
sl@0
   125
	{
sl@0
   126
	//If in stand-alone channel mode, the client assigns a channel number to the MasterSlave channel it creates. 
sl@0
   127
	__ASSERT_ALWAYS(iMasterChannel->iChannelNumber == iSlaveChannel->iChannelNumber,Kern::Fault("MasterSlave channel number ambiguity",0));	
sl@0
   128
	iChannelNumber = iMasterChannel->iChannelNumber;
sl@0
   129
	}
sl@0
   130
#endif
sl@0
   131
sl@0
   132
inline TInt DIicBusChannelMasterSlave::DoCreate()
sl@0
   133
	{
sl@0
   134
	__ASSERT_ALWAYS(iMasterChannel && iSlaveChannel,Kern::Fault("MasterSlave channel not properly initialised",0));
sl@0
   135
	TInt r=iMasterChannel->DoCreate();
sl@0
   136
	if(r == KErrNone)
sl@0
   137
		r=iSlaveChannel->DoCreate();
sl@0
   138
	return r;
sl@0
   139
	}
sl@0
   140
sl@0
   141
inline TInt DIicBusChannelMasterSlave::CancelTransaction(TIicBusTransaction* aTransaction)
sl@0
   142
	{return(iMasterChannel->CancelTransaction(aTransaction));}
sl@0
   143
sl@0
   144
inline TInt DIicBusChannelMasterSlave::RegisterRxBuffer(TPtr8 aRxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset)
sl@0
   145
	{return(iSlaveChannel->RegisterRxBuffer(aRxBuffer, aBufGranularity, aNumWords, aOffset));}
sl@0
   146
sl@0
   147
inline TInt DIicBusChannelMasterSlave::RegisterTxBuffer(TPtr8 aTxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset)
sl@0
   148
	{return(iSlaveChannel->RegisterTxBuffer(aTxBuffer, aBufGranularity, aNumWords, aOffset));}
sl@0
   149
sl@0
   150
inline TInt DIicBusChannelMasterSlave::SetNotificationTrigger(TInt aTrigger)
sl@0
   151
	{return(iSlaveChannel->SetNotificationTrigger(aTrigger));}
sl@0
   152
sl@0
   153
#ifdef _DEBUG
sl@0
   154
inline void DIicBusChannel::DumpChannel()
sl@0
   155
	{
sl@0
   156
	__KTRACE_OPT(KIIC, Kern::Printf("\n"));	// start
sl@0
   157
	switch((TInt)ChannelType())
sl@0
   158
		{
sl@0
   159
		case(EMaster):
sl@0
   160
			{
sl@0
   161
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType = EMaster\n"));
sl@0
   162
			break;
sl@0
   163
			}
sl@0
   164
		case(ESlave):
sl@0
   165
			{
sl@0
   166
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType = ESlave\n"));
sl@0
   167
			break;
sl@0
   168
			}
sl@0
   169
		case(EMasterSlave):
sl@0
   170
			{
sl@0
   171
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType = EMasterSlave\n"));
sl@0
   172
			break;
sl@0
   173
			}
sl@0
   174
		default:
sl@0
   175
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType %d is not recognised \n",((TInt)ChannelType())));
sl@0
   176
		}
sl@0
   177
	switch((TInt)BusType())
sl@0
   178
		{
sl@0
   179
		case(EI2c):
sl@0
   180
			{
sl@0
   181
			__KTRACE_OPT(KIIC, Kern::Printf("BusType = EI2c\n"));
sl@0
   182
			break;
sl@0
   183
			}
sl@0
   184
		case(ESpi):
sl@0
   185
			{
sl@0
   186
			__KTRACE_OPT(KIIC, Kern::Printf("BusType = ESpi\n"));
sl@0
   187
			break;
sl@0
   188
			}
sl@0
   189
		case(EMicrowire):
sl@0
   190
			{
sl@0
   191
			__KTRACE_OPT(KIIC, Kern::Printf("BusType = EMicrowire\n"));
sl@0
   192
			break;
sl@0
   193
			}
sl@0
   194
		case(ECci):
sl@0
   195
			{
sl@0
   196
			__KTRACE_OPT(KIIC, Kern::Printf("BusType = ECci\n"));
sl@0
   197
			break;
sl@0
   198
			}
sl@0
   199
		case(ESccb):
sl@0
   200
			{
sl@0
   201
			__KTRACE_OPT(KIIC, Kern::Printf("BusType = ESccb\n"));
sl@0
   202
			break;
sl@0
   203
			}
sl@0
   204
		default:
sl@0
   205
			__KTRACE_OPT(KIIC, Kern::Printf("BusType %d is not recognised \n",((TInt)BusType())));
sl@0
   206
		}
sl@0
   207
	switch((TInt)ChannelDuplex())
sl@0
   208
		{
sl@0
   209
		case(EHalfDuplex):
sl@0
   210
			{
sl@0
   211
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelDuplex = EHalfDuplex\n"));
sl@0
   212
			break;
sl@0
   213
			}
sl@0
   214
		case(EFullDuplex):
sl@0
   215
			{
sl@0
   216
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelDuplex = EFullDuplex\n"));
sl@0
   217
			break;
sl@0
   218
			}
sl@0
   219
		default:
sl@0
   220
			__KTRACE_OPT(KIIC, Kern::Printf("ChannelDuplex %d is not recognised \n",((TInt)ChannelDuplex())));
sl@0
   221
		}
sl@0
   222
	}
sl@0
   223
#endif