<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Interrupt Handling</TITLE
|
>Interrupt Handling</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="HAL Interfaces"
|
TITLE="HAL Interfaces"
|
HREF="hal-interfaces.html"><LINK
|
HREF="hal-interfaces.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="Architecture Characterization"
|
TITLE="Architecture Characterization"
|
HREF="hal-architecture-characterization.html"><LINK
|
HREF="hal-architecture-characterization.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="HAL I/O"
|
TITLE="HAL I/O"
|
HREF="hal-input-and-output.html"></HEAD
|
HREF="hal-input-and-output.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="SECTION"
|
CLASS="SECTION"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="hal-architecture-characterization.html"
|
HREF="hal-architecture-characterization.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
>Chapter 9. HAL Interfaces</TD
|
>Chapter 9. HAL Interfaces</TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="hal-input-and-output.html"
|
HREF="hal-input-and-output.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H1
|
><H1
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="HAL-INTERRUPT-HANDLING">Interrupt Handling</H1
|
NAME="HAL-INTERRUPT-HANDLING">Interrupt Handling</H1
|
><P
|
><P
|
>These interfaces contain definitions related to interrupt
|
>These interfaces contain definitions related to interrupt
|
handling. They include definitions of exception and interrupt numbers,
|
handling. They include definitions of exception and interrupt numbers,
|
interrupt enabling and masking, and realtime clock operations.</P
|
interrupt enabling and masking, and realtime clock operations.</P
|
><P
|
><P
|
>These definitions are normally found in
|
>These definitions are normally found in
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>cyg/hal/hal_intr.h</TT
|
>cyg/hal/hal_intr.h</TT
|
>. This file is supplied by the
|
>. This file is supplied by the
|
architecture HAL. Any variant or platform specific definitions will
|
architecture HAL. Any variant or platform specific definitions will
|
be found in <TT
|
be found in <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>cyg/hal/var_intr.h</TT
|
>cyg/hal/var_intr.h</TT
|
>,
|
>,
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>cyg/hal/plf_intr.h</TT
|
>cyg/hal/plf_intr.h</TT
|
> or
|
> or
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>cyg/hal/hal_platform_ints.h</TT
|
>cyg/hal/hal_platform_ints.h</TT
|
> in the variant or platform
|
> in the variant or platform
|
HAL, depending on the exact target. These files are include
|
HAL, depending on the exact target. These files are include
|
automatically by this header, so need not be included explicitly.</P
|
automatically by this header, so need not be included explicitly.</P
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H2
|
><H2
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="AEN7921">Vector numbers</H2
|
NAME="AEN7921">Vector numbers</H2
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>CYGNUM_HAL_VECTOR_XXXX
|
>CYGNUM_HAL_VECTOR_XXXX
|
CYGNUM_HAL_VSR_MIN
|
CYGNUM_HAL_VSR_MIN
|
CYGNUM_HAL_VSR_MAX
|
CYGNUM_HAL_VSR_MAX
|
CYGNUM_HAL_VSR_COUNT
|
CYGNUM_HAL_VSR_COUNT
|
|
|
CYGNUM_HAL_INTERRUPT_XXXX
|
CYGNUM_HAL_INTERRUPT_XXXX
|
CYGNUM_HAL_ISR_MIN
|
CYGNUM_HAL_ISR_MIN
|
CYGNUM_HAL_ISR_MAX
|
CYGNUM_HAL_ISR_MAX
|
CYGNUM_HAL_ISR_COUNT
|
CYGNUM_HAL_ISR_COUNT
|
|
|
CYGNUM_HAL_EXCEPTION_XXXX
|
CYGNUM_HAL_EXCEPTION_XXXX
|
CYGNUM_HAL_EXCEPTION_MIN
|
CYGNUM_HAL_EXCEPTION_MIN
|
CYGNUM_HAL_EXCEPTION_MAX
|
CYGNUM_HAL_EXCEPTION_MAX
|
CYGNUM_HAL_EXCEPTION_COUNT</PRE
|
CYGNUM_HAL_EXCEPTION_COUNT</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>All possible VSR, interrupt and exception vectors are specified here,
|
>All possible VSR, interrupt and exception vectors are specified here,
|
together with maximum and minimum values for range checking. While the
|
together with maximum and minimum values for range checking. While the
|
VSR and exception numbers will be defined in this file, the interrupt
|
VSR and exception numbers will be defined in this file, the interrupt
|
numbers will normally be defined in the variant or platform HAL file
|
numbers will normally be defined in the variant or platform HAL file
|
that is included by this header. </P
|
that is included by this header. </P
|
><P
|
><P
|
>There are two ranges of numbers, those for the vector service
|
>There are two ranges of numbers, those for the vector service
|
routines and those for the interrupt service routines. The relationship
|
routines and those for the interrupt service routines. The relationship
|
between these two ranges is undefined, and no equivalence should
|
between these two ranges is undefined, and no equivalence should
|
be assumed if vectors from the two ranges coincide.</P
|
be assumed if vectors from the two ranges coincide.</P
|
><P
|
><P
|
>The VSR vectors correspond to the set of exception vectors that can be
|
>The VSR vectors correspond to the set of exception vectors that can be
|
delivered by the CPU architecture, many of these will be internal
|
delivered by the CPU architecture, many of these will be internal
|
exception traps. The ISR vectors correspond to the set of external
|
exception traps. The ISR vectors correspond to the set of external
|
interrupts that can be delivered and are usually determined by extra
|
interrupts that can be delivered and are usually determined by extra
|
decoding of the interrupt controller by the interrupt VSR.</P
|
decoding of the interrupt controller by the interrupt VSR.</P
|
><P
|
><P
|
>Where a CPU supports synchronous exceptions, the range of such
|
>Where a CPU supports synchronous exceptions, the range of such
|
exceptions allowed are defined by <TT
|
exceptions allowed are defined by <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_EXCEPTION_MIN</TT
|
>CYGNUM_HAL_EXCEPTION_MIN</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_EXCEPTION_MAX</TT
|
>CYGNUM_HAL_EXCEPTION_MAX</TT
|
>. The
|
>. The
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_EXCEPTION_XXXX</TT
|
>CYGNUM_HAL_EXCEPTION_XXXX</TT
|
> definitions are
|
> definitions are
|
standard names used by target independent code to test for the
|
standard names used by target independent code to test for the
|
presence of particular exceptions in the architecture. The actual
|
presence of particular exceptions in the architecture. The actual
|
exception numbers will normally correspond to the VSR exception
|
exception numbers will normally correspond to the VSR exception
|
range. In future other exceptions generated by the system software
|
range. In future other exceptions generated by the system software
|
(such as stack overflow) may be added.</P
|
(such as stack overflow) may be added.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_ISR_COUNT</TT
|
>CYGNUM_HAL_ISR_COUNT</TT
|
>, <TT
|
>, <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_VSR_COUNT</TT
|
>CYGNUM_HAL_VSR_COUNT</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_EXCEPTION_COUNT</TT
|
>CYGNUM_HAL_EXCEPTION_COUNT</TT
|
> define the number of
|
> define the number of
|
ISRs, VSRs and EXCEPTIONs respectively for the purposes of defining
|
ISRs, VSRs and EXCEPTIONs respectively for the purposes of defining
|
arrays etc. There might be a translation from the supplied vector
|
arrays etc. There might be a translation from the supplied vector
|
numbers into array offsets. Hence
|
numbers into array offsets. Hence
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_XXX_COUNT</TT
|
>CYGNUM_HAL_XXX_COUNT</TT
|
> may not simply be
|
> may not simply be
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_XXX_MAX</TT
|
>CYGNUM_HAL_XXX_MAX</TT
|
> - <TT
|
> - <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_XXX_MIN</TT
|
>CYGNUM_HAL_XXX_MIN</TT
|
> or <TT
|
> or <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGNUM_HAL_XXX_MAX</TT
|
>CYGNUM_HAL_XXX_MAX</TT
|
>+1.</P
|
>+1.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H2
|
><H2
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="AEN7939">Interrupt state control</H2
|
NAME="AEN7939">Interrupt state control</H2
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>CYG_INTERRUPT_STATE
|
>CYG_INTERRUPT_STATE
|
HAL_DISABLE_INTERRUPTS( old )
|
HAL_DISABLE_INTERRUPTS( old )
|
HAL_RESTORE_INTERRUPTS( old )
|
HAL_RESTORE_INTERRUPTS( old )
|
HAL_ENABLE_INTERRUPTS()
|
HAL_ENABLE_INTERRUPTS()
|
HAL_QUERY_INTERRUPTS( state )</PRE
|
HAL_QUERY_INTERRUPTS( state )</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>These macros provide control over the state of the CPUs interrupt mask
|
>These macros provide control over the state of the CPUs interrupt mask
|
mechanism. They should normally manipulate a CPU status register to
|
mechanism. They should normally manipulate a CPU status register to
|
enable and disable interrupt delivery. They should not access an
|
enable and disable interrupt delivery. They should not access an
|
interrupt controller.</P
|
interrupt controller.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_INTERRUPT_STATE</TT
|
>CYG_INTERRUPT_STATE</TT
|
> is a data type that should be
|
> is a data type that should be
|
used to store the interrupt state returned by
|
used to store the interrupt state returned by
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_DISABLE_INTERRUPTS()</TT
|
>HAL_DISABLE_INTERRUPTS()</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_QUERY_INTERRUPTS()</TT
|
>HAL_QUERY_INTERRUPTS()</TT
|
> and passed to
|
> and passed to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_RESTORE_INTERRUPTS()</TT
|
>HAL_RESTORE_INTERRUPTS()</TT
|
>.</P
|
>.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_DISABLE_INTERRUPTS()</TT
|
>HAL_DISABLE_INTERRUPTS()</TT
|
> disables the delivery of
|
> disables the delivery of
|
interrupts and stores the original state of the interrupt mask in the
|
interrupts and stores the original state of the interrupt mask in the
|
variable passed in the <TT
|
variable passed in the <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>old</I
|
>old</I
|
></TT
|
></TT
|
> argument.</P
|
> argument.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_RESTORE_INTERRUPTS()</TT
|
>HAL_RESTORE_INTERRUPTS()</TT
|
> restores the state of
|
> restores the state of
|
the interrupt mask to that recorded in <TT
|
the interrupt mask to that recorded in <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>old</I
|
>old</I
|
></TT
|
></TT
|
>.</P
|
>.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_ENABLE_INTERRUPTS()</TT
|
>HAL_ENABLE_INTERRUPTS()</TT
|
> simply enables interrupts
|
> simply enables interrupts
|
regardless of the current state of the mask.</P
|
regardless of the current state of the mask.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_QUERY_INTERRUPTS()</TT
|
>HAL_QUERY_INTERRUPTS()</TT
|
> stores the state of the
|
> stores the state of the
|
interrupt mask in the variable passed in the <TT
|
interrupt mask in the variable passed in the <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>state</I
|
>state</I
|
></TT
|
></TT
|
> argument. The state stored here should also be
|
> argument. The state stored here should also be
|
capable of being passed to
|
capable of being passed to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_RESTORE_INTERRUPTS()</TT
|
>HAL_RESTORE_INTERRUPTS()</TT
|
> at a later point.</P
|
> at a later point.</P
|
><P
|
><P
|
>It is at the HAL implementer’s discretion exactly
|
>It is at the HAL implementer’s discretion exactly
|
which interrupts are masked by this mechanism. Where a CPU has more
|
which interrupts are masked by this mechanism. Where a CPU has more
|
than one interrupt type that may be masked separately (e.g. the
|
than one interrupt type that may be masked separately (e.g. the
|
ARM's IRQ and FIQ) only those that can raise DSRs need
|
ARM's IRQ and FIQ) only those that can raise DSRs need
|
to be masked here. A separate architecture specific mechanism may
|
to be masked here. A separate architecture specific mechanism may
|
then be used to control the other interrupt types.</P
|
then be used to control the other interrupt types.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H2
|
><H2
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="AEN7961">ISR and VSR management</H2
|
NAME="AEN7961">ISR and VSR management</H2
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>HAL_INTERRUPT_IN_USE( vector, state )
|
>HAL_INTERRUPT_IN_USE( vector, state )
|
HAL_INTERRUPT_ATTACH( vector, isr, data, object )
|
HAL_INTERRUPT_ATTACH( vector, isr, data, object )
|
HAL_INTERRUPT_DETACH( vector, isr )
|
HAL_INTERRUPT_DETACH( vector, isr )
|
HAL_VSR_SET( vector, vsr, poldvsr )
|
HAL_VSR_SET( vector, vsr, poldvsr )
|
HAL_VSR_GET( vector, pvsr )
|
HAL_VSR_GET( vector, pvsr )
|
HAL_VSR_SET_TO_ECOS_HANDLER( vector, poldvsr )</PRE
|
HAL_VSR_SET_TO_ECOS_HANDLER( vector, poldvsr )</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>These macros manage the attachment of interrupt and vector service
|
>These macros manage the attachment of interrupt and vector service
|
routines to interrupt and exception vectors respectively.</P
|
routines to interrupt and exception vectors respectively.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_IN_USE()</TT
|
>HAL_INTERRUPT_IN_USE()</TT
|
> tests the state of the
|
> tests the state of the
|
supplied interrupt vector and sets the value of the state parameter to
|
supplied interrupt vector and sets the value of the state parameter to
|
either 1 or 0 depending on whether there is already an ISR attached to
|
either 1 or 0 depending on whether there is already an ISR attached to
|
the vector. The HAL will only allow one ISR to be attached to each
|
the vector. The HAL will only allow one ISR to be attached to each
|
vector, so it is a good idea to use this function before using
|
vector, so it is a good idea to use this function before using
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_ATTACH()</TT
|
>HAL_INTERRUPT_ATTACH()</TT
|
>.</P
|
>.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_ATTACH()</TT
|
>HAL_INTERRUPT_ATTACH()</TT
|
> attaches
|
> attaches
|
the ISR, data pointer and object pointer to the given
|
the ISR, data pointer and object pointer to the given
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>vector</I
|
>vector</I
|
></TT
|
></TT
|
>. When an interrupt occurs on this
|
>. When an interrupt occurs on this
|
vector the ISR is called using the C calling convention and the vector
|
vector the ISR is called using the C calling convention and the vector
|
number and data pointer are passed to it as the first and second
|
number and data pointer are passed to it as the first and second
|
arguments respectively.</P
|
arguments respectively.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_DETACH()</TT
|
>HAL_INTERRUPT_DETACH()</TT
|
> detaches the ISR from the
|
> detaches the ISR from the
|
vector.</P
|
vector.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_VSR_SET()</TT
|
>HAL_VSR_SET()</TT
|
> replaces the VSR attached to the
|
> replaces the VSR attached to the
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>vector</I
|
>vector</I
|
></TT
|
></TT
|
> with the replacement supplied in
|
> with the replacement supplied in
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>vsr</I
|
>vsr</I
|
></TT
|
></TT
|
>. The old VSR is returned in the location
|
>. The old VSR is returned in the location
|
pointed to by <TT
|
pointed to by <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>pvsr</I
|
>pvsr</I
|
></TT
|
></TT
|
>.</P
|
>.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_VSR_GET()</TT
|
>HAL_VSR_GET()</TT
|
> assigns
|
> assigns
|
a copy of the VSR to the location pointed to by <TT
|
a copy of the VSR to the location pointed to by <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>pvsr</I
|
>pvsr</I
|
></TT
|
></TT
|
>.</P
|
>.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_VSR_SET_TO_ECOS_HANDLER()</TT
|
>HAL_VSR_SET_TO_ECOS_HANDLER()</TT
|
> ensures that the
|
> ensures that the
|
VSR for a specific exception is pointing at the eCos exception VSR and
|
VSR for a specific exception is pointing at the eCos exception VSR and
|
not one for RedBoot or some other ROM monitor. The default when
|
not one for RedBoot or some other ROM monitor. The default when
|
running under RedBoot is for exceptions to be handled by RedBoot and
|
running under RedBoot is for exceptions to be handled by RedBoot and
|
passed to GDB. This macro diverts the exception to eCos so that it may
|
passed to GDB. This macro diverts the exception to eCos so that it may
|
be handled by application code. The arguments are the VSR vector to be
|
be handled by application code. The arguments are the VSR vector to be
|
replaces, and a location in which to store the old VSR pointer, so
|
replaces, and a location in which to store the old VSR pointer, so
|
that it may be replaced at a later point.</P
|
that it may be replaced at a later point.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H2
|
><H2
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="AEN7983">Interrupt controller management</H2
|
NAME="AEN7983">Interrupt controller management</H2
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>HAL_INTERRUPT_MASK( vector )
|
>HAL_INTERRUPT_MASK( vector )
|
HAL_INTERRUPT_UNMASK( vector )
|
HAL_INTERRUPT_UNMASK( vector )
|
HAL_INTERRUPT_ACKNOWLEDGE( vector )
|
HAL_INTERRUPT_ACKNOWLEDGE( vector )
|
HAL_INTERRUPT_CONFIGURE( vector, level, up )
|
HAL_INTERRUPT_CONFIGURE( vector, level, up )
|
HAL_INTERRUPT_SET_LEVEL( vector, level )</PRE
|
HAL_INTERRUPT_SET_LEVEL( vector, level )</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>These macros exert control over any prioritized interrupt
|
>These macros exert control over any prioritized interrupt
|
controller that is present. If no priority controller exists, then
|
controller that is present. If no priority controller exists, then
|
these macros should be empty.</P
|
these macros should be empty.</P
|
><DIV
|
><DIV
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><BLOCKQUOTE
|
><BLOCKQUOTE
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><P
|
><P
|
><B
|
><B
|
>Note: </B
|
>Note: </B
|
> These macros may not be reentrant, so care should be taken to
|
> These macros may not be reentrant, so care should be taken to
|
prevent them being called while interrupts are enabled. This means
|
prevent them being called while interrupts are enabled. This means
|
that they can be safely used in initialization code before
|
that they can be safely used in initialization code before
|
interrupts are enabled, and in ISRs. In DSRs, ASRs and thread code,
|
interrupts are enabled, and in ISRs. In DSRs, ASRs and thread code,
|
however, interrupts must be disabled before these macros are
|
however, interrupts must be disabled before these macros are
|
called. Here is an example for use in a DSR where the interrupt
|
called. Here is an example for use in a DSR where the interrupt
|
source is unmasked after data processing:
|
source is unmasked after data processing:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
> ...
|
> ...
|
HAL_DISABLE_INTERRUPTS(old);
|
HAL_DISABLE_INTERRUPTS(old);
|
HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_ETH);
|
HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_ETH);
|
HAL_RESTORE_INTERRUPTS(old);
|
HAL_RESTORE_INTERRUPTS(old);
|
...</PRE
|
...</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></BLOCKQUOTE
|
></BLOCKQUOTE
|
></DIV
|
></DIV
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_MASK()</TT
|
>HAL_INTERRUPT_MASK()</TT
|
> causes the interrupt
|
> causes the interrupt
|
associated with the given vector to be blocked.</P
|
associated with the given vector to be blocked.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_UNMASK()</TT
|
>HAL_INTERRUPT_UNMASK()</TT
|
> causes the interrupt
|
> causes the interrupt
|
associated with the given vector to be unblocked.</P
|
associated with the given vector to be unblocked.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_ACKNOWLEDGE()</TT
|
>HAL_INTERRUPT_ACKNOWLEDGE()</TT
|
> acknowledges the
|
> acknowledges the
|
current interrupt from the given vector. This is usually executed from
|
current interrupt from the given vector. This is usually executed from
|
the ISR for this vector when it is prepared to allow further
|
the ISR for this vector when it is prepared to allow further
|
interrupts. Most interrupt controllers need some form of acknowledge
|
interrupts. Most interrupt controllers need some form of acknowledge
|
action before the next interrupt is allowed through. Executing this
|
action before the next interrupt is allowed through. Executing this
|
macro may cause another interrupt to be delivered. Whether this
|
macro may cause another interrupt to be delivered. Whether this
|
interrupts the current code depends on the state of the CPU interrupt
|
interrupts the current code depends on the state of the CPU interrupt
|
mask.</P
|
mask.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_CONFIGURE()</TT
|
>HAL_INTERRUPT_CONFIGURE()</TT
|
> provides
|
> provides
|
control over how an interrupt signal is detected. The arguments
|
control over how an interrupt signal is detected. The arguments
|
are:</P
|
are:</P
|
><P
|
><P
|
></P
|
></P
|
><DIV
|
><DIV
|
CLASS="VARIABLELIST"
|
CLASS="VARIABLELIST"
|
><DL
|
><DL
|
><DT
|
><DT
|
>vector</DT
|
>vector</DT
|
><DD
|
><DD
|
><P
|
><P
|
>The interrupt vector to be configured.</P
|
>The interrupt vector to be configured.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
>level</DT
|
>level</DT
|
><DD
|
><DD
|
><P
|
><P
|
> Set to <TT
|
> Set to <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>true</TT
|
>true</TT
|
> if the interrupt is detected by
|
> if the interrupt is detected by
|
level, and <TT
|
level, and <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>false</TT
|
>false</TT
|
> if it is edge triggered.
|
> if it is edge triggered.
|
</P
|
</P
|
></DD
|
></DD
|
><DT
|
><DT
|
>up</DT
|
>up</DT
|
><DD
|
><DD
|
><P
|
><P
|
> If the interrupt is set to level detect, then if this is
|
> If the interrupt is set to level detect, then if this is
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>true</TT
|
>true</TT
|
> it is detected by a high signal level,
|
> it is detected by a high signal level,
|
and if <TT
|
and if <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>false</TT
|
>false</TT
|
> by a low signal level. If the
|
> by a low signal level. If the
|
interrupt is set to edge triggered, then if this is
|
interrupt is set to edge triggered, then if this is
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>true</TT
|
>true</TT
|
> it is triggered by a rising edge and if
|
> it is triggered by a rising edge and if
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>false</TT
|
>false</TT
|
> by a falling edge.
|
> by a falling edge.
|
</P
|
</P
|
></DD
|
></DD
|
></DL
|
></DL
|
></DIV
|
></DIV
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_SET_LEVEL()</TT
|
>HAL_INTERRUPT_SET_LEVEL()</TT
|
> provides control over
|
> provides control over
|
the hardware priority of the interrupt. The arguments are:</P
|
the hardware priority of the interrupt. The arguments are:</P
|
><P
|
><P
|
></P
|
></P
|
><DIV
|
><DIV
|
CLASS="VARIABLELIST"
|
CLASS="VARIABLELIST"
|
><DL
|
><DL
|
><DT
|
><DT
|
>vector</DT
|
>vector</DT
|
><DD
|
><DD
|
><P
|
><P
|
>The interrupt whose level is to be set.</P
|
>The interrupt whose level is to be set.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
>level</DT
|
>level</DT
|
><DD
|
><DD
|
><P
|
><P
|
> The priority level to which the interrupt is to set. In some
|
> The priority level to which the interrupt is to set. In some
|
architectures the masking of an interrupt is achieved by
|
architectures the masking of an interrupt is achieved by
|
changing its priority level. Hence this function,
|
changing its priority level. Hence this function,
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_MASK()</TT
|
>HAL_INTERRUPT_MASK()</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_INTERRUPT_UNMASK()</TT
|
>HAL_INTERRUPT_UNMASK()</TT
|
> may interfere with
|
> may interfere with
|
each other.
|
each other.
|
</P
|
</P
|
></DD
|
></DD
|
></DL
|
></DL
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H2
|
><H2
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="AEN8030">Clock control</H2
|
NAME="AEN8030">Clock control</H2
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>HAL_CLOCK_INITIALIZE( period )
|
>HAL_CLOCK_INITIALIZE( period )
|
HAL_CLOCK_RESET( vector, period )
|
HAL_CLOCK_RESET( vector, period )
|
HAL_CLOCK_READ( pvalue )</PRE
|
HAL_CLOCK_READ( pvalue )</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>These macros provide control over a clock or timer device that may be
|
>These macros provide control over a clock or timer device that may be
|
used by the kernel to provide time-out, delay and scheduling
|
used by the kernel to provide time-out, delay and scheduling
|
services. The clock is assumed to be implemented by some form of
|
services. The clock is assumed to be implemented by some form of
|
counter that is incremented or decremented by some external source and
|
counter that is incremented or decremented by some external source and
|
which raises an interrupt when it reaches a predetermined value.</P
|
which raises an interrupt when it reaches a predetermined value.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_CLOCK_INITIALIZE()</TT
|
>HAL_CLOCK_INITIALIZE()</TT
|
> initializes the timer
|
> initializes the timer
|
device to interrupt at the given period. The period is essentially the
|
device to interrupt at the given period. The period is essentially the
|
value used to initialize the timer counter and must be calculated from
|
value used to initialize the timer counter and must be calculated from
|
the timer frequency and the desired interrupt rate. The timer device
|
the timer frequency and the desired interrupt rate. The timer device
|
should generate an interrupt every <TT
|
should generate an interrupt every <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>period</TT
|
>period</TT
|
> cycles.</P
|
> cycles.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_CLOCK_RESET()</TT
|
>HAL_CLOCK_RESET()</TT
|
> re-initializes the timer to
|
> re-initializes the timer to
|
provoke the next interrupt. This macro is only really necessary when
|
provoke the next interrupt. This macro is only really necessary when
|
the timer device needs to be reset in some way after each interrupt.</P
|
the timer device needs to be reset in some way after each interrupt.</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>HAL_CLOCK_READ()</TT
|
>HAL_CLOCK_READ()</TT
|
> reads the current value of the
|
> reads the current value of the
|
timer counter and puts the value in the location pointed to by
|
timer counter and puts the value in the location pointed to by
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>pvalue</I
|
>pvalue</I
|
></TT
|
></TT
|
>. The value stored will always be the
|
>. The value stored will always be the
|
number of timer cycles since the last interrupt, and hence ranges
|
number of timer cycles since the last interrupt, and hence ranges
|
between zero and the initial period value. If this is a count-down
|
between zero and the initial period value. If this is a count-down
|
cyclic timer, some arithmetic may be necessary to generate this value.</P
|
cyclic timer, some arithmetic may be necessary to generate this value.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><H2
|
><H2
|
CLASS="SECTION"
|
CLASS="SECTION"
|
><A
|
><A
|
NAME="AEN8042">Microsecond Delay</H2
|
NAME="AEN8042">Microsecond Delay</H2
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>HAL_DELAY_US(us)</PRE
|
>HAL_DELAY_US(us)</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>This is an optional definition. If defined the macro implements a busy
|
>This is an optional definition. If defined the macro implements a busy
|
loop delay for the given number of microseconds. This is usually
|
loop delay for the given number of microseconds. This is usually
|
implemented by waiting for the required number of hardware timer ticks
|
implemented by waiting for the required number of hardware timer ticks
|
to pass. </P
|
to pass. </P
|
><P
|
><P
|
>This operation should normally be used when a very short delay is
|
>This operation should normally be used when a very short delay is
|
needed when controlling hardware, programming FLASH devices and similar
|
needed when controlling hardware, programming FLASH devices and similar
|
situations where a wait/timeout loop would otherwise be used. Since it
|
situations where a wait/timeout loop would otherwise be used. Since it
|
may disable interrupts, and is implemented by busy waiting, it should
|
may disable interrupts, and is implemented by busy waiting, it should
|
not be used in code that is sensitive to interrupt or context switch
|
not be used in code that is sensitive to interrupt or context switch
|
latencies.</P
|
latencies.</P
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="hal-architecture-characterization.html"
|
HREF="hal-architecture-characterization.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="hal-input-and-output.html"
|
HREF="hal-input-and-output.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>Architecture Characterization</TD
|
>Architecture Characterization</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="hal-interfaces.html"
|
HREF="hal-interfaces.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>HAL I/O</TD
|
>HAL I/O</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|