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

📄 utils.s

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 S
字号:
;; $Revision: 1.2 $;   $Author: mechavar $;     $Date: 2000/05/01 19:37:08 $;; Copyright (c) 2000 ARM, INC.; All Rights Reserved;; ---------------------------------------------------------------------; Low level flash routines	GET	bsl_platform.a	EXPORT	Write_Sectors	EXPORT	Get_Device_Code	AREA	|Utils$$code|, CODE	; ------------------------------------------------------------------	; WAIT_TOGGLE_BIT	; --------	; DQ6 will toggle on suscessive reads until a program or erase cycle        ;  completes.	MACRO$label  WAIT_TOGGLE_BIT	$w1,$w2,$flash$label.Top	LDRH	$w1, [$flash]	LDRH	$w2, [$flash]	EOR	$w1, $w1, $w2	ANDS	$w1, $w1, #0xff	BNE	$label.Top	MEND	; R0 = No. of sectors to write; R1 = Start address of data to write; R2 = Address to write in flash; R3 = Sector SizeWrite_Sectors        STMDB   sp!, {r0, r1, r2, r3, r4, r5, lr}        ADR     r5, Write_Sector_End        MOV     lr, #Write_Sector_End-Write_Sector_Start0        LDR     ip, [r5, #-4]!        STR     ip, [sp, #-4]!        SUBS    lr, lr, #4        BNE     %BT0; ECN: Call routine on stack	MOV	r0, r3        MOV     lr, pc        MOV     pc, sp	ADD     sp, sp, #Write_Sector_End-Write_Sector_Start	LDMIA   sp!, {r0, r1, r2, r3, r4, r5, lr}	ADD	r1, r1, r3	ADD	r2, r2, r3	SUBS	r0, r0, #1	BNE	Write_Sectors	MOV	pc, lr ; R0 = Sector size; R1 = Start address of data to write; R2 = Address to write in flashWrite_Sector_Start        STMDB   sp!, {lr}        MOV     ip, #ROM_BASE0ws1	WAIT_TOGGLE_BIT r3, lr, ip; Enter Software Data Protection sequence;  -- SDP is always ON for the SST39VF400 --        MOV     r3, #0xAA        ORR     r3, r3, #0xAA00        STRH    r3, [ip, r3]        MOV     lr, r3, LSR #1	SUB	r4, lr, #1        STRH    lr, [ip, r4]        MOV     lr, #0xA0        STRH    lr, [ip, r3]        LDRH	lr, [r1], #2        STRH	lr, [r2], #2        SUBS    r0, r0, #2        BHI     %BT0ws2	WAIT_TOGGLE_BIT r3, lr, ip        LDMIA   sp!, {pc}Write_Sector_End	EXPORT	Erase_Sector; R0 = Sector to eraseErase_Sector        STMDB   sp!, {lr}; Place the flash erase routine on the stack        ADR     r1, Erase_Routine_End        MOV     lr, #Erase_Routine_End-Erase_Routine_Start0        LDR     ip, [r1, #-4]!        STR     ip, [sp, #-4]!        SUBS    lr, lr, #4        BNE     %BT0; Call routine on stack        MOV     lr, pc        MOV     pc, sp; Recover the stack space used by the ROM interrogation routine        ADD     sp, sp, #Erase_Routine_End-Erase_Routine_Start        LDMIA   sp!, {lr}	MOV	pc, lrErase_Routine_Start        MOV     ip, #ROM_BASE; Enter Software Data Protection sequence        MOV     r1, #0xAA        ORR     r1, r1, #0xAA00        STRH    r1, [ip, r1]        MOV     r3, r1, LSR #1	SUB	r2, r3, #1        STRH    r3, [ip, r2]        MOV     r3, #0x80        STRH    r3, [ip, r1]        MOV     r3, #0xAA        STRH    r3, [ip, r1]        MOV     r3, #0x55        STRH    r3, [ip, r2]        MOV     r3, #0x30        STRH    r3, [r0]er	WAIT_TOGGLE_BIT r1, r2, ip	MOV	pc, lrErase_Routine_End; No input parameters; Returns Manufacturer and Device Codes in r0Get_Device_Code        STMDB   sp!, {lr}; Place the ROM interrogation routine on the stack        ADR     r0, Device_Code_Routine_End        MOV     lr, #Device_Code_Routine_End-Device_Code_Routine_Start0        LDR     ip, [r0, #-4]!        STR     ip, [sp, #-4]!        SUBS    lr, lr, #4        BNE     %BT0; Call routine on stack        MOV     lr, pc        MOV     pc, sp; Recover the stack space used by the ROM interrogation routine        ADD     sp, sp, #Device_Code_Routine_End-Device_Code_Routine_Start        LDMIA   sp!, {lr}	MOV	pc, lr; Returns R0 = Manufacturer ID in D16-31, Device ID in D0-15Device_Code_Routine_Start        STMDB   sp!, {lr}; Enter Software Product Identification Mode        MOV     ip, #ROM_BASE        MOV     r2, #0xAA        ORR     r2, r2, #0xAA00        STRH    r2, [ip, r2]        MOV     lr, r2, LSR #1	SUB	r1, lr, #1        STRH    lr, [ip, r1]        MOV     lr, #0x90        STRH    lr, [ip, r2]dc1	WAIT_TOGGLE_BIT r0, r1, ip; Read Manufacturer and Device Codes        LDRH    r0, [ip]        LDRH    r1, [ip,#2]	ORR	r0, r1, r0, LSL #16; Exit Software Product Identification Mode        STRH    r2, [ip, r2]        MOV     lr, r2, LSR #1	SUB	r1, lr, #1        STRH    lr, [ip, r1]        MOV     lr, #0xF0        STRH    lr, [ip, r2]dc2	WAIT_TOGGLE_BIT r1, r2, ip        LDMIA   sp!, {pc}Device_Code_Routine_End	END

⌨️ 快捷键说明

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