os/kernelhwsrv/kernel/eka/drivers/iic/iic_transaction.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/drivers/iic/iic_transaction.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,53 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\drivers\iic_transaction.cpp
    1.18 +// IIC Transaction API Implementation
    1.19 +//
    1.20 +
    1.21 +#include <drivers/iic_transaction.h>
    1.22 +#include <drivers/iic_channel.h>
    1.23 +
    1.24 +EXPORT_C void TIicBusSlaveCallback::DfcFunc(TAny* aPtr)
    1.25 +    {
    1.26 +    TIicBusSlaveCallback* pCb = (TIicBusSlaveCallback*) aPtr;
    1.27 +	// pCb can be NULL if a client corrupt it after the dfc has been queued
    1.28 +    __ASSERT_DEBUG(pCb != NULL, Kern::Fault(KIicPanic,__LINE__));
    1.29 +	DIicBusChannelSlave* chan = pCb->iChannel;
    1.30 +	__ASSERT_DEBUG(chan != NULL, Kern::Fault(KIicPanic,__LINE__));
    1.31 +
    1.32 +	chan->ProcessData(pCb->iTrigger, pCb); // Call PSL to fill in iReturn, iRxWords and/or iTxWords
    1.33 +	//
    1.34 +	// Only invoke the client's callback (and update the state machine) if asynchronous channel capture has
    1.35 +	// completed, or if one of the requested triggers has occurred or if a bus error has been witnessed
    1.36 +	TInt8 callbackTrig = 0;
    1.37 +	TInt callbackRet = 0;
    1.38 +	TInt nextSteps = chan->UpdateReqTrig(callbackTrig, callbackRet);
    1.39 +	if(nextSteps & DIicBusChannelSlave::EStopTimer)
    1.40 +		{
    1.41 +		chan->StopTimer();
    1.42 +		}
    1.43 +	if(nextSteps & DIicBusChannelSlave::EInvokeCb)
    1.44 +		{
    1.45 +		(pCb->iCallback)(pCb->iChannelId, callbackRet, (TInt)callbackTrig, pCb->iRxWords, pCb->iTxWords, pCb->iParam);
    1.46 +		// Callback now processed, so re-initialise callback object members
    1.47 +		pCb->iTrigger = 0;
    1.48 +		pCb->iReturn = KErrNone;
    1.49 +		pCb->iRxWords = 0;
    1.50 +		pCb->iTxWords = 0;
    1.51 +		}
    1.52 +	if(nextSteps & DIicBusChannelSlave::EStartTimer)
    1.53 +		{
    1.54 +		chan->StartTimerByState();
    1.55 +		}
    1.56 +    }