From 58f7ce498dfe3f6c1312b28c6cb3d7d2604f6732 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Sun, 12 Apr 2020 22:45:39 +0200 Subject: [PATCH] Comment the setup a bit --- Makefile | 4 ++++ main.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 8c4e287..4def1c0 100644 --- a/Makefile +++ b/Makefile @@ -12,3 +12,7 @@ CPU_FLAGS := -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd %.bin: %.elf arm-none-eabi-objcopy -Obinary $*.elf $*.bin +flash: main.bin + st-flash write /dev/stlinkv1_4 main.bin 0x08000000 + +.PHONY: flash diff --git a/main.c b/main.c index 83f03a4..00aa67a 100644 --- a/main.c +++ b/main.c @@ -18,10 +18,18 @@ #define STM32F1 1 // Needed for libopencm3 void setup (void) { // All the blackbox code + + // Set up clock rcc_clock_setup_in_hse_8mhz_out_24mhz(); + + // Enable the two GPIOs rcc_periph_clock_enable(RCC_GPIOC); rcc_periph_clock_enable(RCC_GPIOA); + + // GPIO C8 amd C9 are the two LEDs gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO8 | GPIO9); + + // GPIO A0 is the push button gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO0); }