aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile10
-rw-r--r--examples/Makefile.include123
-rw-r--r--examples/mb525/fancyblink/Makefile76
-rw-r--r--examples/mb525/pwmleds/Makefile76
-rw-r--r--examples/mb525/pwmleds/pwmleds.c33
-rw-r--r--examples/obldc/Makefile56
-rw-r--r--examples/obldc/can/Makefile22
-rw-r--r--examples/obldc/can/can.c216
-rw-r--r--examples/obldc/can/can.ld31
-rw-r--r--examples/obldc/led/Makefile22
-rw-r--r--examples/obldc/led/led.c67
-rw-r--r--examples/obldc/led/led.ld31
-rw-r--r--examples/obldc/systick/Makefile22
-rw-r--r--examples/obldc/systick/systick.c90
-rw-r--r--examples/obldc/systick/systick.ld31
-rw-r--r--examples/obldc/usart/Makefile22
-rw-r--r--examples/obldc/usart/usart.c91
-rw-r--r--examples/obldc/usart/usart.ld31
-rw-r--r--examples/obldc/usart_irq/Makefile24
-rw-r--r--examples/obldc/usart_irq/usart_irq.c126
-rw-r--r--examples/obldc/usart_irq/usart_irq.ld31
-rw-r--r--examples/other/adc_temperature_sensor/Makefile75
-rw-r--r--examples/other/dma_mem2mem/Makefile75
-rw-r--r--examples/other/dogm128/Makefile75
-rw-r--r--examples/other/i2c_stts75_sensor/Makefile75
-rw-r--r--examples/other/rtc/Makefile75
-rw-r--r--examples/other/systick/Makefile75
-rw-r--r--examples/other/timer_interrupt/Makefile75
-rw-r--r--examples/other/usb_cdcacm/Makefile75
-rw-r--r--examples/other/usb_dfu/Makefile75
-rw-r--r--examples/other/usb_hid/Makefile75
-rw-r--r--examples/other/usb_hid/README4
-rw-r--r--examples/stm32-h103/fancyblink/Makefile75
-rw-r--r--examples/stm32-h103/miniblink/Makefile75
-rw-r--r--examples/stm32-h103/spi/Makefile75
-rw-r--r--examples/stm32-h103/usart/Makefile75
-rw-r--r--examples/stm32-h103/usart/usart.c6
-rw-r--r--examples/stm32-h103/usb_cdcacm/Makefile78
38 files changed, 1086 insertions, 1283 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 0f772e2..30e2505 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -24,7 +24,7 @@ Q := @
MAKEFLAGS += --no-print-directory
endif
-all: stm32-h103 mb525 other lisa-m
+all: stm32-h103 mb525 lisa-m obldc other
stm32-h103:
@printf " BUILD examples/stm32-h103\n"
@@ -42,6 +42,10 @@ other:
@printf " BUILD examples/other\n"
$(Q)$(MAKE) -C other
+obldc:
+ @printf " BUILD examples/obldc\n"
+ $(Q)$(MAKE) -C obldc
+
clean:
@printf " CLEAN examples/stm32-h103\n"
$(Q)$(MAKE) -C stm32-h103 clean
@@ -51,6 +55,8 @@ clean:
$(Q)$(MAKE) -C lisa-m clean
@printf " CLEAN examples/other\n"
$(Q)$(MAKE) -C other clean
+ @printf " CLEAN examples/obldc\n"
+ $(Q)$(MAKE) -C obldc clean
-.PHONY: stm32-h103 mb525 lisa-m other clean
+.PHONY: stm32-h103 mb525 lisa-m other obldc clean
diff --git a/examples/Makefile.include b/examples/Makefile.include
new file mode 100644
index 0000000..bd978fe
--- /dev/null
+++ b/examples/Makefile.include
@@ -0,0 +1,123 @@
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+# PREFIX ?= arm-none-eabi
+PREFIX ?= arm-elf
+CC = $(PREFIX)-gcc
+LD = $(PREFIX)-gcc
+OBJCOPY = $(PREFIX)-objcopy
+OBJDUMP = $(PREFIX)-objdump
+# Uncomment this line if you want to use the installed (not local) library.
+# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
+TOOLCHAIN_DIR = ../../..
+CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
+ -mcpu=cortex-m3 -mthumb
+LDSCRIPT = $(BINARY).ld
+LDFLAGS += -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles \
+ -Wl,--gc-sections
+OBJS += $(BINARY).o
+
+OOCD ?= openocd
+OOCD_INTERFACE ?= flossjtag
+OOCD_BOARD ?= olimex_stm32_h103
+
+# Be silent per default, but 'make V=1' will show all compiler calls.
+ifneq ($(V),1)
+Q := @
+NULL := 2>/dev/null
+else
+LDFLAGS += -Wl,--print-gc-sections
+endif
+
+.SUFFIXES: .elf .bin .hex .srec .list .images
+.SECONDEXPANSION:
+.SECONDARY:
+
+all: images
+
+images: $(BINARY).images
+flash: $(BINARY).flash
+
+%.images: %.bin %.hex %.srec %.list
+ @echo "*** $* images generated ***"
+
+%.bin: %.elf
+ @printf " OBJCOPY $(*).bin\n"
+ $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin
+
+%.hex: %.elf
+ @printf " OBJCOPY $(*).hex\n"
+ $(Q)$(OBJCOPY) -Oihex $(*).elf $(*).hex
+
+%.srec: %.elf
+ @printf " OBJCOPY $(*).srec\n"
+ $(Q)$(OBJCOPY) -Osrec $(*).elf $(*).srec
+
+%.list: %.elf
+ @printf " OBJDUMP $(*).list\n"
+ $(Q)$(OBJDUMP) -S $(*).elf > $(*).list
+
+%.elf: $(OBJS) $(LDSCRIPT)
+ @printf " LD $(subst $(shell pwd)/,,$(@))\n"
+ $(Q)$(LD) $(LDFLAGS) -o $(*).elf $(OBJS) -lopenstm32
+
+%.o: %.c Makefile
+ @printf " CC $(subst $(shell pwd)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) -o $@ -c $<
+
+clean:
+ @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
+ $(Q)rm -f *.o
+ @printf " CLEAN *.elf\n"
+ $(Q)rm -f *.elf
+ @printf " CLEAN *.bin\n"
+ $(Q)rm -f *.bin
+ @printf " CLEAN *.hex\n"
+ $(Q)rm -f *.hex
+ @printf " CLEAN *.srec\n"
+ $(Q)rm -f *.srec
+ @printf " CLEAN *.list\n"
+ $(Q)rm -f *.list
+
+ifeq ($(OOCD_SERIAL),)
+%.flash: %.hex
+ @printf " FLASH $<\n"
+ @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
+ $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
+ -f board/$(OOCD_BOARD).cfg \
+ -c "init" -c "reset init" \
+ -c "stm32x mass_erase 0" \
+ -c "flash write_image $(*).hex" \
+ -c "reset" \
+ -c "shutdown" $(NULL)
+else
+%.flash: %.hex
+ @printf " FLASH $<\n"
+ @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
+ $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
+ -f board/$(OOCD_BOARD).cfg \
+ -c "ft2232_serial $(OOCD_SERIAL)" \
+ -c "init" -c "reset init" \
+ -c "stm32x mass_erase 0" \
+ -c "flash write_image $(*).hex" \
+ -c "reset" \
+ -c "shutdown" $(NULL)
+endif
+
+.PHONY: images clean
diff --git a/examples/mb525/fancyblink/Makefile b/examples/mb525/fancyblink/Makefile
index ae68552..a712cc4 100644
--- a/examples/mb525/fancyblink/Makefile
+++ b/examples/mb525/fancyblink/Makefile
@@ -19,78 +19,4 @@
BINARY = fancyblink
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-#LDFLAGS = -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/mb525/pwmleds/Makefile b/examples/mb525/pwmleds/Makefile
index ee3e8eb..241e1fa 100644
--- a/examples/mb525/pwmleds/Makefile
+++ b/examples/mb525/pwmleds/Makefile
@@ -19,78 +19,4 @@
BINARY = pwmleds
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-#LDFLAGS = -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/mb525/pwmleds/pwmleds.c b/examples/mb525/pwmleds/pwmleds.c
index 23ebbe1..ca707ac 100644
--- a/examples/mb525/pwmleds/pwmleds.c
+++ b/examples/mb525/pwmleds/pwmleds.c
@@ -245,7 +245,7 @@ void clock_setup(void)
/* Enable GPIOC, Alternate Function clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR,
- RCC_APB2ENR_IOPCEN | RCC_APB2ENR_AFIOEN);
+ RCC_APB2ENR_IOPCEN | RCC_APB2ENR_AFIOEN);
}
void gpio_setup(void)
@@ -255,8 +255,11 @@ void gpio_setup(void)
* 'output alternate function push-pull'.
*/
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,
- GPIO_CNF_OUTPUT_ALTFN_PUSHPULL,
- GPIO6 | GPIO7 | GPIO8 | GPIO9);
+ GPIO_CNF_OUTPUT_ALTFN_PUSHPULL,
+ GPIO_TIM3_FR_CH1 |
+ GPIO_TIM3_FR_CH2 |
+ GPIO_TIM3_FR_CH3 |
+ GPIO_TIM3_FR_CH4);
/* Remap TIM3:
* CH1 -> PC6
@@ -454,18 +457,18 @@ int main(void)
if (j == 100) {
j = 0;
switch (k += kd) {
- case 0:
- j0 = 255;
- break;
- case 1:
- j1 = 255;
- break;
- case 2:
- j2 = 255;
- break;
- case 3:
- j3 = 255;
- break;
+ case 0:
+ j0 = 255;
+ break;
+ case 1:
+ j1 = 255;
+ break;
+ case 2:
+ j2 = 255;
+ break;
+ case 3:
+ j3 = 255;
+ break;
}
if (k == 3)
kd =- 1;
diff --git a/examples/obldc/Makefile b/examples/obldc/Makefile
new file mode 100644
index 0000000..8014fce
--- /dev/null
+++ b/examples/obldc/Makefile
@@ -0,0 +1,56 @@
+##
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+# Be silent per default, but 'make V=1' will show all compiler calls.
+ifneq ($(V),1)
+Q := @
+# Do not print "Entering directory ...".
+MAKEFLAGS += --no-print-directory
+endif
+
+all: led systick usart can
+
+led:
+ @printf " BUILD examples/obldc/led\n"
+ $(Q)$(MAKE) -C led
+
+systick:
+ @printf " BUILD examples/obldc/systick\n"
+ $(Q)$(MAKE) -C systick
+
+usart:
+ @printf " BUILD examples/obldc/usart\n"
+ $(Q)$(MAKE) -C usart
+
+can:
+ @printf " BUILD examples/obldc/can\n"
+ $(Q)$(MAKE) -C can
+
+clean:
+ @printf " CLEAN examples/obldc/led\n"
+ $(Q)$(MAKE) -C led clean
+ @printf " CLEAN examples/obldc/systick\n"
+ $(Q)$(MAKE) -C systick clean
+ @printf " CLEAN examples/obldc/usart\n"
+ $(Q)$(MAKE) -C usart clean
+ @printf " CLEAN examples/obldc/can\n"
+ $(Q)$(MAKE) -C can clean
+
+.PHONY: led systick usart can
+
diff --git a/examples/obldc/can/Makefile b/examples/obldc/can/Makefile
new file mode 100644
index 0000000..397a445
--- /dev/null
+++ b/examples/obldc/can/Makefile
@@ -0,0 +1,22 @@
+##
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = can
+
+include ../../Makefile.include
diff --git a/examples/obldc/can/can.c b/examples/obldc/can/can.c
new file mode 100644
index 0000000..d96d1c9
--- /dev/null
+++ b/examples/obldc/can/can.c
@@ -0,0 +1,216 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ * Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopenstm32/rcc.h>
+#include <libopenstm32/flash.h>
+#include <libopenstm32/gpio.h>
+#include <libopenstm32/nvic.h>
+#include <libopenstm32/systick.h>
+#include <libopenstm32/can.h>
+
+struct can_tx_msg {
+ u32 std_id;
+ u32 ext_id;
+ u8 ide;
+ u8 rtr;
+ u8 dlc;
+ u8 data[8];
+};
+
+struct can_rx_msg {
+ u32 std_id;
+ u32 ext_id;
+ u8 ide;
+ u8 rtr;
+ u8 dlc;
+ u8 data[8];
+ u8 fmi;
+};
+
+struct can_tx_msg can_tx_msg;
+struct can_rx_msg can_rx_msg;
+
+void gpio_setup(void)
+{
+ /* Enable GPIOA clock. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
+
+ /* Enable GPIOB clock. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
+
+ gpio_set(GPIOA, GPIO6); /* LED0 off */
+ gpio_set(GPIOA, GPIO7); /* LED1 off */
+ gpio_set(GPIOB, GPIO0); /* LED2 off */
+ gpio_set(GPIOB, GPIO1); /* LED3 off */
+
+ /* Set GPIO6/7 (in GPIO port A) to 'output push-pull' for the LEDs. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
+
+ /* Set GPIO6/7 (in GPIO port B) to 'output push-pull' for the LEDs. */
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO0);
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);
+}
+
+void systick_setup(void)
+{
+ /* 72MHz / 8 => 9000000 counts per second */
+ systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
+
+ /* 9000000/9000 = 1000 overflows per second - every 1ms one interrupt */
+ systick_set_reload(9000);
+
+ systick_interrupt_enable();
+
+ /* Start counting. */
+ systick_counter_enable();
+}
+
+void can_setup(void)
+{
+ /* Enable peripheral clocks. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
+ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_CANEN);
+
+ /* Configure CAN pin: RX (input pull-up). */
+ gpio_set_mode(GPIOA, GPIO_MODE_INPUT,
+ GPIO_CNF_INPUT_PULL_UPDOWN, GPIO_CAN_RX);
+ gpio_set(GPIOA, GPIO_CAN_RX);
+
+ /* Configure CAN pin: TX. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_CAN_TX);
+
+ /* NVIC setup. */
+ nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ);
+ nvic_set_priority(NVIC_USB_LP_CAN_RX0_IRQ, 1);
+
+ /* Reset CAN. */
+ can_reset(CAN1);
+
+ /* CAN cell init. */
+ if (can_init(CAN1,
+ false, /* TTCM: Time triggered comm mode? */
+ true, /* ABOM: Automatic bus-off management? */
+ false, /* AWUM: Automatic wakeup mode? */
+ false, /* NART: No automatic retransmission? */
+ false, /* RFLM: Receive FIFO locked mode? */
+ false, /* TXFP: Transmit FIFO priority? */
+ CAN_BTR_SJW_1TQ,
+ CAN_BTR_TS1_3TQ,
+ CAN_BTR_TS2_4TQ,
+ 12)) /* BRP+1: Baud rate prescaler */
+ {
+ gpio_set(GPIOA, GPIO6); /* LED0 off */
+ gpio_set(GPIOA, GPIO7); /* LED1 off */
+ gpio_set(GPIOB, GPIO0); /* LED2 off */
+ gpio_clear(GPIOB, GPIO1); /* LED3 on */
+
+ /* Die because we failed to initialize. */
+ while (1)
+ __asm__("nop");
+ }
+
+ /* CAN filter 0 init. */
+ can_filter_id_mask_32bit_init(CAN1,
+ 0, /* Filter ID */
+ 0, /* CAN ID */
+ 0, /* CAN ID mask */
+ 0, /* FIFO assignment (here: FIFO0) */
+ true); /* Enable the filter. */
+
+ /* Enable CAN RX interrupt. */
+ can_enable_irq(CAN1, CAN_IER_FMPIE0);
+}
+
+void sys_tick_handler(void)
+{
+ static int temp32 = 0;
+ static u8 data[8] = {0, 1, 2, 0, 0, 0, 0, 0};
+
+ /* We call this handler every 1ms so 1000ms = 1s on/off. */
+ if (++temp32 != 1000)
+ return;
+
+ temp32 = 0;
+
+ /* Transmit CAN frame. */
+ data[0]++;
+ if (can_transmit(CAN1,
+ 0, /* (EX/ST)ID: CAN ID */
+ false, /* IDE: CAN ID extended? */
+ false, /* RTR: Request transmit? */
+ 8, /* DLC: Data length */
+ data) == -1)
+ {
+ gpio_set(GPIOA, GPIO6); /* LED0 off */
+ gpio_set(GPIOA, GPIO7); /* LED1 off */
+ gpio_clear(GPIOB, GPIO0); /* LED2 on */
+ gpio_set(GPIOB, GPIO1); /* LED3 off */
+ }
+}
+
+void usb_lp_can_rx0_isr(void)
+{
+ u32 id, fmi;
+ bool ext, rtr;
+ u8 length, data[8];
+
+ can_receive(CAN1, 0, false, &id, &ext, &rtr, &fmi, &length, data);
+
+ if (data[0] & 1)
+ gpio_clear(GPIOA, GPIO6);
+ else
+ gpio_set(GPIOA, GPIO6);
+
+ if (data[0] & 2)
+ gpio_clear(GPIOA, GPIO7);
+ else
+ gpio_set(GPIOA, GPIO7);
+
+ if (data[0] & 4)
+ gpio_clear(GPIOB, GPIO0);
+ else
+ gpio_set(GPIOB, GPIO0);
+
+ if (data[0] & 8)
+ gpio_clear(GPIOB, GPIO1);
+ else
+ gpio_set(GPIOB, GPIO1);
+
+ can_fifo_release(CAN1, 0);
+}
+
+int main(void)
+{
+ rcc_clock_setup_in_hse_8mhz_out_72mhz();
+ gpio_setup();
+ can_setup();
+ systick_setup();
+
+ while (1); /* Halt. */
+
+ return 0;
+}
diff --git a/examples/obldc/can/can.ld b/examples/obldc/can/can.ld
new file mode 100644
index 0000000..a1e9de5
--- /dev/null
+++ b/examples/obldc/can/can.ld
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for an STM32F103RBT6 board (128K flash, 20K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+}
+
+/* Include the common ld script from libopenstm32. */
+INCLUDE libopenstm32.ld
+
diff --git a/examples/obldc/led/Makefile b/examples/obldc/led/Makefile
new file mode 100644
index 0000000..40d30f3
--- /dev/null
+++ b/examples/obldc/led/Makefile
@@ -0,0 +1,22 @@
+##
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = led
+
+include ../../Makefile.include
diff --git a/examples/obldc/led/led.c b/examples/obldc/led/led.c
new file mode 100644
index 0000000..7784106
--- /dev/null
+++ b/examples/obldc/led/led.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopenstm32/rcc.h>
+#include <libopenstm32/gpio.h>
+
+/* Set STM32 to 72 MHz. */
+void clock_setup(void)
+{
+ rcc_clock_setup_in_hse_8mhz_out_72mhz();
+
+ /* Enable GPIOA clock. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
+
+ /* Enable GPIOB clock. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
+}
+
+void gpio_setup(void)
+{
+ /* Set GPIO6 and 7 (in GPIO port A) to 'output push-pull'. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO6 | GPIO7);
+
+ /* Set GPIO0 and 1 (in GPIO port B) to 'output push-pull'. */
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO0 | GPIO1);
+}
+
+int main(void)
+{
+ int i;
+
+ clock_setup();
+ gpio_setup();
+
+ /* Blink the LEDs on the board. */
+ while (1) {
+ gpio_toggle(GPIOA, GPIO6); /* LED on/off */
+ for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
+ gpio_toggle(GPIOA, GPIO7); /* LED on/off */
+ for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
+ gpio_toggle(GPIOB, GPIO0); /* LED on/off */
+ for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
+ gpio_toggle(GPIOB, GPIO1); /* LED on/off */
+ for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
+ }
+
+ return 0;
+}
diff --git a/examples/obldc/led/led.ld b/examples/obldc/led/led.ld
new file mode 100644
index 0000000..c8683d5
--- /dev/null
+++ b/examples/obldc/led/led.ld
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for Open-BLDC (STM32F103CBT6, 128K flash, 20K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+}
+
+/* Include the common ld script from libopenstm32. */
+INCLUDE libopenstm32.ld
+
diff --git a/examples/obldc/systick/Makefile b/examples/obldc/systick/Makefile
new file mode 100644
index 0000000..a83b7ff
--- /dev/null
+++ b/examples/obldc/systick/Makefile
@@ -0,0 +1,22 @@
+##
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = systick
+
+include ../../Makefile.include
diff --git a/examples/obldc/systick/systick.c b/examples/obldc/systick/systick.c
new file mode 100644
index 0000000..c469c1c
--- /dev/null
+++ b/examples/obldc/systick/systick.c
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ * Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopenstm32/rcc.h>
+#include <libopenstm32/flash.h>
+#include <libopenstm32/gpio.h>
+#include <libopenstm32/nvic.h>
+#include <libopenstm32/systick.h>
+
+u32 temp32;
+
+void gpio_setup(void)
+{
+ /* Enable GPIOA clock. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
+
+ /* Enable GPIOB clock. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
+
+ gpio_set(GPIOA, GPIO6); /* LED0 off */
+ gpio_set(GPIOA, GPIO7); /* LED1 off */
+ gpio_set(GPIOB, GPIO0); /* LED2 off */
+ gpio_set(GPIOB, GPIO1); /* LED3 off */
+
+ /* Set GPIO6/7 (in GPIO port A) to 'output push-pull' for the LEDs. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
+
+ /* Set GPIO6/7 (in GPIO port B) to 'output push-pull' for the LEDs. */
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO0);
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);
+}
+
+void sys_tick_handler(void)
+{
+ temp32++;
+
+ /* We call this handler every 1ms so 1000ms = 1s on/off. */
+ if (temp32 == 1000) {
+ gpio_toggle(GPIOA, GPIO6); /* LED2 on/off */
+ temp32 = 0;
+ }
+}
+
+int main(void)
+{
+ rcc_clock_setup_in_hse_8mhz_out_72mhz();
+ gpio_setup();
+
+ gpio_clear(GPIOA, GPIO7); /* LED1 on */
+ gpio_set(GPIOA, GPIO6); /* LED2 off */
+
+ temp32 = 0;
+
+ /* 72MHz / 8 => 9000000 counts per second */
+ systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
+
+ /* 9000000/9000 = 1000 overflows per second - every 1ms one interrupt */
+ systick_set_reload(9000);
+
+ systick_interrupt_enable();
+
+ /* Start counting. */
+ systick_counter_enable();
+
+ while (1); /* Halt. */
+
+ return 0;
+}
diff --git a/examples/obldc/systick/systick.ld b/examples/obldc/systick/systick.ld
new file mode 100644
index 0000000..0d79751
--- /dev/null
+++ b/examples/obldc/systick/systick.ld
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for an STM32F103CBT6 board (128K flash, 20K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+}
+
+/* Include the common ld script from libopenstm32. */
+INCLUDE libopenstm32.ld
+
diff --git a/examples/obldc/usart/Makefile b/examples/obldc/usart/Makefile
new file mode 100644
index 0000000..6484117
--- /dev/null
+++ b/examples/obldc/usart/Makefile
@@ -0,0 +1,22 @@
+##
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = usart
+
+include ../../Makefile.include
diff --git a/examples/obldc/usart/usart.c b/examples/obldc/usart/usart.c
new file mode 100644
index 0000000..8712181
--- /dev/null
+++ b/examples/obldc/usart/usart.c
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopenstm32/rcc.h>
+#include <libopenstm32/gpio.h>
+#include <libopenstm32/usart.h>
+
+void clock_setup(void)
+{
+ rcc_clock_setup_in_hse_8mhz_out_72mhz();
+
+ /* Enable GPIOA clock. For LED gpio's */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
+
+ /* Enable clocks for GPIO port B (for GPIO_USART1_TX) and USART1. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
+}
+
+void usart_setup(void)
+{
+
+ /* Setup GPIO6 (in GPIO port A) to 'output push-pull' for led use. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL,
+ GPIO6);
+
+ AFIO_MAPR |= AFIO_MAPR_USART1_REMAP;
+
+ /* Setup GPIO pin GPIO_USART3_TX/GPIO10 on GPIO port B for transmit. */
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_RE_TX);
+
+ /* Setup UART parameters. */
+ usart_set_baudrate(USART1, 230400);
+ usart_set_databits(USART1, 8);
+ usart_set_stopbits(USART1, USART_STOPBITS_1);
+ usart_set_mode(USART1, USART_MODE_TX);
+ usart_set_parity(USART1, USART_PARITY_NONE);
+ usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE);
+
+ /* Finally enable the USART. */
+ usart_enable(USART1);
+}
+
+void gpio_setup(void)
+{
+ /* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
+}
+
+int main(void)
+{
+ int i, j = 0, c = 0;
+
+ clock_setup();
+ gpio_setup();
+ usart_setup();
+
+ /* Blink the LED (PC12) on the board with every transmitted byte. */
+ while (1) {
+ gpio_toggle(GPIOA, GPIO6); /* LED on/off */
+ usart_send_blocking(USART1, c + '0'); /* Send one byte on USART3. */
+ c = (c == 9) ? 0 : c + 1; /* Increment c. */
+ if ((j++ % 80) == 0) { /* Newline after line full. */
+ usart_send_blocking(USART1, '\r');
+ usart_send_blocking(USART1, '\n');
+ }
+ for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */
+ }
+
+ return 0;
+}
diff --git a/examples/obldc/usart/usart.ld b/examples/obldc/usart/usart.ld
new file mode 100644
index 0000000..c8683d5
--- /dev/null
+++ b/examples/obldc/usart/usart.ld
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for Open-BLDC (STM32F103CBT6, 128K flash, 20K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+}
+
+/* Include the common ld script from libopenstm32. */
+INCLUDE libopenstm32.ld
+
diff --git a/examples/obldc/usart_irq/Makefile b/examples/obldc/usart_irq/Makefile
new file mode 100644
index 0000000..1c0a6c2
--- /dev/null
+++ b/examples/obldc/usart_irq/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopenstm32 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = usart_irq
+
+OOCD_BOARD = open-bldc
+
+include ../../Makefile.include
diff --git a/examples/obldc/usart_irq/usart_irq.c b/examples/obldc/usart_irq/usart_irq.c
new file mode 100644
index 0000000..5be24d2
--- /dev/null
+++ b/examples/obldc/usart_irq/usart_irq.c
@@ -0,0 +1,126 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopenstm32/rcc.h>
+#include <libopenstm32/gpio.h>
+#include <libopenstm32/usart.h>
+#include <libopenstm32/nvic.h>
+
+void clock_setup(void)
+{
+ rcc_clock_setup_in_hse_8mhz_out_72mhz();
+
+ /* Enable GPIOA clock. For LED gpio's */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
+
+ /* Enable clocks for GPIO port B (for GPIO_USART1_TX) and USART1. */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
+}
+
+void usart_setup(void)
+{
+
+ /* Enable the USART1 interrupt. */
+ nvic_enable_irq(NVIC_USART1_IRQ);
+
+ /* enable USART1 pin software remapping */
+ AFIO_MAPR |= AFIO_MAPR_USART1_REMAP;
+
+ /* Setup GPIO pin GPIO_USART1_RE_TX on GPIO port B for transmit. */
+ gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_RE_TX);
+
+ /* Setup GPIO pin GPIO_USART1_RE_RX on GPIO port B for receive. */
+ gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
+ GPIO_CNF_INPUT_FLOAT, GPIO_USART1_RE_RX);
+
+ /* Setup UART parameters. */
+ usart_set_baudrate(USART1, 230400);
+ usart_set_databits(USART1, 8);
+ usart_set_stopbits(USART1, USART_STOPBITS_1);
+ usart_set_parity(USART1, USART_PARITY_NONE);
+ usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE);
+ usart_set_mode(USART1, USART_MODE_TX_RX);
+
+ /* Enable USART1 Receive interrupt. */
+ USART_CR1(USART1) |= USART_CR1_RXNEIE;
+
+ /* Finally enable the USART. */
+ usart_enable(USART1);
+}
+
+void gpio_setup(void)
+{
+
+ gpio_set(GPIOA, GPIO6 | GPIO7);
+
+ /* Setup GPIO6 and 7 (in GPIO port A) for led use. */
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL,
+ GPIO6 | GPIO7);
+
+}
+
+void usart1_isr(void)
+{
+ static u8 data = 'A';
+
+ /* Check if we were called because of RXNE. */
+ if ((USART_SR(USART1) & USART_SR_RXNE) != 0) {
+
+ /* Indicate that we got data. */
+ gpio_toggle(GPIOA, GPIO6);
+
+ /* Retrieve the data from the peripheral. */
+ data = usart_recv(USART1);
+
+ /* Enable transmit interrupt so it sends back the data. */
+ USART_CR1(USART1) |= USART_CR1_TXEIE;
+ }
+
+ /* Check if we were called because of TXE. */
+ if ((USART_SR(USART1) & USART_SR_TXE) != 0) {
+
+ /* Indicate that we are sending out data. */
+ gpio_toggle(GPIOA, GPIO7);
+
+ /* Put data into the transmit register */
+ usart_send(USART1, data);
+
+ /* Disable the TXE interrupt as we don't need it anymore */
+ USART_CR1(USART1) &= ~USART_CR1_TXEIE;
+ }
+}
+
+int main(void)
+{
+
+ clock_setup();
+ gpio_setup();
+ usart_setup();
+
+ /* Wait forever and do nothing. */
+ while (1) {
+ __asm("nop");
+ }
+
+ return 0;
+}
diff --git a/examples/obldc/usart_irq/usart_irq.ld b/examples/obldc/usart_irq/usart_irq.ld
new file mode 100644
index 0000000..c8683d5
--- /dev/null
+++ b/examples/obldc/usart_irq/usart_irq.ld
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for Open-BLDC (STM32F103CBT6, 128K flash, 20K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+}
+
+/* Include the common ld script from libopenstm32. */
+INCLUDE libopenstm32.ld
+
diff --git a/examples/other/adc_temperature_sensor/Makefile b/examples/other/adc_temperature_sensor/Makefile
index a708bcb..2b26a1b 100644
--- a/examples/other/adc_temperature_sensor/Makefile
+++ b/examples/other/adc_temperature_sensor/Makefile
@@ -19,77 +19,4 @@
BINARY = adc
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/dma_mem2mem/Makefile b/examples/other/dma_mem2mem/Makefile
index 085aa60..b92e395 100644
--- a/examples/other/dma_mem2mem/Makefile
+++ b/examples/other/dma_mem2mem/Makefile
@@ -19,77 +19,4 @@
BINARY = dma
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/dogm128/Makefile b/examples/other/dogm128/Makefile
index 9f33720..158b33b 100644
--- a/examples/other/dogm128/Makefile
+++ b/examples/other/dogm128/Makefile
@@ -19,77 +19,6 @@
BINARY = main
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o dogm128.o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
+OBJS = dogm128.o
+include ../../Makefile.include
diff --git a/examples/other/i2c_stts75_sensor/Makefile b/examples/other/i2c_stts75_sensor/Makefile
index 6b4fa69..6ca704e 100644
--- a/examples/other/i2c_stts75_sensor/Makefile
+++ b/examples/other/i2c_stts75_sensor/Makefile
@@ -19,77 +19,6 @@
BINARY = i2c_stts75_sensor
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o stts75.o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
+OBJS = stts75.o
+include ../../Makefile.include
diff --git a/examples/other/rtc/Makefile b/examples/other/rtc/Makefile
index 3270192..10fa5af 100644
--- a/examples/other/rtc/Makefile
+++ b/examples/other/rtc/Makefile
@@ -19,77 +19,4 @@
BINARY = rtc
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/systick/Makefile b/examples/other/systick/Makefile
index 488f3d6..20c889f 100644
--- a/examples/other/systick/Makefile
+++ b/examples/other/systick/Makefile
@@ -19,77 +19,4 @@
BINARY = systick
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/timer_interrupt/Makefile b/examples/other/timer_interrupt/Makefile
index b01d859..c4cd3b6 100644
--- a/examples/other/timer_interrupt/Makefile
+++ b/examples/other/timer_interrupt/Makefile
@@ -19,77 +19,4 @@
BINARY = timer
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/usb_cdcacm/Makefile b/examples/other/usb_cdcacm/Makefile
index 9b19ee0..1ca37fc 100644
--- a/examples/other/usb_cdcacm/Makefile
+++ b/examples/other/usb_cdcacm/Makefile
@@ -19,77 +19,4 @@
BINARY = cdcacm
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-gcc
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/usb_dfu/Makefile b/examples/other/usb_dfu/Makefile
index 775a991..9b107aa 100644
--- a/examples/other/usb_dfu/Makefile
+++ b/examples/other/usb_dfu/Makefile
@@ -19,77 +19,4 @@
BINARY = usbdfu
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-gcc
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g3 -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles -Wl,--defsym,_stack=0x20001000
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/usb_hid/Makefile b/examples/other/usb_hid/Makefile
index 380d513..378a374 100644
--- a/examples/other/usb_hid/Makefile
+++ b/examples/other/usb_hid/Makefile
@@ -19,77 +19,4 @@
BINARY = usbhid
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-gcc
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g3 -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb -I../usb_dfu
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles -Wl,--defsym,_stack=0x20001000 -Wl,-Ttext,0x8002000
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/other/usb_hid/README b/examples/other/usb_hid/README
index 3ba2aa6..792e0bd 100644
--- a/examples/other/usb_hid/README
+++ b/examples/other/usb_hid/README
@@ -2,7 +2,7 @@
README
------------------------------------------------------------------------------
-This example implements a USB Human Interface Device (HID)
+This example implements a USB Human Interface Device (HID)
to demonstrate the use of the USB device stack.
Building
@@ -39,5 +39,5 @@ Or you can do the same manually via:
> reset
Replace the "jtagkey-tiny.cfg" with whatever JTAG device you are using, and/or
-replace "stm.cfg" with your respective config file.
+replace "stm32.cfg" with your respective config file.
diff --git a/examples/stm32-h103/fancyblink/Makefile b/examples/stm32-h103/fancyblink/Makefile
index 06d821e..a712cc4 100644
--- a/examples/stm32-h103/fancyblink/Makefile
+++ b/examples/stm32-h103/fancyblink/Makefile
@@ -19,77 +19,4 @@
BINARY = fancyblink
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/stm32-h103/miniblink/Makefile b/examples/stm32-h103/miniblink/Makefile
index fa729ae..37c70fd 100644
--- a/examples/stm32-h103/miniblink/Makefile
+++ b/examples/stm32-h103/miniblink/Makefile
@@ -19,77 +19,4 @@
BINARY = miniblink
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/stm32-h103/spi/Makefile b/examples/stm32-h103/spi/Makefile
index 080ebfc..1e22919 100644
--- a/examples/stm32-h103/spi/Makefile
+++ b/examples/stm32-h103/spi/Makefile
@@ -19,77 +19,4 @@
BINARY = spi
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/stm32-h103/usart/Makefile b/examples/stm32-h103/usart/Makefile
index 193be89..6484117 100644
--- a/examples/stm32-h103/usart/Makefile
+++ b/examples/stm32-h103/usart/Makefile
@@ -19,77 +19,4 @@
BINARY = usart
-# PREFIX ?= arm-none-eabi
-PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-ld
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-OPENOCD_BASE = /usr
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/parport.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include
diff --git a/examples/stm32-h103/usart/usart.c b/examples/stm32-h103/usart/usart.c
index d8ffe3d..4470348 100644
--- a/examples/stm32-h103/usart/usart.c
+++ b/examples/stm32-h103/usart/usart.c
@@ -69,11 +69,11 @@ int main(void)
/* Blink the LED (PC12) on the board with every transmitted byte. */
while (1) {
gpio_toggle(GPIOC, GPIO12); /* LED on/off */
- usart_send(USART3, c + '0'); /* Send one byte on USART3. */
+ usart_send_blocking(USART3, c + '0'); /* Send one byte on USART3. */
c = (c == 9) ? 0 : c + 1; /* Increment c. */
if ((j++ % 80) == 0) { /* Newline after line full. */
- usart_send(USART3, '\r');
- usart_send(USART3, '\n');
+ usart_send_blocking(USART3, '\r');
+ usart_send_blocking(USART3, '\n');
}
for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */
}
diff --git a/examples/stm32-h103/usb_cdcacm/Makefile b/examples/stm32-h103/usb_cdcacm/Makefile
index 531bb96..1ca37fc 100644
--- a/examples/stm32-h103/usb_cdcacm/Makefile
+++ b/examples/stm32-h103/usb_cdcacm/Makefile
@@ -19,80 +19,4 @@
BINARY = cdcacm
-PREFIX=/opt/paparazzi/stm32/bin/arm-none-eabi
-# PREFIX ?= arm-none-eabi
-#PREFIX ?= arm-elf
-CC = $(PREFIX)-gcc
-LD = $(PREFIX)-gcc
-OBJCOPY = $(PREFIX)-objcopy
-OBJDUMP = $(PREFIX)-objdump
-# Uncomment this line if you want to use the installed (not local) library.
-#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
-TOOLCHAIN_DIR = ../../..
-CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
- -mcpu=cortex-m3 -mthumb
-LDSCRIPT = $(BINARY).ld
-LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
-OBJS = $(BINARY).o
-
-#OPENOCD_BASE = /usr
-OPENOCD_BASE = /opt/paparazzi/stm32
-OPENOCD = $(OPENOCD_BASE)/bin/openocd
-OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
-#OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/openocd-usb.cfg
-OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey-tiny.cfg
-OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/board/olimex_stm32_h103.cfg
-
-# Be silent per default, but 'make V=1' will show all compiler calls.
-ifneq ($(V),1)
-Q := @
-NULL := 2>/dev/null
-endif
-
-all: images
-
-images: $(BINARY)
- @printf " OBJCOPY $(BINARY).bin\n"
- $(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
- @printf " OBJCOPY $(BINARY).hex\n"
- $(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
- @printf " OBJCOPY $(BINARY).srec\n"
- $(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
- @printf " OBJDUMP $(BINARY).list\n"
- $(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
-
-$(BINARY): $(OBJS) $(LDSCRIPT)
- @printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
-
-%.o: %.c Makefile
- @printf " CC $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- @printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
- $(Q)rm -f *.o
- @printf " CLEAN $(BINARY)\n"
- $(Q)rm -f $(BINARY)
- @printf " CLEAN $(BINARY).bin\n"
- $(Q)rm -f $(BINARY).bin
- @printf " CLEAN $(BINARY).hex\n"
- $(Q)rm -f $(BINARY).hex
- @printf " CLEAN $(BINARY).srec\n"
- $(Q)rm -f $(BINARY).srec
- @printf " CLEAN $(BINARY).list\n"
- $(Q)rm -f $(BINARY).list
-
-flash: images
- @printf " FLASH $(BINARY).bin\n"
- @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
- $(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
- -f $(OPENOCD_FLASHER) \
- -f $(OPENOCD_BOARD) \
- -c "init" -c "reset halt" \
- -c "flash write_image erase $(BINARY).hex" \
- -c "reset" \
- -c "shutdown" $(NULL)
-
-.PHONY: images clean
-
+include ../../Makefile.include