|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-6E208C69-AC2C-4A7A-8203-2C4C3F2E54F5" xml:lang="en"><title>Binding |
|
13 and Unbinding</title><shortdesc>This document describes how device drivers bind and unbind interrupts.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>To handle events, the interrupt source and the ISR have to be registered |
|
15 with the OS: this is called binding the interrupt. An interrupt |
|
16 has to be unbound when its use is complete.</p> |
|
17 <section id="GUID-36710685-0B8C-4D78-A453-B8772F1D6492"><title>Binding</title> <p> An |
|
18 interrupt source ID is bound with the driver's interrupt service routine. |
|
19 This is done using the function <xref href="GUID-E7A7083C-97B9-39B9-A147-4A6E314EE3A3.dita#GUID-E7A7083C-97B9-39B9-A147-4A6E314EE3A3/GUID-4E3CB472-3525-32F8-9BC4-8ECFEE931E7B"><apiname>Interrupt::Bind()</apiname></xref> in the <i>second |
|
20 stage constructor</i> of the physical channel. Interrupt binding can fail |
|
21 if the source has been already used or bound. </p> <codeblock id="GUID-0743023B-86D7-5F76-B58F-A1A2159EFAE4" xml:space="preserve">TInt DExUartPhysicalChannelH4::DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer) |
|
22 { |
|
23 ... |
|
24 // Bind the interrupt service routine (ISR) to a specific |
|
25 // interrupt ID. When the ISR is called, the value aPtr, |
|
26 // (here this object) is passed as the argument. The ISR |
|
27 // must be a static void function, taking a single TAny* |
|
28 // parameter: void Isr(TAny* aParam). Interrupt::Enable() |
|
29 // must be called to start receiving interrupts. Bind() |
|
30 // returns KErrInUse if the ISR is already bound. |
|
31 // |
|
32 TInt r = Interrupt::Bind(iIrqId,UartIsr,this); |
|
33 if (r!=KErrNone) |
|
34 { |
|
35 KDBG(Kern::Printf("DExUartPhysicalChannel::Interrupt Binding |
|
36 for UART failed")); |
|
37 return r; |
|
38 } |
|
39 |
|
40 return KErrNone; |
|
41 }</codeblock></section> |
|
42 <section id="GUID-B68C33DD-AC9D-4211-8ADF-0A2D5F02B721"><title>Unbinding</title> <p> An |
|
43 interrupt is unbound by calling <xref href="GUID-E7A7083C-97B9-39B9-A147-4A6E314EE3A3.dita#GUID-E7A7083C-97B9-39B9-A147-4A6E314EE3A3/GUID-DF98A40B-453C-3BC0-B538-D9A6943732E0"><apiname>Interrupt::UnBind()</apiname></xref>, which |
|
44 de-registers the interrupt source and routine. This must be done before or |
|
45 during physical channel destruction. Unbinding an interrupt does not disable |
|
46 its source. Interrupts have to be disabled explicitly before unbinding to |
|
47 avoid spurious interrupts. </p> <codeblock id="GUID-7F959F0F-E295-5310-8296-7BBF36D408FB" xml:space="preserve">/** |
|
48 Physical channel destructor. Delete and free any objects created and |
|
49 allocated by the physical channel. This is called by the |
|
50 framework while unloading the driver (PDD). |
|
51 */ |
|
52 DExUartPhysicalChannelH4::~DExUartPhysicalChannelH4() |
|
53 { |
|
54 // Unbind the UART interrupt. Interrupt::Unbind() frees the |
|
55 // interrupt service routine (ISR) function from the specified |
|
56 // interrupt ID. |
|
57 // |
|
58 Interrupt::Unbind (iIrqId); |
|
59 }</codeblock></section> |
|
60 </conbody></concept> |