- .text
- .global _start
- _start:
- /* 1. led灯的初始化 */
- /* 1.1 使能GPIOE、DPIOF外设控制器的时钟 */
- ldr r0, =0x50000A28
- ldr r1, [r0]
- orr r1, r1, #(0x3 << 4)
- str r1, [r0]
-
- /* 1.2 设置PE10、PE8、PF10引脚为输出模式 */
- ldr r0, =0x50006000
- ldr r1, [r0]
- bic r1, r1, #(0x3 << 16)
- orr r1, r1, #(0x1 << 16)
- bic r1, r1, #(0x3 << 20)
- orr r1, r1, #(0x1 << 20)
- str r1, [r0]
-
- ldr r0, =0x50007000
- ldr r1, [r0]
- bic r1, r1, #(0x3 << 20)
- orr r1, r1, #(0x1 << 20)
- str r1, [r0]
-
- /* 1.3 设置PE10、PE8、PF10引脚为推挽输出 */
- ldr r0, =0x50006004
- ldr r1, [r0]
- bic r1, r1, #(0x1 << 8)
- bic r1, r1, #(0x1 << 10)
- str r1, [r0]
-
- ldr r0, =0x50007004
- ldr r1, [r0]
- bic r1, r1, #(0x1 << 10)
- str r1, [r0]
-
- /* 1.4 设置PE10、PE8、PF10引脚为低速模式 */
- ldr r0, =0x50006008
- ldr r1, [r0]
- bic r1, r1, #(0x3 << 16)
- bic r1, r1, #(0x3 << 20)
- str r1, [r0]
-
- ldr r0, =0x50007008
- ldr r1, [r0]
- bic r1, r1, #(0x3 << 20)
- str r1, [r0]
-
- /* 1.5 设置PE10、PE8、PF10引脚禁止上拉和下拉电阻 */
- ldr r0, =0x5000600C
- ldr r1, [r0]
- bic r1, r1, #(0x3 << 16)
- bic r1, r1, #(0x3 << 20)
- str r1, [r0]
-
- ldr r0, =0x5000700C
- ldr r1, [r0]
- bic r1, r1, #(0x3 << 20)
- str r1, [r0]
-
- /* led1灯的初始化完成 */
- loop:
- /* 设置PE10引脚输出高电平, 点亮LED1灯 */
- ldr r0, =0x50006014
- ldr r1, [r0]
- orr r1, r1, #(0x1 << 10)
- str r1, [r0]
-
- bl delay_1s
-
- /* 设置PE10引脚输出低电平, 熄灭LED1灯 */
- ldr r0, =0x50006014
- ldr r1, [r0]
- bic r1, r1, #(0x1 << 10)
- str r1, [r0]
-
- bl delay_1s
-
- /* 设置PF10引脚输出低电平, 点亮LED2灯 */
- ldr r0, =0x50007014
- ldr r1, [r0]
- orr r1, r1, #(0x1 << 10)
- str r1, [r0]
-
- bl delay_1s
-
- /* 设置PF10引脚输出低电平, 熄灭LED2灯 */
- ldr r0, =0x50007014
- ldr r1, [r0]
- bic r1, r1, #(0x1 << 10)
- str r1, [r0]
-
- bl delay_1s
-
- /* 设置PE8引脚输出高电平, 点亮LED3灯 */
- ldr r0, =0x50006014
- ldr r1, [r0]
- orr r1, r1, #(0x1 << 8)
- str r1, [r0]
-
- bl delay_1s
-
- /* 设置PE8引脚输出低电平, 熄灭LED3灯 */
- ldr r0, =0x50006014
- ldr r1, [r0]
- bic r1, r1, #(0x1 << 8)
- str r1, [r0]
-
- bl delay_1s
-
- b loop
-
- @ 大概1s的延时函数
- delay_1s:
- mov r3, #0x10000000
- mm:
- cmp r3, #0
- subne r3, r3, #1
- bne mm
- mov pc, lr
-
- .end
-