1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/iic_transaction.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,681 @@
1.4 +/*
1.5 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* e32/include/drivers/iic_transaction.h
1.19 +*
1.20 +*/
1.21 +
1.22 +// WARNING: This file contains some APIs which are internal and are subject
1.23 +// to change without notice. Such APIs should therefore not be used
1.24 +// outside the Kernel and Hardware Services package.
1.25 +
1.26 +/**
1.27 +@file
1.28 +@internalTechnology
1.29 +*/
1.30 +
1.31 +#ifndef __IIC_TRANSACTION_H__
1.32 +#define __IIC_TRANSACTION_H__
1.33 +
1.34 +#include <kernel/kern_priv.h> // for DThread;
1.35 +#include <e32ver.h>
1.36 +
1.37 +static const char KIicPanic[]="Iic PIL";
1.38 +
1.39 +const TInt KNumTrancPriorities=8;
1.40 +const TUint8 KTransactionWithPreamble = 0x80;
1.41 +const TUint8 KTransactionWithMultiTransc = 0x40;
1.42 +
1.43 +#ifdef _DEBUG
1.44 +static const TUint KCtrlIoDumpChan = 1; // StaticExtension value reserved for printing a channel
1.45 +#endif
1.46 +
1.47 +/**
1.48 +@publishedPartner
1.49 +@prototype 9.6
1.50 +
1.51 +The set of endianness values for use with IIC buses
1.52 +
1.53 +*/
1.54 +enum TEndianness
1.55 + {
1.56 + EBigEndian,
1.57 + ELittleEndian
1.58 + };
1.59 +
1.60 +/**
1.61 +@publishedPartner
1.62 +@prototype 9.6
1.63 +
1.64 +The set of bit-order values for use with IIC buses
1.65 +
1.66 +*/
1.67 +enum TBitOrder
1.68 + {
1.69 + ELsbFirst,
1.70 + EMsbFirst
1.71 + };
1.72 +
1.73 +//
1.74 +// Bus-specific configuration for SPI bus
1.75 +//
1.76 +
1.77 +/**
1.78 +@publishedPartner
1.79 +@prototype 9.6
1.80 +
1.81 +The set of word-width values for use with TConfigSpiV01
1.82 +
1.83 +@see TConfigSpiV01
1.84 +
1.85 +*/
1.86 +enum TSpiWordWidth
1.87 + {
1.88 + ESpiWordWidth_8,
1.89 + ESpiWordWidth_10,
1.90 + ESpiWordWidth_12,
1.91 + ESpiWordWidth_16
1.92 + };
1.93 +
1.94 +/**
1.95 +@publishedPartner
1.96 +@prototype 9.6
1.97 +
1.98 +The set of clock mode values for use with TConfigSpiV01
1.99 +
1.100 +@see TConfigSpiV01
1.101 +
1.102 +*/
1.103 +enum TSpiClkMode
1.104 + {
1.105 + ESpiPolarityLowRisingEdge, // Active high, odd edges
1.106 + ESpiPolarityLowFallingEdge, // Active high, even edges
1.107 + ESpiPolarityHighFallingEdge, // Active low, odd edges
1.108 + ESpiPolarityHighRisingEdge // Active low, even edges
1.109 + };
1.110 +
1.111 +/**
1.112 +@publishedPartner
1.113 +@prototype 9.6
1.114 +
1.115 +The set of values to represent the pin sense when selecting a Slave
1.116 +
1.117 +@see TConfigSpiV01
1.118 +
1.119 +*/
1.120 +enum TSpiSsPinMode
1.121 + {
1.122 + ESpiCSPinActiveLow, // Active low
1.123 + ESpiCSPinActiveHigh // Active high
1.124 + };
1.125 +
1.126 +/**
1.127 +@publishedPartner
1.128 +@prototype 9.6
1.129 +
1.130 +Class to represent the configuration data for a SPI bus channel registered with IIC
1.131 +
1.132 +*/
1.133 +class TConfigSpiV01
1.134 + {
1.135 +public:
1.136 + TSpiWordWidth iWordWidth;
1.137 + TInt32 iClkSpeedHz;
1.138 + TSpiClkMode iClkMode;
1.139 + TInt32 iTimeoutPeriod;
1.140 + TEndianness iEndianness;
1.141 + TBitOrder iBitOrder;
1.142 + TUint iTransactionWaitCycles;
1.143 + TSpiSsPinMode iSSPinActiveMode;
1.144 + };
1.145 +
1.146 +typedef TPckgBuf <TConfigSpiV01> TConfigSpiBufV01;
1.147 +
1.148 +
1.149 +//
1.150 +// Bus-specific configuration for I2C bus
1.151 +//
1.152 +
1.153 +/**
1.154 +@publishedPartner
1.155 +@prototype 9.6
1.156 +
1.157 +The set of address types for use with TConfigI2cV01
1.158 +
1.159 +@see TConfigI2cV01
1.160 +
1.161 +*/
1.162 +enum TI2cAddrType
1.163 + {
1.164 + EI2cAddr7Bit,
1.165 + EI2cAddr10Bit
1.166 + };
1.167 +
1.168 +
1.169 +/**
1.170 +@publishedPartner
1.171 +@prototype 9.6
1.172 +
1.173 +Class to represent the configuration data for a I2C bus channel registered with IIC
1.174 +
1.175 +*/
1.176 +class TConfigI2cV01
1.177 + {
1.178 + public:
1.179 + TI2cAddrType iAddrType; // 7 or 10-bit addressing
1.180 + TInt32 iClkSpeedHz;
1.181 + TEndianness iEndianness;
1.182 + TInt32 iTimeoutPeriod;
1.183 + };
1.184 +
1.185 +typedef TPckgBuf <TConfigI2cV01> TConfigI2cBufV01;
1.186 +
1.187 +
1.188 +
1.189 +// Bus realisation configuration
1.190 +//
1.191 +// 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
1.192 +//
1.193 +// 31:29 - HS Master address (I2C only)
1.194 +// 28 - HS address valid bit
1.195 +// 27:23 - Reserved
1.196 +// 22:20 - Bus type
1.197 +// 19:15 - Channel number
1.198 +// 14:10 - Transaction speed
1.199 +// 9:0 - Slave address
1.200 +#define HS_MASTER_ADDR_SHIFT 29
1.201 +#define HS_MASTER_ADDR_MASK 0x7
1.202 +#define HS_ADDR_VALID_SHIFT 28
1.203 +#define HS_ADDR_VALID_MASK 0x1
1.204 +#define BUS_TYPE_SHIFT 20
1.205 +#define BUS_TYPE_MASK 0x7
1.206 +#define CHANNEL_NO_SHIFT 15
1.207 +#define CHANNEL_NO_MASK 0x1F
1.208 +#define TRANS_SPEED_SHIFT 10
1.209 +#define TRANS_SPEED_MASK 0x1F
1.210 +#define SLAVE_ADDR_SHIFT 0
1.211 +#define SLAVE_ADDR_MASK 0x3FF
1.212 +
1.213 +// The SET_CONF_FIELD and GET_CONF_FIELD are for internal use, only.
1.214 +// They are to support the set of macros below which access particular fields of the Bus realisation configuration
1.215 +#define SET_CONF_FIELD(aBusId,aField,aMask,aShift) aBusId=(aBusId&~(aMask<<aShift))|((aField&aMask)<<aShift);
1.216 +#define GET_CONF_FIELD(aBusId,aMask,aShift) (((aBusId)>>(aShift))&(aMask))
1.217 +
1.218 +/**
1.219 +@publishedPartner
1.220 +@prototype 9.6
1.221 +Macro to get the HS Master address of a Bus realisation configuration
1.222 +*/
1.223 +#define GET_HS_MASTER_ADDR(aBusId) GET_CONF_FIELD(aBusId,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT)
1.224 +/**
1.225 +@publishedPartner
1.226 +@prototype 9.6
1.227 +Macro to set the HS Master address of a Bus realisation configuration
1.228 +*/
1.229 +#define SET_HS_MASTER_ADDR(aBusId,aHsMasterAddr) SET_CONF_FIELD(aBusId,aHsMasterAddr,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT)
1.230 +/**
1.231 +@publishedPartner
1.232 +@prototype 9.6
1.233 +Macro to get the HS address valid bit of a Bus realisation configuration
1.234 +*/
1.235 +#define GET_HS_VALID(aBusId,aHsValid) GET_CONF_FIELD(aBusId,aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT)
1.236 +/**
1.237 +@publishedPartner
1.238 +@prototype 9.6
1.239 +Macro to set the HS address valid bit of a Bus realisation configuration
1.240 +*/
1.241 +#define SET_HS_VALID(aBusId,aHsValid) SET_CONF_FIELD(aBusId,aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT)
1.242 +/**
1.243 +@publishedPartner
1.244 +@prototype 9.6
1.245 +Macro to get the Bus type of a Bus realisation configuration
1.246 +*/
1.247 +#define GET_BUS_TYPE(aBusId) GET_CONF_FIELD(aBusId,BUS_TYPE_MASK,BUS_TYPE_SHIFT)
1.248 +/**
1.249 +@publishedPartner
1.250 +@prototype 9.6
1.251 +Macro to set the Bus type of a Bus realisation configuration
1.252 +*/
1.253 +#define SET_BUS_TYPE(aBusId,aBusType) SET_CONF_FIELD(aBusId,aBusType,BUS_TYPE_MASK,BUS_TYPE_SHIFT)
1.254 +/**
1.255 +@publishedPartner
1.256 +@prototype 9.6
1.257 +Macro to get the Channel number of a Bus realisation configuration
1.258 +*/
1.259 +#define GET_CHAN_NUM(aBusId) GET_CONF_FIELD(aBusId,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT)
1.260 +/**
1.261 +@publishedPartner
1.262 +@prototype 9.6
1.263 +Macro to set the Channel number of a Bus realisation configuration
1.264 +*/
1.265 +#define SET_CHAN_NUM(aBusId,aChanNum) SET_CONF_FIELD(aBusId,aChanNum,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT)
1.266 +/**
1.267 +@publishedPartner
1.268 +@prototype 9.6
1.269 +Macro to set the Transaction speed of a Bus realisation configuration
1.270 +*/
1.271 +#define SET_TRANS_SPEED(aBusId,aTransSpeed) SET_CONF_FIELD(aBusId,aTransSpeed,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT)
1.272 +/**
1.273 +@publishedPartner
1.274 +@prototype 9.6
1.275 +Macro to get the Transaction speed of a Bus realisation configuration
1.276 +*/
1.277 +#define GET_TRANS_SPEED(aBusId) GET_CONF_FIELD(aBusId,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT)
1.278 +/**
1.279 +@publishedPartner
1.280 +@prototype 9.6
1.281 +Macro to set the Slave address of a Bus realisation configuration
1.282 +*/
1.283 +#define SET_SLAVE_ADDR(aBusId,aSlaveAddr) SET_CONF_FIELD(aBusId,aSlaveAddr,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT)
1.284 +/**
1.285 +@publishedPartner
1.286 +@prototype 9.6
1.287 +Macro to get the Slave address of a Bus realisation configuration
1.288 +*/
1.289 +#define GET_SLAVE_ADDR(aBusId) GET_CONF_FIELD(aBusId,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT)
1.290 +
1.291 +
1.292 +// The SET_CONFIG_FIELD and GET_CONFIG_FIELD are for internal use, only.
1.293 +// They are to support the TIicBusRealisation class
1.294 +// These macros should be considered deprecated - they will be removed when the TIicBusRealisation class is removed
1.295 +#define SET_CONFIG_FIELD(aField,aMask,aShift) iConfig=(iConfig&~(aMask<<aShift))|((aField&aMask)<<aShift)
1.296 +#define GET_CONFIG_FIELD(aField,aMask,aShift) aField=((iConfig>>aShift)&aMask)
1.297 +
1.298 +/**
1.299 +@publishedPartner
1.300 +@deprecated
1.301 +
1.302 +Class to represent and provide access to configuration data used on a per-transaction basis with IIC
1.303 +
1.304 +*/
1.305 +class TIicBusRealisationConfig
1.306 + {
1.307 +public:
1.308 + // default constructor - just resets the value..
1.309 + inline TIicBusRealisationConfig() : iConfig(0) {}
1.310 +
1.311 + inline TIicBusRealisationConfig& operator=(const TIicBusRealisationConfig &aObj){iConfig = aObj.GetConfig(); return *this;}
1.312 +
1.313 + inline void Clear() {iConfig = 0;}
1.314 + inline TUint32 GetConfig() const {return iConfig;}
1.315 + inline void SetConfig(TUint32 aConfig) {iConfig = aConfig;}
1.316 +
1.317 + inline void SetHsMasterAddr(TUint8 aHsMasterAddr) {SET_CONFIG_FIELD(aHsMasterAddr,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT);};
1.318 + inline void GetHsMasterAddr(TUint8& aHsMasterAddr) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,HS_MASTER_ADDR_MASK,HS_MASTER_ADDR_SHIFT);aHsMasterAddr=(TUint8)tempVar;};};
1.319 +
1.320 + inline void SetHsValid(TUint8 aHsValid) {SET_CONFIG_FIELD(aHsValid,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT);};
1.321 + inline void GetHsValid(TUint8& aHsValid) const{{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,HS_ADDR_VALID_MASK,HS_ADDR_VALID_SHIFT);aHsValid=(TUint8)tempVar;};};
1.322 +
1.323 + inline void SetBusType(TUint8 aBusType) {SET_CONFIG_FIELD(aBusType,BUS_TYPE_MASK,BUS_TYPE_SHIFT);};
1.324 + inline void GetBusType(TUint8& aBusType) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,BUS_TYPE_MASK,BUS_TYPE_SHIFT);aBusType=(TUint8)tempVar;};};
1.325 +
1.326 + inline void SetChanNum(TUint8 aChanNum) {SET_CONFIG_FIELD(aChanNum,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT);};
1.327 + inline void GetChanNum(TUint8& aChanNum) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,CHANNEL_NO_MASK,CHANNEL_NO_SHIFT);aChanNum=(TUint8)tempVar;};};
1.328 +
1.329 + inline void SetTransSpeed(TUint8 aTransSpeed) {SET_CONFIG_FIELD(aTransSpeed,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT);};
1.330 + inline void GetTransSpeed(TUint8& aTransSpeed) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,TRANS_SPEED_MASK,TRANS_SPEED_SHIFT);aTransSpeed=(TUint8)tempVar;};};
1.331 +
1.332 + inline void SetSlaveAddr(TUint16 aSlaveAddr) {SET_CONFIG_FIELD(aSlaveAddr,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT);};
1.333 + inline void GetSlaveAddr(TUint16& aSlaveAddr) const {{TUint32 tempVar;GET_CONFIG_FIELD(tempVar,SLAVE_ADDR_MASK,SLAVE_ADDR_SHIFT);aSlaveAddr=(TUint16)tempVar;};};
1.334 +
1.335 +private:
1.336 + TUint32 iConfig;
1.337 + };
1.338 +
1.339 +
1.340 +// Forward declarations
1.341 +class TIicBusTransaction;
1.342 +class DIicBusChannelMaster;
1.343 +
1.344 +//
1.345 +// Master-side items
1.346 +//
1.347 +
1.348 +/**
1.349 +@publishedPartner
1.350 +@prototype 9.6
1.351 +
1.352 +Class to represent and provide access to configuration data used on a per-transaction basis with IIC
1.353 +
1.354 +@see TIicBusTransaction
1.355 +
1.356 +*/
1.357 +class TIicBusTransfer
1.358 + {
1.359 +public:
1.360 + enum TReqType
1.361 + {
1.362 + EMasterRead,
1.363 + EMasterWrite,
1.364 + };
1.365 + // the client interface for creating and linking simple requests
1.366 + // default constructor..
1.367 + inline TIicBusTransfer();
1.368 + inline TIicBusTransfer(TReqType aType, TInt8 aGranularity, TDes8* aBuffer);
1.369 + inline void LinkAfter(TIicBusTransfer* aPrev);
1.370 + inline TInt8 WordWidth();
1.371 + inline TReqType Direction();
1.372 + inline TInt Length();
1.373 + inline const TIicBusTransfer* Next();
1.374 +
1.375 + inline TInt SetTransferData(TReqType aType, TInt8 aGranularity, TDes8* aBuffer);
1.376 + const TDes8* GetBuffer() {return (const TDes8*)iBuffer;}
1.377 +
1.378 +private:
1.379 + TInt8 iType; // as one of TReqType
1.380 + TInt8 iBufGranularity; // width of a transfer word in bits
1.381 + TInt8 iSpare1;
1.382 + TDes8* iBuffer; // the data for this transfer (packed into 8-bit words with padding). Access must be guarded for safety.
1.383 + TIicBusTransfer* iNext;
1.384 + TIicBusTransaction* iTransaction; // pointer to the TIicBusTransaction owning the list that this transfer has been added to
1.385 +
1.386 + friend class TIicBusTransaction;
1.387 + friend class DIicBusChannelMaster;
1.388 + };
1.389 +
1.390 +const TInt8 KTransferQueued = 0x01;
1.391 +/**
1.392 +@publishedPartner
1.393 +@prototype 9.6
1.394 +
1.395 +Definition of function prototype for a callback function provided by a client
1.396 +for invocation on the after the client transaction has been processed by a Master
1.397 +channel. The function will be executed in the context of the client thread.
1.398 +
1.399 +@see TIicBusTransaction
1.400 +
1.401 +*/
1.402 +typedef void (*TIicBusCbFn)(TIicBusTransaction* /*aTransction*/,
1.403 + TInt /*aBusId*/,
1.404 + TInt /*aResult*/,
1.405 + TAny* /*aParam*/);
1.406 +
1.407 +class TIicBusCallback; // Forward declaration
1.408 +
1.409 +/**
1.410 +@publishedPartner
1.411 +@prototype 9.6
1.412 +
1.413 +Class to represent a transaction for processing by an IIC Master Channel
1.414 +
1.415 +@see IicBus
1.416 +
1.417 +*/
1.418 +class TIicBusTransaction : public SOrdQueLink
1.419 + {
1.420 + public:
1.421 + enum TState {EFree,EDelivered,EAccepted};
1.422 +
1.423 + //default constuctor.
1.424 + inline TIicBusTransaction();
1.425 +
1.426 + // the client interface for creating half duplex transactions
1.427 + inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TInt aPriority=0);
1.428 + inline ~TIicBusTransaction();
1.429 + inline TInt SetHalfDuplexTrans(TDes8* aHeader, TIicBusTransfer* aHdTrans);
1.430 +
1.431 + // The client interface for setting full duplex transaction: the API checks that it is possible to have the 2 transactions done in parallel.
1.432 + // It does not check if the channel supports full duplex, so the transaction may still fail at queuing time.
1.433 + inline TInt SetFullDuplexTrans(TIicBusTransfer* aFdTrans);
1.434 + inline TInt RemoveTrans(TIicBusTransfer* aTrans);
1.435 + // Client interface to explicitly disassociate transfer lists from the transaction, when the
1.436 + // transaction is in state EFree.
1.437 + // These methods are for optional use. If the transfer list will not be further accessed,
1.438 + // then there is no need to explicitly disassociate it from a transaction. However, if
1.439 + // it will be accessed again its iTransaction pointer will refer to this object, so should
1.440 + // be cleared to prevent corruption - and this is the purpose of these methods.
1.441 + inline TInt RemoveHalfDuplexTrans();
1.442 + inline TInt RemoveFullDuplexTrans();
1.443 +
1.444 + // Accessor method to allow PSL access to iFlags to determine transaction type
1.445 + inline TUint Flags();
1.446 + protected:
1.447 + inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TUint8 aFlags, TInt aPriority=0);
1.448 + public:
1.449 + inline TUint8 State();
1.450 + inline TInt GetBusId();
1.451 + private:
1.452 + TDes8* iHeader;
1.453 + TUint8 iFlags; // used to indicate if it supports a preamble
1.454 + TUint8 iState;
1.455 + TInt8 iSpare1;
1.456 + TInt8 iSpare2;
1.457 +#ifdef STANDALONE_CHANNEL
1.458 + //iBusId is needed by client when calling QueueTransaction
1.459 + public:
1.460 + TInt iBusId;
1.461 +#else
1.462 + private:
1.463 + TInt iBusId;
1.464 +#endif
1.465 + TIicBusTransfer* iHalfDuplexTrans;
1.466 + TIicBusTransfer* iFullDuplexTrans;
1.467 + TIicBusCallback* iCallback;
1.468 +
1.469 + NFastSemaphore iSyncNotification;
1.470 + TInt iResult;
1.471 + friend class DIicBusChannelMaster;
1.472 +#ifndef STANDALONE_CHANNEL
1.473 + friend class DIicBusController;
1.474 +#endif
1.475 + };
1.476 +
1.477 +
1.478 +/**
1.479 +@publishedPartner
1.480 +@prototype 9.6
1.481 +
1.482 +Class to represent a callback object for use with asynchronous transactions processed by IIC Master channels
1.483 +
1.484 +@see IicBus
1.485 +
1.486 +*/
1.487 +class TIicBusCallback : public TDfc
1.488 + {
1.489 +public:
1.490 + inline TIicBusCallback(TIicBusCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority);
1.491 + inline ~TIicBusCallback();
1.492 +private:
1.493 + inline static void DfcFunc(TAny* aPtr);
1.494 +private:
1.495 + TIicBusTransaction* iTransaction;
1.496 + TInt iBusId;
1.497 + TInt iResult; // the result of this transaction as a system wide error
1.498 + TAny* iParam;
1.499 + TIicBusCbFn iCallback;
1.500 +
1.501 + friend class DIicBusChannelMaster;
1.502 + };
1.503 +
1.504 +// Forward declarations
1.505 +class DIicBusChannelSlave;
1.506 +class TIicBusSlaveCallback;
1.507 +
1.508 +/**
1.509 +@publishedPartner
1.510 +@prototype 9.6
1.511 +
1.512 +Definition of function prototype for a callback function provided by a client
1.513 +for invocation when an asynchronous event (such as a notification, or completion
1.514 +of the asynchronous capture of a channel) occurs for a Slave channel.
1.515 +
1.516 +@see IicBus
1.517 +
1.518 +*/
1.519 +typedef void (*TIicBusSlaveCbFn)(TInt /*aChannelId*/,
1.520 + TInt /*aReturn*/,
1.521 + TInt /*aTrigger*/,
1.522 + TInt16 /*aRxWords*/,
1.523 + TInt16 /*aTxWords*/,
1.524 + TAny* /*aParam*/);
1.525 +
1.526 +/**
1.527 +@publishedPartner
1.528 +@prototype 9.6
1.529 +
1.530 +A Slave callback notification object.
1.531 +It wraps a DFC in client's thread which is queued by the channel generic implementation
1.532 +when the transfer are completed asynchronously (e.g. in ISR).
1.533 +Alternatively, if the entire transaction is processed synchronously in the client's thread,
1.534 +the callback function will be called directly.
1.535 +
1.536 +@see IicBus
1.537 +
1.538 +*/
1.539 +NONSHARABLE_CLASS(TIicBusSlaveCallback) : public TDfc
1.540 + {
1.541 +public:
1.542 + inline TIicBusSlaveCallback(TIicBusSlaveCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority);
1.543 + inline void SetReturn(TInt aRet); // to be used by PSL
1.544 + inline void SetTxWords(TInt16 aTxWords); // to be used by PSL
1.545 + inline void SetRxWords(TInt16 aRxWords); // to be used by PSL
1.546 +
1.547 + inline TInt GetTrigger(); // to be used by PSL
1.548 + inline void SetTrigger(TInt aTrigger); // to be used by PSL
1.549 +
1.550 +private:
1.551 + IMPORT_C static void DfcFunc(TAny* aPtr);
1.552 +
1.553 +private:
1.554 + TInt iChannelId;
1.555 + TInt iReturn; // a system wide error code
1.556 + TInt iTrigger; // a bitmask containing the reason(s) why this callback was queued (see TIicBusSlaveTrigger)
1.557 + TInt16 iRxWords; // number of words received
1.558 + TInt16 iTxWords; // number of words transmitted
1.559 + TAny* iParam;
1.560 + DIicBusChannelSlave* iChannel;
1.561 + TIicBusSlaveCbFn iCallback;
1.562 +
1.563 + friend class DIicBusChannelSlave;
1.564 + };
1.565 +
1.566 +/**
1.567 +@publishedPartner
1.568 +@prototype 9.6
1.569 +
1.570 + Prototype function pointer for a client supplied preamble:
1.571 +The supplied function shall not:
1.572 + - spin
1.573 + - block or wait on a fast mutex
1.574 + - use any Kernel or base port services that do any of the above (e.g. alloc/free memory,
1.575 + signal a DMutex, complete a request, access user side memory)
1.576 +
1.577 +@see IicBus
1.578 +
1.579 +*/
1.580 +typedef void (*TIicBusPreamble)(TIicBusTransaction* /*aTransaction*/,
1.581 + TAny* /*aArg*/);
1.582 +
1.583 +/**
1.584 +@publishedPartner
1.585 +@prototype 9.6
1.586 +
1.587 +Transaction which support preamble
1.588 +
1.589 +@see TIicBusTransaction
1.590 +
1.591 +*/
1.592 +class TIicBusTransactionPreamble : public TIicBusTransaction
1.593 + {
1.594 +public:
1.595 + // the client interface for creating transactions that support a preamble
1.596 + inline TIicBusTransactionPreamble(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusPreamble aPreamble, TAny* aArg, TInt aPriority=0);
1.597 +private:
1.598 + TIicBusPreamble iPreamble; // preamble function pointer
1.599 + TAny* iPreambleArg; // argument to be passed to preamble
1.600 +protected:
1.601 + inline TIicBusTransactionPreamble(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusPreamble aPreamble, TAny* aArg, TUint8 aFlags, TInt aPriority=0);
1.602 + friend class DIicBusChannelMaster;
1.603 + };
1.604 +
1.605 +/**
1.606 +@publishedPartner
1.607 +@prototype 9.6
1.608 +
1.609 +Prototype function pointer for a client supplied multi transaction callback.
1.610 +The function should return a pointer to a new transaction which will be send
1.611 +within the same request. The function is called in the channel thread after
1.612 +calling channel PSL DoRequest
1.613 +
1.614 +@see TIicBusTransaction
1.615 +
1.616 +*/
1.617 +typedef TIicBusTransaction* (*TIicBusMultiTranscCbFn) (
1.618 + TIicBusTransaction* /*aTransaction*/,
1.619 + TAny* /*aArg*/);
1.620 +
1.621 +/**
1.622 +@publishedPartner
1.623 +@prototype 9.6
1.624 +
1.625 +Transaction which support multi-transaction
1.626 +
1.627 +@see TIicBusTransaction
1.628 +
1.629 +*/
1.630 +class TIicBusTransactionMultiTransc : public TIicBusTransaction
1.631 + {
1.632 +public:
1.633 + inline TIicBusTransactionMultiTransc(TDes8* aHeader, TIicBusTransfer* aHdTrans, TIicBusMultiTranscCbFn aMultiTransc, TAny* aArg, TInt aPriority=0);
1.634 +private:
1.635 + TIicBusMultiTranscCbFn iMultiTransc;
1.636 + TAny* iMultiTranscArg;
1.637 + friend class DIicBusChannelMaster;
1.638 + };
1.639 +
1.640 +/**
1.641 +@publishedPartner
1.642 +@prototype 9.6
1.643 +
1.644 +Transaction which support both preamble and multi-transaction
1.645 +
1.646 +@see TIicBusTransactionPreamble
1.647 +
1.648 +*/
1.649 +class TIicBusTransactionPreambleExt : public TIicBusTransactionPreamble
1.650 + {
1.651 +public:
1.652 + inline TIicBusTransactionPreambleExt(TDes8* aHeader, TIicBusTransfer* aHdTrans,
1.653 + TIicBusPreamble aPreamble, TAny* aPreambleArg,
1.654 + TIicBusMultiTranscCbFn aMultiTransc, TAny* aMultiTranscArg, TInt aPriority=0);
1.655 +private:
1.656 + TIicBusMultiTranscCbFn iMultiTransc;
1.657 + TAny* iMultiTranscArg;
1.658 + friend class DIicBusChannelMaster;
1.659 + };
1.660 +
1.661 +
1.662 +/**
1.663 +@publishedPartner
1.664 +@prototype 9.6
1.665 +
1.666 +Enumeration of IIC Slave channel trigger values
1.667 +
1.668 +@see IicBus
1.669 +*/
1.670 +enum TIicBusSlaveTrigger
1.671 + {
1.672 + ERxAllBytes = 0x01, // Master has written the required number of bytes
1.673 + ERxUnderrun = 0x02, // Master has written less than the required number of bytes, and ceased transmitting
1.674 + ERxOverrun = 0x04, // Master has written the required number of bytes and is continuing to transmit
1.675 + ETxAllBytes = 0x08, // Master has read the required number of bytes
1.676 + ETxUnderrun = 0x10, // Master has read the required number of bytes and is continuing to read
1.677 + ETxOverrun = 0x20, // Master has read less than the required number of bytes, and ceased reading
1.678 + EGeneralBusError = 0x40, // An error has occurred during a transaction
1.679 + EAsyncCaptChan = 0x80 // Completion of asynchronous CaptureChannel
1.680 + };
1.681 +
1.682 +#include <drivers/iic_transaction.inl>
1.683 +
1.684 +#endif // __IIC_TRANSACTION_H__