Blink LED with timer

This commit is contained in:
Alexander Heldt
2024-08-03 11:50:37 +02:00
parent 062a014c7c
commit a3c1de878a
10 changed files with 9001 additions and 954 deletions

Binary file not shown.

View File

@@ -35,6 +35,7 @@ Discarded input sections
.group 0x00000000 0xc build/main.o .group 0x00000000 0xc build/main.o
.group 0x00000000 0xc build/main.o .group 0x00000000 0xc build/main.o
.group 0x00000000 0xc build/main.o .group 0x00000000 0xc build/main.o
.group 0x00000000 0xc build/main.o
.text 0x00000000 0x0 build/main.o .text 0x00000000 0x0 build/main.o
.data 0x00000000 0x0 build/main.o .data 0x00000000 0x0 build/main.o
.bss 0x00000000 0x0 build/main.o .bss 0x00000000 0x0 build/main.o
@@ -51,6 +52,7 @@ Discarded input sections
.debug_macro 0x00000000 0x89 build/main.o .debug_macro 0x00000000 0x89 build/main.o
.debug_macro 0x00000000 0x4cc build/main.o .debug_macro 0x00000000 0x4cc build/main.o
.debug_macro 0x00000000 0x22 build/main.o .debug_macro 0x00000000 0x22 build/main.o
.debug_macro 0x00000000 0x34 build/main.o
.group 0x00000000 0xc build/startup.o .group 0x00000000 0xc build/startup.o
.group 0x00000000 0xc build/startup.o .group 0x00000000 0xc build/startup.o
.group 0x00000000 0xc build/startup.o .group 0x00000000 0xc build/startup.o
@@ -64,6 +66,36 @@ Discarded input sections
.debug_macro 0x00000000 0x103 build/startup.o .debug_macro 0x00000000 0x103 build/startup.o
.debug_macro 0x00000000 0x6a build/startup.o .debug_macro 0x00000000 0x6a build/startup.o
.debug_macro 0x00000000 0x1df build/startup.o .debug_macro 0x00000000 0x1df build/startup.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.group 0x00000000 0xc build/timer.o
.text 0x00000000 0x0 build/timer.o
.data 0x00000000 0x0 build/timer.o
.bss 0x00000000 0x0 build/timer.o
.debug_macro 0x00000000 0x22 build/timer.o
.debug_macro 0x00000000 0x75 build/timer.o
.debug_macro 0x00000000 0x2a build/timer.o
.debug_macro 0x00000000 0x5c build/timer.o
.debug_macro 0x00000000 0x3c build/timer.o
.debug_macro 0x00000000 0x103 build/timer.o
.debug_macro 0x00000000 0x3a build/timer.o
.debug_macro 0x00000000 0x57 build/timer.o
.debug_macro 0x00000000 0x6a build/timer.o
.debug_macro 0x00000000 0x1df build/timer.o
.debug_macro 0x00000000 0x89 build/timer.o
.debug_macro 0x00000000 0x4cc build/timer.o
.debug_macro 0x00000000 0x22 build/timer.o
Memory Configuration Memory Configuration
@@ -79,6 +111,7 @@ LOAD /nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/bin/
LOAD build/gpio.o LOAD build/gpio.o
LOAD build/main.o LOAD build/main.o
LOAD build/startup.o LOAD build/startup.o
LOAD build/timer.o
0x20020000 stack_start = (ORIGIN (sram) + LENGTH (sram)) 0x20020000 stack_start = (ORIGIN (sram) + LENGTH (sram))
.isr_vector 0x08000000 0x198 .isr_vector 0x08000000 0x198
@@ -88,7 +121,7 @@ LOAD build/startup.o
0x08000000 interrupt_vector_table 0x08000000 interrupt_vector_table
0x08000198 . = ALIGN (0x4) 0x08000198 . = ALIGN (0x4)
.text 0x08000198 0x2f4 .text 0x08000198 0x358
0x08000198 . = ALIGN (0x4) 0x08000198 . = ALIGN (0x4)
*(.text) *(.text)
*(.text.*) *(.text.*)
@@ -101,109 +134,113 @@ LOAD build/startup.o
*fill* 0x08000246 0x2 *fill* 0x08000246 0x2
.text.system_clock_init .text.system_clock_init
0x08000248 0x144 build/main.o 0x08000248 0x144 build/main.o
.text.spin 0x0800038c 0x22 build/main.o .text.main 0x0800038c 0x88 build/main.o
*fill* 0x080003ae 0x2 0x0800038c main
.text.main 0x080003b0 0x60 build/main.o
0x080003b0 main
.text.init_memory .text.init_memory
0x08000410 0x64 build/startup.o 0x08000414 0x64 build/startup.o
0x08000410 init_memory 0x08000414 init_memory
.text.reset 0x08000474 0x10 build/startup.o .text.reset 0x08000478 0x10 build/startup.o
0x08000474 reset 0x08000478 reset
.text.default_handler .text.default_handler
0x08000484 0x8 build/startup.o 0x08000488 0x8 build/startup.o
0x08000484 exti0 0x08000488 exti0
0x08000484 debug_monitor 0x08000488 debug_monitor
0x08000484 rcc 0x08000488 rcc
0x08000484 x 0x08000488 x
0x08000484 sdio 0x08000488 sdio
0x08000484 usage_fault 0x08000488 usage_fault
0x08000484 tim1_up_tim10 0x08000488 tim1_up_tim10
0x08000484 usart1 0x08000488 usart1
0x08000484 i2c3_er 0x08000488 i2c3_er
0x08000484 spi2 0x08000488 spi2
0x08000484 dma1_stream1 0x08000488 dma1_stream1
0x08000484 bus_fault 0x08000488 bus_fault
0x08000484 spi5 0x08000488 spi5
0x08000484 exti3 0x08000488 exti3
0x08000484 dma2_stream5 0x08000488 dma2_stream5
0x08000484 tim2 0x08000488 tim2
0x08000484 dma1_stream6 0x08000488 dma1_stream6
0x08000484 default_handler 0x08000488 default_handler
0x08000484 i2c1_er 0x08000488 i2c1_er
0x08000484 hard_fault 0x08000488 hard_fault
0x08000484 usart6 0x08000488 usart6
0x08000484 exti15_10 0x08000488 exti15_10
0x08000484 usart2 0x08000488 usart2
0x08000484 pend_sv 0x08000488 pend_sv
0x08000484 i2c1_ev 0x08000488 i2c1_ev
0x08000484 wwdg 0x08000488 wwdg
0x08000484 adc 0x08000488 adc
0x08000484 rtc_alarm 0x08000488 rtc_alarm
0x08000484 spi3 0x08000488 spi3
0x08000484 exti1 0x08000488 exti1
0x08000484 mem_manage 0x08000488 mem_manage
0x08000484 dma2_stream1 0x08000488 dma2_stream1
0x08000484 dma1_stream2 0x08000488 dma1_stream2
0x08000484 dma2_stream3 0x08000488 dma2_stream3
0x08000484 sv_call 0x08000488 sv_call
0x08000484 tim3 0x08000488 tim3
0x08000484 otg_fs 0x08000488 otg_fs
0x08000484 dma1_stream5 0x08000488 dma1_stream5
0x08000484 dma2_stream6 0x08000488 dma2_stream6
0x08000484 flash 0x08000488 flash
0x08000484 tamp_stamp 0x08000488 tamp_stamp
0x08000484 i2c3_ev 0x08000488 i2c3_ev
0x08000484 rtc_wkup 0x08000488 rtc_wkup
0x08000484 dma2_stream0 0x08000488 dma2_stream0
0x08000484 pvd 0x08000488 pvd
0x08000484 fpu 0x08000488 fpu
0x08000484 exti4 0x08000488 exti4
0x08000484 exti2 0x08000488 exti2
0x08000484 spi1 0x08000488 spi1
0x08000484 dma1_stream0 0x08000488 dma1_stream0
0x08000484 tim1_brk_tim9 0x08000488 tim1_brk_tim9
0x08000484 i2c2_ev 0x08000488 i2c2_ev
0x08000484 otg_fs_wkup 0x08000488 otg_fs_wkup
0x08000484 spi4 0x08000488 spi4
0x08000484 dma2_stream2 0x08000488 dma2_stream2
0x08000484 tim1_cc 0x08000488 tim1_cc
0x08000484 tim1_trg_com_tim11 0x08000488 tim1_trg_com_tim11
0x08000484 exti9_5 0x08000488 exti9_5
0x08000484 dma1_stream3 0x08000488 dma1_stream3
0x08000484 dma2_stream4 0x08000488 dma2_stream4
0x08000484 i2c2_er 0x08000488 i2c2_er
0x08000484 dma2_stream7 0x08000488 dma2_stream7
0x08000484 dma1_stream7 0x08000488 dma1_stream7
0x08000484 nmi 0x08000488 nmi
0x08000484 systick 0x08000488 systick
0x08000484 tim4 0x08000488 tim4
0x08000484 tim5 0x08000488 tim5
0x08000484 dma1_stream4 0x08000488 dma1_stream4
.text.tim4_init
0x08000490 0x40 build/timer.o
0x08000490 tim4_init
.text.tim4_start
0x080004d0 0x20 build/timer.o
0x080004d0 tim4_start
*(.rodata) *(.rodata)
*(.rodata.*) *(.rodata.*)
0x0800048c . = ALIGN (0x4) 0x080004f0 . = ALIGN (0x4)
0x0800048c _data_addr = LOADADDR (.data) 0x080004f0 _data_addr = LOADADDR (.data)
.glue_7 0x0800048c 0x0 .glue_7 0x080004f0 0x0
.glue_7 0x0800048c 0x0 linker stubs .glue_7 0x080004f0 0x0 linker stubs
.glue_7t 0x0800048c 0x0 .glue_7t 0x080004f0 0x0
.glue_7t 0x0800048c 0x0 linker stubs .glue_7t 0x080004f0 0x0 linker stubs
.vfp11_veneer 0x0800048c 0x0 .vfp11_veneer 0x080004f0 0x0
.vfp11_veneer 0x0800048c 0x0 linker stubs .vfp11_veneer 0x080004f0 0x0 linker stubs
.v4_bx 0x0800048c 0x0 .v4_bx 0x080004f0 0x0
.v4_bx 0x0800048c 0x0 linker stubs .v4_bx 0x080004f0 0x0 linker stubs
.iplt 0x0800048c 0x0 .iplt 0x080004f0 0x0
.iplt 0x0800048c 0x0 build/main.o .iplt 0x080004f0 0x0 build/main.o
.rel.dyn 0x0800048c 0x0 .rel.dyn 0x080004f0 0x0
.rel.iplt 0x0800048c 0x0 build/main.o .rel.iplt 0x080004f0 0x0 build/main.o
.data 0x20000000 0x0 load address 0x0800048c .data 0x20000000 0x0 load address 0x080004f0
0x20000000 . = ALIGN (0x4) 0x20000000 . = ALIGN (0x4)
0x20000000 _data_start = . 0x20000000 _data_start = .
*(.data) *(.data)
@@ -211,10 +248,10 @@ LOAD build/startup.o
0x20000000 . = ALIGN (0x4) 0x20000000 . = ALIGN (0x4)
0x20000000 _data_end = . 0x20000000 _data_end = .
.igot.plt 0x20000000 0x0 load address 0x0800048c .igot.plt 0x20000000 0x0 load address 0x080004f0
.igot.plt 0x20000000 0x0 build/main.o .igot.plt 0x20000000 0x0 build/main.o
.bss 0x20000000 0x0 load address 0x0800048c .bss 0x20000000 0x0 load address 0x080004f0
0x20000000 . = ALIGN (0x4) 0x20000000 . = ALIGN (0x4)
0x20000000 _bss_start = . 0x20000000 _bss_start = .
*(.bss) *(.bss)
@@ -224,34 +261,40 @@ LOAD build/startup.o
OUTPUT(build/final.elf elf32-littlearm) OUTPUT(build/final.elf elf32-littlearm)
LOAD linker stubs LOAD linker stubs
.debug_info 0x00000000 0x6f5 .debug_info 0x00000000 0xb25
.debug_info 0x00000000 0x21a build/gpio.o .debug_info 0x00000000 0x21a build/gpio.o
.debug_info 0x0000021a 0x353 build/main.o .debug_info 0x0000021a 0x44e build/main.o
.debug_info 0x0000056d 0x188 build/startup.o .debug_info 0x00000668 0x188 build/startup.o
.debug_info 0x000007f0 0x335 build/timer.o
.debug_abbrev 0x00000000 0x397 .debug_abbrev 0x00000000 0x44b
.debug_abbrev 0x00000000 0x12b build/gpio.o .debug_abbrev 0x00000000 0x12b build/gpio.o
.debug_abbrev 0x0000012b 0x145 build/main.o .debug_abbrev 0x0000012b 0x144 build/main.o
.debug_abbrev 0x00000270 0x127 build/startup.o .debug_abbrev 0x0000026f 0x127 build/startup.o
.debug_abbrev 0x00000396 0xb5 build/timer.o
.debug_aranges 0x00000000 0x88 .debug_aranges 0x00000000 0xa8
.debug_aranges .debug_aranges
0x00000000 0x28 build/gpio.o 0x00000000 0x28 build/gpio.o
.debug_aranges .debug_aranges
0x00000028 0x30 build/main.o 0x00000028 0x28 build/main.o
.debug_aranges .debug_aranges
0x00000058 0x30 build/startup.o 0x00000050 0x30 build/startup.o
.debug_aranges
0x00000080 0x28 build/timer.o
.debug_rnglists .debug_rnglists
0x00000000 0x58 0x00000000 0x6c
.debug_rnglists .debug_rnglists
0x00000000 0x19 build/gpio.o 0x00000000 0x19 build/gpio.o
.debug_rnglists .debug_rnglists
0x00000019 0x20 build/main.o 0x00000019 0x1b build/main.o
.debug_rnglists .debug_rnglists
0x00000039 0x1f build/startup.o 0x00000034 0x1f build/startup.o
.debug_rnglists
0x00000053 0x19 build/timer.o
.debug_macro 0x00000000 0x2f1d .debug_macro 0x00000000 0x3ba0
.debug_macro 0x00000000 0xb56 build/gpio.o .debug_macro 0x00000000 0xb56 build/gpio.o
.debug_macro 0x00000b56 0x22 build/gpio.o .debug_macro 0x00000b56 0x22 build/gpio.o
.debug_macro 0x00000b78 0x75 build/gpio.o .debug_macro 0x00000b78 0x75 build/gpio.o
@@ -267,33 +310,39 @@ LOAD linker stubs
.debug_macro 0x00001115 0x4cc build/gpio.o .debug_macro 0x00001115 0x4cc build/gpio.o
.debug_macro 0x000015e1 0x22 build/gpio.o .debug_macro 0x000015e1 0x22 build/gpio.o
.debug_macro 0x00001603 0x34 build/gpio.o .debug_macro 0x00001603 0x34 build/gpio.o
.debug_macro 0x00001637 0xb7d build/main.o .debug_macro 0x00001637 0xb80 build/main.o
.debug_macro 0x000021b4 0x11e build/main.o .debug_macro 0x000021b7 0x12a build/main.o
.debug_macro 0x000022d2 0x2e build/main.o .debug_macro 0x000022e1 0x46 build/main.o
.debug_macro 0x00002300 0x46 build/main.o .debug_macro 0x00002327 0x2e build/main.o
.debug_macro 0x00002346 0x2e build/main.o .debug_macro 0x00002355 0x22 build/main.o
.debug_macro 0x00002374 0xb02 build/startup.o .debug_macro 0x00002377 0xb02 build/startup.o
.debug_macro 0x00002e76 0x56 build/startup.o .debug_macro 0x00002e79 0x56 build/startup.o
.debug_macro 0x00002ecc 0x51 build/startup.o .debug_macro 0x00002ecf 0x51 build/startup.o
.debug_macro 0x00002f20 0xb5c build/timer.o
.debug_macro 0x00003a7c 0x124 build/timer.o
.debug_line 0x00000000 0x3ee .debug_line 0x00000000 0x4b9
.debug_line 0x00000000 0x116 build/gpio.o .debug_line 0x00000000 0x116 build/gpio.o
.debug_line 0x00000116 0x1ee build/main.o .debug_line 0x00000116 0x1da build/main.o
.debug_line 0x00000304 0xea build/startup.o .debug_line 0x000002f0 0xea build/startup.o
.debug_line 0x000003da 0xdf build/timer.o
.debug_str 0x00000000 0x5d86 .debug_str 0x00000000 0x5eb8
.debug_str 0x00000000 0x5372 build/gpio.o .debug_str 0x00000000 0x5372 build/gpio.o
0x551a (size before relaxing) 0x551a (size before relaxing)
.debug_str 0x00005372 0x98c build/main.o .debug_str 0x00005372 0xab2 build/main.o
0x5e56 (size before relaxing) 0x5f7c (size before relaxing)
.debug_str 0x00005cfe 0x88 build/startup.o .debug_str 0x00005e24 0x88 build/startup.o
0x3cdf (size before relaxing) 0x3cdf (size before relaxing)
.debug_str 0x00005eac 0xc build/timer.o
0x5b1a (size before relaxing)
.comment 0x00000000 0x45 .comment 0x00000000 0x45
.comment 0x00000000 0x45 build/gpio.o .comment 0x00000000 0x45 build/gpio.o
0x46 (size before relaxing) 0x46 (size before relaxing)
.comment 0x00000045 0x46 build/main.o .comment 0x00000045 0x46 build/main.o
.comment 0x00000045 0x46 build/startup.o .comment 0x00000045 0x46 build/startup.o
.comment 0x00000045 0x46 build/timer.o
.ARM.attributes .ARM.attributes
0x00000000 0x34 0x00000000 0x34
@@ -303,20 +352,26 @@ LOAD linker stubs
0x00000034 0x34 build/main.o 0x00000034 0x34 build/main.o
.ARM.attributes .ARM.attributes
0x00000068 0x34 build/startup.o 0x00000068 0x34 build/startup.o
.ARM.attributes
0x0000009c 0x34 build/timer.o
.debug_line_str .debug_line_str
0x00000000 0x273 0x00000000 0x283
.debug_line_str .debug_line_str
0x00000000 0x24e build/gpio.o 0x00000000 0x24e build/gpio.o
0x260 (size before relaxing) 0x260 (size before relaxing)
.debug_line_str .debug_line_str
0x0000024e 0x1b build/main.o 0x0000024e 0x23 build/main.o
0x274 (size before relaxing) 0x27c (size before relaxing)
.debug_line_str .debug_line_str
0x00000269 0xa build/startup.o 0x00000271 0xa build/startup.o
0x21b (size before relaxing) 0x21b (size before relaxing)
.debug_line_str
0x0000027b 0x8 build/timer.o
0x25e (size before relaxing)
.debug_frame 0x00000000 0x144 .debug_frame 0x00000000 0x16c
.debug_frame 0x00000000 0x60 build/gpio.o .debug_frame 0x00000000 0x60 build/gpio.o
.debug_frame 0x00000060 0x78 build/main.o .debug_frame 0x00000060 0x50 build/main.o
.debug_frame 0x000000d8 0x6c build/startup.o .debug_frame 0x000000b0 0x6c build/startup.o
.debug_frame 0x0000011c 0x50 build/timer.o

File diff suppressed because it is too large Load Diff

View File

@@ -1963,6 +1963,20 @@ extern intmax_t _wcstoimax_r(struct _reent *, const wchar_t *__restrict, wchar_t
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
extern uintmax_t _wcstoumax_r(struct _reent *, const wchar_t *__restrict, wchar_t **__restrict, int); extern uintmax_t _wcstoumax_r(struct _reent *, const wchar_t *__restrict, wchar_t **__restrict, int);
# 2 "src/main.c" 2 # 2 "src/main.c" 2
# 1 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/lib/gcc/arm-none-eabi/12.3.1/include/stdbool.h" 1 3 4
# 29 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/lib/gcc/arm-none-eabi/12.3.1/include/stdbool.h" 3 4
#define _STDBOOL_H
#define bool _Bool
#define true ((_Bool)+1u)
#define false ((_Bool)+0u)
# 50 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/lib/gcc/arm-none-eabi/12.3.1/include/stdbool.h" 3 4
#define __bool_true_false_are_defined 1
# 3 "src/main.c" 2
# 1 "src/rcc.h" 1 # 1 "src/rcc.h" 1
#define RCC_H_ #define RCC_H_
@@ -2085,26 +2099,17 @@ struct rcc {
#define RCC_APB1ENR_PWREN_BIT 28 #define RCC_APB1ENR_PWREN_BIT 28
#define RCC_APB1ENR_PWREN_CLOCK_ENABLE (1 << RCC_APB1ENR_PWREN_BIT) #define RCC_APB1ENR_PWREN_CLOCK_ENABLE (1 << RCC_APB1ENR_PWREN_BIT)
# 3 "src/main.c" 2
#define RCC_APB1ENR_TIM4_BIT 2
#define RCC_APB1ENR_TIM4_ENABLE (1 << RCC_APB1ENR_TIM4_BIT)
# 5 "src/main.c" 2
# 1 "src/gpio.h" 1 # 1 "src/gpio.h" 1
#define GPIO_H_ #define GPIO_H_
# 1 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/lib/gcc/arm-none-eabi/12.3.1/include/stdbool.h" 1 3 4
# 29 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/lib/gcc/arm-none-eabi/12.3.1/include/stdbool.h" 3 4
#define _STDBOOL_H
#define bool _Bool
#define true ((_Bool)+1u)
#define false ((_Bool)+0u)
# 50 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/lib/gcc/arm-none-eabi/12.3.1/include/stdbool.h" 3 4
#define __bool_true_false_are_defined 1
# 5 "src/gpio.h" 2
struct gpio { struct gpio {
volatile uint32_t MODER; volatile uint32_t MODER;
volatile uint32_t OTYPER; volatile uint32_t OTYPER;
@@ -2143,7 +2148,7 @@ void gpio_write(uint16_t pin,
_Bool _Bool
# 40 "src/gpio.h" # 40 "src/gpio.h"
val); val);
# 4 "src/main.c" 2 # 6 "src/main.c" 2
# 1 "src/flash.h" 1 # 1 "src/flash.h" 1
#define FLASH_H_ #define FLASH_H_
@@ -2177,7 +2182,7 @@ struct flash {
#define FLASH_ACR_LATENCY_BIT 0 #define FLASH_ACR_LATENCY_BIT 0
#define FLASH_ACR_LATENCY_MASK (0b1111) #define FLASH_ACR_LATENCY_MASK (0b1111)
#define FLASH_ACR_LATENCY(latency) ((latency & FLASH_ACR_LATENCY_MASK) << FLASH_ACR_LATENCY_BIT) #define FLASH_ACR_LATENCY(latency) ((latency & FLASH_ACR_LATENCY_MASK) << FLASH_ACR_LATENCY_BIT)
# 5 "src/main.c" 2 # 7 "src/main.c" 2
# 1 "src/pwr.h" 1 # 1 "src/pwr.h" 1
#define PWR_H_ #define PWR_H_
@@ -2199,7 +2204,45 @@ struct pwr {
#define PWR_CR_VOS_BIT 14 #define PWR_CR_VOS_BIT 14
#define PWR_CR_VOS_MASK (0b11) #define PWR_CR_VOS_MASK (0b11)
#define PWR_CR_VOS(scale) ((scale & PWR_CR_VOS_MASK) << PWR_CR_VOS_BIT) #define PWR_CR_VOS(scale) ((scale & PWR_CR_VOS_MASK) << PWR_CR_VOS_BIT)
# 6 "src/main.c" 2 # 8 "src/main.c" 2
# 1 "src/timer.h" 1
#define TIMER_H_
struct timer {
volatile uint32_t CR1;
volatile uint32_t CR2;
volatile uint32_t SMCR;
volatile uint32_t DIER;
volatile uint32_t SR;
volatile uint32_t EGR;
volatile uint32_t CCMR1;
volatile uint32_t CCMR2;
volatile uint32_t CCER;
volatile uint32_t CNT;
volatile uint32_t PSC;
volatile uint32_t ARR;
volatile uint32_t RCR;
volatile uint32_t CCR1;
volatile uint32_t CCR2;
volatile uint32_t CCR3;
volatile uint32_t CCR4;
volatile uint32_t BDTR;
volatile uint32_t DCR;
volatile uint32_t DMAR;
};
#define TIM4_BASE_ADDR (0x40000800U)
#define TIM4 ((struct timer *) TIM4_BASE_ADDR)
#define TIM4_CR_CEN_BIT 0
#define TIM4_ENABLE (1 << TIM4_CR_CEN_BIT)
void tim4_init(void);
void tim4_start(void);
# 9 "src/main.c" 2
#define exit 42 #define exit 42
@@ -2267,29 +2310,33 @@ static void system_clock_init(void) {
((struct rcc *) (0x40023800U))->CR &= ~(1 << 0); ((struct rcc *) (0x40023800U))->CR &= ~(1 << 0);
} }
static inline void spin(volatile uint32_t count) {
while (count--) (void) 0;
}
int main(void) { int main(void) {
(void) system_clock_init(); (void) system_clock_init();
(void) tim4_init();
(void) tim4_start();
uint16_t led = (((('C') - 'A') << 8) | 13); uint16_t led = (((('C') - 'A') << 8) | 13);
((struct rcc *) (0x40023800U))->AHB1ENR |= (1 << (led >> 8)); ((struct rcc *) (0x40023800U))->AHB1ENR |= (1 << (led >> 8));
gpio_set_mode(led, GPIO_MODE_OUTPUT); gpio_set_mode(led, GPIO_MODE_OUTPUT);
for (;;) {
gpio_write(led, uint16_t counter = ((struct timer *) (0x40000800U))->CNT;
# 84 "src/main.c" 3 4
((_Bool)+1u) # 87 "src/main.c" 3 4
# 84 "src/main.c" _Bool
); # 87 "src/main.c"
spin(999999); led_on =
gpio_write(led, # 87 "src/main.c" 3 4
# 86 "src/main.c" 3 4 ((_Bool)+0u)
((_Bool)+0u) # 87 "src/main.c"
# 86 "src/main.c" ;
); while(1) {
spin(999999); if ((((struct timer *) (0x40000800U))->CNT - counter) >= 250) {
led_on = !led_on;
gpio_write(led, led_on);
counter = ((struct timer *) (0x40000800U))->CNT;
}
}; };
return 42; return 42;

Binary file not shown.

5608
build/timer.S Normal file

File diff suppressed because it is too large Load Diff

2148
build/timer.i Normal file

File diff suppressed because it is too large Load Diff

BIN
build/timer.o Normal file

Binary file not shown.

View File

@@ -1,8 +1,11 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h>
#include "rcc.h" #include "rcc.h"
#include "gpio.h" #include "gpio.h"
#include "flash.h" #include "flash.h"
#include "pwr.h" #include "pwr.h"
#include "timer.h"
#define exit 42 #define exit 42
@@ -70,21 +73,25 @@ static void system_clock_init(void) {
RCC->CR &= ~RCC_CR_HSION_ON; RCC->CR &= ~RCC_CR_HSION_ON;
} }
static inline void spin(volatile uint32_t count) {
while (count--) (void) 0;
}
int main(void) { int main(void) {
(void) system_clock_init(); (void) system_clock_init();
(void) tim4_init();
(void) tim4_start();
uint16_t led = PIN('C', 13); // Blue LED uint16_t led = PIN('C', 13); // Blue LED
RCC->AHB1ENR |= BIT(PINPORT(led)); // Enable GPIO clock for LED RCC->AHB1ENR |= BIT(PINPORT(led)); // Enable GPIO clock for LED
gpio_set_mode(led, GPIO_MODE_OUTPUT); // Set blue LED to output mode gpio_set_mode(led, GPIO_MODE_OUTPUT); // Set blue LED to output mode
for (;;) {
gpio_write(led, true); uint16_t counter = TIM4->CNT;
spin(999999); bool led_on = false;
gpio_write(led, false); while(1) {
spin(999999); if ((TIM4->CNT - counter) >= 250) {
led_on = !led_on;
gpio_write(led, led_on);
counter = TIM4->CNT;
}
}; };
return exit; return exit;

View File

@@ -118,4 +118,7 @@ struct rcc {
#define RCC_APB1ENR_PWREN_BIT 28 #define RCC_APB1ENR_PWREN_BIT 28
#define RCC_APB1ENR_PWREN_CLOCK_ENABLE (1 << RCC_APB1ENR_PWREN_BIT) #define RCC_APB1ENR_PWREN_CLOCK_ENABLE (1 << RCC_APB1ENR_PWREN_BIT)
#define RCC_APB1ENR_TIM4_BIT 2
#define RCC_APB1ENR_TIM4_ENABLE (1 << RCC_APB1ENR_TIM4_BIT)
#endif #endif