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