]> mj.ucw.cz Git - home-hw.git/commitdiff
protab: blink-usbboot
authorMartin Mares <mj@ucw.cz>
Sun, 25 Jul 2021 08:59:43 +0000 (10:59 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 25 Jul 2021 08:59:43 +0000 (10:59 +0200)
protab/blink-usbboot/Makefile [new file with mode: 0644]
protab/blink-usbboot/blink.c [new file with mode: 0644]

diff --git a/protab/blink-usbboot/Makefile b/protab/blink-usbboot/Makefile
new file mode 100644 (file)
index 0000000..011261f
--- /dev/null
@@ -0,0 +1,8 @@
+ROOT=../..
+BINARY=blink
+OBJS=blink.o
+LIB_OBJS=
+WITH_BOOT_LOADER=1
+WITH_DFU_FLASH=1
+
+include $(ROOT)/mk/bluepill.mk
diff --git a/protab/blink-usbboot/blink.c b/protab/blink-usbboot/blink.c
new file mode 100644 (file)
index 0000000..7fe240a
--- /dev/null
@@ -0,0 +1,23 @@
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
+
+int main(void)
+{
+       rcc_clock_setup_in_hse_8mhz_out_72mhz();
+       rcc_periph_clock_enable(RCC_GPIOC);
+
+       // PC13 = BluePill LED
+       gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);
+
+       for (;;) {
+               gpio_clear(GPIOC, GPIO13);
+
+               for (int i=0; i<10000000; i++)
+                       asm volatile ("");
+
+               gpio_set(GPIOC, GPIO13);
+
+               for (int i=0; i<10000000; i++)
+                       asm volatile ("");
+       }
+}