.text
.global _start
_start:
bl rcc_init
bl led_init
bl led1_init
bl led2_init
loop:
bl led_on
bl delay_1s
bl led_off
bl delay_1s
bl led1_on
bl delay_1s
bl led1_off
bl delay_1s
bl led2_on
bl delay_1s
bl led2_off
bl delay_1s
b loop
rcc_init:
ldr r0,=0x50000A28
ldr r1,[r0]
orr r1,#(0x3<<4)
str r1,[r0]
mov pc,lr
led_init:
ldr r0,=0x50006000
ldr r1,[r0]
orr r1,#(1<<20)
str r1,[r0]
add r0,#4
ldr r1,[r0]
bic r1,#0x400
str r1,[r0]
add r0,#4
mov r1,#0
str r1,[r0]
add r0,#4
mov r1,#0
str r1,[r0]
mov pc,lr
led_on:
ldr r0,=0x50006014
ldr r1,=0x400
str r1,[r0]
mov pc,lr
led_off:
ldr r0,=0x50006014
mov r1,#0
str r1,[r0]
mov pc,lr
led2_init:
ldr r0,=0x50007000
ldr r1,[r0]
orr r1,#(1<<20)
str r1,[r0]
add r0,#4
ldr r1,[r0]
bic r1,#(1<<10)
str r1,[r0]
add r0,#4
ldr r1,[r0]
bic r1,#(1<<20)
str r1,[r0]
add r0,#4
ldr r1,[r0]
bic r1,#(0x3<<20)
str r1,[r0]
mov pc,lr
led2_on:
ldr r0,=0x50007014
ldr r1,[r0]
orr r1,#(1<<10)
str r1,[r0]
mov pc,lr
led2_off:
ldr r0,=0x50007014
ldr r1,[r0]
bic r1,#(1<<10)
str r1,[r0]
mov pc,lr
led1_init:
ldr r0,=0x50006000
ldr r1,[r0]
orr r1,#(1<<16)
str r1,[r0]
add r0,#4
mov r1,#0
str r1,[r0]
add r0,#4
mov r1,#0
str r1,[r0]
add r0,#4
mov r1,#0
str r1,[r0]
mov pc,lr
led1_on:
ldr r0,=0x50006014
mov r1,#0
orr r1,r1,#(1<<8)
str r1,[r0]
mov pc,lr
led1_off:
ldr r0,=0x50006014
ldr r1,[r0]
bic r1,#(1<<8)
str r1,[r0]
mov pc,lr
@ 大概1s的延时函数
delay_1s:
mov r3, #0x10000000
mm:
cmp r3, #0
subne r3, r3, #1
bne mm
mov pc, lr
.end