lab2-extra: enable LEDs by performing direct register writes

This commit is contained in:
ІО-23 Шмуляр Олег 2025-02-12 22:55:24 +02:00
parent 1a6d8232a4
commit 1e54d5cd27
2 changed files with 21 additions and 1 deletions

View File

@ -23,7 +23,7 @@ lab1_v2.bin: lab1_v2.S lab1_v2.ld
qemu: build
qemu-system-gnuarmeclipse --verbose --verbose --board STM32F4-Discovery \
--mcu STM32F407VG -d unimp,guest_errors --nographic \
--mcu STM32F407VG -d unimp,guest_errors \
--semihosting-config enable=on,target=native -s -S \
--image start.bin

20
start.S
View File

@ -3,6 +3,8 @@
.thumb
.equ SYSTICK_OFFSET, 0xE000E010
.equ RCC_OFFSET, 0x40023800
.equ GPIOD_OFFSET, 0x40020C00
.section .text
@ -16,6 +18,7 @@ v2_img_start:
v2_img_end: @ ==__hard_reset__
__hard_reset__:
bl setup_leds
bl load_systick_timer
bl lab1_v1
@ -77,3 +80,20 @@ bootload_v2:
blx r3
pop {pc}
setup_leds:
@ RCC reset & enable GPIOD
ldr r0, =RCC_OFFSET
mov r1, #0x8
str r1, [r0, #0x30] @ ENABLE
@ GPIOD config
ldr r0, =GPIOD_OFFSET
ldr r1, =0x55000000
str r1, [r0] @ Mode Register
mov r1, #0xF000
str r1, [r0, #0x14] @ Output Data Register
mov pc, lr