gpt4 book ai didi

c - Keil Arm 编译器 : Is there a way to hook in the same function for two interrupts without modifying the Interrupt Vector Table?

转载 作者:太空宇宙 更新时间:2023-11-04 06:46:19 24 4
gpt4 key购买 nike

在嵌入式项目中,我需要使用同一个 IRQ 处理程序处理两个不同的外部中断。我不想直接更改启动程序集中的中断 vector 表条目,因此我必须坚持使用 IRQ 处理程序例程(EXTI9_5_IRQHandler 和 EXTI15_10_IRQHandler)的预定义函数名称。

对于这两个中断,我需要完全相同的代码来处理中断。

当然,我可以这样编程:

void realIRQHandler (void)
{
//do some magic interrupt handling here
return;
}

void EXTI9_5_IRQHandler(void)
{
realIRQHandler(); //calls the real IRQ handler function
}

void EXTI15_10_IRQHandler(void)
{
realIRQHandler(); //calls the real IRQ handler function
}

这最终会做我想做的,但它会有一个普通的函数调用,在每次中断调用中都会有将寄存器推送和恢复到堆栈的开销。

有没有办法以某种方式替换 EXTI9_5_IRQHandlerEXTI15_10_IRQHandler 中的那些函数调用,并将其替换为一些无条件分支或跳转?

返回/退出时,realIRQHandler 的末尾需要什么?

谢谢!问候,菲利克斯

最佳答案

I don't want to change the interrupt vector table entries in the startup assembly directly

这就是问题所在。该表的唯一正确解决方案是修改 vector 表。因此, vector 表不应定义在某个启动文件中,而应定义在它自己的文件中。链接描述文件或 .c 文件(函数指针数组)。

如果不能修改 vector 表,就不能在工具链上进行微 Controller 编程。因此,如果您的编译器/链接器无法提供一种简单的方法来执行此操作,您将不得不自定义启动代码。

关于c - Keil Arm 编译器 : Is there a way to hook in the same function for two interrupts without modifying the Interrupt Vector Table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57570040/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com