summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2021-09-26 12:50:49 +0200
committerxengineering <me@xengineering.eu>2021-09-26 14:07:59 +0200
commit5d17a976070be9d66349da0ddd28361884f3461d (patch)
treeef3e2c0078863aa651008e4f2f9eb4f846bfcc50 /src
parent7211bd49452e67e0b53ea06ca474f4e54af991ae (diff)
downloadledcontrol-5d17a976070be9d66349da0ddd28361884f3461d.tar
ledcontrol-5d17a976070be9d66349da0ddd28361884f3461d.tar.zst
ledcontrol-5d17a976070be9d66349da0ddd28361884f3461d.zip
Link against libopencm3
Diffstat (limited to 'src')
-rw-r--r--src/main.c47
-rw-r--r--src/test_program.c8
2 files changed, 47 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..7a5290f
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,47 @@
+
+
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
+
+
+#define DELAY 1000000
+
+
+void clock_init(void);
+void gpio_init(void);
+void delay(void);
+
+
+int main(void)
+{
+ clock_init();
+ gpio_init();
+
+ while(1){
+ gpio_toggle(GPIOC, GPIO13);
+ delay();
+ }
+
+ return 0;
+}
+
+
+void clock_init(void)
+{
+ rcc_periph_clock_enable(RCC_GPIOC); // for PC13 blinking
+}
+
+
+void gpio_init(void)
+{
+ gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);
+ gpio_set(GPIOC, GPIO13);
+}
+
+
+void delay(void)
+{
+ for (int i = 0; i < DELAY; i++) {
+ __asm__("nop");
+ }
+}
diff --git a/src/test_program.c b/src/test_program.c
deleted file mode 100644
index 80f569b..0000000
--- a/src/test_program.c
+++ /dev/null
@@ -1,8 +0,0 @@
-static const int a = 7;
-static int b = 8;
-static int sum;
-
-void main()
-{
- sum = a + b;
-}