📄 71x_vect.s
字号:
#******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
#* File Name : 71x_vect.s
#* Author : MCD Application Team
#* Date First Issued : 16/05/2003
#* Description : This file used to initialize the exception and IRQ
#* vectors, and to enter/return to/from exceptions handlers.
#*******************************************************************************
#* History:
#* 01/01/2004 : V1.2
#* 14/07/2004 : V1.3
#*******************************************************************************
.equ EIC_base_addr, 0xFFFFF800/* EIC base address. */
.equ CICR_off_addr, 0x04 /* Current Interrupt Channel Register. */
.equ IVR_off_addr, 0x18 /* Interrupt Vector Register. */
.equ IPR_off_addr, 0x40 /* Interrupt Pending Register. */
#*******************************************************************************
# Import the Reset_Handler address from 71x_init.s
#*******************************************************************************
.extern Reset_Handler
#*******************************************************************************
# Import exception handlers
#*******************************************************************************
.extern Undefined_Handler
.extern SWI_Handler
.extern Prefetch_Handler
.extern Abort_Handler
.extern FIQ_Handler
#*******************************************************************************
# Import IRQ handlers from 71x_it.c
#*******************************************************************************
.extern T0TIMI_IRQHandler
.extern FLASH_IRQHandler
.extern RCCU_IRQHandler
.extern RTC_IRQHandler
.extern WDG_IRQHandler
.extern XTI_IRQHandler
.extern USBHP_IRQHandler
.extern I2C0ITERR_IRQHandler
.extern I2C1ITERR_IRQHandler
.extern UART0_IRQHandler
.extern UART1_IRQHandler
.extern UART2_IRQHandler
.extern UART3_IRQHandler
.extern BSPI0_IRQHandler
.extern BSPI1_IRQHandler
.extern I2C0_IRQHandler
.extern I2C1_IRQHandler
.extern CAN_IRQHandler
.extern ADC12_IRQHandler
.extern T1TIMI_IRQHandler
.extern T2TIMI_IRQHandler
.extern T3TIMI_IRQHandler
.extern HDLC_IRQHandler
.extern USBLP_IRQHandler
.extern T0TOI_IRQHandler
.extern T0OC1_IRQHandler
.extern T0OC2_IRQHandler
#*******************************************************************************
# Export Peripherals IRQ handlers table address
#*******************************************************************************
.global T0TIMI_Addr
.global IRQHandler
#*******************************************************************************
#
#*******************************************************************************
.global vector_begin
.global vector_end
.text
vector_begin:
#*******************************************************************************
# Exception vectors
#*******************************************************************************
LDR PC, =Reset_Handler
LDR PC, =UndefinedHandler
LDR PC, =SWIHandler
LDR PC, =PrefetchAbortHandler
LDR PC, =DataAbortHandler
NOP /* Reserved vector */
LDR PC, =IRQHandler
LDR PC, =FIQHandler
#*******************************************************************************
# Peripherals IRQ handlers address table
#*******************************************************************************
T0TIMI_Addr: .long T0TIMIIRQHandler
FLASH_Addr: .long FLASHIRQHandler
RCCU_Addr: .long RCCUIRQHandler
RTC_Addr: .long RTCIRQHandler
WDG_Addr: .long WDGIRQHandler
XTI_Addr: .long XTIIRQHandler
USBHP_Addr: .long USBHPIRQHandler
I2C0ITERR_Addr: .long I2C0ITERRIRQHandler
I2C1ITERR_ADDR: .long I2C1ITERRIRQHandler
UART0_Addr: .long UART0IRQHandler
UART1_Addr: .long UART1IRQHandler
UART2_ADDR: .long UART2IRQHandler
UART3_ADDR: .long UART3IRQHandler
BSPI0_ADDR: .long BSPI0IRQHandler
BSPI1_Addr: .long BSPI1IRQHandler
I2C0_Addr: .long I2C0IRQHandler
I2C1_Addr: .long I2C1IRQHandler
CAN_Addr: .long CANIRQHandler
ADC12_Addr: .long ADC12IRQHandler
T1TIMI_Addr: .long T1TIMIIRQHandler
T2TIMI_Addr: .long T2TIMIIRQHandler
T3TIMI_Addr: .long T3TIMIIRQHandler
.long 0 /* reserved */
.long 0 /* reserved */
.long 0 /* reserved */
HDLC_Addr: .long HDLCIRQHandler
USBLP_Addr: .long USBLPIRQHandler
.long 0 /* reserved */
.long 0 /* reserved */
T0TOI_Addr: .long T0TOIIRQHandler
T0OC1_Addr: .long T0OC1IRQHandler
T0OC2_Addr: .long T0OC2IRQHandler
vector_end:
#*******************************************************************************
# Exception Handlers
#*******************************************************************************
#*******************************************************************************
#* Macro Name : SaveContext
#* Description : This macro used to save the context before entering
# an exception handler.
#* Input : The range of registers to store.
#* Output : none
#*******************************************************************************
.macro SaveContext reg1,reg2
STMFD sp!,{\reg1-\reg2,lr} /* Save The workspace plus the current return */
/* address lr_ mode into the stack. */
MRS r1,spsr /* Save the spsr_mode into r1. */
STMFD sp!,{r1} /* Save spsr. */
.endm
#*******************************************************************************
#* Macro Name : RestoreContext
#* Description : This macro used to restore the context to return from
# an exception handler and continue the program execution.
#* Input : The range of registers to restore.
#* Output : none
#*******************************************************************************
.macro RestoreContext reg1,reg2
LDMFD sp!,{r1} /* Restore the saved spsr_mode into r1. */
MSR spsr_cxsf,r1 /* Restore spsr_mode. */
LDMFD sp!,{\reg1-\reg2,pc}^/* Return to the instruction following
the exception interrupt. */
.endm
#*******************************************************************************
#* Function Name : UndefinedHandler
#* Description : This function called when undefined instruction
# exception is entered.
#* Input : none
#* Output : none
#*******************************************************************************
UndefinedHandler:
SaveContext r0,r11 /* Save the workspace plus the current */
/* return address lr_ und and spsr_und. */
BL Undefined_Handler/* Branch to Undefined_Handler. */
RestoreContext r0,r11 /* Return to the instruction following
the undefined instruction. */
#*******************************************************************************
#* Function Name : SWIHandler
#* Description : This function called when SWI instruction executed.
#* Input : none
#* Output : none
#*******************************************************************************
SWIHandler:
SaveContext r0,r11 /* Save the workspace plus the current */
/* return address lr_ svc and spsr_svc. */
BL SWI_Handler /* Branch to SWI_Handler. */
RestoreContext r0,r11 /* Return to the instruction following
the SWI instruction. */
#*******************************************************************************
#* Function Name : IRQHandler
#* Description : This function called when IRQ exception is entered.
#* Input : none
#* Output : none
#*******************************************************************************
IRQHandler:
SUB lr,lr,#4 /* Update the link register */
SaveContext r0,r11 /* Save the workspace plus the current */
/* return address lr_ irq and spsr_irq. */
LDR lr, =ReturnAddress /* Read the return address. */
LDR r0, =EIC_base_addr
LDR r1, =IVR_off_addr
ADD pc,r0,r1 /* Branch to the IRQ handler. */
ReturnAddress:
/* Clear pending bit in EIC (using the proper IPRx) */
LDR r0, =EIC_base_addr
LDR r2, [r0, #CICR_off_addr] /* Get the IRQ channel number. */
MOV r3,#1
MOV r3,r3,LSL r2
STR r3,[r0, #IPR_off_addr] /* Clear the corresponding IPR bit. */
RestoreContext r0,r11 /* Restore the context and return to the
program execution. */
#*******************************************************************************
#* Function Name : PrefetchAbortHandler
#* Description : This function called when Prefetch Abort
# exception is entered.
#* Input : none
#* Output : none
#*******************************************************************************
PrefetchAbortHandler:
SUB lr,lr,#4 /* Update the link register. */
SaveContext r0,r11 /* Save the workspace plus the current */
/* return address lr_abt and spsr_abt. */
BL Prefetch_Handler/* Branch to Prefetch_Handler. */
RestoreContext r0,r11 /* Return to the instruction following that
has generated the prefetch abort exception. */
#*******************************************************************************
#* Function Name : DataAbortHandler
#* Description : This function is called when Data Abort
# exception is entered.
#* Input : none
#* Output : none
#*******************************************************************************
DataAbortHandler:
SUB lr,lr,#8 /* Update the link register. */
SaveContext r0,r11 /* Save the workspace plus the current */
/* return address lr_ abt and spsr_abt. */
BL Abort_Handler /* Branch to Abort_Handler. */
RestoreContext r0,r11 /* Return to the instruction following that
has generated the data abort exception. */
#*******************************************************************************
#* Function Name : FIQHandler
#* Description : This function is called when FIQ
# exception is entered.
#* Input : none
#* Output : none
#*******************************************************************************
FIQHandler:
SUB lr,lr,#4 /* Update the link register. */
SaveContext r0,r7 /* Save the workspace plus the current */
/* return address lr_ fiq and spsr_fiq. */
BL FIQ_Handler /* Branch to FIQ_Handler. */
RestoreContext r0,r7 /* Restore the context and return to the
program execution. */
#*******************************************************************************
#* Macro Name : IRQ_to_SYS
#* Description : This macro used to switch form IRQ mode to SYS mode
#* Input : none.
#* Output : none
#*******************************************************************************
.macro IRQ_to_SYS
MSR cpsr_c,#0x1F /* Switch to SYS mode */
STMFD sp!,{lr} /* Save the link register. */
.endm
#*******************************************************************************
#* Macro Name : SYS_to_IRQ
#* Description : This macro used to switch from SYS mode to IRQ mode
# then to return to IRQHnadler routine.
#* Input : none.
#* Output : none.
#*******************************************************************************
.macro SYS_to_IRQ
LDMFD sp!,{lr} /* Restore the link register. */
MSR cpsr_c,#0xD2 /* Switch to IRQ mode. */
MOV pc,lr /* Return to IRQHandler routine to clear the
pending bit. */
.endm
#*******************************************************************************
#* Function Name : T0TIMIIRQHandler
#* Description : This function used to switch to SYS mode before entering
# the T0TIMI_IRQHandler function located in 71x_it.c.
# Then to return to IRQ mode after the
# T0TIMI_IRQHandler function termination.
#* Input : none.
#* Output : none.
#*******************************************************************************
T0TIMIIRQHandler:
IRQ_to_SYS
BL T0TIMI_IRQHandler
SYS_to_IRQ
#*******************************************************************************
#* Function Name : FLASHIRQHandler
#* Description : This function used to switch to SYS mode before entering
# the FLASH_IRQHandler function located in 71x_it.c.
# Then to return to IRQ mode after the
# FLASH_IRQHandler function termination.
#* Input : none
#* Output : none
#*******************************************************************************
FLASHIRQHandler:
IRQ_to_SYS
BL FLASH_IRQHandler
SYS_to_IRQ
#*******************************************************************************
#* Function Name : RCCUIRQHandler
#* Description : This function used to switch to SYS mode before entering
# the RCCU_IRQHandler function located in 71x_it.c.
# Then to return to IRQ mode after the
# RCCU_IRQHandler function termination.
#* Input : none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -