wait_irq.mac

来自「有关ATMEL AT91系列CPU的驱动函数库」· MAC 代码 · 共 63 行

MAC
63
字号
#------------------------------------------------------------------------------
#-         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          : wait_irq.mac
#- Object               : Assembler Wait Interrupt Handler Macro
#-
#- 1.0 01/04/00 JCZ     : Creation
#- 1.1 02/11/00 JPP     : Green Hills
#------------------------------------------------------------------------------

#            AREA        wait_irq, CODE, READONLY, INTERWORK

            .INCLUDE     "../../periph/timer_counter/tc.inc"
           
#------------------------------------------------------------------------------
#- Function         : wait_irq
#- Treatments       : Wait Interrupt Handler
#- Operations       :
#-      - Write the IVR ( Protect Mode support )
#-      - Write the End of Interrupt Command Register
#-      - Read the TC Status Register to remove the wake-up interrupt 
#-      - Return
#------------------------------------------------------------------------------
          .macro wait_irq_asm_handler WaitDesc, IrqHandler

            .global  IrqHandler
            .extern  WaitDesc
            
IrqHandler:
#- Adjust and save LR_irq in IRQ stack
            stmfd       sp!, {r0}

#- 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         r0, =AIC_BASE
            str         r0, [r0, #AIC_IVR]
#- Mark the End of Interrupt on the AIC
            str         r0, [r0, #AIC_EOICR]

#- Read the Status Register of the used Timer Counter
            ldr         r0, =WaitDesc
            ldr         r0, [r0]        	/* get the Timer Counter Descriptor Address   */
            ldr         r0, [r0]        	/* get the Timer Counter Channel Base Address */
            ldr         r0, [r0, #TC_SR]
            
#- Adjust and save LR_irq in IRQ stack
            ldmia       sp!, {r0}

#- Adjust LR_irq and return 
            subs        pc, r14, #4

            .endm

#            END

⌨️ 快捷键说明

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