2 # Copyright 2015, Olivier MATZ <zer0@droids-corp.org>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 # * Neither the name of the University of California, Berkeley nor the
13 # names of its contributors may be used to endorse or promote products
14 # derived from this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 # DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 UCGINE ?= $(abspath ../..)
28 include $(UCGINE)/mk/ucgine-pre.mk
31 PROG = $(O)/test-callout
33 UCGINE_SUBARCH ?= stm32f4
34 CFLAGS += -DUCGINE_ARCH_$(UCGINE_ARCH)
35 CFLAGS += -DUCGINE_SUBARCH_$(UCGINE_SUBARCH)
36 CFLAGS += $(ARCH_CFLAGS)
37 CFLAGS += -g -Werror -I.
39 LDFLAGS += $(ARCH_LDFLAGS)
41 ifeq ($(UCGINE_ARCH),avr)
44 AVRDUDE_PORT = /dev/ttyUSB0
45 AVRDUDE_PROG = arduino
47 CFLAGS += -DF_CPU=$(F_CPU)
48 CFLAGS += -I$(UCGINE)/arch/avr/uart/include
49 CFLAGS += -mmcu=$(MCU)
50 LDFLAGS += -mmcu=$(MCU)
53 ifeq ($(UCGINE_ARCH),stm32)
54 ifeq ($(UCGINE_SUBARCH),stm32f3)
56 STLINK ?= /home/zer0/projects/stm32/stlink
57 STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F3-Discovery_FW_V1.1.0
58 CFLAGS += -Tstm32_flash.ld
59 CFLAGS += -I$(STM_COMMON)/src
60 CFLAGS += -I$(STM_COMMON)/Libraries
61 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include
62 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Device/ST/STM32F30x/Include
63 CFLAGS += -I$(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/inc
64 CFLAGS += -I$(UCGINE)/lib/gloss/include
65 CFLAGS += -I$(UCGINE)/arch/stm32/include
66 CFLAGS += -I$(UCGINE)/arch/stm32/uart/include
67 LDFLAGS += -Tstm32_flash.ld
68 # stm32 standard periph lib
69 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_exti.c
70 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_gpio.c
71 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_rcc.c
72 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_misc.c
74 exe-y-$(PROG) += $(STM_COMMON)/src/stm32f3_discovery.c
75 # system & startup file
76 exe-y-$(PROG) += $(STM_COMMON)/src/system_stm32f30x.c
77 exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/TrueSTUDIO/startup_stm32f30x.s
78 # reentrant interrupts
79 exe-y-$(PROG) += $(UCGINE)/arch/stm32/ucg_reent_intr.c
82 STLINK ?= /home/zer0/projects/stm32/stlink
83 STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F4-Discovery_FW_V1.1.0
84 CFLAGS += -Tstm32_flash.ld
85 CFLAGS += -I$(STM_COMMON)/Utilities/STM32F4-Discovery
86 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include
87 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Include
88 CFLAGS += -I$(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/inc
89 CFLAGS += -I$(UCGINE)/lib/gloss/include
90 CFLAGS += -I$(UCGINE)/arch/stm32/include
91 CFLAGS += -I$(UCGINE)/arch/stm32/uart/include
92 LDFLAGS += -Tstm32_flash.ld
93 exe-y-$(PROG) += system_stm32f4xx.c
94 # stm32 standard periph lib
95 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
96 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
97 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
98 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c
100 exe-y-$(PROG) += $(STM_COMMON)/Utilities/STM32F4-Discovery/stm32f4_discovery.c
102 exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s
103 # reentrant interrupts
104 exe-y-$(PROG) += $(UCGINE)/arch/stm32/ucg_reent_intr.c
108 ifeq ($(UCGINE_ARCH),posix)
109 $(error Not supported on posix)
113 CFLAGS += -I$(UCGINE)/lib/callout/include
114 exe-y-$(PROG) += $(UCGINE)/lib/callout/ucg_callout.c
116 exe-y-$(PROG) += main.c
118 objcopy-hex-y-$(PROG).hex := $(PROG)
119 objcopy-bin-y-$(PROG).bin := $(PROG)
121 include $(UCGINE)/mk/ucgine-post.mk
132 ifeq ($(CROSS),arm-none-eabi-)
133 $(STLINK)/st-flash write $(PROG).bin 0x8000000
136 avrdude -e -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROG) \
137 -b $(AVRDUDE_BAUD) -U flash:w:$(PROG):e