?? irq.s
字號(hào):
;/*******************************************************************************************************
;** File Name: IRQ.s
;** Descriptions: The irq handle that what allow the interrupt nesting.
;********************************************************************************************************/
NoInt EQU 0x80 ;Bit7,I位
USR32Mode EQU 0x10 ;M[4:0]=10000,用戶模式
SVC32Mode EQU 0x13 ;M[4:0]=10011,管理模式
SYS32Mode EQU 0x1f ;M[4:0]=1ffff,系統(tǒng)模式
IRQ32Mode EQU 0x12 ;M[4:0]=10010,IRQ中斷模式
FIQ32Mode EQU 0x11 ;M[4:0]=10001,快速中斷模式
CODE32
AREA IRQ,CODE,READONLY
;中斷服務(wù)程序與C語(yǔ)言的接口的宏定義
MACRO
$IRQ_Label HANDLER $IRQ_Exception_Function
EXPORT $IRQ_Label ; 輸出的標(biāo)號(hào)
IMPORT $IRQ_Exception_Function ; 引用的外部標(biāo)號(hào)
$IRQ_Label
SUB LR, LR, #4 ; 計(jì)算返回地址
STMFD SP!, {R0-R3, R12, LR} ; 保存任務(wù)環(huán)境
MRS R3, SPSR ; 保存狀態(tài)
STMFD SP, {R3,LR}^ ; Protects SPSR and SP in user status, Notice: DO NOT write back.保存SPSR和用戶狀態(tài)的SP,注意不能回寫
; If the SP is written back, it should be adjusted to its appropriate value later.如果回寫的是用戶的SP,則后面要調(diào)整SP
NOP
SUB SP, SP, #4*2
MSR CPSR_c, #(NoInt | SYS32Mode) ; Switch to the System Mode 切換到系統(tǒng)模式
BL $IRQ_Exception_Function ; call the C interrupt handler funtion 調(diào)用c語(yǔ)言的中斷處理程序
;MSR寫狀態(tài)寄存器指令使得CPSR[7:0]=0b10010010
;作用為關(guān)IRQ中斷
MSR CPSR_c, #(NoInt | IRQ32Mode) ; Switch bak to IRQ mode 切換回irq模式
LDMFD SP, {R3,LR}^ ; Recover SPSR and SP in user status, Notic: DO NOT write back. 恢復(fù)SPSR和用戶狀態(tài)的SP,注意不能回寫
; If the SP is written back, it should be adjusted to its appropriate value later.如果回寫的是用戶的SP,所以后面要調(diào)整SP
MSR SPSR_cxsf, R3
ADD SP, SP, #4*2 ;
LDMFD SP!, {R0-R3, R12, PC}^ ;
MEND
;/* 以下添加中斷句柄,用戶根據(jù)實(shí)際情況改變 */
;/* Add interrupt handler here,user could change it as needed */
;定時(shí)器0中斷(HANDLER宏調(diào)用)
;Timer0_Handler HANDLER Timer0
END
;/*********************************************************************************************************
;** End Of File
;********************************************************************************************************/
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -