kernel/eka/drivers/iic/iic_transaction.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\drivers\iic_transaction.cpp
       
    15 // IIC Transaction API Implementation
       
    16 //
       
    17 
       
    18 #include <drivers/iic_transaction.h>
       
    19 #include <drivers/iic_channel.h>
       
    20 
       
    21 EXPORT_C void TIicBusSlaveCallback::DfcFunc(TAny* aPtr)
       
    22     {
       
    23     TIicBusSlaveCallback* pCb = (TIicBusSlaveCallback*) aPtr;
       
    24 	// pCb can be NULL if a client corrupt it after the dfc has been queued
       
    25     __ASSERT_DEBUG(pCb != NULL, Kern::Fault(KIicPanic,__LINE__));
       
    26 	DIicBusChannelSlave* chan = pCb->iChannel;
       
    27 	__ASSERT_DEBUG(chan != NULL, Kern::Fault(KIicPanic,__LINE__));
       
    28 
       
    29 	chan->ProcessData(pCb->iTrigger, pCb); // Call PSL to fill in iReturn, iRxWords and/or iTxWords
       
    30 	//
       
    31 	// Only invoke the client's callback (and update the state machine) if asynchronous channel capture has
       
    32 	// completed, or if one of the requested triggers has occurred or if a bus error has been witnessed
       
    33 	TInt8 callbackTrig = 0;
       
    34 	TInt callbackRet = 0;
       
    35 	TInt nextSteps = chan->UpdateReqTrig(callbackTrig, callbackRet);
       
    36 	if(nextSteps & DIicBusChannelSlave::EStopTimer)
       
    37 		{
       
    38 		chan->StopTimer();
       
    39 		}
       
    40 	if(nextSteps & DIicBusChannelSlave::EInvokeCb)
       
    41 		{
       
    42 		(pCb->iCallback)(pCb->iChannelId, callbackRet, (TInt)callbackTrig, pCb->iRxWords, pCb->iTxWords, pCb->iParam);
       
    43 		// Callback now processed, so re-initialise callback object members
       
    44 		pCb->iTrigger = 0;
       
    45 		pCb->iReturn = KErrNone;
       
    46 		pCb->iRxWords = 0;
       
    47 		pCb->iTxWords = 0;
       
    48 		}
       
    49 	if(nextSteps & DIicBusChannelSlave::EStartTimer)
       
    50 		{
       
    51 		chan->StartTimerByState();
       
    52 		}
       
    53     }