📄 asm_isr.s
字号:
#------------------------------------------------------------------------------
#- ATMEL Microcontroller Software Support - ROUSSET -
#------------------------------------------------------------------------------
# The software is delivered "AS IS" without warranty or condition of any
# kind, either express, implied or statutory. This includes without
# limitation any warranty or condition with respect to merchantability or
# fitness for any particular purpose, or against the infringements of
# intellectual property rights of others.
#-----------------------------------------------------------------------------
#- File source : it_handler.s
#- Object : Example of IT handler calling a C function
#- Compilation flag : None
#-
#- 1.0 16/03/01 ODi, : Creation ARM ADS
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#- LISR vector handler for system peripherals
#--------------------------------------------
#- This macro save the context, call the LISR dispatch routine, and restore
#- the context
#------------------------------------------------------------------------------
#.INCLUDE "AT91RM9200.inc"
#--------------------------------
#- ARM Core Mode and Status Bits
#--------------------------------
#7 work mode
.EQU ARM_MODE_USER, 0x10
.EQU ARM_MODE_FIQ, 0x11
.EQU ARM_MODE_IRQ, 0x12
.EQU ARM_MODE_SVC, 0x13
.EQU ARM_MODE_ABORT, 0x17
.EQU ARM_MODE_UNDEF, 0x1B
.EQU ARM_MODE_SYS, 0x1F
#interrupt shield bit
.EQU I_BIT, 0x80
.EQU F_BIT, 0x40
#state shield bit
.EQU T_BIT, 0x20
.EQU AT91C_AIC_IVR, (0xFFFFF100) @- (AIC) IRQ Vector Register
.EQU AT91C_AIC_EOICR, (0xFFFFF130) @- (AIC) End of Interrupt Command Register
.EQU AT91C_BASE_AIC, (0xFFFFF000) @- (AIC) Base Address
.macro IRQHandle in_handle,out_handle
.extern \in_handle
.global \out_handle
\out_handle:
#- Adjust and save LR_irq in IRQ stack
sub r14, r14, #4
stmfd sp!, {r14}
#- Write in the IVR to support Protect Mode
#- No effect in Normal Mode
#- De-assert the NIRQ and clear the source in Protect Mode
ldr r14, =AT91C_BASE_AIC
str r14, [r14, #AT91C_AIC_IVR-AT91C_BASE_AIC]
#- Save SPSR and r0 in IRQ stack
mrs r14, SPSR
stmfd sp!, {r0, r14}
#- Enable Interrupt and Switch in SYS Mode
mrs r0, CPSR
bic r0, r0, #I_BIT
orr r0, r0, #ARM_MODE_SYS
msr CPSR_c, r0
#- Save scratch/used registers and LR in User Stack
stmfd sp!, { r1-r3, r12, r14}
ldr r1, =\in_handle
mov lr, pc
bx r1
#- Restore scratch/used registers and LR from User Stack
ldmia sp!, { r1-r3, r12, r14}
#- Disable Interrupt and switch back in IRQ mode
mrs r0, CPSR
bic r0, r0, #ARM_MODE_SYS
orr r0, r0, #I_BIT|ARM_MODE_IRQ
msr CPSR_c, r0
#- Mark the End of Interrupt on the AIC
ldr r0, =AT91C_BASE_AIC
str r0, [r0, #AT91C_AIC_EOICR-AT91C_BASE_AIC]
#- Restore SPSR_irq and r0 from IRQ stack
ldmia sp!, {r0, r14}
msr SPSR_cxsf, r14
#- Restore adjusted LR_irq from IRQ stack directly in the PC
ldmia sp!, {pc}^
.ENDM
IRQHandle AT91F_DBGU_Handler,AT91F_ASM_DBGU_Handler
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -