sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\drivers\pbus\pccard\epoc\pccd_medchg.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <pccd_medchg.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
DPlatPcCardMediaChange::DPlatPcCardMediaChange(TInt aMediaChangeNum)
|
sl@0
|
21 |
//
|
sl@0
|
22 |
// Constructor
|
sl@0
|
23 |
//
|
sl@0
|
24 |
: DPcCardMediaChange(aMediaChangeNum),
|
sl@0
|
25 |
iDelayCallBack(DelayCallBack,this)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
}
|
sl@0
|
28 |
|
sl@0
|
29 |
TInt DPlatPcCardMediaChange::Create()
|
sl@0
|
30 |
//
|
sl@0
|
31 |
// Initialiser.
|
sl@0
|
32 |
//
|
sl@0
|
33 |
{
|
sl@0
|
34 |
|
sl@0
|
35 |
TInt r=DPcCardMediaChange::Create();
|
sl@0
|
36 |
if (r==KErrNone)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
iMedChgIntId=ThePccdCntrlInterface->IntIdMediaChange(iMediaChangeNum);
|
sl@0
|
39 |
r=Interrupt::Bind(iMedChgIntId,Isr,this);
|
sl@0
|
40 |
}
|
sl@0
|
41 |
__KTRACE_OPT(KPBUS1,Kern::Printf("<PlatMedCh:Init(M:%d)-%d",iMediaChangeNum,r));
|
sl@0
|
42 |
return(r);
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
void DPlatPcCardMediaChange::Isr(TAny *aPtr)
|
sl@0
|
46 |
//
|
sl@0
|
47 |
// Handle the media change (this function, never postponed is called on media
|
sl@0
|
48 |
// change interrupt).
|
sl@0
|
49 |
//
|
sl@0
|
50 |
{
|
sl@0
|
51 |
__KTRACE_OPT(KFAIL,Kern::Printf("!^"));
|
sl@0
|
52 |
DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
|
sl@0
|
53 |
Interrupt::Disable(pM->iMedChgIntId);
|
sl@0
|
54 |
ThePccdCntrlInterface->ClearMediaChange(pM->iMediaChangeNum);
|
sl@0
|
55 |
pM->DoorOpenService();
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
void DPlatPcCardMediaChange::DelayCallBack(TAny *aPtr)
|
sl@0
|
59 |
//
|
sl@0
|
60 |
// Timer callback after media change
|
sl@0
|
61 |
//
|
sl@0
|
62 |
{
|
sl@0
|
63 |
DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
|
sl@0
|
64 |
pM->DoorClosedService();
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
void DPlatPcCardMediaChange::ForceMediaChange()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
Interrupt::Disable(iMedChgIntId);
|
sl@0
|
70 |
ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
|
sl@0
|
71 |
DoorOpenService();
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
void DPlatPcCardMediaChange::DoDoorOpen()
|
sl@0
|
75 |
//
|
sl@0
|
76 |
// Called after media change has been recognised
|
sl@0
|
77 |
//
|
sl@0
|
78 |
{
|
sl@0
|
79 |
|
sl@0
|
80 |
__KTRACE_OPT(KPBUS2,Kern::Printf(">PlatMedCh(%d):DoDoorOpen",iMediaChangeNum));
|
sl@0
|
81 |
iDelayCallBack.OneShot(NKern::TimerTicks(20),ETrue);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
void DPlatPcCardMediaChange::DoDoorClosed()
|
sl@0
|
85 |
//
|
sl@0
|
86 |
// Handle the media door closing (called on tick).
|
sl@0
|
87 |
//
|
sl@0
|
88 |
{
|
sl@0
|
89 |
|
sl@0
|
90 |
ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
|
sl@0
|
91 |
Interrupt::Enable(iMedChgIntId);
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
TMediaState DPlatPcCardMediaChange::MediaState()
|
sl@0
|
95 |
//
|
sl@0
|
96 |
// Return status of media changed signal.
|
sl@0
|
97 |
//
|
sl@0
|
98 |
{
|
sl@0
|
99 |
|
sl@0
|
100 |
return ThePccdCntrlInterface->MediaState(iMediaChangeNum);
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|