# # Copyright 2015, Olivier MATZ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the University of California, Berkeley nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. UCGINE ?= $(abspath ../..) include $(UCGINE)/mk/ucgine-pre.mk O ?= $(CURDIR)/build PROG = $(O)/test-callout UCGINE_SUBARCH ?= stm32f4 CFLAGS += -DUCGINE_ARCH_$(UCGINE_ARCH) CFLAGS += -DUCGINE_SUBARCH_$(UCGINE_SUBARCH) CFLAGS += $(ARCH_CFLAGS) CFLAGS += -g -Werror -I. LDFLAGS += $(ARCH_LDFLAGS) ifeq ($(UCGINE_ARCH),avr) MCU = atmega328p F_CPU = 8000000UL AVRDUDE_PORT = /dev/ttyUSB0 AVRDUDE_PROG = arduino AVRDUDE_BAUD = 57600 CFLAGS += -DF_CPU=$(F_CPU) CFLAGS += -I$(UCGINE)/arch/avr/uart/include CFLAGS += -mmcu=$(MCU) LDFLAGS += -mmcu=$(MCU) endif ifeq ($(UCGINE_ARCH),stm32) ifeq ($(UCGINE_SUBARCH),stm32f3) ver = 3 STLINK ?= /home/zer0/projects/stm32/stlink STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F3-Discovery_FW_V1.1.0 CFLAGS += -Tstm32_flash.ld CFLAGS += -I$(STM_COMMON)/src CFLAGS += -I$(STM_COMMON)/Libraries CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Device/ST/STM32F30x/Include CFLAGS += -I$(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/inc CFLAGS += -I$(UCGINE)/lib/gloss/include CFLAGS += -I$(UCGINE)/arch/stm32/include CFLAGS += -I$(UCGINE)/arch/stm32/uart/include LDFLAGS += -Tstm32_flash.ld # stm32 standard periph lib exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_exti.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_gpio.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_rcc.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_misc.c # leds exe-y-$(PROG) += $(STM_COMMON)/src/stm32f3_discovery.c # system & startup file exe-y-$(PROG) += $(STM_COMMON)/src/system_stm32f30x.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/TrueSTUDIO/startup_stm32f30x.s # reentrant interrupts exe-y-$(PROG) += $(UCGINE)/arch/stm32/ucg_reent_intr.c else ver = 4 STLINK ?= /home/zer0/projects/stm32/stlink STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F4-Discovery_FW_V1.1.0 CFLAGS += -Tstm32_flash.ld CFLAGS += -I$(STM_COMMON)/Utilities/STM32F4-Discovery CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Include CFLAGS += -I$(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/inc CFLAGS += -I$(UCGINE)/lib/gloss/include CFLAGS += -I$(UCGINE)/arch/stm32/include CFLAGS += -I$(UCGINE)/arch/stm32/uart/include LDFLAGS += -Tstm32_flash.ld exe-y-$(PROG) += system_stm32f4xx.c # stm32 standard periph lib exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c # leds exe-y-$(PROG) += $(STM_COMMON)/Utilities/STM32F4-Discovery/stm32f4_discovery.c # startup file exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s # reentrant interrupts exe-y-$(PROG) += $(UCGINE)/arch/stm32/ucg_reent_intr.c endif endif ifeq ($(UCGINE_ARCH),posix) $(error Not supported on posix) endif # callout CFLAGS += -I$(UCGINE)/lib/callout/include exe-y-$(PROG) += $(UCGINE)/lib/callout/ucg_callout.c exe-y-$(PROG) += main.c objcopy-hex-y-$(PROG).hex := $(PROG) objcopy-bin-y-$(PROG).bin := $(PROG) include $(UCGINE)/mk/ucgine-post.mk .PHONY: all all: $(all-targets) .PHONY: clean clean: _ucgine_clean # Flash the STM32 .PHONY: burn burn: all ifeq ($(CROSS),arm-none-eabi-) $(STLINK)/st-flash write $(PROG).bin 0x8000000 endif ifeq ($(CROSS),avr-) avrdude -e -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROG) \ -b $(AVRDUDE_BAUD) -U flash:w:$(PROG):e endif