ARM的中断函数是在startup code中定义的,在CODE区分配中断向量表时,及将中断函数定义出了
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD GPIO0_IRQHandler ; GPIO P0 Interrupt
DCD GPIO1_IRQHandler ; GPIO P1 Interrupt
DCD GPIO2_IRQHandler ; GPIO P2 Interrupt
DCD GPIO3_IRQHandler ; GPIO P3 Interrupt
DCD GPIO4_IRQHandler ; GPIO P4 Interrupt
DCD CP_IRQHandler ; Capture/PWM
DCD ADC_IRQHandler ; A/D Converter
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
DCD UART0_IRQHandler ; UART0
DCD UART1_IRQHandler ; UART1
DCD UART2_IRQHandler ; UART2
DCD UART3_IRQHandler ; UART3
DCD TIMER0_IRQHandler ; Timer0
DCD TIMER1_IRQHandler ; Timer1
DCD TIMER2_IRQHandler ; Timer2
DCD TIMER3_IRQHandler ; Timer3
DCD WDT_IRQHandler ; Watchdog timer
DCD I2C0_IRQHandler ; I2C0
DCD I2C1_IRQHandler ; I2C1
DCD SSP0_IRQHandler ; SSP0
DCD SSP1_IRQHandler ; SSP1
DCD TIMER01_IRQHandler ; Timer0 & Timer1
DCD TIMER23_IRQHandler ; Timer2 & Timer3
DCD Reserved_IRQHandler ; Reserved
DCD Reserved_IRQHandler ; Reserved
AREA |.text|, CODE, READONLY
不同芯片有各自的startup code,所以定义不同。
在startup code中定义的中断函数都是[weak]属性,如果编译器在别的文件中发现相同的函数名,则在链接时用别处的地址进行链接。
所以只要在工程的具体位置,按startup code中定义的名称直接完整该函数即可,不用在特别声明和与中断向量号联系起来。
Default_Handler PROC
EXPORT GPIO0_IRQHandler [WEAK]
EXPORT GPIO1_IRQHandler [WEAK]
EXPORT GPIO2_IRQHandler [WEAK]
EXPORT GPIO3_IRQHandler [WEAK]
EXPORT GPIO4_IRQHandler [WEAK]
EXPORT CP_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT SSP0RXINT_IRQHandler [WEAK]
EXPORT SSP0TXINT_IRQHandler [WEAK]
EXPORT SSP0RORINT_IRQHandler [WEAK]
EXPORT SSP0RTINT_IRQHandler [WEAK]
EXPORT SSP1RXINT_IRQHandler [WEAK]
EXPORT SSP1TXINT_IRQHandler [WEAK]
EXPORT SSP1RORINT_IRQHandler [WEAK]
EXPORT SSP1RTINT_IRQHandler [WEAK]
EXPORT UART0_IRQHandler [WEAK]
EXPORT UART1_IRQHandler [WEAK]
EXPORT UART2_IRQHandler [WEAK]
EXPORT UART3_IRQHandler [WEAK]
EXPORT TIMER0_IRQHandler [WEAK]
EXPORT TIMER1_IRQHandler [WEAK]
EXPORT TIMER2_IRQHandler [WEAK]
EXPORT TIMER3_IRQHandler [WEAK]
EXPORT WDT_IRQHandler [WEAK]
EXPORT I2C0_IRQHandler [WEAK]
EXPORT I2C1_IRQHandler [WEAK]
EXPORT SSP0_IRQHandler [WEAK]
EXPORT SSP1_IRQHandler [WEAK]
EXPORT TIMER01_IRQHandler [WEAK]
EXPORT TIMER23_IRQHandler [WEAK]
在具体的.c文件中
/*---------------------------------------------------------------------------------------------------------*/
/* Interrupt Handler */
/*---------------------------------------------------------------------------------------------------------*/
void I2C0_IRQHandler(void)
{
uint32_t status;
status = I2C0->STAT;
switch (status)
{
/* Arbitration loss */
case 0x38:
if (I2CHandler[0].ArbitLossCallBackFn)
I2CHandler[0].ArbitLossCallBackFn(status);
break;
/* Bus error */
case 0x00:
if (I2CHandler[0].BusErrCallBackFn)
I2CHandler[0].BusErrCallBackFn(status);
break;
default:
if (I2CHandler[0].I2CCallBackFn)
I2CHandler[0].I2CCallBackFn(status);
break;
}
}
上一篇:ARM中断向量程序实例
下一篇:初识stm32-----串口1的中断收发
推荐阅读最新更新时间:2024-03-16 16:20
设计资源 培训 开发板 精华推荐
- 【TI首届低功耗设计大赛】“偷电”的蓝牙温度计_Part4_软件环境搭建
- 最近想做这个课题《无线通信信号分析与测量装置》大家来讨论下吧!
- G2553 IIc硬件IIC,求教
- 用WDT时复位后单片机就死了
- outportb(regaddr,data) 是否等价于:data=*regaddr?
- 我的电子技术入门之路
- 如何使用74HC573来实现一个接口多种用途?
- 软件测试经典资料大推荐(十九)---步步为赢:软件测试管理全程实践
- 有没有大师在,帮忙分析分析这块板子,有那些错误点,怎么画的更好呢?感谢~~
- 求救!请问市面上有 GSM 网络的语音接入设备(板卡或mddem都可以)-- 不是短信猫,要可以支持语音AT指令和实现DTMF按键采集接口!