kerneltest/e32test/iic/iic_psl/i2c.cpp
changeset 247 d8d70de2bd36
parent 90 947f0dc9f7a8
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
    45 	I2C_PRINT(("I2C AssignChanNum - on entry, iBaseChanNum = 0x%x\n",iBaseChanNum));
    45 	I2C_PRINT(("I2C AssignChanNum - on entry, iBaseChanNum = 0x%x\n",iBaseChanNum));
    46 	return iBaseChanNum++; // Arbitrary, for illustration
    46 	return iBaseChanNum++; // Arbitrary, for illustration
    47 	}
    47 	}
    48 #endif/*STANDALONE_CHANNEL*/
    48 #endif/*STANDALONE_CHANNEL*/
    49 
    49 
    50 #ifdef SLAVE_MODE
    50 //Macros MASTER_MODE and SLAVE_MODE are intentionally omitted from this file
       
    51 //This is for master and slave stubs to exercise the channel class,
       
    52 //and we need these stubs for code coverage tests.
    51 LOCAL_C TInt16 AssignSlaveChanId()
    53 LOCAL_C TInt16 AssignSlaveChanId()
    52 	{
    54 	{
    53 	static TInt16 iBaseSlaveChanId = KI2cSlaveChannelIdBase;
    55 	static TInt16 iBaseSlaveChanId = KI2cSlaveChannelIdBase;
    54 	I2C_PRINT(("I2C AssignSlaveChanId - on entry, iBaseSlaveChanId = 0x%x\n",iBaseSlaveChanId));
    56 	I2C_PRINT(("I2C AssignSlaveChanId - on entry, iBaseSlaveChanId = 0x%x\n",iBaseSlaveChanId));
    55 	return iBaseSlaveChanId++; // Arbitrary, for illustration
    57 	return iBaseSlaveChanId++; // Arbitrary, for illustration
    56 	}
    58 	}
    57 #endif/*SLAVE_MODE*/
       
    58 
    59 
    59 NONSHARABLE_CLASS(DSimulatedI2cDevice) : public DPhysicalDevice
    60 NONSHARABLE_CLASS(DSimulatedI2cDevice) : public DPhysicalDevice
    60 	{
    61 	{
    61 // Class to faciliate loading of the IIC classes
    62 // Class to faciliate loading of the IIC classes
    62 public:
    63 public:
   228 		}
   229 		}
   229 #endif
   230 #endif
   230 	return new DSimulatedI2cDevice;
   231 	return new DSimulatedI2cDevice;
   231 	}
   232 	}
   232 
   233 
   233 
       
   234 #ifdef MASTER_MODE
       
   235 #ifdef STANDALONE_CHANNEL
   234 #ifdef STANDALONE_CHANNEL
   236 EXPORT_C
   235 EXPORT_C
   237 #endif
   236 #endif
   238 DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(const TBusType aBusType, const TChannelDuplex aChanDuplex)
   237 DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(const TBusType aBusType, const TChannelDuplex aChanDuplex)
   239 	: DIicBusChannelMaster(aBusType,aChanDuplex)
   238 	: DIicBusChannelMaster(aBusType,aChanDuplex)
   251 	TInt r=Init();	// PIL Base class initialisation
   250 	TInt r=Init();	// PIL Base class initialisation
   252 	r=Kern::DynamicDfcQCreate(iDynamicDfcQ,KI2cThreadPriority,KI2cThreadName);
   251 	r=Kern::DynamicDfcQCreate(iDynamicDfcQ,KI2cThreadPriority,KI2cThreadName);
   253 	if(r == KErrNone)
   252 	if(r == KErrNone)
   254 		SetDfcQ((TDfcQue*)iDynamicDfcQ);
   253 		SetDfcQ((TDfcQue*)iDynamicDfcQ);
   255 	DSimulatedIicBusChannelMasterI2c::SetRequestDelayed(this,EFalse);
   254 	DSimulatedIicBusChannelMasterI2c::SetRequestDelayed(this,EFalse);
       
   255 	//Call to base class DoCreate(not strictly necessary)
       
   256 	DIicBusChannelMaster::DoCreate();
   256 	return r;
   257 	return r;
   257 	}
   258 	}
   258 
   259 
   259 TInt DSimulatedIicBusChannelMasterI2c::CheckHdr(TDes8* aHdr)
   260 TInt DSimulatedIicBusChannelMasterI2c::CheckHdr(TDes8* aHdr)
   260 	{
   261 	{
   421 			break;
   422 			break;
   422 			}
   423 			}
   423 		default:
   424 		default:
   424 			{
   425 			{
   425 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
   426 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
   426 			r=KErrNotSupported;
   427 			//For default case call the base class method for consistent handling
       
   428             r=DIicBusChannelMaster::StaticExtension(aFunction,NULL,NULL);
   427 			}
   429 			}
   428 		}
   430 		}
   429 		
   431 		
   430 #ifdef IIC_INSTRUMENTATION_MACRO
   432 #ifdef IIC_INSTRUMENTATION_MACRO
   431 	IIC_MSTATEXT_END_PSL_TRACE;
   433 	IIC_MSTATEXT_END_PSL_TRACE;
   432 #endif		
   434 #endif		
   433 	return r;
   435 	return r;
   434 	}
   436 	}
   435 
       
   436 //#ifdef MASTER_MODE
       
   437 #endif
       
   438 
       
   439 #ifdef SLAVE_MODE
       
   440 
   437 
   441 void DSimulatedIicBusChannelSlaveI2c::SlaveAsyncSimCallback(TAny* aPtr)
   438 void DSimulatedIicBusChannelSlaveI2c::SlaveAsyncSimCallback(TAny* aPtr)
   442 	{
   439 	{
   443 	// To support simulating an asynchronous capture operation
   440 	// To support simulating an asynchronous capture operation
   444 	I2C_PRINT(("SlaveAsyncSimCallback\n"));
   441 	I2C_PRINT(("SlaveAsyncSimCallback\n"));
  1040 			}
  1037 			}
  1041 
  1038 
  1042 		default:
  1039 		default:
  1043 			{
  1040 			{
  1044 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
  1041 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
  1045 			r=KErrNotSupported;
  1042 			//For default case call the base class method for consistent handling
       
  1043             r=DIicBusChannelSlave::StaticExtension(aFunction,NULL,NULL);
  1046 			}
  1044 			}
  1047 		}
  1045 		}
  1048 #ifdef IIC_INSTRUMENTATION_MACRO
  1046 #ifdef IIC_INSTRUMENTATION_MACRO
  1049 	IIC_SSTATEXT_END_PSL_TRACE;
  1047 	IIC_SSTATEXT_END_PSL_TRACE;
  1050 #endif
  1048 #endif
  1051 	return r;
  1049 	return r;
  1052 	}
  1050 	}
  1053 
  1051 
  1054 
       
  1055 
       
  1056 //#ifdef MASTER_MODE
       
  1057 #endif
       
  1058 
       
  1059 #if defined(MASTER_MODE) && defined(SLAVE_MODE)
       
  1060 #ifdef STANDALONE_CHANNEL
  1052 #ifdef STANDALONE_CHANNEL
  1061 EXPORT_C
  1053 EXPORT_C
  1062 #endif
  1054 #endif
  1063 DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(TBusType /*aBusType*/, TChannelDuplex aChanDuplex, DSimulatedIicBusChannelMasterI2c* aMasterChan, DSimulatedIicBusChannelSlaveI2c* aSlaveChan)
  1055 DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(TBusType /*aBusType*/, TChannelDuplex aChanDuplex, DSimulatedIicBusChannelMasterI2c* aMasterChan, DSimulatedIicBusChannelSlaveI2c* aSlaveChan)
  1064 	: DIicBusChannelMasterSlave(EI2c, aChanDuplex, aMasterChan, aSlaveChan)
  1056 	: DIicBusChannelMasterSlave(EI2c, aChanDuplex, aMasterChan, aSlaveChan)
  1105 			break;
  1097 			break;
  1106 			}
  1098 			}
  1107 		default:
  1099 		default:
  1108 			{
  1100 			{
  1109 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
  1101 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
  1110 			r=KErrNotSupported;
  1102 			//For default case call the base class method for consistent handling
       
  1103 			r=DIicBusChannelMasterSlave::StaticExtension(aFunction,NULL,NULL);
  1111 			}
  1104 			}
  1112 		}
  1105 		}
  1113 	return r;
  1106 	return r;
  1114 	}
  1107 	}
  1115 
  1108 
  1116 
  1109 
  1117 //#if defined(MASTER_MODE) && defined(SLAVE_MODE)
  1110 
  1118 #endif
  1111 
  1119 
       
  1120 
       
  1121