From bdb1a498df58f00c84378ff54e9077f1bfb197a7 Mon Sep 17 00:00:00 2001 From: Mike Szczys Date: Sun, 3 Jun 2012 10:47:18 -0500 Subject: [PATCH] Added STM32F0-Discovery board to the blink example code --- example/blink/Makefile | 5 ++++- example/blink/main.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/example/blink/Makefile b/example/blink/Makefile index cf7221d..60fab84 100644 --- a/example/blink/Makefile +++ b/example/blink/Makefile @@ -12,8 +12,9 @@ DEF_CFLAGS+=-Wl,-Ttext,0x20000000 -Wl,-e,0x20000000 CFLAGS_VL=$(DEF_CFLAGS) -mcpu=cortex-m3 -DCONFIG_STM32VL_DISCOVERY=1 CFLAGS_L=$(DEF_CFLAGS) -mcpu=cortex-m3 -DCONFIG_STM32L_DISCOVERY CFLAGS_F4=$(DEF_CFLAGS) -mcpu=cortex-m4 -DCONFIG_STM32F4_DISCOVERY=1 +CFLAGS_F0=$(DEF_CFLAGS) -mcpu=cortex-m0 -DCONFIG_STM32F0_DISCOVERY=1 -all: blink_32VL.elf blink_32L.elf blink_F4.elf +all: blink_32VL.elf blink_32L.elf blink_F4.elf blink_F0.elf %.bin: %.elf $(OBJCOPY) -O binary $^ $@ @@ -24,6 +25,8 @@ blink_32L.elf: main.c $(CC) $(CFLAGS_L) $^ -o $@ blink_F4.elf: main.c $(CC) $(CFLAGS_F4) $^ -o $@ +blink_F0.elf: main.c + $(CC) $(CFLAGS_F0) $^ -o $@ clean: rm -rf *.elf diff --git a/example/blink/main.c b/example/blink/main.c index b70a136..26fcca0 100644 --- a/example/blink/main.c +++ b/example/blink/main.c @@ -58,6 +58,26 @@ static inline void setup_leds(void) (1 << (13 * 2)) | (1 << (14 * 2)) | (1 << (15 * 2)); } +#elif CONFIG_STM32F0_DISCOVERY + +#define GPIOC 0x48000800 /* port C */ +#define GPIOC_MODER (GPIOC + 0x00) /* port mode register */ +#define LED_PORT_ODR (GPIOC + 0x14) /* port output data register */ + +#define LED_BLUE (1 << 8) /* port C, pin 8 */ +#define LED_GREEN (1 << 9) /* port C, pin 9 */ +#define LED_ORANGE 0 +#define LED_RED 0 + +void _tmain(void) { + main(); +} +static inline void setup_leds(void) +{ + /* configure port 8 and 9 as output */ + *(volatile uint32_t*)GPIOC_MODER |= (1 << (9* 2)) | (1 << (8 * 2)); +} + #else #error "Architecture must be defined!" #endif /* otherwise, error */ -- 2.47.2