📄 irq_pio.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 Interrupt Handler.
- Translator : ARM Software Development Toolkit V2.11a
-
- Imported Resources :
- PIOHandlerTable
- PtPIOBase
- Exported Resources :
- pio_interrupt_handler
-
- 1.0 JCZ 03/11/97 : Creation
- 1.1 JCZ 24/04/98 : Add END at the end of file
- 1.2 JCZ 15/09/98 : See irq.mac 1.1
- 2.0 JCZ 21/10/98 : Clean up and add interworking capabilities
------------------------------------------------------------------------------
The handlers for each PIO are stored in the table <PIOHandlerTable>.
When an interrupt occurs, the core branchs here. After management of the
system each PIO lines interrupt is tested. If present the corresponding
handler is called with as argument the PIO Controller base address and a mask
identifying the PIO line.
The PIO lines are looked for byte by byte to decrease latency time on
highest bits.
------------------------------------------------------------------------------
*/
/* AREA AT91Lib, CODE, READONLY, INTERWORK */
/* .section code,r
.interwork
*/
/* -------------------------- List of Included Files --------------------------- */
.INCLUDE "../Include/arm.inc"
.INCLUDE "../Include/pio.inc"
.INCLUDE "../Include/aic.inc"
.INCLUDE "../Include/irq.mac"
/* ------------------------ List of constants and types ------------------------ */
/* None */
/* ------------------------ List of Imported resources ------------------------- */
.global PIOHandlerTable
/* ------------------------ List of Internal resources ------------------------- */
PtPIOBase:
.long PIO_BASE
/* ------------------------- List of Exported resources ------------------------- */
/*
------------------------------------------------------------------------------
- Function : pio_interrupt_handler
- Treatments : Parallel IO Controller Interrupt Handler.
- Input Parameters : None
- Output Parameters :
- When the handler is called :
- r0 = PIO Controller Base Address
- r1 = Current Bit mask (to identify the pin)
- Registers lost : None
- Called Functions : The corresponding handler, when an interrupt is found.
- Called Macros :
- IRQ_ENTRY, IRQ_EXIT
------------------------------------------------------------------------------
*/
.list
.global pio_interrupt_handler
pio_interrupt_handler:
/*- Manage Exception Entry */
IRQ_ENTRY r4-r7
/*- Load the Address of the PIO Controller Base address */
ldr r4, PtPIOBase
/* Load the address of the PIO Handler Table */
ldr r5, =PIOHandlerTable
look_for_interrupt:
/*- Read the interrupt status register and clear it */
ldr r0, [r4, #PIO_ISR]
/*- Read the Interrupt Mask Register */
ldr r1, [r4, #PIO_IMR]
/*- Clear disabled status bits */
and r6, r1, r0
/*- Initialize bit mask */
mov r7, #1
/*- Byte 0 */
/*-------- */
/*- If byte 0 == 0x00 */
ands r0, r6, #0xFF
/*- | Shift left mask 8 times */
moveq r7, r7, lsl #8
/*- | Update the Handler Pointer */
addeq r5, r5, #8*4
beq TestByte1
/*- Else */
/*- | While mask differs from 1<<8 */
Loop0:
ands r0, r7, #1<<8
bne TestByte1
/*- | | If current bit is 1 */
ands r0, r6, r7
/*- | | | Load parameters */
movne r0, r4
movne r1, r7
/*- | | | Update the Return Address and Branch on handler */
ldrne r2, [r5]
movne r14, pc
bxne r2
/*- | | EndIf */
/*- | | Update the handler pointer */
add r5, r5, #4
/*- | | Left Shift the bit mask */
mov r7, r7, lsl #1
/*- | EndWhile */
b Loop0
/*- EndIf */
/*- Byte 1 */
/*-------- */
TestByte1:
/*- If byte 1 == 0x00 */
ands r0, r6, #0xFF00
/*- | Shift left mask 8 times */
moveq r7, r7, lsl #8
/*- | Update the Handler Pointer */
addeq r5, r5, #8*4
beq TestByte2
/*- Else */
/*- | While mask differs from 1<<16 */
Loop1:
ands r0, r7, #1<<16
bne TestByte2
/*- | | If current bit is 1 */
ands r0, r6, r7
/*- | | | Load parameters */
movne r0, r4
movne r1, r7
/*- | | | Update the Return Address and Branch on handler */
ldrne r2, [r5]
movne r14, pc
bxne r2
/*- | | EndIf */
/*- | | Update the handler pointer */
add r5, r5, #4
/*- | | Left Shift the bit mask */
mov r7, r7, lsl #1
/*- | EndWhile */
b Loop1
/*- EndIf */
/*- Byte 2 */
/*-------- */
TestByte2:
/*- If byte 2 == 0x00 */
ands r0, r6, #0xFF0000
/*- | Shift left mask 8 times */
moveq r7, r7, lsl #8
/*- | Update the Handler Pointer */
addeq r5, r5, #8*4
beq TestByte3
/*- Else */
/*- | While mask differs from 1<<24 */
Loop2:
ands r0, r7, #1<<24
bne TestByte3
/*- | | If current bit is 1 */
ands r0, r6, r7
/*- | | | Load parameters */
movne r0, r4
movne r1, r7
/*- | | | Update the Return Address and Branch on handler */
ldrne r2, [r5]
movne r14, pc
bxne r2
/*- | | EndIf */
/*- | | Update the handler pointer */
add r5, r5, #4
/*- | | Left Shift the bit mask */
mov r7, r7, lsl #1
/*- | EndWhile */
b Loop2
/*- EndIf */
/*- Byte 3 */
/*-------- */
TestByte3:
/*- If byte 3 != 0x00 */
ands r0, r6, #0xFF000000
beq EndTest
/*- | While mask differs from 0 */
Loop3:
cmp r7, #0
beq EndTest
/*- | | If current bit is 1 */
ands r0, r6, r7
/*- | | | Load parameters */
movne r0, r4
movne r1, r7
/*- | | | Update the Return Address and Branch on handler */
ldrne r2, [r5]
movne r14, pc
bxne r2
/*- | | EndIf */
/*- | | Update the handler pointer */
add r5, r5, #4
/*- | | Left Shift the bit mask */
mov r7, r7, lsl #1
/*- | EndWhile */
b Loop3
/*- EndIf */
EndTest:
/*- Manage Exception exit */
IRQ_EXIT r4-r7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -