First public contribution.
1 // Copyright (c) 1995-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\drivers\pbus\pccard\epoc\pccd_medchg.cpp
18 #include <pccd_medchg.h>
20 DPlatPcCardMediaChange::DPlatPcCardMediaChange(TInt aMediaChangeNum)
24 : DPcCardMediaChange(aMediaChangeNum),
25 iDelayCallBack(DelayCallBack,this)
29 TInt DPlatPcCardMediaChange::Create()
35 TInt r=DPcCardMediaChange::Create();
38 iMedChgIntId=ThePccdCntrlInterface->IntIdMediaChange(iMediaChangeNum);
39 r=Interrupt::Bind(iMedChgIntId,Isr,this);
41 __KTRACE_OPT(KPBUS1,Kern::Printf("<PlatMedCh:Init(M:%d)-%d",iMediaChangeNum,r));
45 void DPlatPcCardMediaChange::Isr(TAny *aPtr)
47 // Handle the media change (this function, never postponed is called on media
51 __KTRACE_OPT(KFAIL,Kern::Printf("!^"));
52 DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
53 Interrupt::Disable(pM->iMedChgIntId);
54 ThePccdCntrlInterface->ClearMediaChange(pM->iMediaChangeNum);
55 pM->DoorOpenService();
58 void DPlatPcCardMediaChange::DelayCallBack(TAny *aPtr)
60 // Timer callback after media change
63 DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
64 pM->DoorClosedService();
67 void DPlatPcCardMediaChange::ForceMediaChange()
69 Interrupt::Disable(iMedChgIntId);
70 ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
74 void DPlatPcCardMediaChange::DoDoorOpen()
76 // Called after media change has been recognised
80 __KTRACE_OPT(KPBUS2,Kern::Printf(">PlatMedCh(%d):DoDoorOpen",iMediaChangeNum));
81 iDelayCallBack.OneShot(NKern::TimerTicks(20),ETrue);
84 void DPlatPcCardMediaChange::DoDoorClosed()
86 // Handle the media door closing (called on tick).
90 ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
91 Interrupt::Enable(iMedChgIntId);
94 TMediaState DPlatPcCardMediaChange::MediaState()
96 // Return status of media changed signal.
100 return ThePccdCntrlInterface->MediaState(iMediaChangeNum);