-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
autopilot.makefile
280 lines (227 loc) · 6.99 KB
/
autopilot.makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2008 Antoine Drouin
#
# This file is part of paparazzi.
#tin
# paparazzi 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 2, or (at your option)
# any later version.
#
# paparazzi 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 paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#
######################################################################
##
## COMMON FIXEDWING ALL TARGETS (SIM + AP + FBW ...)
##
#
# Board config + Include paths
#
$(TARGET).CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
$(TARGET).CFLAGS += -DPERIPHERALS_AUTO_INIT
$(TARGET).CFLAGS += $(FIXEDWING_INC)
# would be better to auto-generate this
$(TARGET).CFLAGS += -DFIRMWARE=FIXEDWING
$(TARGET).srcs += mcu.c
$(TARGET).srcs += $(SRC_ARCH)/mcu_arch.c
#
# Common Options
#
ifeq ($(OPTIONS), minimal)
else
$(TARGET).CFLAGS += -DWIND_INFO
endif
$(TARGET).CFLAGS += -DTRAFFIC_INFO
#
# LEDs
#
ifneq ($(ARCH), jsbsim)
$(TARGET).CFLAGS += -DUSE_LED
endif
ifneq ($(ARCH), lpc21)
ifneq ($(ARCH), jsbsim)
$(TARGET).srcs += $(SRC_ARCH)/led_hw.c
endif
endif
#
# Sys-time
#
PERIODIC_FREQUENCY ?= 60
$(TARGET).CFLAGS += -DPERIODIC_FREQUENCY=$(PERIODIC_FREQUENCY)
$(TARGET).srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c
$(TARGET).CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_RESOLUTION='(1./$(PERIODIC_FREQUENCY).)'
#
# InterMCU & Commands
#
$(TARGET).CFLAGS += -DINTER_MCU
$(TARGET).srcs += $(SRC_FIXEDWING)/inter_mcu.c
#
# Math functions
#
$(TARGET).srcs += math/pprz_geodetic_int.c math/pprz_geodetic_float.c math/pprz_geodetic_double.c math/pprz_trig_int.c math/pprz_orientation_conversion.c
#
# I2C
#
$(TARGET).srcs += mcu_periph/i2c.c
$(TARGET).srcs += $(SRC_ARCH)/mcu_periph/i2c_arch.c
######################################################################
##
## COMMON FOR ALL NON-SIMULATION TARGETS
##
#
# Interrupt Vectors
#
ifeq ($(ARCH), lpc21)
ns_srcs += $(SRC_ARCH)/armVIC.c
endif
ifeq ($(ARCH), stm32)
ns_srcs += lisa/plug_sys.c
endif
#
# Main
#
ns_srcs += $(SRC_FIRMWARE)/main.c
#
# LEDs
#
ns_CFLAGS += -DUSE_LED
ifneq ($(SYS_TIME_LED),none)
ns_CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
endif
#
# UARTS
#
ns_srcs += mcu_periph/uart.c
ns_srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
#
# ANALOG
#
ns_CFLAGS += -DUSE_ADC
#ifeq ($(ARCH), lpc21)
ns_srcs += $(SRC_ARCH)/mcu_periph/adc_arch.c
ifeq ($(ARCH), stm32)
ns_CFLAGS += -DUSE_AD1 -DUSE_AD1_1 -DUSE_AD1_2 -DUSE_AD1_3 -DUSE_AD1_4
endif
######################################################################
##
## FLY BY WIRE THREAD SPECIFIC
##
fbw_CFLAGS += -DFBW
fbw_srcs += $(SRC_FIRMWARE)/main_fbw.c
fbw_srcs += subsystems/electrical.c
fbw_srcs += subsystems/commands.c
fbw_srcs += subsystems/actuators.c
fbw_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
######################################################################
##
## AUTOPILOT THREAD SPECIFIC
##
ap_CFLAGS += -DAP
ap_srcs += $(SRC_FIRMWARE)/main_ap.c
ap_srcs += $(SRC_FIRMWARE)/autopilot.c
ap_srcs += $(SRC_FIRMWARE)/ap_downlink.c
ap_srcs += state.c
ap_srcs += subsystems/settings.c
ap_srcs += $(SRC_ARCH)/subsystems/settings_arch.c
# BARO
ifeq ($(BOARD), umarim)
ifeq ($(BOARD_VERSION), 1.0)
ap_srcs += boards/umarim/baro_board.c
ap_CFLAGS += -DUSE_I2C1 -DUSE_ADS1114_1
ap_CFLAGS += -DADS1114_I2C_DEV=i2c1
ap_srcs += peripherals/ads1114.c
endif
else ifeq ($(BOARD), lisa_l)
ap_CFLAGS += -DUSE_I2C2
endif
# ahrs frequencies if configured
ifdef AHRS_PROPAGATE_FREQUENCY
ap_CFLAGS += -DAHRS_PROPAGATE_FREQUENCY=$(AHRS_PROPAGATE_FREQUENCY)
endif
ifdef AHRS_CORRECT_FREQUENCY
ap_CFLAGS += -DAHRS_CORRECT_FREQUENCY=$(AHRS_CORRECT_FREQUENCY)
endif
######################################################################
##
## SIMULATOR THREAD SPECIFIC
##
UNAME = $(shell uname -s)
ifeq ("$(UNAME)","Darwin")
sim.CFLAGS += $(shell if test -d /opt/paparazzi/include; then echo "-I/opt/paparazzi/include"; elif test -d /opt/local/include; then echo "-I/opt/local/include"; fi)
endif
sim.CFLAGS += $(CPPFLAGS)
sim.CFLAGS += $(fbw_CFLAGS) $(ap_CFLAGS)
sim.srcs += $(fbw_srcs) $(ap_srcs)
sim.CFLAGS += -DSITL
sim.srcs += $(SRC_ARCH)/sim_ap.c
sim.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport
sim.srcs += subsystems/datalink/downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/sim_gps.c $(SRC_ARCH)/ivy_transport.c $(SRC_ARCH)/sim_adc_generic.c
sim.srcs += subsystems/settings.c
sim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c
# hack: always compile some of the sim functions, so ocaml sim does not complain about no-existing functions
sim.srcs += $(SRC_ARCH)/sim_ahrs.c $(SRC_ARCH)/sim_ir.c
######################################################################
##
## JSBSIM THREAD SPECIFIC
##
JSBSIM_ROOT ?= /opt/jsbsim
JSBSIM_INC = $(JSBSIM_ROOT)/include/JSBSim
JSBSIM_LIB = $(JSBSIM_ROOT)/lib
# use the paparazzi-jsbsim package if it is installed,
# otherwise look for JSBsim under /opt/jsbsim
JSBSIM_PKG ?= $(shell pkg-config JSBSim --exists && echo 'yes')
ifeq ($(JSBSIM_PKG), yes)
jsbsim.CFLAGS += $(shell pkg-config JSBSim --cflags)
jsbsim.LDFLAGS += $(shell pkg-config JSBSim --libs)
else
JSBSIM_PKG = no
jsbsim.CFLAGS += -I$(JSBSIM_INC)
jsbsim.LDFLAGS += -L$(JSBSIM_LIB) -lJSBSim
endif
jsbsim.CFLAGS += $(fbw_CFLAGS) $(ap_CFLAGS)
jsbsim.srcs += $(fbw_srcs) $(ap_srcs)
jsbsim.CFLAGS += -DSITL
jsbsim.srcs += $(SIMDIR)/sim_ac_jsbsim.c $(SIMDIR)/sim_ac_fw.c $(SIMDIR)/sim_ac_flightgear.c
# external libraries
jsbsim.CFLAGS += -I/usr/include $(shell pkg-config glib-2.0 --cflags)
jsbsim.LDFLAGS += $(shell pkg-config glib-2.0 --libs) -lglibivy -lm
jsbsim.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport
jsbsim.srcs += subsystems/datalink/downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/jsbsim_hw.c $(SRC_ARCH)/jsbsim_ir.c $(SRC_ARCH)/jsbsim_gps.c $(SRC_ARCH)/jsbsim_ahrs.c $(SRC_ARCH)/ivy_transport.c $(SRC_ARCH)/jsbsim_transport.c
jsbsim.srcs += subsystems/settings.c
jsbsim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c
######################################################################
##
## Final Target Allocations
##
#
# SINGLE MCU / DUAL MCU
#
ifeq ($(BOARD),classix)
include $(CFG_FIXEDWING)/intermcu_spi.makefile
else
# Single MCU's run both
ifeq ($(SEPARATE_FBW),)
ap.CFLAGS += $(fbw_CFLAGS)
ap.srcs += $(fbw_srcs)
else
# avoid fbw_telemetry_mode error
ap_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
endif
endif
#
# No-Sim parameters
#
fbw.CFLAGS += $(fbw_CFLAGS) $(ns_CFLAGS)
fbw.srcs += $(fbw_srcs) $(ns_srcs)
ap.CFLAGS += $(ap_CFLAGS) $(ns_CFLAGS)
ap.srcs += $(ap_srcs) $(ns_srcs)