Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "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.
18 #include "T_MmcSDPsuBaseDriverData.h"
20 //MMCSD Commands index
23 _LIT(KCmdIsLocked, "IsLocked");
24 _LIT(KCmdIsOff, "IsOff");
25 _LIT(KCmdMaxCurrentInMicroAmps, "MaxCurrentInMicroAmps");
26 _LIT(KCmdResetInactivityTimer, "ResetInactivityTimer");
27 _LIT(KCmdVoltageSupported, "VoltageSupported");
28 _LIT(KCmdInactivityCount, "InactivityCount");
29 _LIT(KCmdNotLockedCount, "NotLockedCount");
30 _LIT(KCmdInactivityTimeout, "InactivityTimeout");
31 _LIT(KCmdNotLockedTimeout, "NotLockedTimeout");
32 _LIT(KCmdMemVoltageSupported, "MemVoltageSupported");
33 _LIT(KCmdMemMaxCurrentInMicroAmps, "MemMaxCurrentInMicroAmps");
34 _LIT(KCmdVoltCheckInterval, "VoltCheckInterval");
37 _LIT(KExpectedLockState, "expectedlockstate");
38 _LIT(KExpectedPsuState, "expectedpsustate");
39 _LIT(KExpectedCurrent, "expectedcurrent");
40 _LIT(KExpectedVoltage, "expectedvoltage");
41 _LIT(KExpectedInactivityCount, "expectedinactivityCount");
42 _LIT(KExpectedNotLockedCount, "expectednotLockedCount");
43 _LIT(KExpectedInactivityTimeout, "expectedinactivityTimeout");
44 _LIT(KExpectedNotLockedTimeout, "expectednotlockedtimeOut");
45 _LIT(KExpectedMemVoltageSupported, "expectedmemVoltageSupported");
46 _LIT(KExpectedMemMaxCurrentInMicroAmps, "expectedmemMaxCurrentInMicroAmps");
47 _LIT(KExpectedVoltageinterval, "expectedvoltageinterval");
51 //////////////////////////////////////////////////////////////////////
52 // Construction/Destruction
53 //////////////////////////////////////////////////////////////////////
55 CT_MMCSDPsuBaseDriverData* CT_MMCSDPsuBaseDriverData::NewL()
57 CT_MMCSDPsuBaseDriverData* ret=new (ELeave) CT_MMCSDPsuBaseDriverData();
58 CleanupStack::PushL(ret);
60 CleanupStack::Pop(ret);
65 CT_MMCSDPsuBaseDriverData::CT_MMCSDPsuBaseDriverData()
66 : CT_MmcSDDriverData()
71 void CT_MMCSDPsuBaseDriverData::ConstructL()
73 * Second phase construction
82 * @leave system wide error
85 CT_MmcSDDriverData::ConstructL();
88 CT_MMCSDPsuBaseDriverData::~CT_MMCSDPsuBaseDriverData()
95 TBool CT_MMCSDPsuBaseDriverData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
97 * Process a command read from the ini file
99 * @param aCommand The command to process
100 * @param aSection The section in the ini containing data for the command
101 * @param aAsyncErrorIndex Command index for async calls to return errors to
103 * @return ETrue if the command is processed
105 * @leave System wide error
110 if ( aCommand==KCmdIsLocked )
112 DoCmdIsLocked(aSection);
114 else if ( aCommand==KCmdIsOff )
116 DoCmdIsOff(aSection);
118 else if ( aCommand==KCmdMaxCurrentInMicroAmps )
120 DoCmdMaxCurrentInMicroAmps(aSection);
122 else if ( aCommand==KCmdResetInactivityTimer )
124 DoCmdResetInactivityTimer();
126 else if ( aCommand==KCmdVoltageSupported)
128 DoCmdVoltageSupported(aSection);
130 else if ( aCommand==KCmdInactivityCount)
132 DoCmdInactivityCount(aSection);
134 else if ( aCommand==KCmdNotLockedCount)
136 DoCmdNotLockedCount(aSection);
138 else if ( aCommand==KCmdInactivityTimeout)
140 DoCmdInactivityTimeout(aSection);
142 else if ( aCommand==KCmdNotLockedTimeout)
144 DoCmdNotLockedTimeout(aSection);
146 else if ( aCommand==KCmdMemVoltageSupported)
148 DoCmdMemVoltageSupported(aSection);
150 else if ( aCommand==KCmdMemMaxCurrentInMicroAmps)
152 DoCmdMemMaxCurrentInMicroAmps(aSection);
154 else if ( aCommand==KCmdVoltCheckInterval)
156 DoCmdVoltCheckInterval(aSection);
160 ret=CT_MmcSDDriverData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
166 * Checks whether this PSU is powering a bus containing a locked device
167 * i.e. one that is recognised and in use by a client
169 * @param aSection The section in the ini containing data for the command
173 * @leave System wide error
175 void CT_MMCSDPsuBaseDriverData::DoCmdIsLocked(const TDesC& aSection)
179 err = iMmcSDController->IsLocked(lockstate);
182 ERR_PRINTF2(_L("Getting Lock Information Error %d"), err);
188 INFO_PRINTF2(_L("PSUBASE: IsLocked = %d \n"),lockstate);
189 TBool expectedlockstate;
190 if(GetBoolFromConfig(aSection, KExpectedLockState(), expectedlockstate))
192 if(lockstate != expectedlockstate)
194 SetBlockResult(EFail);
195 ERR_PRINTF3(_L("lockstate(%d) != expectedlockstate(%d)"), lockstate, expectedlockstate);
200 SetBlockResult(EFail);
201 WARN_PRINTF1(_L("expectedlockstate Value Missing From INI File"));
207 * Checks whether the PSU is off
209 * @param aSection The section in the ini containing data for the command
213 * @leave System wide error
215 void CT_MMCSDPsuBaseDriverData::DoCmdIsOff(const TDesC& aSection)
219 err = iMmcSDController->IsOff(psustate);
222 ERR_PRINTF2(_L("Getting PSU State Information Error %d"), err);
228 INFO_PRINTF2(_L("PSUBASE: IsOff = %d \n"),psustate);
229 TBool expectedpsustate;
230 if(GetBoolFromConfig(aSection, KExpectedPsuState(), expectedpsustate))
232 if(psustate != expectedpsustate)
234 SetBlockResult(EFail);
235 ERR_PRINTF3(_L("psustate(%d) != expectedpsustate(%d)"), psustate, expectedpsustate);
240 SetBlockResult(EFail);
241 WARN_PRINTF1(_L("expectedpsustate Value Missing From INI File"));
247 * Gets the maximum current (in microAmps) that the PSU is able to supply
249 * @param aSection The section in the ini containing data for the command
253 * @leave System wide error
255 void CT_MMCSDPsuBaseDriverData::DoCmdMaxCurrentInMicroAmps(const TDesC& aSection)
259 err = iMmcSDController->MaxCurrentInMicroAmps(current);
262 ERR_PRINTF2(_L("Getting MaxCurrentInMicroAmps Error %d"), err);
267 //MaxCurrentInMicroAmps
268 INFO_PRINTF2(_L("PSUBASE: MaxCurrentInMicroAmps = %d \n"),current);
269 TInt expectedcurrent;
270 if(GetIntFromConfig(aSection, KExpectedCurrent(), expectedcurrent))
272 if(current != expectedcurrent)
274 SetBlockResult(EFail);
275 ERR_PRINTF3(_L("current(%d) != expectedcurrent(%d)"), current, expectedcurrent);
280 SetBlockResult(EFail);
281 WARN_PRINTF1(_L("expectedcurrent Value Missing From INI File"));
287 * Resets inactivity and not-locked counts
291 * @leave System wide error
293 void CT_MMCSDPsuBaseDriverData::DoCmdResetInactivityTimer()
296 err = iMmcSDController->ResetInactivityTimer();
299 ERR_PRINTF2(_L("ResetInactivityTimer Error %d"), err);
305 * Gets the voltage level, or range of supported voltage levels
307 * @param aSection The section in the ini containing data for the command
311 * @leave System wide error
313 void CT_MMCSDPsuBaseDriverData::DoCmdVoltageSupported(const TDesC& aSection)
317 err = iMmcSDController->VoltageSupported(volt);
320 ERR_PRINTF2(_L("VoltageSupported Error %d"), err);
326 INFO_PRINTF2(_L("PSUBASE: VoltageSupported = %x \n"),volt);
328 if(GetUintFromConfig(aSection, KExpectedVoltage(), expectedvolt))
330 if(volt != expectedvolt)
332 SetBlockResult(EFail);
333 ERR_PRINTF3(_L("volt(%x) != expectedvolt(%x)"), volt, expectedvolt);
338 SetBlockResult(EFail);
339 WARN_PRINTF1(_L("expectedvolt Value Missing From INI File"));
345 * Bus inactivity counter
347 * @param aSection The section in the ini containing data for the command
351 * @leave System wide error
353 void CT_MMCSDPsuBaseDriverData::DoCmdInactivityCount(const TDesC& aSection)
356 TInt inactivityCount;
357 err = iMmcSDController->InactivityCount(inactivityCount);
360 ERR_PRINTF2(_L("InactivityCount Error %d"), err);
366 INFO_PRINTF2(_L("PSUBASE: InactivityCount = %d \n"),inactivityCount);
367 TInt expectedinactivityCount;
368 if(GetIntFromConfig(aSection, KExpectedInactivityCount(), expectedinactivityCount))
370 if(inactivityCount != expectedinactivityCount)
372 SetBlockResult(EFail);
373 ERR_PRINTF3(_L("inactivityCount(%d) != expectedinactivityCount(%d)"), inactivityCount, expectedinactivityCount);
378 SetBlockResult(EFail);
379 WARN_PRINTF1(_L("expectedinactivityCount Value Missing From INI File"));
385 * Bus not locked counter
387 * @param aSection The section in the ini containing data for the command
391 * @leave System wide error
393 void CT_MMCSDPsuBaseDriverData::DoCmdNotLockedCount(const TDesC& aSection)
397 err = iMmcSDController->NotLockedCount(notLockedCount);
400 ERR_PRINTF2(_L("NotLockedCount Error %d"), err);
406 INFO_PRINTF2(_L("PSUBASE: NotLockedCount = %d \n"),notLockedCount);
407 TInt expectednotLockedCount;
408 if(GetIntFromConfig(aSection, KExpectedNotLockedCount(), expectednotLockedCount))
410 if(notLockedCount != expectednotLockedCount)
412 SetBlockResult(EFail);
413 ERR_PRINTF3(_L("notLockedCount(%d) != expectednotLockedCount(%d)"), notLockedCount, expectednotLockedCount);
418 SetBlockResult(EFail);
419 WARN_PRINTF1(_L("expectednotLockedCount Value Missing From INI File"));
425 * Bus inactivity timeout period, in seconds, when clients are registered
427 * @param aSection The section in the ini containing data for the command
431 * @leave System wide error
433 void CT_MMCSDPsuBaseDriverData::DoCmdInactivityTimeout(const TDesC& aSection)
436 TInt inactivityTimeout;
437 err = iMmcSDController->InactivityTimeout(inactivityTimeout);
440 ERR_PRINTF2(_L("InactivityTimeout Error %d"), err);
446 INFO_PRINTF2(_L("PSUBASE: InactivityTimeout = %d \n"),inactivityTimeout);
447 TInt expectedinactivityTimeout;
448 if(GetIntFromConfig(aSection, KExpectedInactivityTimeout(), expectedinactivityTimeout))
450 if(inactivityTimeout != expectedinactivityTimeout)
452 SetBlockResult(EFail);
453 ERR_PRINTF3(_L("inactivityTimeout(%d) != expectedinactivityTimeout(%d)"), inactivityTimeout, expectedinactivityTimeout);
458 SetBlockResult(EFail);
459 WARN_PRINTF1(_L("expectedinactivityTimeout Value Missing From INI File"));
465 * Bus not locked timeout period, in seconds, when no clients are registered
467 * @param aSection The section in the ini containing data for the command
471 * @leave System wide error
473 void CT_MMCSDPsuBaseDriverData::DoCmdNotLockedTimeout(const TDesC& aSection)
476 TInt notLockedTimeout;
477 err = iMmcSDController->NotLockedTimeout(notLockedTimeout);
480 ERR_PRINTF2(_L("NotLockedTimeout Error %d"), err);
486 INFO_PRINTF2(_L("PSUBASE: NotLockedTimeout = %d \n"),notLockedTimeout);
487 TInt expectednotLockedTimeout;
488 if(GetIntFromConfig(aSection, KExpectedNotLockedTimeout(), expectednotLockedTimeout))
490 if(notLockedTimeout != expectednotLockedTimeout)
492 SetBlockResult(EFail);
493 ERR_PRINTF3(_L("notLockedTimeout(%d) != expectednotLockedTimeout(%d)"), notLockedTimeout, expectednotLockedTimeout);
498 SetBlockResult(EFail);
499 WARN_PRINTF1(_L("expectednotLockedTimeout Value Missing From INI File"));
505 * Indicates the voltage level, or range of voltages supported
507 * @param aSection The section in the ini containing data for the command
511 * @leave System wide error
513 void CT_MMCSDPsuBaseDriverData::DoCmdMemVoltageSupported(const TDesC& aSection)
516 TUint memVoltageSupported;
517 err = iMmcSDController->MemVoltageSupported(memVoltageSupported);
520 ERR_PRINTF2(_L("MemVoltageSupported Error %u"), err);
525 //MemVoltageSupported
526 INFO_PRINTF2(_L("PSUBASE: MemVoltageSupported = %x \n"),memVoltageSupported);
527 TUint expectedmemVoltageSupported;
528 if(GetUintFromConfig(aSection, KExpectedMemVoltageSupported(), expectedmemVoltageSupported))
530 if(memVoltageSupported != expectedmemVoltageSupported)
532 SetBlockResult(EFail);
533 ERR_PRINTF3(_L("memVoltageSupported(%x) != expectedmemVoltageSupported(%x)"), memVoltageSupported, expectedmemVoltageSupported);
538 SetBlockResult(EFail);
539 WARN_PRINTF1(_L("expectedmemVoltageSupported Value Missing From INI File"));
545 * The maximum current (in microAmps) that the PSU is able to supply
547 * @param aSection The section in the ini containing data for the command
551 * @leave System wide error
553 void CT_MMCSDPsuBaseDriverData::DoCmdMemMaxCurrentInMicroAmps(const TDesC& aSection)
556 TInt memMaxCurrentInMicroAmps;
557 err = iMmcSDController->MemMaxCurrentInMicroAmps(memMaxCurrentInMicroAmps);
560 ERR_PRINTF2(_L("MemMaxCurrentInMicroAmps Error %d"), err);
565 //MemMaxCurrentInMicroAmps
566 INFO_PRINTF2(_L("PSUBASE: MemMaxCurrentInMicroAmps = %d \n"),memMaxCurrentInMicroAmps);
567 TInt expectedmemMaxCurrentInMicroAmps;
568 if(GetIntFromConfig(aSection, KExpectedMemMaxCurrentInMicroAmps(), expectedmemMaxCurrentInMicroAmps))
570 if(memMaxCurrentInMicroAmps != expectedmemMaxCurrentInMicroAmps)
572 SetBlockResult(EFail);
573 ERR_PRINTF3(_L("memMaxCurrentInMicroAmps(%d) != expectedmemMaxCurrentInMicroAmps(%d)"), memMaxCurrentInMicroAmps, expectedmemMaxCurrentInMicroAmps);
578 SetBlockResult(EFail);
579 WARN_PRINTF1(_L("expectedmemMaxCurrentInMicroAmps Value Missing From INI File"));
585 * Indicates whether the platform hardware has support for checking whether the voltage level of the
586 * PSU is within its expected voltage limit while turned on
588 * @param aSection The section in the ini containing data for the command
592 * @leave System wide error
594 void CT_MMCSDPsuBaseDriverData::DoCmdVoltCheckInterval(const TDesC& aSection)
597 TUint voltCheckInterval;
598 err = iMmcSDController->VoltCheckInterval(voltCheckInterval);
601 ERR_PRINTF2(_L("VoltCheckInterval Error %d"), err);
607 INFO_PRINTF2(_L("PSUBASE: VoltCheckInterval = %u \n"),voltCheckInterval);
608 TUint expectedvoltCheckInterval;
609 if(GetUintFromConfig(aSection, KExpectedVoltageinterval(), expectedvoltCheckInterval))
611 if(voltCheckInterval != expectedvoltCheckInterval)
613 SetBlockResult(EFail);
614 ERR_PRINTF3(_L("voltCheckInterval(%u) != expectedvoltCheckInterval(%u)"), voltCheckInterval, expectedvoltCheckInterval);
619 SetBlockResult(EFail);
620 WARN_PRINTF1(_L("expectedvoltCheckInterval Value Missing From INI File"));