Cortex-A7:__disable_irq和GIC_DisableIRQ、__enable_irq和GIC_EnableIRQ的区别(1)API介绍

0 相关资料

ARM® Generic Interrupt Controller Architecture version 2.0.pdf

1 API介绍

1.1 __disable_irq

__disable_irq函数的作用是失能IRQ,也就是不响应中断。实现代码如下:

/**
  \brief   Disable IRQ Interrupts
  \details Disables IRQ interrupts by setting the I-bit in the CPSR.
  Can only be executed in Privileged modes.
 */
__STATIC_FORCEINLINE void __disable_irq(void)
{
  __ASM volatile ("cpsid i" : : : "memory");
}

具体工作就是操作CPSR寄存器的I位,将I位设置为1,失能IRQ。相关寄存器如下:
在这里插入图片描述
在这里插入图片描述

1.2 GIC_DisableIRQ

GIC_DisableIRQ是将指定的中断禁用,不再响应该中断。

/** \brief Disables the given interrupt using GIC's ICENABLER register.
* \param [in] IRQn The interrupt to be disabled.
*/
__STATIC_INLINE void GIC_DisableIRQ(IRQn_Type IRQn)
{
  GICDistributor->ICENABLER[IRQn / 32U] = 1U << (IRQn % 32U);
}

具体工作就是将中断对应的中断清使能位置1,相关寄存器说明如下:
在这里插入图片描述

1.3 __enable_irq

__enable_irq函数的作用是取消对IRQ的失能,也就是响应中断。实现代码如下:

/**
  \brief   Enable IRQ Interrupts
  \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
           Can only be executed in Privileged modes.
 */
__STATIC_FORCEINLINE void __enable_irq(void)
{
  __ASM volatile ("cpsie i" : : : "memory");
}

具体工作就是操作CPSR寄存器的I位,将I位设置为0,取消对IRQ的失能。相关寄存器如下:
在这里插入图片描述
在这里插入图片描述

1.4 GIC_EnableIRQ

GIC_EnableIRQ函数的作用是将指定的中断使能,响应该中断。

/** \brief Enables the given interrupt using GIC's ISENABLER register.
* \param [in] IRQn The interrupt to be enabled.
*/
__STATIC_INLINE void GIC_EnableIRQ(IRQn_Type IRQn)
{
  GICDistributor->ISENABLER[IRQn / 32U] = 1U << (IRQn % 32U);
}

具体工作就是将中断对应的中断设置使能位置1,相关寄存器说明如下:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NW嵌入式开发

感谢您的支持,让我们一起进步!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值