diff options
| author | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2025-12-18 16:37:25 +0500 |
|---|---|---|
| committer | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2025-12-18 16:37:25 +0500 |
| commit | df6f89abeab60e91a348484cdceadb758290f234 (patch) | |
| tree | e666933a0906cf80d063e71c6ac3c62827f8a5db /src | |
Template init
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 17 | ||||
| -rw-r--r-- | src/bin/main.d | 18 | ||||
| -rw-r--r-- | src/bin/main.o | bin | 0 -> 77016 bytes | |||
| -rwxr-xr-x | src/blink-led.bin | bin | 0 -> 692 bytes | |||
| -rwxr-xr-x | src/blink-led.elf | bin | 0 -> 92140 bytes | |||
| -rw-r--r-- | src/generated.stm32f103c8.ld | 69 | ||||
| -rw-r--r-- | src/main.c | 14 |
7 files changed, 118 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..9e86f13 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,17 @@ +PROJECT = blink-led +BUILD_DIR = bin + +CFILES = main.c + +# TODO - you will need to edit these two lines! +DEVICE=stm32f103c8 +OOCD_FILE = board/stm32f4discovery.cfg + +# You shouldn't have to edit anything below here. +VPATH += $(SHARED_DIR) +INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR)) +OPENCM3_DIR=../libopencm3 + +include $(OPENCM3_DIR)/mk/genlink-config.mk +include ../rules.mk +include $(OPENCM3_DIR)/mk/genlink-rules.mk diff --git a/src/bin/main.d b/src/bin/main.d new file mode 100644 index 0000000..0bf80b9 --- /dev/null +++ b/src/bin/main.d @@ -0,0 +1,18 @@ +bin/main.o: main.c ../libopencm3/include/libopencm3/stm32/rcc.h \ + ../libopencm3/include/libopencm3/cm3/common.h \ + /usr/lib/gcc/arm-none-eabi/14.2.0/include/stdint.h \ + /usr/arm-none-eabi/include/stdint.h \ + /usr/arm-none-eabi/include/machine/_default_types.h \ + /usr/arm-none-eabi/include/sys/features.h \ + /usr/arm-none-eabi/include/_newlib_version.h \ + /usr/arm-none-eabi/include/sys/_intsup.h \ + /usr/arm-none-eabi/include/sys/_stdint.h \ + /usr/lib/gcc/arm-none-eabi/14.2.0/include/stdbool.h \ + ../libopencm3/include/libopencm3/stm32/memorymap.h \ + ../libopencm3/include/libopencm3/stm32/f1/memorymap.h \ + ../libopencm3/include/libopencm3/cm3/memorymap.h \ + ../libopencm3/include/libopencm3/stm32/f1/rcc.h \ + ../libopencm3/include/libopencm3/stm32/common/rcc_common_all.h \ + ../libopencm3/include/libopencm3/stm32/gpio.h \ + ../libopencm3/include/libopencm3/stm32/f1/gpio.h \ + ../libopencm3/include/libopencm3/stm32/common/gpio_common_all.h diff --git a/src/bin/main.o b/src/bin/main.o Binary files differnew file mode 100644 index 0000000..faa4061 --- /dev/null +++ b/src/bin/main.o diff --git a/src/blink-led.bin b/src/blink-led.bin Binary files differnew file mode 100755 index 0000000..028bf9d --- /dev/null +++ b/src/blink-led.bin diff --git a/src/blink-led.elf b/src/blink-led.elf Binary files differnew file mode 100755 index 0000000..05500f1 --- /dev/null +++ b/src/blink-led.elf diff --git a/src/generated.stm32f103c8.ld b/src/generated.stm32f103c8.ld new file mode 100644 index 0000000..7b7234a --- /dev/null +++ b/src/generated.stm32f103c8.ld @@ -0,0 +1,69 @@ +EXTERN(vector_table) +ENTRY(reset_handler) +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K +} +SECTIONS +{ + .text : { + *(.vectors) + *(.text*) + . = ALIGN(4); + *(.rodata*) + . = ALIGN(4); + } >rom + .preinit_array : { + . = ALIGN(4); + __preinit_array_start = .; + KEEP (*(.preinit_array)) + __preinit_array_end = .; + } >rom + .init_array : { + . = ALIGN(4); + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; + } >rom + .fini_array : { + . = ALIGN(4); + __fini_array_start = .; + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + __fini_array_end = .; + } >rom + .ARM.extab : { + *(.ARM.extab*) + } >rom + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >rom + . = ALIGN(4); + _etext = .; + .noinit (NOLOAD) : { + *(.noinit*) + } >ram + . = ALIGN(4); + .data : { + _data = .; + *(.data*) + *(.ramtext*) + . = ALIGN(4); + _edata = .; + } >ram AT >rom + _data_loadaddr = LOADADDR(.data); + .bss : { + *(.bss*) + *(COMMON) + . = ALIGN(4); + _ebss = .; + } >ram + /DISCARD/ : { *(.eh_frame) } + . = ALIGN(4); + end = .; +} +PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram)); diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..7b446ca --- /dev/null +++ b/src/main.c @@ -0,0 +1,14 @@ +#define STM32F1 +#include <libopencm3/stm32/rcc.h> +#include <libopencm3/stm32/gpio.h> + +int main(void) { + rcc_periph_clock_enable(RCC_GPIOC); + + gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13); + while (1) { + for (int i = 0; i < 1000000; i++) + __asm__("nop"); + gpio_toggle(GPIOC, GPIO13); + } +} |
