aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gravekamp <me@thomas-gravekamp.nl>2017-10-31 23:33:50 +0100
committerThomas Gravekamp <me@thomas-gravekamp.nl>2017-10-31 23:34:43 +0100
commit9bc221d2c6b3d4b69fdfa2ab3d5cafc05a5d7304 (patch)
tree85bf83e137461ec89ba74fd27e472a362102d77c
parentc5a0d0355b72aca0ce9a92225130600ff30de54b (diff)
Add initial files.
-rw-r--r--.gitignore3
-rw-r--r--Makefile5
-rw-r--r--README.md7
-rw-r--r--src/main.c33
4 files changed, 48 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..99e62ac
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+STM32-base
+bin
+sobj
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4a84ce2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+DEVICE = STM32F030x4
+FLASH = 0x08000000
+
+# Include the main makefile
+include ./STM32-base/make/common.mk
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1fccee0
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+# STM32-base F0 template
+
+This repository contains a template for starting projects based on the STM32F0 series devices using the [STM32-base repository](https://github.com/ThomasGravekamp/STM32-base). The code found in this repository has been tested with a STM32F030x4 device.
+
+## Usage
+
+To use this template, clone the [STM32-base repository](https://github.com/ThomasGravekamp/STM32-base) either directly in this templates folder or create a symbolic link to it.
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..e9a7b77
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,33 @@
+#include <stm32f0xx.h>
+
+// Quick and dirty delay
+static void delay (unsigned int time) {
+ for (unsigned int i = 0; i < time; i++)
+ for (volatile unsigned int j = 0; j < 2000; j++);
+}
+
+int main (void) {
+ // Turn on the GPIOA peripheral
+ RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
+
+ // Put pin in general purpose output mode (B01)
+ GPIOA->MODER |= GPIO_MODER_MODER4_0;
+ // Set the output type to push pull (B0 = default)
+ // GPIOA->OTYPER = ~GPIO_OTYPER_OT_4;
+ // Set the output speed to low (B00 = default)
+ // GPIOA->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR4;
+ // Set the pull up/down resistors (B00 = default)
+ // GPIOA->PUPDR &= ~GPIO_PUPDR_PUPDR4;
+
+ while (1) {
+ // Reset the bit for port A4
+ GPIOA->BSRR = GPIO_BSRR_BR_4;
+
+ delay(500);
+
+ // Set the bit for port A4
+ GPIOA->BSRR = GPIO_BSRR_BS_4;
+
+ delay(500);
+ }
+}