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

📄 startup.s

📁 LPC2100DEMO板开发原代码,包括网络键盘定时器发光管等驱动代码
💻 S
字号:
;/*******************************************************************************************************
;**                                     西安傅立叶电子科技
;**                                Xian FFT Electornic Technology
;**                                   http://www.fftchina.com
;********************************************************************************************************/

;** 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

;define the stack size

FIQ_STACK_LEGTH         EQU         0
IRQ_STACK_LEGTH         EQU         9*8             ;every layer need 9 bytes stack , permit 8 layer .
ABT_STACK_LEGTH         EQU         0
UND_STACK_LEGTH         EQU         0

NoInt       EQU 0x80

USR32Mode   EQU 0x10
SVC32Mode   EQU 0x13
SYS32Mode   EQU 0x1f
IRQ32Mode   EQU 0x12
FIQ32Mode   EQU 0x11

PINSEL2     EQU 0xE002C014

BCFG0       EQU 0xFFE00000
BCFG1       EQU 0xFFE00004
BCFG2       EQU 0xFFE00008
BCFG3       EQU 0xFFE0000C

    IMPORT __use_no_semihosting_swi
    IMPORT __use_two_region_memory

;The imported labels        

    IMPORT  FIQ_Exception                   ;Fast interrupt exceptions handler 
    IMPORT  __main                          ;The entry point to the main function  
    IMPORT  TargetResetInit                 ;initialize the target board 
    IMPORT  SoftwareInterrupt

;The emported labels        

	EXPORT  bottom_of_heap
    EXPORT  bottom_of_Stacks
    EXPORT  top_of_heap
    EXPORT  StackUsr
    
    EXPORT  Reset
    EXPORT  __user_initial_stackheap

    CODE32

    AREA    vectors,CODE,READONLY
        ENTRY
;interrupt vectors

Reset
        LDR     PC, ResetAddr
        LDR     PC, UndefinedAddr
        LDR     PC, SWI_Addr
        LDR     PC, PrefetchAddr
        LDR     PC, DataAbortAddr
        DCD     0xb9205f80
        LDR     PC, [PC, #-0xff0]
        LDR     PC, FIQ_Addr

ResetAddr           DCD     ResetInit
UndefinedAddr       DCD     Undefined
SWI_Addr            DCD     SoftwareInterrupt
PrefetchAddr        DCD     PrefetchAbort
DataAbortAddr       DCD     DataAbort
Nouse               DCD     0
IRQ_Addr            DCD     0
FIQ_Addr            DCD     FIQ_Handler

Undefined
        B       Undefined
        

PrefetchAbort
        B       PrefetchAbort


DataAbort
        B       DataAbort


FIQ_Handler
        STMFD   SP!, {R0-R3, LR}
        BL      FIQ_Exception
        LDMFD   SP!, {R0-R3, LR}
        SUBS    PC,  LR,  #4

;/*********************************************************************************************************
;** unction name: InitStack
;** Descriptions: Initialize the stacks
;********************************************************************************************************/
InitStack    
        MOV     R0, LR
;Build the SVC stack

        MSR     CPSR_c, #0xd2
        LDR     SP, StackIrq
;Build the FIQ stack	

        MSR     CPSR_c, #0xd1
        LDR     SP, StackFiq
;Build the DATAABORT stack

        MSR     CPSR_c, #0xd7
        LDR     SP, StackAbt
;Build the UDF stack

        MSR     CPSR_c, #0xdb
        LDR     SP, StackUnd
;Build the SYS stack

        MSR     CPSR_c, #0xdf
        LDR     SP, =StackUsr

        MOV     PC, R0

;/*********************************************************************************************************
;** unction name: ResetInit
;** Descriptions: RESET
;********************************************************************************************************/
ResetInit
;Initial the extenal bus controller


        LDR     R0, =PINSEL2
    IF :DEF: EN_CRP
        LDR     R1, =0x0f814910
    ELSE
        LDR     R1, =0x0f814914
    ENDIF
        STR     R1, [R0]

        LDR     R0, =BCFG0
        LDR     R1, =0x1000ffef
        STR     R1, [R0]

        LDR     R0, =BCFG1
        LDR     R1, =0x1000ffef
        STR     R1, [R0]

        LDR     R0, =BCFG2
        LDR     R1, =0x10001460
        STR     R1, [R0]

        LDR     R0, =BCFG3
        LDR     R1, =0x10001460
        STR     R1, [R0]
        
        BL      InitStack               ; Initialize the stack
        BL      TargetResetInit         ; Initialize the target board
                                        ; Jump to the entry point of C program
        B       __main


;/*********************************************************************************************************
;** 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
;********************************************************************************************************/
__user_initial_stackheap    
    LDR   r0,=bottom_of_heap		
;    LDR   r1,=StackUsr			
    LDR   r2,=top_of_heap		
    LDR   r3,=bottom_of_Stacks		
    MOV   pc,lr				
        
StackIrq           DCD     IrqStackSpace + (IRQ_STACK_LEGTH - 1)* 4
StackFiq           DCD     FiqStackSpace + (FIQ_STACK_LEGTH - 1)* 4
StackAbt           DCD     AbtStackSpace + (ABT_STACK_LEGTH - 1)* 4
StackUnd           DCD     UndtStackSpace + (UND_STACK_LEGTH - 1)* 4

;/*********************************************************************************************************
;** unction name: CrpData
;** Descriptions: encrypt the chip
;********************************************************************************************************/
    IF :DEF: EN_CRP
        IF  . >= 0x1fc
        INFO    1,"\nThe data at 0x000001fc must be 0x87654321.\nPlease delete some source before this line."
        ENDIF
CrpData
    WHILE . < 0x1fc
    NOP
    WEND
CrpData1
    DCD     0x87654321          ;/*When the Data is 为0x87654321,user code be protected.*/
    ENDIF

        AREA    MyStacks, DATA, NOINIT, ALIGN=2
IrqStackSpace      SPACE   IRQ_STACK_LEGTH * 4  ;Stack spaces for Interrupt ReQuest Mode
FiqStackSpace      SPACE   FIQ_STACK_LEGTH * 4  ;Stack spaces for Fast Interrupt reQuest Mode
AbtStackSpace      SPACE   ABT_STACK_LEGTH * 4  ;Stack spaces for Suspend Mode
UndtStackSpace     SPACE   UND_STACK_LEGTH * 4  ;Stack spaces for Undefined 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

        AREA    Stacks, DATA, NOINIT
StackUsr

    END

⌨️ 快捷键说明

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