Nucleus 实时操作系统中断(下)

Nucleus RTOS兼容性

由于中断在Nucleus SE中的实现方式与Nucleus rto截然不同,因此不应期望有特定的兼容性。Nucleus RTOS有一个本机/低级/高级中断方案,这在某种程度上类似于Nucleus SE中的本机中断和管理中断。

低级和高级ISR

低级ISR

低级中断服务程序(LISR)作为普通ISR执行,包括使用当前堆栈。Nucleus RTOS在调用LISR之前保存上下文,并在LISR返回后恢复上下文。因此,lisr可以用C编写,并且可以调用其他C例程。然而,只有少数Nucleus RTOS服务可用于LISR。如果中断处理需要额外的Nucleus RTOS服务,则必须激活高级中断服务程序(HISR)。Nucleus RTOS支持多个lisr的嵌套。

高级ISR

HISR是动态创建和删除的。每个HISR都有自己的堆栈空间和自己的控制块。每个内存都由应用程序提供。当然,HISR必须在LISR激活之前创建。

由于HISR有自己的堆栈和控制块,所以如果它试图访问已经被访问的Nucleus RTOS数据结构,则可以暂时阻止HISR。

HISR有三个优先级。如果在处理低优先级HISR期间激活了高优先级HISR,则低优先级HISR被抢占的方式与任务被抢占的方式大致相同。相同优先级的hisr按照它们最初激活的顺序执行。在恢复正常任务调度之前,将处理所有激活的HISR。

Nucleus RTOS中断API调用

Nucleus RTOS有许多API调用来支持其中断结构。这些都不是在Nucleus SE中实现的。

对于本机中断,API调用提供以下功能:

控制(启用/禁用)中断(本地和全局)

设置中断向量

对于低电平中断:

向内核注册一个低级ISR

对于高级中断:

创建/删除高级中断

激活高级中断

获取应用程序中(当前)的高级中断数

获取指向所有高级中断的控制块的指针

获取指向当前高级中断控制块的指针

获取有关高级中断的信息

全局控制中断

此服务以独立于任务的方式启用或禁用中断。因此,由该服务禁用的中断将保持禁用状态,直到随后对此服务的调用启用为止。

服务调用原型:

INT NU_Control_Interrupts(INT new_level);

参数:

new_level–系统的新中断级别。菜单禁用中断(禁用所有中断)和菜单启用中断(启用所有中断)选项始终可用。根据体系结构,还可以使用其他选项。

返回:

此服务返回以前级别的已启用中断。

本地控制中断

此服务以依赖于任务的方式启用或禁用中断。此服务将状态寄存器更改为指定的值。状态寄存器将被设置回下一个上下文开关上一次调用NU_Control_Interrupts()时设置的值。

服务调用原型:

INT NU_Local_Control_Interrupts(INT new_level);

参数:

new_level–当前任务的新中断级别。菜单禁用中断(禁用所有中断)和菜单启用中断(启用所有中断)选项始终可用。根据体系结构,还可以使用其他选项。

返回:

此服务返回以前级别的已启用中断。

设置中断向量

此服务用自定义中断服务例程(ISR)替换vector指定的中断向量。

服务调用原型:

VOID *NU_Setup_Vector(INT vector, VOID *new);

参数:

vector–用于注册中断的中断向量

新–ISR将在vector注册

返回:

此服务返回一个指向先前在中断向量上注册的ISR的指针。

注册LISR中断

此服务将LISR函数与中断向量相关联。系统上下文在调用指定的LISR之前自动保存,并在LISR返回后恢复。

服务调用原型:

STATUS NU_Register_LISR(INT vector, VOID(*lisr_entry)(INT),

VOID (**old_lisr)(INT));

Parameters:

vector – the interrupt vector at which to register the interrupt

lisr_entry – the function to register at the vector; a value of NU_NULL clears the vector

old_lisr – the subroutine previously registered at the specified vector

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_VECTOR – the specified vector is invalid

NU_NOT_REGISTERED – the vector is not currently registered as de-registration was specified by lisr_entry

NU_NO_MORE_LISRS – the maximum number of registered LISRs has been exceeded

Create a HISR

This service creates a High-Level Interrupt Service Routine (HISR).

Service call prototype:

STATUS NU_Create_HISR(NU_HISR *hisr, CHAR *name,

VOID (*hisr_entry)(VOID), OPTION priority, VOID *stack_pointer, UNSIGNED stack_size);
Parameters:

hisr – pointer to a user-supplied HISR control block

name – pointer to a 7-character, null-terminated name for the HISR

hisr_entry – the function entry point of the HISR

priority – there are three HISR priorities (0-2); priority 0 is the highest

stack_pointer – pointer to the HISR’s stack area

stack_size – number of bytes in the HISR stack

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR control block pointer is NULL or is already in use

NU_INVALID_ENTRY – the HISR entry pointer is NULL

NU_INVALID_PRIORITY – the HISR priority is invalid

NU_INVALID_MEMORY – the stack pointer is NULL

NU_INVALID_SIZE – the stack size is too small

Delete a HISR

This service deletes a previously created HISR.

Service call prototype:

STATUS NU_Delete_HISR(NU_HISR *hisr);

Parameters:

hisr – pointer to a user-supplied HISR control block

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR pointer is invalid

激活HISR

此服务将激活HISR。如果指定的HISR当前正在执行,则在当前执行完成之前不会处理此激活请求。每个激活请求执行一次HISR。

服务调用原型:

TATUS NU_Activate_HISR (NU_HISR *hisr);

Parameters:

hisr – pointer to the HISR control block

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR control block pointer is not valid

Obtain the Number of HISRs in a System

This service returns the number of established HISRs. All created HISRs are considered established. Deleted HISRs are no longer considered established.

Service call prototype:

UNSIGNED NU_Established_HISRs(VOID);

Parameters:

none

Returns:

This service call returns the number of established HISRs in the system

Obtain Pointers to HISR Control Blocks

This service builds a sequential list of pointers to all established HISRs in the system.

Service call prototype:

UNSIGNED NU_HISR_Pointers(NU_HISR **pointer_list,

UNSIGNED maximum_pointers);

Parameters:

pointer_list – pointer to an array of NU_HISR pointers; this array will be filled with pointers of established HISRs in the system

maximum_pointers – the maximum number of NU_HISR pointers to place into the array; typically, this will be the size of the pointer_list array

Returns:

This service call returns the number of HISRS that are active in the system

Obtain a Pointer to the Current HISR

This service returns the currently executing HISR’s pointer.

Service call prototype:

NU_HISR *NU_Current_HISR_Pointer(VOID);

Parameters:

none

Returns:

This service call returns a pointer the currently executing HISR’s control block. If the caller is not an HISR, the value returned is NU_NULL .

Obtain Information About a HISR

This service returns various information about the specified HISR.

Service call prototype:

STATUS NU_HISR_Information(NU_HISR *hisr, char *name,

UNSIGNED *scheduled_count, DATA_ELEMENT *priority,

VOID **stack_base, UNSIGNED *stack_size,

UNSIGNED *minimum_stack);

Parameters:

HISR – pointer to the HISR

name – pointer to an 8-character destination area for the HISR’s name; this includes space for the null terminator

scheduled_count – pointer to a variable for holding the total number of times this HISR has been scheduled

priority – pointer to a variable for holding the HISR’s priority

stack_base – pointer to a pointer for holding the original stack pointer; this is the same pointer supplied during creation of the HISR

stack_size – pointer to a
variable for holding the total size of the HISR’s stack

minimum_stack – pointer to a variable for holding the minimum amount of available stack space detected during HISR execution

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR pointer is invalid

API Calls from ISRs

API Calls from LISRs

A LISR may only make use of the following Nucleus RTOS services:

NU_Activate_HISR()

NU_Local_Control_Interrupts()

NU_Current_HISR_Pointer()

NU_Current_Task_Pointer()

NU_Retrieve_Clock()

API Calls from HISRs

HISRs are allowed access to most Nucleus RTOS services, with the
exception of self-suspension services. Additionally, since an HISR cannot
suspend on a Nucleus RTOS service, the “suspend” parameter must always be set to NU_NO_SUSPEND .

Nucleus 实时操作系统中断(下)相关推荐

  1. Nucleus 实时操作系统中断(上)

    Nucleus 实时操作系统中断(上) Interrupts in the Nucleus SE RTOS 所有现代微处理器和微控制器都有某种中断设施.这种能力对于提供许多应用程序所需的响应能力是必不 ...

  2. 实时操作系统概述(推荐) .

    一 实时操作系统概述 1  操作系统概述 在计算机技术发展的初期阶段,计算机系统中没有操作系统(Operating System)这个概念.应用程序开发人员都要对处理器和硬件进行彻头彻尾的控制.实际上 ...

  3. [嵌入式]嵌入式系统概述

    第1章  嵌入式系统概述   1.1  嵌入式系统概述 ·嵌入式系统的定义      嵌入式系统是以应用为中心.以计算机技术为基础.软件硬件可剪裁.适应于对系统功能.可靠性.成本.体积.功耗等有严格要 ...

  4. 主流嵌入式操作系统介绍(一)

    主流嵌入式操作系统介绍(一) 2010年08月13日 http://www.edu03.com/2010/0610/863.html 嵌入式系统是以应用为中心,软硬件可裁减的,适用于对功能.可靠性.成 ...

  5. 嵌入式操作系统的基本概念

    一什么是嵌入式系统 嵌入式系统一般指非pc系统,有计算机功能但又不称之为计算机的设备或器材.它是以应用为中心,软硬件可裁减的,适应应用系统对功能.可靠性.成本.体积.功耗等综合性严格要求的专用计算机系 ...

  6. 如何区分嵌入式系统和嵌入式操作系统

    一 什么是嵌入式系统  嵌入式系统一般指非pc系统,有计算机功能但又不称之为计算机的设备或器材.它是以应用为中 心,软硬件可裁减的,适应应用系统对功能.可靠性.成本.体积.功耗等综合性严格要求的专用计 ...

  7. 篇3:嵌入式系统和嵌入式操作系统

    一 什么是嵌入式系统 嵌入式系统一般指非PC系统,有计算机功能但又不称之为计算机的设备或器材.它是以应用为中心,软硬件可裁减的,适应应用系统对功能.可靠性.成本.体积.功耗等综合性严格要求的专用计算机 ...

  8. 嵌入式系统和嵌入式操作系统

    嵌入式系统和嵌入式操作系统 西南交通大学电气学院 张湘 肖建 2004-10-2 文章从概念.特点.种类等不同方面就嵌入式系统和嵌入式操作系统做了介绍. 一 什么是嵌入式系统 嵌入式系统一般指非PC系 ...

  9. 嵌入式操作系统介绍分析

    一,各种嵌入式操作系统介绍 1.uC/OS-II u C / OS 是一种免费公开源代码.结构小巧.具有可剥夺实时内核的实时操作系统. μC/OS-II 的前身是μC/OS,最早出自于1992 年美国 ...

最新文章

  1. 清除webBrowser 缓存和Cookie的解决方案
  2. 基于数据库数据增量同步_基于 Flink SQL CDC 的实时数据同步方案
  3. 用计算机弹假面骑士build,假面骑士build中只有资深粉丝才知道的梗第一弹
  4. mysql limit索引变_Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架...
  5. javascript单例模式【转载】
  6. fatal error: highgui.h: No such file or directory
  7. 系统架构师 项目经理 哪个更有前景_OLED和QLED电视有什么区别?哪个更好更有前景?...
  8. 随机地图生成工具 fastMapper
  9. java求等比数列求和_agile java 等比数列求和
  10. VM虚拟机安装Linux系统
  11. 2183440-33-5,Methyltetrazine-PEG8-acid在存在活化剂(如EDC或HATU)的情况下,它可用于与含胺分子共轭
  12. 相亲APP源码开发搭建应用场景及解决方案
  13. java 小球抛物线_vue 2.0 购物车小球抛物线
  14. BufferedInputStream的作用比较
  15. 细说JVM系列:自动内存管理内存回收:垃圾收集理论-垃圾收集算法
  16. 怎样区别交换机、路由器和猫
  17. Android获取AP热点IP,获取连接到本机AP热点设备的IP地址
  18. [水晶报表]为水晶报表(含子报表)绑定数据
  19. 希捷硬盘的问题/移动硬盘/USB 硬盘和芯片
  20. Windows10安装Apache2.4

热门文章

  1. 2021-2027全球与中国跨临界二氧化碳系统市场现状及未来发展趋势报告
  2. keyshot怎么批量渲染_提高Keyshot逼真渲染的小技巧
  3. 求字符串全排列 python实现
  4. 【J2SE】学习基础
  5. 什么是高/低方差、高/低偏差、(推荐阅读)
  6. TorchScript神经网络集成技术
  7. 语义分割:基于openCV和深度学习(二)
  8. Docker核心技术之镜像
  9. 第三个Python程序:Python函数
  10. android studio so文件的添加