|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * e32/include/drivers/iic_transaction.h |
|
16 * |
|
17 */ |
|
18 |
|
19 // WARNING: This file contains some APIs which are internal and are subject |
|
20 // to change without notice. Such APIs should therefore not be used |
|
21 // outside the Kernel and Hardware Services package. |
|
22 |
|
23 /** |
|
24 @file |
|
25 @internalTechnology |
|
26 */ |
|
27 |
|
28 #ifndef __IIC_TRANSACTION_H__ |
|
29 #define __IIC_TRANSACTION_H__ |
|
30 |
|
31 #include <kernel/kern_priv.h> // for DThread; |
|
32 #include <e32ver.h> |
|
33 |
|
34 static const char KIicPanic[]="Iic PIL"; |
|
35 |
|
36 const TInt KNumTrancPriorities=8; |
|
37 const TUint8 KTransactionWithPreamble = 0x80; |
|
38 const TUint8 KTransactionWithMultiTransc = 0x40; |
|
39 |
|
40 #ifdef _DEBUG |
|
41 static const TUint KCtrlIoDumpChan = 1; // StaticExtension value reserved for printing a channel |
|
42 #endif |
|
43 |
|
44 /** |
|
45 @publishedPartner |
|
46 @prototype 9.6 |
|
47 |
|
48 The set of endianness values for use with IIC buses |
|
49 |
|
50 */ |
|
51 enum TEndianness |
|
52 { |
|
53 EBigEndian, |
|
54 ELittleEndian |
|
55 }; |
|
56 |
|
57 /** |
|
58 @publishedPartner |
|
59 @prototype 9.6 |
|
60 |
|
61 The set of bit-order values for use with IIC buses |
|
62 |
|
63 */ |
|
64 enum TBitOrder |
|
65 { |
|
66 ELsbFirst, |
|
67 EMsbFirst |
|
68 }; |
|
69 |
|
70 // |
|
71 // Bus-specific configuration for SPI bus |
|
72 // |
|
73 |
|
74 /** |
|
75 @publishedPartner |
|
76 @prototype 9.6 |
|
77 |
|
78 The set of word-width values for use with TConfigSpiV01 |
|
79 |
|
80 @see TConfigSpiV01 |
|
81 |
|
82 */ |
|
83 enum TSpiWordWidth |
|
84 { |
|
85 ESpiWordWidth_8, |
|
86 ESpiWordWidth_10, |
|
87 ESpiWordWidth_12, |
|
88 ESpiWordWidth_16 |
|
89 }; |
|
90 |
|
91 /** |
|
92 @publishedPartner |
|
93 @prototype 9.6 |
|
94 |
|
95 The set of clock mode values for use with TConfigSpiV01 |
|
96 |
|
97 @see TConfigSpiV01 |
|
98 |
|
99 */ |
|
100 enum TSpiClkMode |
|
101 { |
|
102 ESpiPolarityLowRisingEdge, // Active high, odd edges |
|
103 ESpiPolarityLowFallingEdge, // Active high, even edges |
|
104 ESpiPolarityHighFallingEdge, // Active low, odd edges |
|
105 ESpiPolarityHighRisingEdge // Active low, even edges |
|
106 }; |
|
107 |
|
108 /** |
|
109 @publishedPartner |
|
110 @prototype 9.6 |
|
111 |
|
112 The set of values to represent the pin sense when selecting a Slave |
|
113 |
|
114 @see TConfigSpiV01 |
|
115 |
|
116 */ |
|
117 enum TSpiSsPinMode |
|
118 { |
|
119 ESpiCSPinActiveLow, // Active low |
|
120 ESpiCSPinActiveHigh // Active high |
|
121 }; |
|
122 |
|
123 /** |
|
124 @publishedPartner |
|
125 @prototype 9.6 |
|
126 |
|
127 Class to represent the configuration data for a SPI bus channel registered with IIC |
|
128 |
|
129 */ |
|
130 class TConfigSpiV01 |
|
131 { |
|
132 public: |
|
133 TSpiWordWidth iWordWidth; |
|
134 TInt32 iClkSpeedHz; |
|
135 TSpiClkMode iClkMode; |
|
136 TInt32 iTimeoutPeriod; |
|
137 TEndianness iEndianness; |
|
138 TBitOrder iBitOrder; |
|
139 TUint iTransactionWaitCycles; |
|
140 TSpiSsPinMode iSSPinActiveMode; |
|
141 }; |
|
142 |
|
143 typedef TPckgBuf <TConfigSpiV01> TConfigSpiBufV01; |
|
144 |
|
145 |
|
146 // |
|
147 // Bus-specific configuration for I2C bus |
|
148 // |
|
149 |
|
150 /** |
|
151 @publishedPartner |
|
152 @prototype 9.6 |
|
153 |
|
154 The set of address types for use with TConfigI2cV01 |
|
155 |
|
156 @see TConfigI2cV01 |
|
157 |
|
158 */ |
|
159 enum TI2cAddrType |
|
160 { |
|
161 EI2cAddr7Bit, |
|
162 EI2cAddr10Bit |
|
163 }; |
|
164 |
|
165 |
|
166 /** |
|
167 @publishedPartner |
|
168 @prototype 9.6 |
|
169 |
|
170 Class to represent the configuration data for a I2C bus channel registered with IIC |
|
171 |
|
172 */ |
|
173 class TConfigI2cV01 |
|
174 { |
|
175 public: |
|
176 TI2cAddrType iAddrType; // 7 or 10-bit addressing |
|
177 TInt32 iClkSpeedHz; |
|
178 TEndianness iEndianness; |
|
179 TInt32 iTimeoutPeriod; |
|
180 }; |
|
181 |
|
182 typedef TPckgBuf <TConfigI2cV01> TConfigI2cBufV01; |
|
183 |
|
184 |
|
185 |
|
186 // Bus realisation configuration |
|
187 // |
|
188 // 31 30 29 28 | 27 26 25 24 | 23 22 21 20 | 19 18 17 16 | 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 |
|
189 // |
|
190 // 31:29 - HS Master address (I2C only) |
|
191 // 28 - HS address valid bit |
|
192 // 27:23 - Reserved |
|
193 // 22:20 - Bus type |
|
194 // 19:15 - Channel number |
|
195 // 14:10 - Transaction speed |
|
196 // 9:0 - Slave address |
|
197 #define HS_MASTER_ADDR_SHIFT 29 |
|
198 #define HS_MASTER_ADDR_MASK 0x7 |
|
199 #define HS_ADDR_VALID_SHIFT 28 |
|
200 #define HS_ADDR_VALID_MASK 0x1 |
|
201 #define BUS_TYPE_SHIFT 20 |
|
202 #define BUS_TYPE_MASK 0x7 |
|
203 #define CHANNEL_NO_SHIFT 15 |
|
204 #define CHANNEL_NO_MASK 0x1F |
|
205 #define TRANS_SPEED_SHIFT 10 |
|
206 #define TRANS_SPEED_MASK 0x1F |
|
207 #define SLAVE_ADDR_SHIFT 0 |
|
208 #define SLAVE_ADDR_MASK 0x3FF |
|
209 |
|
210 // The SET_CONF_FIELD and GET_CONF_FIELD are for internal use, only. |
|
211 // They are to support the set of macros below which access particular fields of the Bus realisation configuration |
|
212 #define SET_CONF_FIELD(aBusId,aField,aMask,aShift) aBusId=(aBusId&~(aMask<<aShift))|((aField&aMask)<<aShift); |
|
213 #define GET_CONF_FIELD(aBusId,aMask,aShift) (((aBusId)>>(aShift))&(aMask)) |
|
214 |
|
215 /** |
|
216 @publishedPartner |
|
217 @prototype 9.6 |
|
218 Macro to get the HS Master address of a Bus realisation configuration |
|
219 */ |
|
220 #define GET_HS_MASTER_ADDR(aBusId) GET_CONF_FIELD(aBusId,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT) |
|
221 /** |
|
222 @publishedPartner |
|
223 @prototype 9.6 |
|
224 Macro to set the HS Master address of a Bus realisation configuration |
|
225 */ |
|
226 #define SET_HS_MASTER_ADDR(aBusId,aHsMasterAddr) SET_CONF_FIELD(aBusId,aHsMasterAddr,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT) |
|
227 /** |
|
228 @publishedPartner |
|
229 @prototype 9.6 |
|
230 Macro to get the HS address valid bit of a Bus realisation configuration |
|
231 */ |
|
232 #define GET_HS_VALID(aBusId,aHsValid) GET_CONF_FIELD(aBusId,aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT) |
|
233 /** |
|
234 @publishedPartner |
|
235 @prototype 9.6 |
|
236 Macro to set the HS address valid bit of a Bus realisation configuration |
|
237 */ |
|
238 #define SET_HS_VALID(aBusId,aHsValid) SET_CONF_FIELD(aBusId,aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT) |
|
239 /** |
|
240 @publishedPartner |
|
241 @prototype 9.6 |
|
242 Macro to get the Bus type of a Bus realisation configuration |
|
243 */ |
|
244 #define GET_BUS_TYPE(aBusId) GET_CONF_FIELD(aBusId,BUS_TYPE_MASK,BUS_TYPE_SHIFT) |
|
245 /** |
|
246 @publishedPartner |
|
247 @prototype 9.6 |
|
248 Macro to set the Bus type of a Bus realisation configuration |
|
249 */ |
|
250 #define SET_BUS_TYPE(aBusId,aBusType) SET_CONF_FIELD(aBusId,aBusType,BUS_TYPE_MASK,BUS_TYPE_SHIFT) |
|
251 /** |
|
252 @publishedPartner |
|
253 @prototype 9.6 |
|
254 Macro to get the Channel number of a Bus realisation configuration |
|
255 */ |
|
256 #define GET_CHAN_NUM(aBusId) GET_CONF_FIELD(aBusId,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT) |
|
257 /** |
|
258 @publishedPartner |
|
259 @prototype 9.6 |
|
260 Macro to set the Channel number of a Bus realisation configuration |
|
261 */ |
|
262 #define SET_CHAN_NUM(aBusId,aChanNum) SET_CONF_FIELD(aBusId,aChanNum,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT) |
|
263 /** |
|
264 @publishedPartner |
|
265 @prototype 9.6 |
|
266 Macro to set the Transaction speed of a Bus realisation configuration |
|
267 */ |
|
268 #define SET_TRANS_SPEED(aBusId,aTransSpeed) SET_CONF_FIELD(aBusId,aTransSpeed,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT) |
|
269 /** |
|
270 @publishedPartner |
|
271 @prototype 9.6 |
|
272 Macro to get the Transaction speed of a Bus realisation configuration |
|
273 */ |
|
274 #define GET_TRANS_SPEED(aBusId) GET_CONF_FIELD(aBusId,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT) |
|
275 /** |
|
276 @publishedPartner |
|
277 @prototype 9.6 |
|
278 Macro to set the Slave address of a Bus realisation configuration |
|
279 */ |
|
280 #define SET_SLAVE_ADDR(aBusId,aSlaveAddr) SET_CONF_FIELD(aBusId,aSlaveAddr,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT) |
|
281 /** |
|
282 @publishedPartner |
|
283 @prototype 9.6 |
|
284 Macro to get the Slave address of a Bus realisation configuration |
|
285 */ |
|
286 #define GET_SLAVE_ADDR(aBusId) GET_CONF_FIELD(aBusId,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT) |
|
287 |
|
288 |
|
289 // The SET_CONFIG_FIELD and GET_CONFIG_FIELD are for internal use, only. |
|
290 // They are to support the TIicBusRealisation class |
|
291 // These macros should be considered deprecated - they will be removed when the TIicBusRealisation class is removed |
|
292 #define SET_CONFIG_FIELD(aField,aMask,aShift) iConfig=(iConfig&~(aMask<<aShift))|((aField&aMask)<<aShift) |
|
293 #define GET_CONFIG_FIELD(aField,aMask,aShift) aField=((iConfig>>aShift)&aMask) |
|
294 |
|
295 /** |
|
296 @publishedPartner |
|
297 @deprecated |
|
298 |
|
299 Class to represent and provide access to configuration data used on a per-transaction basis with IIC |
|
300 |
|
301 */ |
|
302 class TIicBusRealisationConfig |
|
303 { |
|
304 public: |
|
305 // default constructor - just resets the value.. |
|
306 inline TIicBusRealisationConfig() : iConfig(0) {} |
|
307 |
|
308 inline TIicBusRealisationConfig& operator=(const TIicBusRealisationConfig &aObj){iConfig = aObj.GetConfig(); return *this;} |
|
309 |
|
310 inline void Clear() {iConfig = 0;} |
|
311 inline TUint32 GetConfig() const {return iConfig;} |
|
312 inline void SetConfig(TUint32 aConfig) {iConfig = aConfig;} |
|
313 |
|
314 inline void SetHsMasterAddr(TUint8 aHsMasterAddr) {SET_CONFIG_FIELD(aHsMasterAddr,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT);}; |
|
315 inline void GetHsMasterAddr(TUint8& aHsMasterAddr) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT);aHsMasterAddr=(TUint8)tempVar;};}; |
|
316 |
|
317 inline void SetHsValid(TUint8 aHsValid) {SET_CONFIG_FIELD(aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT);}; |
|
318 inline void GetHsValid(TUint8& aHsValid) const{{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT);aHsValid=(TUint8)tempVar;};}; |
|
319 |
|
320 inline void SetBusType(TUint8 aBusType) {SET_CONFIG_FIELD(aBusType,BUS_TYPE_MASK,BUS_TYPE_SHIFT);}; |
|
321 inline void GetBusType(TUint8& aBusType) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,BUS_TYPE_MASK,BUS_TYPE_SHIFT);aBusType=(TUint8)tempVar;};}; |
|
322 |
|
323 inline void SetChanNum(TUint8 aChanNum) {SET_CONFIG_FIELD(aChanNum,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT);}; |
|
324 inline void GetChanNum(TUint8& aChanNum) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT);aChanNum=(TUint8)tempVar;};}; |
|
325 |
|
326 inline void SetTransSpeed(TUint8 aTransSpeed) {SET_CONFIG_FIELD(aTransSpeed,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT);}; |
|
327 inline void GetTransSpeed(TUint8& aTransSpeed) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT);aTransSpeed=(TUint8)tempVar;};}; |
|
328 |
|
329 inline void SetSlaveAddr(TUint16 aSlaveAddr) {SET_CONFIG_FIELD(aSlaveAddr,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT);}; |
|
330 inline void GetSlaveAddr(TUint16& aSlaveAddr) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT);aSlaveAddr=(TUint16)tempVar;};}; |
|
331 |
|
332 private: |
|
333 TUint32 iConfig; |
|
334 }; |
|
335 |
|
336 |
|
337 // Forward declarations |
|
338 class TIicBusTransaction; |
|
339 class DIicBusChannelMaster; |
|
340 |
|
341 // |
|
342 // Master-side items |
|
343 // |
|
344 |
|
345 /** |
|
346 @publishedPartner |
|
347 @prototype 9.6 |
|
348 |
|
349 Class to represent and provide access to configuration data used on a per-transaction basis with IIC |
|
350 |
|
351 @see TIicBusTransaction |
|
352 |
|
353 */ |
|
354 class TIicBusTransfer |
|
355 { |
|
356 public: |
|
357 enum TReqType |
|
358 { |
|
359 EMasterRead, |
|
360 EMasterWrite, |
|
361 }; |
|
362 // the client interface for creating and linking simple requests |
|
363 // default constructor.. |
|
364 inline TIicBusTransfer(); |
|
365 inline TIicBusTransfer(TReqType aType, TInt8 aGranularity, TDes8* aBuffer); |
|
366 inline void LinkAfter(TIicBusTransfer* aPrev); |
|
367 inline TInt8 WordWidth(); |
|
368 inline TReqType Direction(); |
|
369 inline TInt Length(); |
|
370 inline const TIicBusTransfer* Next(); |
|
371 |
|
372 inline TInt SetTransferData(TReqType aType, TInt8 aGranularity, TDes8* aBuffer); |
|
373 const TDes8* GetBuffer() {return (const TDes8*)iBuffer;} |
|
374 |
|
375 private: |
|
376 TInt8 iType; // as one of TReqType |
|
377 TInt8 iBufGranularity; // width of a transfer word in bits |
|
378 TInt8 iSpare1; |
|
379 TDes8* iBuffer; // the data for this transfer (packed into 8-bit words with padding). Access must be guarded for safety. |
|
380 TIicBusTransfer* iNext; |
|
381 TIicBusTransaction* iTransaction; // pointer to the TIicBusTransaction owning the list that this transfer has been added to |
|
382 |
|
383 friend class TIicBusTransaction; |
|
384 friend class DIicBusChannelMaster; |
|
385 }; |
|
386 |
|
387 const TInt8 KTransferQueued = 0x01; |
|
388 /** |
|
389 @publishedPartner |
|
390 @prototype 9.6 |
|
391 |
|
392 Definition of function prototype for a callback function provided by a client |
|
393 for invocation on the after the client transaction has been processed by a Master |
|
394 channel. The function will be executed in the context of the client thread. |
|
395 |
|
396 @see TIicBusTransaction |
|
397 |
|
398 */ |
|
399 typedef void (*TIicBusCbFn)(TIicBusTransaction* /*aTransction*/, |
|
400 TInt /*aBusId*/, |
|
401 TInt /*aResult*/, |
|
402 TAny* /*aParam*/); |
|
403 |
|
404 class TIicBusCallback; // Forward declaration |
|
405 |
|
406 /** |
|
407 @publishedPartner |
|
408 @prototype 9.6 |
|
409 |
|
410 Class to represent a transaction for processing by an IIC Master Channel |
|
411 |
|
412 @see IicBus |
|
413 |
|
414 */ |
|
415 class TIicBusTransaction : public SOrdQueLink |
|
416 { |
|
417 public: |
|
418 enum TState {EFree,EDelivered,EAccepted}; |
|
419 |
|
420 //default constuctor. |
|
421 inline TIicBusTransaction(); |
|
422 |
|
423 // the client interface for creating half duplex transactions |
|
424 inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TInt aPriority=0); |
|
425 inline ~TIicBusTransaction(); |
|
426 inline TInt SetHalfDuplexTrans(TDes8* aHeader, TIicBusTransfer* aHdTrans); |
|
427 |
|
428 // The client interface for setting full duplex transaction: the API checks that it is possible to have the 2 transactions done in parallel. |
|
429 // It does not check if the channel supports full duplex, so the transaction may still fail at queuing time. |
|
430 inline TInt SetFullDuplexTrans(TIicBusTransfer* aFdTrans); |
|
431 inline TInt RemoveTrans(TIicBusTransfer* aTrans); |
|
432 // Client interface to explicitly disassociate transfer lists from the transaction, when the |
|
433 // transaction is in state EFree. |
|
434 // These methods are for optional use. If the transfer list will not be further accessed, |
|
435 // then there is no need to explicitly disassociate it from a transaction. However, if |
|
436 // it will be accessed again its iTransaction pointer will refer to this object, so should |
|
437 // be cleared to prevent corruption - and this is the purpose of these methods. |
|
438 inline TInt RemoveHalfDuplexTrans(); |
|
439 inline TInt RemoveFullDuplexTrans(); |
|
440 |
|
441 // Accessor method to allow PSL access to iFlags to determine transaction type |
|
442 inline TUint Flags(); |
|
443 protected: |
|
444 inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TUint8 aFlags, TInt aPriority=0); |
|
445 public: |
|
446 inline TUint8 State(); |
|
447 inline TInt GetBusId(); |
|
448 private: |
|
449 TDes8* iHeader; |
|
450 TUint8 iFlags; // used to indicate if it supports a preamble |
|
451 TUint8 iState; |
|
452 TInt8 iSpare1; |
|
453 TInt8 iSpare2; |
|
454 #ifdef STANDALONE_CHANNEL |
|
455 //iBusId is needed by client when calling QueueTransaction |
|
456 public: |
|
457 TInt iBusId; |
|
458 #else |
|
459 private: |
|
460 TInt iBusId; |
|
461 #endif |
|
462 TIicBusTransfer* iHalfDuplexTrans; |
|
463 TIicBusTransfer* iFullDuplexTrans; |
|
464 TIicBusCallback* iCallback; |
|
465 |
|
466 NFastSemaphore iSyncNotification; |
|
467 TInt iResult; |
|
468 friend class DIicBusChannelMaster; |
|
469 #ifndef STANDALONE_CHANNEL |
|
470 friend class DIicBusController; |
|
471 #endif |
|
472 }; |
|
473 |
|
474 |
|
475 /** |
|
476 @publishedPartner |
|
477 @prototype 9.6 |
|
478 |
|
479 Class to represent a callback object for use with asynchronous transactions processed by IIC Master channels |
|
480 |
|
481 @see IicBus |
|
482 |
|
483 */ |
|
484 class TIicBusCallback : public TDfc |
|
485 { |
|
486 public: |
|
487 inline TIicBusCallback(TIicBusCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority); |
|
488 inline ~TIicBusCallback(); |
|
489 private: |
|
490 inline static void DfcFunc(TAny* aPtr); |
|
491 private: |
|
492 TIicBusTransaction* iTransaction; |
|
493 TInt iBusId; |
|
494 TInt iResult; // the result of this transaction as a system wide error |
|
495 TAny* iParam; |
|
496 TIicBusCbFn iCallback; |
|
497 |
|
498 friend class DIicBusChannelMaster; |
|
499 }; |
|
500 |
|
501 // Forward declarations |
|
502 class DIicBusChannelSlave; |
|
503 class TIicBusSlaveCallback; |
|
504 |
|
505 /** |
|
506 @publishedPartner |
|
507 @prototype 9.6 |
|
508 |
|
509 Definition of function prototype for a callback function provided by a client |
|
510 for invocation when an asynchronous event (such as a notification, or completion |
|
511 of the asynchronous capture of a channel) occurs for a Slave channel. |
|
512 |
|
513 @see IicBus |
|
514 |
|
515 */ |
|
516 typedef void (*TIicBusSlaveCbFn)(TInt /*aChannelId*/, |
|
517 TInt /*aReturn*/, |
|
518 TInt /*aTrigger*/, |
|
519 TInt16 /*aRxWords*/, |
|
520 TInt16 /*aTxWords*/, |
|
521 TAny* /*aParam*/); |
|
522 |
|
523 /** |
|
524 @publishedPartner |
|
525 @prototype 9.6 |
|
526 |
|
527 A Slave callback notification object. |
|
528 It wraps a DFC in client's thread which is queued by the channel generic implementation |
|
529 when the transfer are completed asynchronously (e.g. in ISR). |
|
530 Alternatively, if the entire transaction is processed synchronously in the client's thread, |
|
531 the callback function will be called directly. |
|
532 |
|
533 @see IicBus |
|
534 |
|
535 */ |
|
536 NONSHARABLE_CLASS(TIicBusSlaveCallback) : public TDfc |
|
537 { |
|
538 public: |
|
539 inline TIicBusSlaveCallback(TIicBusSlaveCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority); |
|
540 inline void SetReturn(TInt aRet); // to be used by PSL |
|
541 inline void SetTxWords(TInt16 aTxWords); // to be used by PSL |
|
542 inline void SetRxWords(TInt16 aRxWords); // to be used by PSL |
|
543 |
|
544 inline TInt GetTrigger(); // to be used by PSL |
|
545 inline void SetTrigger(TInt aTrigger); // to be used by PSL |
|
546 |
|
547 private: |
|
548 IMPORT_C static void DfcFunc(TAny* aPtr); |
|
549 |
|
550 private: |
|
551 TInt iChannelId; |
|
552 TInt iReturn; // a system wide error code |
|
553 TInt iTrigger; // a bitmask containing the reason(s) why this callback was queued (see TIicBusSlaveTrigger) |
|
554 TInt16 iRxWords; // number of words received |
|
555 TInt16 iTxWords; // number of words transmitted |
|
556 TAny* iParam; |
|
557 DIicBusChannelSlave* iChannel; |
|
558 TIicBusSlaveCbFn iCallback; |
|
559 |
|
560 friend class DIicBusChannelSlave; |
|
561 }; |
|
562 |
|
563 /** |
|
564 @publishedPartner |
|
565 @prototype 9.6 |
|
566 |
|
567 Prototype function pointer for a client supplied preamble: |
|
568 The supplied function shall not: |
|
569 - spin |
|
570 - block or wait on a fast mutex |
|
571 - use any Kernel or base port services that do any of the above (e.g. alloc/free memory, |
|
572 signal a DMutex, complete a request, access user side memory) |
|
573 |
|
574 @see IicBus |
|
575 |
|
576 */ |
|
577 typedef void (*TIicBusPreamble)(TIicBusTransaction* /*aTransaction*/, |
|
578 TAny* /*aArg*/); |
|
579 |
|
580 /** |
|
581 @publishedPartner |
|
582 @prototype 9.6 |
|
583 |
|
584 Transaction which support preamble |
|
585 |
|
586 @see TIicBusTransaction |
|
587 |
|
588 */ |
|
589 class TIicBusTransactionPreamble : public TIicBusTransaction |
|
590 { |
|
591 public: |
|
592 // the client interface for creating transactions that support a preamble |
|
593 inline TIicBusTransactionPreamble(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusPreamble aPreamble, TAny* aArg, TInt aPriority=0); |
|
594 private: |
|
595 TIicBusPreamble iPreamble; // preamble function pointer |
|
596 TAny* iPreambleArg; // argument to be passed to preamble |
|
597 protected: |
|
598 inline TIicBusTransactionPreamble(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusPreamble aPreamble, TAny* aArg, TUint8 aFlags, TInt aPriority=0); |
|
599 friend class DIicBusChannelMaster; |
|
600 }; |
|
601 |
|
602 /** |
|
603 @publishedPartner |
|
604 @prototype 9.6 |
|
605 |
|
606 Prototype function pointer for a client supplied multi transaction callback. |
|
607 The function should return a pointer to a new transaction which will be send |
|
608 within the same request. The function is called in the channel thread after |
|
609 calling channel PSL DoRequest |
|
610 |
|
611 @see TIicBusTransaction |
|
612 |
|
613 */ |
|
614 typedef TIicBusTransaction* (*TIicBusMultiTranscCbFn) ( |
|
615 TIicBusTransaction* /*aTransaction*/, |
|
616 TAny* /*aArg*/); |
|
617 |
|
618 /** |
|
619 @publishedPartner |
|
620 @prototype 9.6 |
|
621 |
|
622 Transaction which support multi-transaction |
|
623 |
|
624 @see TIicBusTransaction |
|
625 |
|
626 */ |
|
627 class TIicBusTransactionMultiTransc : public TIicBusTransaction |
|
628 { |
|
629 public: |
|
630 inline TIicBusTransactionMultiTransc(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusMultiTranscCbFn aMultiTransc, TAny* aArg, TInt aPriority=0); |
|
631 private: |
|
632 TIicBusMultiTranscCbFn iMultiTransc; |
|
633 TAny* iMultiTranscArg; |
|
634 friend class DIicBusChannelMaster; |
|
635 }; |
|
636 |
|
637 /** |
|
638 @publishedPartner |
|
639 @prototype 9.6 |
|
640 |
|
641 Transaction which support both preamble and multi-transaction |
|
642 |
|
643 @see TIicBusTransactionPreamble |
|
644 |
|
645 */ |
|
646 class TIicBusTransactionPreambleExt : public TIicBusTransactionPreamble |
|
647 { |
|
648 public: |
|
649 inline TIicBusTransactionPreambleExt(TDes8* aHeader, TIicBusTransfer* aHdTrans, |
|
650 TIicBusPreamble aPreamble, TAny* aPreambleArg, |
|
651 TIicBusMultiTranscCbFn aMultiTransc, TAny* aMultiTranscArg, TInt aPriority=0); |
|
652 private: |
|
653 TIicBusMultiTranscCbFn iMultiTransc; |
|
654 TAny* iMultiTranscArg; |
|
655 friend class DIicBusChannelMaster; |
|
656 }; |
|
657 |
|
658 |
|
659 /** |
|
660 @publishedPartner |
|
661 @prototype 9.6 |
|
662 |
|
663 Enumeration of IIC Slave channel trigger values |
|
664 |
|
665 @see IicBus |
|
666 */ |
|
667 enum TIicBusSlaveTrigger |
|
668 { |
|
669 ERxAllBytes = 0x01, // Master has written the required number of bytes |
|
670 ERxUnderrun = 0x02, // Master has written less than the required number of bytes, and ceased transmitting |
|
671 ERxOverrun = 0x04, // Master has written the required number of bytes and is continuing to transmit |
|
672 ETxAllBytes = 0x08, // Master has read the required number of bytes |
|
673 ETxUnderrun = 0x10, // Master has read the required number of bytes and is continuing to read |
|
674 ETxOverrun = 0x20, // Master has read less than the required number of bytes, and ceased reading |
|
675 EGeneralBusError = 0x40, // An error has occurred during a transaction |
|
676 EAsyncCaptChan = 0x80 // Completion of asynchronous CaptureChannel |
|
677 }; |
|
678 |
|
679 #include <drivers/iic_transaction.inl> |
|
680 |
|
681 #endif // __IIC_TRANSACTION_H__ |