⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irq_pio.s

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 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          : irq_pio.s
;- Object               : Assembler PIO Controller Interrupt Handler.
;-
;- 1.0 14/01/02  PFi    : Creation
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
;- Area Definition
;-----------------
;- Must be defined as function to put first in the code as it must be mapped
;- at SRAM.
;------------------------------------------------------------------------------
           AREA    AT91Lib, CODE, READONLY, INTERWORK

           INCLUDE     ../../periph/pio/pio.inc
           INCLUDE     ../../periph/aic/irq.mac
           
;------------------------------------------------------------------------------
;- Function             : pio_asm_irq_handler
;- Treatments           : Parallel IO Controller Interrupt Handler.
;- Called Functions     : pioa_irq_handler
;- Called Macros        : IRQ_ENTRY, IRQ_EXIT
;------------------------------------------------------------------------------

            EXPORT pio_asm_irq_handler
            IMPORT pio_c_irq_handler
            
pio_asm_irq_handler

;- Manage Exception Entry

            IRQ_ENTRY

;- Call the PIO Interrupt C handler

            ldr         r0, =pio_c_irq_handler
            mov         r14, pc
            bx          r0

;- Manage Exception Exit

            IRQ_EXIT

;------------------------------------------------------------------------------
;- Function             : irq0_asm_irq_handler
;- Treatments           : IRQ0 IO Controller Interrupt Handler.
;- Called Functions     : at91_IRQ0_handler
;- Called Macros        : IRQ_ENTRY, IRQ_EXIT
;------------------------------------------------------------------------------
            EXPORT  irq0_asm_irq_handler 
            IMPORT  at91_IRQ0_handler
            
irq0_asm_irq_handler

;- Manage Exception Entry

            IRQ_ENTRY

;- Call the PIO Interrupt C handler

            ldr         r0, =at91_IRQ0_handler
            mov         r14, pc
            bx          r0

;- Manage Exception Exit

            IRQ_EXIT        

;------------------------------------------------------------------------------
;- Function             : sw_asm_irq_handler
;- Treatments           : software Controller Interrupt Handler.
;- Called Functions     : aic_sotfware_interrupt
;- Called Macros        : IRQ_ENTRY, IRQ_EXIT
;------------------------------------------------------------------------------
            EXPORT  sw_asm_irq_handler
            IMPORT  aic_sotfware_interrupt
            

sw_asm_irq_handler

;- Manage Exception Entry

           IRQ_ENTRY

;- Call the PIO Interrupt C handler

            ldr         r0, =aic_sotfware_interrupt
            mov         r14, pc
            bx          r0

;- Manage Exception Exit
 
           IRQ_EXIT
           
;------------------------------------------------------------------------------
;- Function             : asm_fiq_init_handler
;- Treatments           : FIQ Init register.
;- Called Functions     : none
;- Called Macros        : IRQ_ENTRY, IRQ_EXIT
;------------------------------------------------------------------------------
           EXPORT      asm_fiq_init_handler

asm_fiq_init_handler

;- Adjust and save LR_irq in IRQ stack

            sub         r14, r14, #4
            stmfd       sp!, {r14}
            ldr         r12, =AIC_BASE

;- De-assert the NIRQ and clear the source in Protect Mode

            str         r12, [r12, #AIC_IVR]

;- Not Marking the End of Interrupt on the AIC

;- Restore adjusted  LR_irq from IRQ stack directly in the PC

            ldmia       sp!, {pc}^

;------------------------------------------------------------------------------
;- Function             : asm_fiq_handler
;- Treatments           : software Controller Interrupt Handler.
;- Called Functions     : aic_sotfware_interrupt
;- Called Macros        : IRQ_ENTRY, IRQ_EXIT
;------------------------------------------------------------------------------
          EXPORT    asm_fiq_handler 
          IMPORT    FIQ_handler           
        
;- Adjust and save LR_fiq in FIQ stack

asm_fiq_handler
        
;- 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

            str         r12, [r12, #AIC_IVR]

;- 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, #F_BIT
            orr         r0, r0, #ARM_MODE_SYS
            msr         CPSR_c, r0                  ;- Swap in SYS mode
            stmfd       sp!, { r1-r3, r12, r14}

;- Call the Interrupt C handler

            ldr     r0, =FIQ_handler
            mov         r14, pc
            bx          r0           

;- 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, #F_BIT | ARM_MODE_FIQ
            msr         CPSR_c, r0          			;- Swap in FIQ mode

;- No Mark the End of Interrupt on the 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}^

       END            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -