2012-06-15 20:10:19 +00:00
|
|
|
# put your *.o targets here, make should handle the rest!
|
|
|
|
SRCS = main.c system_stm32f0xx.c
|
|
|
|
|
|
|
|
# all the files will be generated with this name (main.elf, main.bin, main.hex, etc)
|
|
|
|
PROJ_NAME=main
|
|
|
|
|
2012-06-16 22:19:45 +00:00
|
|
|
# Location of the Libraries folder from the STM32F0xx Standard Peripheral Library
|
|
|
|
STD_PERIPH_LIB=Libraries
|
|
|
|
|
2012-06-16 18:47:01 +00:00
|
|
|
# location of OpenOCD Board .cfg files (only used with 'make program')
|
|
|
|
OPENOCD_BOARD_DIR=/usr/share/openocd/scripts/board
|
|
|
|
|
2012-06-16 22:28:00 +00:00
|
|
|
# Configuration (cfg) file containing programming directives for OpenOCD
|
|
|
|
OPENOCD_PROC_FILE=extra/stm32f0-openocd.cfg
|
|
|
|
|
2012-06-15 20:10:19 +00:00
|
|
|
# that's it, no need to change anything below this line!
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
|
|
|
|
CC=arm-none-eabi-gcc
|
|
|
|
OBJCOPY=arm-none-eabi-objcopy
|
|
|
|
|
2012-06-16 18:47:01 +00:00
|
|
|
CFLAGS = -g -O2 -Wall -TDevice/stm32_flash.ld
|
2012-06-15 20:10:19 +00:00
|
|
|
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m0 -march=armv6s-m
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
|
|
|
|
vpath %.c src
|
2012-06-16 22:19:45 +00:00
|
|
|
vpath %.a $(STD_PERIPH_LIB)
|
2012-06-15 20:10:19 +00:00
|
|
|
|
|
|
|
ROOT=$(shell pwd)
|
|
|
|
|
2012-06-16 22:19:45 +00:00
|
|
|
CFLAGS += -Iinc -I$(STD_PERIPH_LIB) -I$(STD_PERIPH_LIB)/CMSIS/Device/ST/STM32F0xx/Include
|
|
|
|
CFLAGS += -I$(STD_PERIPH_LIB)/CMSIS/Include -I$(STD_PERIPH_LIB)/STM32F0xx_StdPeriph_Driver/inc
|
2012-06-15 20:10:19 +00:00
|
|
|
|
2012-06-16 18:47:01 +00:00
|
|
|
SRCS += Device/startup_stm32f0xx.s # add startup file to build
|
2012-06-15 20:10:19 +00:00
|
|
|
|
|
|
|
OBJS = $(SRCS:.c=.o)
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
|
|
|
|
.PHONY: lib proj
|
|
|
|
|
|
|
|
all: lib proj
|
|
|
|
|
|
|
|
lib:
|
2012-06-16 22:19:45 +00:00
|
|
|
$(MAKE) -C $(STD_PERIPH_LIB)
|
2012-06-15 20:10:19 +00:00
|
|
|
|
|
|
|
proj: $(PROJ_NAME).elf
|
|
|
|
|
|
|
|
$(PROJ_NAME).elf: $(SRCS)
|
2012-06-16 22:19:45 +00:00
|
|
|
$(CC) $(CFLAGS) $^ -o $@ -L$(STD_PERIPH_LIB) -lstm32f0
|
2012-06-15 20:10:19 +00:00
|
|
|
$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
|
|
|
|
$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
|
2012-06-16 18:47:01 +00:00
|
|
|
|
|
|
|
program: $(PROJ_NAME).bin
|
2012-06-16 22:28:00 +00:00
|
|
|
openocd -f $(OPENOCD_BOARD_DIR)/stm32f0discovery.cfg -f $(OPENOCD_PROC_FILE) -c "stm_flash `pwd`/$(PROJ_NAME).bin" -c shutdown
|
2012-06-15 20:10:19 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f *.o
|
|
|
|
rm -f $(PROJ_NAME).elf
|
|
|
|
rm -f $(PROJ_NAME).hex
|
|
|
|
rm -f $(PROJ_NAME).bin
|