From 2275ed7b0c355920927be6709a87a0482a749eb2 Mon Sep 17 00:00:00 2001 From: chrysn Date: Sun, 26 Feb 2012 03:40:18 +0100 Subject: overhauled documentation includes minor refactoring in example code and modification of how the generic and the tinygecko specific vector.h go together (bringing it in line with stm32/f1's memorymap.h) --- examples/efm32/tinygecko/Makefile.include | 2 +- .../efm32-tg-stk3300/miniblink/miniblink.c | 35 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'examples/efm32') 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 #include +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; } -- cgit v1.2.3