⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal-interrupt-handling.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 2 页
字号:
> with the replacement supplied in<TTCLASS="PARAMETER"><I>vsr</I></TT>. The old VSR is returned in the locationpointed to by <TTCLASS="PARAMETER"><I>pvsr</I></TT>.</P><P><TTCLASS="FUNCTION">HAL_VSR_GET()</TT> assignsa copy of the VSR to the location pointed to by <TTCLASS="PARAMETER"><I>pvsr</I></TT>.</P><P><TTCLASS="FUNCTION">HAL_VSR_SET_TO_ECOS_HANDLER()</TT> ensures that theVSR for a specific exception is pointing at the eCos exception VSR andnot one for RedBoot or some other ROM monitor. The default whenrunning under RedBoot is for exceptions to be handled by RedBoot andpassed to GDB. This macro diverts the exception to eCos so that it maybe handled by application code. The arguments are the VSR vector to bereplaces, and a location in which to store the old VSR pointer, sothat it may be replaced at a later point.</P></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN7983">Interrupt controller management</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_INTERRUPT_MASK( vector )HAL_INTERRUPT_UNMASK( vector )HAL_INTERRUPT_ACKNOWLEDGE( vector )HAL_INTERRUPT_CONFIGURE( vector, level, up )HAL_INTERRUPT_SET_LEVEL( vector, level )</PRE></TD></TR></TABLE><P>These macros exert control over any prioritized interruptcontroller that is present. If no priority controller exists, thenthese macros should be empty.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>  These macros may not be reentrant, so care should be taken to  prevent them being called while interrupts are enabled. This means  that they can be safely used in initialization code before  interrupts are enabled, and in ISRs. In DSRs, ASRs and thread code,  however, interrupts must be disabled before these macros are  called. Here is an example for use in a DSR where the interrupt  source is unmasked after data processing:  </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> ... HAL_DISABLE_INTERRUPTS(old); HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_ETH); HAL_RESTORE_INTERRUPTS(old); ...</PRE></TD></TR></TABLE></BLOCKQUOTE></DIV><P><TTCLASS="FUNCTION">HAL_INTERRUPT_MASK()</TT> causes the interruptassociated with the given vector to be blocked.</P><P><TTCLASS="FUNCTION">HAL_INTERRUPT_UNMASK()</TT> causes the interruptassociated with the given vector to be unblocked.</P><P><TTCLASS="FUNCTION">HAL_INTERRUPT_ACKNOWLEDGE()</TT> acknowledges thecurrent interrupt from the given vector. This is usually executed fromthe ISR for this vector when it is prepared to allow furtherinterrupts.  Most interrupt controllers need some form of acknowledgeaction before the next interrupt is allowed through. Executing thismacro may cause another interrupt to be delivered. Whether thisinterrupts the current code depends on the state of the CPU interruptmask.</P><P><TTCLASS="FUNCTION">HAL_INTERRUPT_CONFIGURE()</TT> providescontrol over how an interrupt signal is detected. The argumentsare:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT>vector</DT><DD><P>The interrupt vector to be configured.</P></DD><DT>level</DT><DD><P>      Set to <TTCLASS="VARNAME">true</TT> if the interrupt is detected by      level, and <TTCLASS="VARNAME">false</TT> if it is edge triggered.      </P></DD><DT>up</DT><DD><P>      If the interrupt is set to level detect, then if this is      <TTCLASS="VARNAME">true</TT> it is detected by a high signal level,      and if <TTCLASS="VARNAME">false</TT> by a low signal level. If the      interrupt is set to edge triggered, then if this is      <TTCLASS="VARNAME">true</TT> it is triggered by a rising edge and if      <TTCLASS="VARNAME">false</TT> by a falling edge.      </P></DD></DL></DIV><P><TTCLASS="FUNCTION">HAL_INTERRUPT_SET_LEVEL()</TT> provides control overthe hardware priority of the interrupt. The arguments are:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT>vector</DT><DD><P>The interrupt whose level is to be set.</P></DD><DT>level</DT><DD><P>      The priority level to which the interrupt is to set. In some      architectures the masking of an interrupt is achieved by      changing its priority level. Hence this function,      <TTCLASS="FUNCTION">HAL_INTERRUPT_MASK()</TT> and      <TTCLASS="FUNCTION">HAL_INTERRUPT_UNMASK()</TT> may interfere with      each other.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN8030">Clock control</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_CLOCK_INITIALIZE( period )HAL_CLOCK_RESET( vector, period )HAL_CLOCK_READ( pvalue )</PRE></TD></TR></TABLE><P>These macros provide control over a clock or timer device that may beused by the kernel to provide time-out, delay and schedulingservices. The clock is assumed to be implemented by some form ofcounter that is incremented or decremented by some external source andwhich raises an interrupt when it reaches a predetermined value.</P><P><TTCLASS="FUNCTION">HAL_CLOCK_INITIALIZE()</TT> initializes the timerdevice to interrupt at the given period. The period is essentially thevalue used to initialize the timer counter and must be calculated fromthe timer frequency and the desired interrupt rate. The timer deviceshould generate an interrupt every <TTCLASS="VARNAME">period</TT> cycles.</P><P><TTCLASS="FUNCTION">HAL_CLOCK_RESET()</TT> re-initializes the timer toprovoke the next interrupt. This macro is only really necessary whenthe timer device needs to be reset in some way after each interrupt.</P><P><TTCLASS="FUNCTION">HAL_CLOCK_READ()</TT> reads the current value of thetimer counter and puts the value in the location pointed to by<TTCLASS="PARAMETER"><I>pvalue</I></TT>. The value stored will always be thenumber of timer cycles since the last interrupt, and hence rangesbetween zero and the initial period value. If this is a count-downcyclic timer, some arithmetic may be necessary to generate this value.</P></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN8042">Microsecond Delay</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_DELAY_US(us)</PRE></TD></TR></TABLE><P>This is an optional definition. If defined the macro implements a busyloop delay for the given number of microseconds. This is usuallyimplemented by waiting for the required number of hardware timer ticksto pass. </P><P>This operation should normally be used when a very short delay isneeded when controlling hardware, programming FLASH devices and similarsituations where a wait/timeout loop would otherwise be used. Since itmay disable interrupts, and is implemented by busy waiting, it shouldnot be used in code that is sensitive to interrupt or context switchlatencies.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="hal-architecture-characterization.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="hal-input-and-output.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Architecture Characterization</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="hal-interfaces.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">HAL I/O</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -