📄 startup.s
字号:
;/****************************************Copyright (c)**************************************************
;** Guangzou ZLG-MCU Development Co.,LTD.
;** graduate school
;** http://www.zlgmcu.com
;**
;**--------------File Info-------------------------------------------------------------------------------
;** File name: Startup.s
;** Last modified Date: 2005-11-14
;** Last Version: 1.0
;** Descriptions: The start up codes for LPC2200, including the initializing codes for the entry point of exceptions and the stacks of user tasks.
;** Every project should have a independent copy of this file for related modifications
;**------------------------------------------------------------------------------------------------------
;** Created by: Chenmingji
;** Created date: 2005-11-14
;** Version: 1.0
;** Descriptions: The original version
;**
;** Modified by:
;** Modified date:
;** Version:
;** Descriptions:
;**
;********************************************************************************************************/
INCLUDE LPC2294.INC ; Include the head file 引入头文件
;define the stack size
;定义堆栈的大小
FIQ_STACK_LEGTH EQU 9*8
IRQ_STACK_LEGTH EQU 9*8
NoInt EQU 0x80
NoFIQ EQU 0x40
USR32Mode EQU 0x10
SVC32Mode EQU 0x13
SYS32Mode EQU 0x1f
IRQ32Mode EQU 0x12
FIQ32Mode EQU 0x11
;/* Define the Bus Speed */
BCFG_08DEF EQU 0x00000000 ;// 8Bit Bus
BCFG_16DEF EQU 0x10000400 ;// 16Bit Bus
BCFG_32DEF EQU 0x20000400 ;// 32Bit Bus
;// | IDCY | WST1 | WST2
;// | Idle width | Read width | Write width
;// | 0x00 ~ 0x0f| 0x00 ~ 0x1f| 0x00~0x1f
BCFG_FLASH EQU (BCFG_16DEF | (0x00<<00) | (0x03<<05) | (0x03<<11)) ;// For Flash
BCFG_PSRAM EQU (BCFG_16DEF | (0x00<<00) | (0x03<<05) | (0x03<<11)) ;// For PSRAM
BCFG_CS2 EQU (BCFG_16DEF | (0x0f<<00) | (0x1f<<05) | (0x1f<<11)) ;// Blank
BCFG_CS3 EQU (BCFG_16DEF | (0x08<<00) | (0x0f<<05) | (0x0f<<11)) ;// For Peripheral Equipment
IMPORT __use_no_semihosting_swi
IMPORT __use_two_region_memory
;The imported labels
;引入的外部标号在这声明
IMPORT __main ;The entry point to the main function C语言主程序入口
;The exported labels
;给外部使用的标号在这声明
EXPORT bottom_of_heap
EXPORT bottom_of_Stacks
EXPORT top_of_heap
EXPORT Reset
EXPORT __user_initial_stackheap
CODE32
AREA vectors,CODE,READONLY
ENTRY
;interrupt vectors
;中断向量表
Reset
B ResetInit
IF :DEF: Low
DCD 0x55aa5a5a
ELSE
DCD 0xaa55a5a5
ENDIF
DCD 0xffffffff
IMPORT RunFirst
B RunFirst
IMPORT malloc
IMPORT free
CODE16
SUB SP, #4
PUSH {R0}
LDR R0, =malloc+1
STR R0, [SP, #4]
POP {R0, PC}
SUB SP, #4
PUSH {R0}
LDR R0, =free+1
STR R0, [SP, #4]
POP {R0, PC}
CODE32
;/*********************************************************************************************************
;** unction name 函数名称: ResetInit
;** Descriptions 功能描述: RESET 复位入口
;** input parameters 输 入: None 无
;** Returned value 输 出 : None 无
;** Used global variables 全局变量: None 无
;** Calling modules 调用模块: None 无
;**
;** Created by 作 者: Chenmingji 陈明计
;** Created Date 日 期: 2005/11/14 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by 修 改:
;** Modified date 日 期:
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
ResetInit
;Initial extenal bus controller.
;初始化外部总线控制器,根据目标板决定配置
LDR R0, =PINSEL2
LDR R1, =0x0f814914
STR R1, [R0]
LDR R0, =BCFG0
LDR R1, =BCFG_FLASH
STR R1, [R0]
LDR R0, =BCFG1
LDR R1, =BCFG_PSRAM
STR R1, [R0]
LDR R0, =BCFG2
LDR R1, =BCFG_CS2
STR R1, [R0]
LDR R0, =BCFG3
LDR R1, =BCFG_CS3
STR R1, [R0]
;Build the FIQ stack
;设置快速中断模式堆栈
MSR CPSR_c, #(FIQ32Mode | NoInt | NoFIQ)
LDR SP, StackFiq
;Build the SYS stack
;设置系统模式堆栈
MSR CPSR_c, #(SYS32Mode | NoInt | NoFIQ)
B __main
code16
EXPORT upgradeOK
upgradeOK
LDR R0, =RunFirst
BX R0
code32
EXPORT FIR_Handle
IMPORT FIQ_ISR
FIR_Handle
STMFD SP!, {R0-R3, LR}
LDR R3, =FIQ_ISR+1
ADD LR, PC, #1
BX R3
CODE16
BX PC
NOP
CODE32
LDMFD SP!, {R0-R3, LR}
SUBS PC, LR, #4
;/*********************************************************************************************************
;** unction name 函数名称: __user_initial_stackheap
;** Descriptions 功能描述: Initial the function library stacks and heaps, can not deleted! 库函数初始化堆和栈,不能删除
;** input parameters 输 入: reference by function library 参考库函数手册
;** Returned value 输 出 : reference by function library 参考库函数手册
;** Used global variables 全局变量: None 无
;** Calling modules 调用模块: None 无
;**
;** Created by 作 者: Chenmingji 陈明计
;** Created Date 日 期: 2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by
;** Modified date
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
__user_initial_stackheap
LDR R0, =bottom_of_heap
; LDR R1, =StackUsr
LDR R2, =top_of_heap
LDR R3, =bottom_of_Stacks
MOV PC, LR
StackFiq DCD FiqStackSpace + (FIQ_STACK_LEGTH - 1)* 4
EXPORT _sys_exit
_sys_exit
B .
EXPORT __rt_div0
EXPORT fputc
EXPORT fgetc
EXPORT _sys_close
EXPORT _sys_write
EXPORT _sys_read
; EXPORT _ttywrch
EXPORT _sys_istty
EXPORT _sys_seek
EXPORT _sys_ensure
EXPORT _sys_flen
EXPORT _sys_tmpnam
EXPORT _sys_command_string
__rt_div0
fputc
fgetc
_sys_close
_sys_write
_sys_read
;_ttywrch
_sys_istty
_sys_seek
_sys_ensure
_sys_flen
_sys_tmpnam
_sys_command_string
MOV R0, #0
MOV PC, LR
EXPORT FiqStackSpace
;/* 分配堆栈空间 */
AREA MyStacks, DATA, NOINIT, ALIGN=2
FiqStackSpace SPACE FIQ_STACK_LEGTH * 4 ;Stack spaces for Fast Interrupt reQuest Mode 快速中断模式堆栈空间
AREA Heap, DATA, NOINIT
bottom_of_heap SPACE 1
AREA StackBottom, DATA, NOINIT
bottom_of_Stacks SPACE 1
AREA HeapTop, DATA, NOINIT
top_of_heap
END
;/*********************************************************************************************************
;** End Of File
;********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -