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

📄 71x_vect.s

📁 ARM7 based on STR71x, UCOS migration
💻 S
📖 第 1 页 / 共 3 页
字号:
	STRB	R1,[R0]

	CMP	R1,#1				; if (OSIntNesting == 1) {
	BNE	OS_Tick_ISR_1
	LDR	R4,_OS_TCBCur			;     OSTCBCur->OSTCBStkPtr = SP
	LDR	R5,[R4]
	STR	SP,[R5]				; }

OS_Tick_ISR_1
	MSR	CPSR_c,#(NO_INT | MODE_IRQ)	; Change to IRQ mode (to use the IRQ stack to handle interrupt)

;===============================================
	LDR	lr, =ReturnAddress		; Read the return address.
	LDR	r0, =EIC_base_addr
	LDR	r1, =IVR_off_addr
	ADD	pc,r0,r1			; Branch to the IRQ handler.
ReturnAddress
						; Clear pending bit in EIC (using the proper IPRx)
	LDR	r0, =EIC_base_addr
	LDR	r2, [r0, #CICR_off_addr]	; Get the IRQ channel number.
	MOV	r3,#1
	MOV	r3,r3,LSL r2
	STR	r3,[r0, #IPR_off_addr]		; Clear the corresponding IPR bit.
;===============================================
	MSR	CPSR_c,#(NO_INT | MODE_SYS)	; Change to SYS mode
	BL	OSIntExit			; OSIntExit();

;===============================================
; Restore task's context and return to Task
	LDMFD   SP!,{R4}			; pop new task's CPSR
	MSR     CPSR_cxsf,r4
	LDMFD   SP!,{R0-R12,LR,PC}		; pop new task's R0-R12,LR & PC

;	RestoreContext r0,r12			; Restore the context and return to the...
						; ...program execution.

;*******************************************************************************
;* Function Name  : PrefetchAbortHandler
;* Description    : This function called when Prefetch Abort
;                   exception is entered.
;* Input          : none
;* Output         : none
;*******************************************************************************

PrefetchAbortHandler
        SUB    lr,lr,#4       ; Update the link register.
        SaveContext r0,r12    ; Save the workspace plus the current
                              ; return address lr_abt and spsr_abt.
        BL     Prefetch_Handler; Branch to Prefetch_Handler.
        RestoreContext r0,r12 ; Return to the instruction following that...
                              ; ...has generated the prefetch abort exception.

;*******************************************************************************
;* Function Name  : DataAbortHandler
;* Description    : This function is called when Data Abort
;                   exception is entered.
;* Input          : none
;* Output         : none
;*******************************************************************************

DataAbortHandler
        SUB    lr,lr,#8       ; Update the link register.
        SaveContext r0,r12    ; Save the workspace plus the current
                              ; return address lr_ abt and spsr_abt.
        BL     Abort_Handler  ; Branch to Abort_Handler.
        RestoreContext r0,r12 ; Return to the instruction following that...
                              ; ...has generated the data abort exception.

;*******************************************************************************
;* Function Name  : FIQHandler
;* Description    : This function is called when FIQ
;                   exception is entered.
;* Input          : none
;* Output         : none
;*******************************************************************************

FIQHandler
	SUB	lr,lr,#4			; Update the link register
	SaveContext r0,r12			; Save the workspace plus the current of return address lr_ irq and spsr_irq.

	MSR	CPSR_c,#(NO_INT | MODE_SYS)	; Change to SYS mode

; Handle nesting counter
	LDR	R0,_OS_IntNesting		; OSIntNesting++;
	LDRB	R1,[R0]
	ADD	R1,R1,#1
	STRB	R1,[R0]
	CMP	R1,#1				; if (OSIntNesting == 1) {
	BNE	CPU_FIQ_ISR
	LDR	R4,_OS_TCBCur			;     OSTCBCur->OSTCBStkPtr = SP
	LDR	R5,[R4]
	STR	SP,[R5]				; }
CPU_FIQ_ISR
	MSR	CPSR_c,#(NO_INT | MODE_FIQ)	; Change to FIQ mode (to use the FIQ stack to handle interrupt)

	BL	FIQ_Handler

	MSR	CPSR_c,#(NO_INT | MODE_SYS)	; Change to SYS mode
	BL	OSIntExit			; OSIntExit();

	MSR	CPSR_c,#(NO_INT | MODE_FIQ)	; Change to FIQ mode (to use the FIQ stack to handle interrupt)
; Restore task's context and return to Task
	RestoreContext r0,r12			; Restore the context and return to the...
						; ...program execution.

;*******************************************************************************
;* Macro Name     : IRQ_to_SYS
;* Description    : This macro used to switch form IRQ mode to SYS mode
;* Input          : none.
;* Output         : none
;*******************************************************************************
       MACRO
       IRQ_to_SYS
        MSR    cpsr_c,#0x1F   ; Switch to SYS mode
        STMFD  sp!,{lr}       ; Save the link register.
       MEND
;*******************************************************************************
;* Macro Name     : SYS_to_IRQ
;* Description    : This macro used to switch from SYS mode to IRQ mode
;                   then to return to IRQHnadler routine.
;* Input          : none.
;* Output         : none.
;*******************************************************************************
       MACRO
        SYS_to_IRQ
        LDMFD  sp!,{lr}      ; Restore the link register.
        MSR    cpsr_c,#0xD2  ; Switch to IRQ mode.
        MOV    pc,lr         ; Return to IRQHandler routine to clear the
                             ; pending bit.
       MEND
;*******************************************************************************
;* Function Name  : T0TIMIIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the T0TIMI_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   T0TIMI_IRQHandler function termination.
;* Input          : none.
;* Output         : none.
;*******************************************************************************
T0TIMIIRQHandler
        IRQ_to_SYS
        BL     T0TIMI_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : FLASHIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the FLASH_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   FLASH_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
FLASHIRQHandler
        IRQ_to_SYS
        BL     FLASH_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : RCCUIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the RCCU_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   RCCU_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
RCCUIRQHandler
        IRQ_to_SYS
        BL     RCCU_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : RTCIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the RTC_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   RTC_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
RTCIRQHandler
        IRQ_to_SYS
        BL     RTC_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : WDGIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the WDG_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   WDG_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
WDGIRQHandler
        IRQ_to_SYS
        BL     WDG_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : XTIIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the XTI_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   XTI_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
XTIIRQHandler
        IRQ_to_SYS
        BL     XTI_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : USBHPIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the USBHP_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   USBHP_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
USBHPIRQHandler
        IRQ_to_SYS
        BL     USBHP_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : I2C0ITERRIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the I2C0ITERR_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   I2C0ITERR_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
I2C0ITERRIRQHandler
        IRQ_to_SYS
        BL     I2C0ITERR_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : I2C1ITERRIRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the I2C1ITERR_IRQHandler function located in 71x_it.c.
;                   Then to return to IRQ mode after the
;                   I2C1ITERR_IRQHandler function termination.
;* Input          : none
;* Output         : none
;*******************************************************************************
I2C1ITERRIRQHandler
        IRQ_to_SYS
        BL     I2C1ITERR_IRQHandler
        SYS_to_IRQ
;*******************************************************************************
;* Function Name  : UART0IRQHandler
;* Description    : This function used to switch to SYS mode before entering
;                   the UART0_IRQHandler function located in 71x_it.c.

⌨️ 快捷键说明

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