]> git.gag.com Git - fw/stlink/commitdiff
Added STM32F0-Discovery board to the blink example code
authorMike Szczys <mike@jumptuck.com>
Sun, 3 Jun 2012 15:47:18 +0000 (10:47 -0500)
committerMike Szczys <mike@jumptuck.com>
Sun, 3 Jun 2012 15:47:18 +0000 (10:47 -0500)
example/blink/Makefile
example/blink/main.c

index cf7221da81cb33c234d59978c9872f2d7e56a1c7..60fab84c8c46b7345644bc2cf265ee3be15b8efc 100644 (file)
@@ -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
index b70a136a35c695410d268e5738c64bca82ae5d3a..26fcca029ebd3487f6a941b4e88b60eb604b427c 100644 (file)
@@ -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 */