📄 irq_usart.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_usart.s
;- Object : Assembler USART Interrupt Handler.
;- Translator : ARM Software Development Toolkit V2.11a
;-
;- Imported Resources :
;- USARTHandlerTable, PtUSART0Base, PtUSART1Base
;- Exported Resources :
;- usart0_interrupt_handler, usart1_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
;------------------------------------------------------------------------------
; Function :
; This file allows to manage 3 different types of interrupt from one USART.
; One error interrupt, one in receive and one in transmit. Each is identified
; by a Mask and a Handler stored in the table <USARTHandlerTable>.
; When an interrupt occurs, the Status Register of the USART is read, masked
; with the Interrupt Mask Register firstly and with each of the three masks
; read in the table. When a result is not null, the corresponding handler is
; executed.
; Masks and Handlers are definable with the C function <enable_usart_irq>.
; Note in thumb mode, handler addresses are saved with bit 0 set. Then,
; you don't need to set it before execution of bx.
;------------------------------------------------------------------------------
AREA AT91Lib, CODE, READONLY, INTERWORK
; -------------------------- List of Included Files ---------------------------
INCLUDE Include/arm.inc
INCLUDE Include/usart.inc
INCLUDE Include/aic.inc
INCLUDE Include/irq.mac
; ------------------------ List of constants and types ------------------------
; None
; ------------------------ List of Imported resources -------------------------
IMPORT USARTHandlerTable
; ------------------------ List of Internal resources -------------------------
PtUSART0Base
DCD USART0_BASE
PtUSART1Base
DCD USART1_BASE
;------------------------------------------------------------------------------
;- Function : look_for_interrupt
;- Treatments : Look for Interrupt from a USART
;- Input Parameters : r4 = USART Base Address
;- : r5 = USART Handler Table Address
;- Output Parameters :
;- When Handler is called :
;- r0 = USART Base Address
;- r1 = USART Handler Table Address
;- Registers lost : None
;- Called Functions : None
;- Called Macros : IRQ_EXIT
;------------------------------------------------------------------------------
look_for_interrupt
;- Read the Channel Status Register
ldr r0, [r4, #US_CSR]
;- Read the Interrupt Mask Register
ldr r1, [r4, #US_IMR]
;- Clear bits of the status for disabled interrupt
and r6, r0, r1
;- If any error interrupt
ldr r1, [r5, #ErrorMask]
ands r0, r6, r1
; | Load parameters
movne r0, r4
movne r1, r5
;- | Branch on the error handler
ldrne r2, [r5, #ErrorHandler]
movne lr, pc
bxne r2
;- EndIf
;- If any receive interrupt
ldr r1, [r5, #RxMask]
ands r0, r6, r1
; | Load parameters
movne r0, r4
movne r1, r5
;- | Branch on the receive handler
ldrne r2, [r5, #RxHandler]
movne lr, pc
bxne r2
;- EndIf
;- If any transmit interrupt
ldr r1, [r5, #TxMask]
ands r0, r6, r1
; | Load parameters
movne r0, r4
movne r1, r5
;- | Branch on the transmit handler
ldrne r2, [r5, #TxHandler]
movne lr, pc
bxne r2
;- EndIf
IRQ_EXIT r4-r6
; ------------------------ List of Exported resources -------------------------
;------------------------------------------------------------------------------
;- Function : usart0_interrupt_handler
;- Treatments : USART Channel 0 Interrupt Handler.
;- Input Parameters : None
;- Output Parameters : r4 = USART 0 Base Address
;- : r5 = USART 0 Handler Table Address
;- Registers lost : None
;- Called Functions : look_for_interrupt
;- Called Macros : IRQ_ENTRY
;------------------------------------------------------------------------------
EXPORT usart0_interrupt_handler
usart0_interrupt_handler
IRQ_ENTRY r4-r6
;- Load the USART 0 Base address
ldr r4, PtUSART0Base
;- Load the address of the USART Handler Table
ldr r5, =USARTHandlerTable
;- Look for all present interrupt and manage them
b look_for_interrupt
;------------------------------------------------------------------------------
;- Function : usart1_interrupt_handler
;- Treatments : USART Channel 1 Interrupt Handler.
;- Input Parameters : None
;- Output Parameters : r4 = USART 1 Base Address
;- : r5 = USART 1 Handler Table Address
;- Registers lost : None
;- Called Functions : look_for_interrupt
;- Called Macros : IRQ_ENTRY
;------------------------------------------------------------------------------
EXPORT usart1_interrupt_handler
usart1_interrupt_handler
IRQ_ENTRY r4-r6
;- Load the USART 0 Base address
ldr r4, PtUSART1Base
;- Load the address of the USART Handler Table
ldr r5, =USARTHandlerTable
add r5, r5 , #SIZE_USART_HANDLER_TABLE
;- Look for all present interrupt and manage them
b look_for_interrupt
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -