aboutsummaryrefslogtreecommitdiff
path: root/examples/efm32
diff options
context:
space:
mode:
Diffstat (limited to 'examples/efm32')
-rw-r--r--examples/efm32/tinygecko/Makefile.include2
-rw-r--r--examples/efm32/tinygecko/efm32-tg-stk3300/miniblink/miniblink.c35
2 files changed, 31 insertions, 6 deletions
diff --git a/examples/efm32/tinygecko/Makefile.include b/examples/efm32/tinygecko/Makefile.include
index 1ee8d49..76691ce 100644
--- a/examples/efm32/tinygecko/Makefile.include
+++ b/examples/efm32/tinygecko/Makefile.include
@@ -30,7 +30,7 @@ GDB = $(PREFIX)-gdb
#TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
TOOLCHAIN_DIR = ../../../../..
CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \
- -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -DSTM32F1
+ -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD
LDSCRIPT ?= ${TOOLCHAIN_DIR}/lib/efm32/tinygecko/$(MCU).ld
LDFLAGS += -lc -lnosys -L$(TOOLCHAIN_DIR)/lib/efm32/tinygecko \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
diff --git a/examples/efm32/tinygecko/efm32-tg-stk3300/miniblink/miniblink.c b/examples/efm32/tinygecko/efm32-tg-stk3300/miniblink/miniblink.c
index 3053626..0941add 100644
--- a/examples/efm32/tinygecko/efm32-tg-stk3300/miniblink/miniblink.c
+++ b/examples/efm32/tinygecko/efm32-tg-stk3300/miniblink/miniblink.c
@@ -21,11 +21,37 @@
#include <libopencm3/efm32/tinygecko/gpio.h>
#include <libopencm3/efm32/tinygecko/cmu.h>
+void led_setup(void);
+void led_toggle(void);
+
+/** @file
+ * Minimal example for making the User LED of the EFM32-TG-STK330 eval board blink.
+ */
+
+/**
+ * Toggle the User LED in an infinite loop, with time between the toggling
+ * determined by a busy loop stupidly counting up.
+ */
+
int main(void)
{
// FIXME: As of now, this doesn't work without x being volatile; an issue with linking?
volatile int x;
+ led_setup();
+
+ while(1) {
+ for(x = 0; x < 200000; ++x);
+ led_toggle();
+ };
+}
+
+/**
+ * Enable GPIO, and set up port D7 as an output pin.
+ */
+
+void led_setup(void)
+{
// Before GPIO works, according to d0034_efm32tg_reference_manual.pdf
// note in section 28.3.7, we'll have to enable GPIO in CMU_HFPERCLKEN0
@@ -36,10 +62,9 @@ int main(void)
// and 16.3 (called UIF_LED0)
GPIO_PD_MODEL = GPIO_MODE_PUSHPULL<<(7*4);
- GPIO_PD_DOUTSET = 1<<7;
+}
- while(1) {
- for(x = 0; x < 200000; ++x);
- GPIO_PD_DOUTTGL = 1<<7;
- };
+void led_toggle(void)
+{
+ GPIO_PD_DOUTTGL = 1<<7;
}