First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #ifndef __IIC_MASTER_H_
21 #define __IIC_MASTER_H_
23 #include <drivers/iic_channel.h>
24 // #include platform specific header files here ...
26 _LIT(KIicPslThreadName,"IicPslChannelThread_");
28 const TInt KIicPslDfcPriority = 0; // Arbitrary, can be 0-7, 7 highest
29 const TInt KIicPslThreadPriority = 24;
31 // DIicBusChannelMasterPsl class declaration:
32 class DIicBusChannelMasterPsl: public DIicBusChannelMaster
35 // Method to create a channel
36 static DIicBusChannelMasterPsl* New(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
38 // Gateway function for PSL implementation
39 virtual TInt DoRequest(TIicBusTransaction* aTransaction);
41 // Overloaded constructor
42 DIicBusChannelMasterPsl(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
45 // Override base-class pure virtual methods
46 virtual TInt DoCreate(); // 2nd stage construction.
47 virtual TInt CheckHdr(TDes8* aHdr);
48 virtual TInt HandleSlaveTimeout();
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);
58 // Dfc and timeout Callback functions
59 static void TransferEndDfc(TAny* aPtr);
60 static void TransferTimeoutDfc(TAny* aPtr);
61 static void TimeoutCallback(TAny* aPtr);
64 static void IicIsr(TAny* aPtr);
66 // DFC for handling transfer completion
69 // Flags indicating the current Rx/Tx activity
70 TIicOperationType iOperation;
72 // Granularity of data transmitted
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.
85 // Register base for the Master channel
86 TUint iMasterChanBase;
88 // Interrupt ID for the Master channel
91 // Pointers used to store current transfers information
92 TIicBusTransfer* iHalfDTransfer;
93 TIicBusTransfer* iFullDTransfer;
95 // Pointer to the current transaction.
96 TIicBusTransaction* iCurrTransaction;
98 // Pointers to buffers used for Rx and Tx transfers
104 // Timer to guard against hardware timeout
105 NTimer iHwGuardTimer;
107 // Status of the transaction
108 volatile TInt iTransactionStatus;
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
117 #endif //__IIC_MASTER_H_