您的位置:首页 > 房产 > 家装 > Cortex-A7:__disable_irq和GIC_DisableIRQ、__enable_irq和GIC_EnableIRQ的区别(1)API介绍

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

2024/10/6 2:20:04 来源:https://blog.csdn.net/kevin1499/article/details/142281528  浏览:    关键词: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,相关寄存器说明如下:
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com