arch_interrupt.h 源码
2026/7/20大约 1 分钟源码参考架构层中断管理头文件
arch_interrupt.h — 中断管理接口头文件
源文件路径: arch/arm/armv7m/include/arch_interrupt.h
引用章节: 4.9 中断管理
完整源码
/**
***********************************************************************************************************************
* Copyright (c) 2020, China Mobile Communications Group Co.,Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* @file arch_interrupt.h
*
* @brief Header file for interrupt related functions.
*
* @revision
* Date Author Notes
* 2021-01-12 OneOS Team First version.
***********************************************************************************************************************
*/
#ifndef __ARCH_INTERRUPT_H__
#define __ARCH_INTERRUPT_H__
#include <os_types.h>
#include <oneos_config.h>
#ifdef __cplusplus
extern "C" {
#endif
extern os_ubase_t os_irq_lock(void);
extern void os_irq_unlock(os_ubase_t irq_save);
extern void os_irq_disable(void);
extern void os_irq_enable(void);
extern os_bool_t os_is_irq_active(void);
extern os_bool_t os_is_irq_disabled(void);
extern uint32_t os_irq_num(void);
extern os_bool_t os_is_fault_active(void);
#ifdef OS_USING_INTERRUPT_STACK_OVERFLOW_CHECK
extern void os_interrupt_stack_check(void);
#else
#define os_interrupt_stack_check()
#endif
#ifdef __cplusplus
}
#endif
#endif /* __ARCH_INTERRUPT_H__ */关键说明
| 模块 | 说明 |
|---|---|
| 中断控制 | os_irq_lock/unlock 保存/恢复 PRIMASK(支持嵌套),os_irq_disable/enable 不保存状态(不可嵌套) |
| 状态查询 | os_is_irq_active 读 IPSR 判断中断上下文,os_is_irq_disabled 读 PRIMASK 判断中断开关 |
| 中断号 | os_irq_num 读取 IPSR 获取当前中断号(0=任务上下文,≥16=外设中断) |
| 异常判断 | os_is_fault_active 判断 IPSR 是否在 [3,6] 范围(HardFault~UsageFault) |
| 栈检测 | os_interrupt_stack_check 由 OS_USING_INTERRUPT_STACK_OVERFLOW_CHECK 条件编译控制 |