ARM中斷函數(shù)定義
ARM的中斷函數(shù)是在startup code中定義的,在CODE區(qū)分配中斷向量表時(shí),及將中斷函數(shù)定義出了
本文引用地址:http://butianyuan.cn/article/201808/388107.htm; 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 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中定義的中斷函數(shù)都是[weak]屬性,如果編譯器在別的文件中發(fā)現(xiàn)相同的函數(shù)名,則在鏈接時(shí)用別處的地址進(jìn)行鏈接。
所以只要在工程的具體位置,按startup code中定義的名稱直接完整該函數(shù)即可,不用在特別聲明和與中斷向量號(hào)聯(lián)系起來(lái)。
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 */
/* 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;
}
}
評(píng)論