diff --git a/Makefile b/Makefile index eeca7ececf..c9d41d87e6 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,14 @@ # the Free Software Foundation, 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. +# The default is to produce a quiet echo of compilation commands +# Launch with "make Q=''" to get full echo +Q=@ + +ifeq ($(Q),@) +MAKEFLAGS += --no-print-directory +endif + PAPARAZZI_SRC=$(shell pwd) include conf/Makefile.local @@ -35,6 +43,7 @@ SIMULATOR=sw/simulator SUPERVISION=sw/supervision/paparazzi.pl MAKE=make + all: static static : lib tools configurator cockpit tmtc logalizer sim_static wind static_h multimon @@ -131,7 +140,8 @@ static_h : PAPARAZZI_HOME=`pwd` PAPARAZZI_SRC=`pwd` make -f Makefile.gen ac_h : tools static_h - PAPARAZZI_HOME=`pwd` PAPARAZZI_SRC=`pwd` $(TOOLS)/gen_aircraft.out $(AIRCRAFT) + @echo BUILD $(AIRCRAFT) + $(Q)PAPARAZZI_HOME=`pwd` PAPARAZZI_SRC=`pwd` Q=$(Q) $(TOOLS)/gen_aircraft.out $(AIRCRAFT) hard_ac: ac_h fbw ap ac: hard_ac @@ -163,6 +173,11 @@ clean: dist_clean : clean +help: + @echo "'make' to compile the libraries and tools" + @echo "'make AIRCRAFT=NAME ac' to compile the NAMEd aircraft" + @echo "'make AIRCRAFT=NAME sim' to compile the simulated NAMEd aircraft" + @echo "'make Q='' ...' to get full echo of commands" test_all_example_airframes: diff --git a/Makefile.ac b/Makefile.ac index 994160de11..0214b13311 100644 --- a/Makefile.ac +++ b/Makefile.ac @@ -37,46 +37,57 @@ FLIGHT_PLAN_XML=$(ACINCLUDE)/flight_plan.xml INFLIGHT_CALIB_H=$(ACINCLUDE)/inflight_calib.h MAKEFILE_AC=$(ACINCLUDE)/Makefile.ac +# "make Q=''" to get full echo +Q=@ + all: $(AIRFRAME_H) $(RADIO_H) $(CONTROL_H) $(CONTROL_C) $(FLIGHT_PLAN_H) $(FLIGHT_PLAN_XML) $(INFLIGHT_CALIB_H) $(MAKEFILE_AC) $(PERIODIC_H) - $(AIRFRAME_H) : $(CONF)/$(AIRFRAME) $(CONF_XML) - $(TOOLS)/gen_airframe.out $(AC_ID) $(AIRCRAFT) $< > /tmp/airframe.h - mv /tmp/airframe.h $@ + @echo BUILD $@ + $(Q)$(TOOLS)/gen_airframe.out $(AC_ID) $(AIRCRAFT) $< > /tmp/airframe.h + $(Q)mv /tmp/airframe.h $@ $(RADIO_H) : $(CONF)/$(RADIO) $(CONF_XML) - $(TOOLS)/gen_radio.out $< > /tmp/radio.h - mv /tmp/radio.h $@ + @echo BUILD $@ + $(Q)$(TOOLS)/gen_radio.out $< > /tmp/radio.h + $(Q)mv /tmp/radio.h $@ $(PERIODIC_H) : $(MESSAGES_XML) $(CONF_XML) $(CONF)/$(TELEMETRY) - TMP_FILE=`mktemp`;\ + @echo BUILD $@ + $(Q)TMP_FILE=`mktemp`;\ $(TOOLS)/gen_periodic.out $(MESSAGES_XML) $(CONF)/$(TELEMETRY) > $$TMP_FILE;\ mv $$TMP_FILE $@ - chmod a+r $@ + $(Q)chmod a+r $@ $(CONTROL_H) : $(CONF)/$(AIRFRAME) $(CONF_XML) - $(TOOLS)/gen_control.out h $< > /tmp/control.h - mv /tmp/control.h $@ + @echo BUILD $@ + $(Q)$(TOOLS)/gen_control.out h $< > /tmp/control.h + $(Q)mv /tmp/control.h $@ $(CONTROL_C) : $(CONF)/$(AIRFRAME) $(CONF_XML) - mkdir -p $(ACINCLUDE)/ap - $(TOOLS)/gen_control.out c $< > /tmp/control.c - mv /tmp/control.c $@ + @echo BUILD $@ + $(Q)mkdir -p $(ACINCLUDE)/ap + $(Q)$(TOOLS)/gen_control.out c $< > /tmp/control.c + $(Q)mv /tmp/control.c $@ $(FLIGHT_PLAN_H) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) - $(TOOLS)/gen_flight_plan.out $< > /tmp/fp.h - mv /tmp/fp.h $@ + @echo BUILD $@ + $(Q)$(TOOLS)/gen_flight_plan.out $< > /tmp/fp.h + $(Q)mv /tmp/fp.h $@ $(FLIGHT_PLAN_XML) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) - $(TOOLS)/gen_flight_plan.out -dump $< > /tmp/fp.xml - mv /tmp/fp.xml $@ + @echo BUILD $@ + $(Q)$(TOOLS)/gen_flight_plan.out -dump $< > /tmp/fp.xml + $(Q)mv /tmp/fp.xml $@ $(INFLIGHT_CALIB_H) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) - $(TOOLS)/gen_calib.out $< > /tmp/c.h - mv /tmp/c.h $@ + @echo BUILD $@ + $(Q)$(TOOLS)/gen_calib.out $< > /tmp/c.h + $(Q)mv /tmp/c.h $@ $(MAKEFILE_AC) : $(CONF)/$(AIRFRAME) - $(TOOLS)/extract_makefile.out $< > $@ + @echo BUILD $@ + $(Q)$(TOOLS)/extract_makefile.out $< > $@ clean : rm -f $(ACINCLUDE)/*.h diff --git a/Makefile.gen b/Makefile.gen index 5286d77d69..921cb7d494 100644 --- a/Makefile.gen +++ b/Makefile.gen @@ -27,7 +27,6 @@ include conf/Makefile.local CONF=conf XML_GET=sw/lib/ocaml/xml_get.out - STATICINCLUDE =$(PAPARAZZI_HOME)/var/include MESSAGES_H=$(STATICINCLUDE)/messages.h MESSAGES_FBW_H=$(STATICINCLUDE)/messages_fbw.h @@ -38,7 +37,7 @@ UBX_XML = $(CONF)/ubx.xml static: $(MESSAGES_H) $(UBX_PROTOCOL_H) $(DL_PROTOCOL_H) -$(MESSAGES_H) : $(MESSAGES_XML) $(CONF_XML) +$(MESSAGES_H) : $(MESSAGES_XML) $(CONF_XML) $(TOOLS)/gen_messages.out test -d $(STATICINCLUDE) || mkdir -p $(STATICINCLUDE) TMP_FILE=`mktemp`;\ $(TOOLS)/gen_messages.out $< telemetry > $$TMP_FILE;\ diff --git a/conf/Makefile.avr b/conf/Makefile.avr index 15cab4d996..c8b7ba8e0c 100644 --- a/conf/Makefile.avr +++ b/conf/Makefile.avr @@ -48,6 +48,9 @@ UISP = uisp UISP_FLAGS = $(ISP_FLAGS) #UISP_FLAGS = $(SERIAL_FLAGS) +# Launch with "make Q=''" to get full command display +Q=@ + # # End of configuration part. @@ -105,12 +108,14 @@ check_fuses: check_arch $(OBJDIR)/%.elf: $($(TARGET).objs) - $(LD) \ + @echo LD $@ + $(Q)$(LD) \ $(LOCAL_LDFLAGS) \ $^ \ -o $@ \ $(LDFLAGS) - $(SIZE) $@ + @echo SIZE + $(Q)$(SIZE) $@ %.s: %.c @@ -120,10 +125,12 @@ $(OBJDIR)/%.s: %.c $(CC) $(CFLAGS) -S -o $@ $< $(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + @echo CC $@ + $(Q)$(CC) $(CFLAGS) -c -o $@ $< $(OBJDIR)/%.o: $(SRC_ARCH)/%.c - $(CC) $(CFLAGS) -c -o $@ $< + @echo CC $@ + $(Q)$(CC) $(CFLAGS) -c -o $@ $< $(OBJDIR)/%.o: $(SRC_ARCH)/%.S $(CC) $(CFLAGS) -c -o $@ $< @@ -152,11 +159,12 @@ avr_clean: # $(OBJDIR)/.depend: + @echo DEPEND $@ @test -d $(OBJDIR) || mkdir -p $(OBJDIR) - $(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@ + $(Q)$(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),erase) -include $(OBJDIR)/.depend +-include $(OBJDIR)/.depend endif endif diff --git a/conf/Makefile.sim b/conf/Makefile.sim index 8b54402316..a5d511b729 100644 --- a/conf/Makefile.sim +++ b/conf/Makefile.sim @@ -36,6 +36,8 @@ CAMLINCLUDES = -I +lablgtk2 -I $(PAPARAZZI_SRC)/sw/lib/ocaml -I $(SIMDIR) SIMSITLML = $(OBJDIR)/simsitl.ml SITLCMA = $(SIMDIR)/sitl.cma +# Launch with "make Q=''" to get full command display +Q=@ # # End of configuration part. @@ -62,8 +64,10 @@ $(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o) all compile: $(OBJDIR)/simsitl + $(OBJDIR)/simsitl : $($(TARGET).objs) $(SITLCMA) $(SIMSITLML) - $(OCAMLC) -custom $(CAMLINCLUDES) -o $@ glibivy-ocaml.cma lib-pprz.cma lablgtk.cma $($(TARGET).objs) gtkInit.cmo $(SITLCMA) $(SIMSITLML) + @echo LD $@ + $(Q)$(OCAMLC) -custom $(CAMLINCLUDES) -o $@ glibivy-ocaml.cma lib-pprz.cma lablgtk.cma $($(TARGET).objs) gtkInit.cmo $(SITLCMA) $(SIMSITLML) # The id of the A/C is hardcoded in the code (to be improved with dynlink ?) @@ -78,10 +82,12 @@ $(OBJDIR)/%.s: %.c $(CC) $(CFLAGS) -S -o $@ $< $(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + @echo CC $@ + $(Q)$(CC) $(CFLAGS) -c -o $@ $< $(OBJDIR)/%.o: $(SRC_ARCH)/%.c - $(CC) $(CFLAGS) -c -o $@ $< + @echo CC $@ + $(Q)$(CC) $(CFLAGS) -c -o $@ $< $(OBJDIR)/%.o: $(SRC_ARCH)/%.S $(CC) $(CFLAGS) -c -o $@ $< @@ -94,13 +100,13 @@ avr_clean: # # Dependencies # - $(OBJDIR)/.depend: @test -d $(OBJDIR) || mkdir -p $(OBJDIR) - $(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@ + @echo DEPEND $@ + $(Q)$(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),erase) -include $(OBJDIR)/.depend +-include $(OBJDIR)/.depend endif endif diff --git a/conf/airframes/flyingtux.xml b/conf/airframes/flyingtux.xml index bbba08e714..14dd4b1c52 100644 --- a/conf/airframes/flyingtux.xml +++ b/conf/airframes/flyingtux.xml @@ -105,37 +105,19 @@ -
- - -
- -include $(PAPARAZZI_SRC)/conf/autopilot/v1_2.makefile -fbw.srcs += commands.c +include $(PAPARAZZI_SRC)/conf/autopilot/v1_2_1.makefile +include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu_avr.makefile -fbw.CFLAGS += -DACTUATORS=\"servos_4017.h\" -fbw.srcs += $(SRC_ARCH)/servos_4017.c +ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport +ap.srcs += pprz_transport.c downlink.c -fbw.CFLAGS += -DRADIO_CONTROL -fbw.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c +ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem +ap.srcs += $(SRC_ARCH)/modem_hw.c -fbw.CFLAGS += -DDOWNLINK -DUART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=uart0 -fbw.srcs += fbw_downlink.c $(SRC_ARCH)/uart_hw.c - -fbw.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK -fbw.srcs += inter_mcu.c $(SRC_ARCH)/spi_hw.c - -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_AP_DEVICE=uart0 -ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c - -ap.CFLAGS += -DMCU_SPI_LINK -ap.srcs += inter_mcu.c link_mcu.c $(SRC_ARCH)/link_mcu_ap.c $(SRC_ARCH)/spi_hw.c - -ap.CFLAGS += -DINFRARED -DGPS -DUBX -DRADIO_CONTROL -# -DRADIO_CONTROL_CALIB -# ap.EXTRA_SRCS += if_calib.c +ap.CFLAGS += -DRADIO_CONTROL_CALIB +ap.srcs += if_calib.c diff --git a/conf/airframes/microjet1.xml b/conf/airframes/microjet1.xml index 19ca40afb4..1f28236d1f 100644 --- a/conf/airframes/microjet1.xml +++ b/conf/airframes/microjet1.xml @@ -98,35 +98,19 @@ -
- - -
- -include $(PAPARAZZI_SRC)/conf/autopilot/v1_2.makefile -fbw.srcs += commands.c +include $(PAPARAZZI_SRC)/conf/autopilot/v1_2_1.makefile +include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu_avr.makefile -fbw.CFLAGS += -DACTUATORS=\"servos_4017.h\" -fbw.srcs += $(SRC_ARCH)/servos_4017.c +ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport +ap.srcs += pprz_transport.c downlink.c -fbw.CFLAGS += -DRADIO_CONTROL -fbw.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c +ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem +ap.srcs += $(SRC_ARCH)/modem_hw.c -fbw.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=uart0 -fbw.srcs += downlink.c $(SRC_ARCH)/uart_hw.c - -fbw.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK -fbw.srcs += inter_mcu.c $(SRC_ARCH)/spi_hw.c - -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_AP_DEVICE=uart0 -ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c - -ap.CFLAGS += -DMCU_SPI_LINK -ap.srcs += inter_mcu.c link_mcu.c $(SRC_ARCH)/link_mcu_ap.c $(SRC_ARCH)/spi_hw.c - -ap.CFLAGS += -DGPS -DUBX -DINFRARED -DRADIO_CONTROL +ap.CFLAGS += -DRADIO_CONTROL_CALIB +ap.srcs += if_calib.c diff --git a/conf/airframes/plaster1.xml b/conf/airframes/plaster1.xml index 737f57c178..bc7ecff23f 100755 --- a/conf/airframes/plaster1.xml +++ b/conf/airframes/plaster1.xml @@ -108,14 +108,19 @@ + include $(PAPARAZZI_SRC)/conf/autopilot/v1_2_1.makefile include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu_avr.makefile -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_AP_DEVICE=uart0 +ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport ap.srcs += pprz_transport.c downlink.c -# ap.CFLAGS += -DMODEM -# ap.srcs += $(SRC_ARCH)/modem_hw.c +# ap.CFLAGS += -DUSE_UART0 -DDOWNLINK_AP_DEVICE=Uart0 +ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem +ap.srcs += $(SRC_ARCH)/modem_hw.c + +ap.CFLAGS += -DRADIO_CONTROL_CALIB +ap.srcs += if_calib.c diff --git a/conf/airframes/twinstar1.xml b/conf/airframes/twinstar1.xml index 99827f0ca0..b85282e026 100644 --- a/conf/airframes/twinstar1.xml +++ b/conf/airframes/twinstar1.xml @@ -104,8 +104,16 @@ + +# Virtual AC + +# Config for HITL simulation on a V1_2_1 bi-AVR board include $(PAPARAZZI_SRC)/conf/autopilot/v1_2_1.makefile include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu_avr.makefile +ap.CFLAGS += -DUSE_UART0 -DHITL + +# Config for SITL simulation include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile - + + diff --git a/conf/airframes/twinstar2.xml b/conf/airframes/twinstar2.xml index 401e7be816..ca6d0f5a6b 100644 --- a/conf/airframes/twinstar2.xml +++ b/conf/airframes/twinstar2.xml @@ -109,17 +109,19 @@ +# Virtual AC + +# Config for HITL simulation on a V1_2_1 bi-AVR board include $(PAPARAZZI_SRC)/conf/autopilot/v1_2_1.makefile include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu_avr.makefile -include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile - ap.CFLAGS += -DMOBILE_CAM -DDATALINK ap.EXTRA_SRCS += traffic_info.c datalink.c +ap.CFLAGS += -DUSE_UART0 -DHITL + +# Config for SITL simulation +include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile sim.CFLAGS += -DDATALINK -DMOBILE_CAM sim.EXTRA_SRCS += traffic_info.c datalink.c -#ap.CFLAGS += -DWAVECARD -#ap.EXTRA_SRCS += wavecard.c -#ap.CFLAGS += -DMAXSTREAM -#ap.EXTRA_SRCS += maxstream.c + diff --git a/conf/airframes/twinstar4.xml b/conf/airframes/twinstar4.xml index 093bb2850f..e0c3a31116 100755 --- a/conf/airframes/twinstar4.xml +++ b/conf/airframes/twinstar4.xml @@ -109,38 +109,24 @@ - -
- - -
include $(PAPARAZZI_SRC)/conf/autopilot/v1_2_1.makefile +include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu_avr.makefile -fbw.srcs += commands.c +ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport +ap.srcs += pprz_transport.c downlink.c -fbw.CFLAGS += -DACTUATORS=\"servos_4017.h\" -DSERVOS_4017 -fbw.srcs += $(SRC_ARCH)/servos_4017.c +ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem +ap.srcs += $(SRC_ARCH)/modem_hw.c -fbw.CFLAGS += -DRADIO_CONTROL -fbw.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c +ap.CFLAGS += -DRADIO_CONTROL_CALIB +ap.srcs += if_calib.c -fbw.CFLAGS += -DDOWNLINK -DUART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=uart0 -fbw.srcs += fbw_downlink.c $(SRC_ARCH)/uart_hw.c - -fbw.CFLAGS += -DDEBUG - -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_AP_DEVICE=uart0 - -ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c - -ap.CFLAGS += -DINFRARED -DGPS -DUBX -DRADIO_CONTROL_CALIB -ap.CFLAGS += -DLED -DLED_1_BANK=D -DLED_1_PIN=0 -DLED_2_BANK=D -DLED_2_PIN=1 -DRADIO_CONTROL -ap.EXTRA_SRCS += if_calib.c ap.CFLAGS += -DDATALINK -ap.EXTRA_SRCS += traffic_info.c datalink.c +ap.srcs += traffic_info.c datalink.c ap.CFLAGS += -DWAVECARD -ap.EXTRA_SRCS += wavecard.c +ap.srcs += wavecard.c + diff --git a/conf/autopilot/sitl.makefile b/conf/autopilot/sitl.makefile index 7c27b5bdf7..0f7e8656ed 100644 --- a/conf/autopilot/sitl.makefile +++ b/conf/autopilot/sitl.makefile @@ -3,5 +3,4 @@ sim.ARCH = sitl sim.TARGET = autopilot sim.TARGETDIR = autopilot sim.CFLAGS += -DSITL -DAP -DFBW -DRADIO_CONTROL -DINTER_MCU -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport -DINFRARED -# ap.CFLAGS += -DGPS -DUBX sim.srcs = radio_control.c downlink.c commands.c gps.c inter_mcu.c link_mcu.c infrared.c pid.c nav.c estimator.c cam.c sys_time.c main_fbw.c main_ap.c $(SRC_ARCH)/ppm_hw.c $(SRC_ARCH)/sim_gps.c $(SRC_ARCH)/sim_ir.c $(SRC_ARCH)/sim_ap.c $(SRC_ARCH)/ivy_transport.c diff --git a/conf/autopilot/twin_mcu.makefile b/conf/autopilot/twin_mcu.makefile index 6f8a4f256d..0f33cf40db 100644 --- a/conf/autopilot/twin_mcu.makefile +++ b/conf/autopilot/twin_mcu.makefile @@ -2,5 +2,5 @@ ap.srcs += main_ap.c sys_time.c main.c inter_mcu.c link_mcu.c gps_ubx.c gps.c in ap.CFLAGS += -DMCU_SPI_LINK -DGPS -DUBX -DINFRARED -DRADIO_CONTROL -DINTER_MCU fbw.srcs += sys_time.c main_fbw.c main.c commands.c radio_control.c pprz_transport.c downlink.c inter_mcu.c -fbw.CFLAGS += -DRADIO_CONTROL -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=uart0 -DINTER_MCU -DMCU_SPI_LINK +fbw.CFLAGS += -DRADIO_CONTROL -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DINTER_MCU -DMCU_SPI_LINK diff --git a/conf/autopilot/twin_mcu_avr.makefile b/conf/autopilot/twin_mcu_avr.makefile index 5fbe89921f..741391cc97 100644 --- a/conf/autopilot/twin_mcu_avr.makefile +++ b/conf/autopilot/twin_mcu_avr.makefile @@ -2,7 +2,7 @@ include $(PAPARAZZI_SRC)/conf/autopilot/twin_avr.makefile include $(PAPARAZZI_SRC)/conf/autopilot/twin_mcu.makefile ap.srcs += $(SRC_ARCH)/adc_hw.c $(SRC_ARCH)/uart_hw.c $(SRC_ARCH)/link_mcu_ap.c $(SRC_ARCH)/spi_hw.c -ap.CFLAGS += -DGPS_LINK=uart1 +ap.CFLAGS += -DUSE_UART1 -DGPS_LINK=uart1 fbw.CFLAGS += -DACTUATORS=\"servos_4017.h\" -DSERVOS_4017 -DADC fbw.srcs += $(SRC_ARCH)/adc_hw.c $(SRC_ARCH)/servos_4017.c $(SRC_ARCH)/ppm_hw.c $(SRC_ARCH)/uart_hw.c $(SRC_ARCH)/spi_hw.c diff --git a/conf/ubx.xml b/conf/ubx.xml index 9c7e5e7afa..1b5d993e75 100644 --- a/conf/ubx.xml +++ b/conf/ubx.xml @@ -145,4 +145,14 @@ + + + + + + + + + + diff --git a/sw/airborne/downlink.h b/sw/airborne/downlink.h index b71c3bc9d0..fcd9260284 100644 --- a/sw/airborne/downlink.h +++ b/sw/airborne/downlink.h @@ -31,6 +31,7 @@ #include "ivy_transport.h" #else #include "pprz_transport.h" +#include "modem.h" #endif extern uint8_t downlink_nb_ovrn; diff --git a/sw/airborne/gps_ubx.c b/sw/airborne/gps_ubx.c index 3f54117ae9..c9ee3d4831 100644 --- a/sw/airborne/gps_ubx.c +++ b/sw/airborne/gps_ubx.c @@ -52,12 +52,13 @@ static uint8_t ubx_msg_buf[UBX_MAX_PAYLOAD]; #define RadianOfDeg(d) ((d)/180.*3.1415927) -#ifdef SIMUL -#include "infrared.h" -#define IR_START 0xA1 /* simulator/mc.ml */ -volatile int16_t simul_ir_roll; -volatile int16_t simul_ir_pitch; -#endif +#ifdef HITL +/* With HITL simulation, the GPS uart link is connected to the simulator which + sends the UBX frames. This link is also used for the infrared data + (replacing the adc, c.f. infrared.c) */ +volatile int16_t hitl_ir_roll; +volatile int16_t hitl_ir_pitch; +#endif /* HITL */ #define UNINIT 0 #define GOT_SYNC1 1 @@ -68,12 +69,6 @@ volatile int16_t simul_ir_pitch; #define GOT_LEN2 6 #define GOT_PAYLOAD 7 #define GOT_CHECKSUM1 8 -#ifdef SIMUL -#define GOT_IR_START 20 -#define GOT_IR1 21 -#define GOT_IR2 22 -#define GOT_IR3 23 -#endif static uint8_t ubx_status; static uint16_t ubx_len; @@ -82,14 +77,6 @@ static uint8_t ck_a, ck_b, ubx_id, ubx_class; uint8_t send_ck_a, send_ck_b; void gps_init( void ) { - /* Enable uart */ -#ifdef SIMUL - uart0_init(); - simul_ir_roll = ir_roll_neutral; - simul_ir_pitch = ir_pitch_neutral; -#else - Uart1Init(); -#endif ubx_status = UNINIT; } @@ -167,14 +154,15 @@ void parse_gps_msg( void ) { } } } -#ifdef SIMUL +#ifdef HITL if (ubx_class == UBX_USR_ID) { if (ubx_id == UBX_USR_IRSIM_ID) { - simul_ir_roll = UBX_USR_IRSIM_ROLL(ubx_msg_buf); - simul_ir_pitch = UBX_USR_IRSIM_PITCH(ubx_msg_buf); + /** Message from the simalator, containing infrared data */ + hitl_ir_roll = UBX_USR_IRSIM_ROLL(ubx_msg_buf); + hitl_ir_pitch = UBX_USR_IRSIM_PITCH(ubx_msg_buf); } } -#endif +#endif /* HITL */ } diff --git a/sw/airborne/infrared.c b/sw/airborne/infrared.c index 9e29962715..6e066f4ec0 100644 --- a/sw/airborne/infrared.c +++ b/sw/airborne/infrared.c @@ -77,27 +77,26 @@ void ir_init(void) { estimator_rad_of_ir = ir_rad_of_ir; } -/** \fn void ir_update(void) - * \brief Update \a ir */ -/** Different if the \a SIMUL flag is true or not. \n +/** \brief Update \a ir_roll and ir_pitch from ADCs or from simulator + * message in HITL mode */ void ir_update(void) { -#if defined SITL - /** ir_roll set by simulator in sim_ir.c */ -#else -#if defined SIMUL - extern volatile int16_t simul_ir_roll, simul_ir_pitch; - ir_roll = simul_ir_roll; - ir_pitch = simul_ir_pitch; -#else +#if ! defined SITL +#if defined HITL + extern volatile int16_t hitl_ir_roll, hitl_ir_pitch; /* From gps_ubx.c */ + ir_roll = hitl_ir_roll; + ir_pitch = hitl_ir_pitch; +#else /* HITL */ int16_t x1_mean = buf_ir1.sum/buf_ir1.av_nb_sample; int16_t x2_mean = buf_ir2.sum/buf_ir2.av_nb_sample; ir_roll = IR_RollOfIrs(x1_mean, x2_mean); ir_pitch = IR_PitchOfIrs(x1_mean, x2_mean); -#endif +#endif /* !HITL */ + ir_roll -= IR_ADC_ROLL_NEUTRAL; ir_pitch -= IR_ADC_PITCH_NEUTRAL; -#endif +#endif /* !SITL */ +/** #else ir_roll set by simulator in sim_ir.c */ } /** \brief Contrast measurement diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index 6b220a1cc2..408b79b90e 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -41,6 +41,7 @@ #include "sys_time.h" #include "flight_plan.h" #include "datalink.h" +#include "wavecard.h" #ifdef LED #include "led.h" @@ -516,9 +517,11 @@ void init_ap( void ) { srf08_init(); #endif #if USE_UART0 - uart0_init_tx(); - uart0_init_rx(); -#endif //IMU + Uart0Init(); +#endif +#if USE_UART1 + Uart1Init(); +#endif /************* Links initialization ***************/ diff --git a/sw/airborne/modem.h b/sw/airborne/modem.h index 4c4f19e7a5..6e268837cc 100644 --- a/sw/airborne/modem.h +++ b/sw/airborne/modem.h @@ -104,7 +104,7 @@ extern uint8_t ck_a, ck_b; tx_tail = 0; \ } - +#define ModemTransmit(_x) ModemPut1Byte(_x) #endif // MODEM diff --git a/sw/airborne/pprz_transport.h b/sw/airborne/pprz_transport.h index 8da95c2b5e..cf0b8c0e8e 100644 --- a/sw/airborne/pprz_transport.h +++ b/sw/airborne/pprz_transport.h @@ -38,9 +38,9 @@ extern uint8_t ck_a, ck_b; #define _Link(dev, _x) __Link(dev, _x) #define Link(_x) _Link(DOWNLINK_DEVICE, _x) -#define PprzTransportCheckFreeSpace(_x) Link(_check_free_space(_x)) +#define PprzTransportCheckFreeSpace(_x) Link(CheckFreeSpace(_x)) -#define PprzTransportPut1Byte(_x) Link(_transmit(_x)) +#define PprzTransportPut1Byte(_x) Link(Transmit(_x)) #define PprzTransportHeader(payload_len) { \ PprzTransportPut1Byte(STX); \ diff --git a/sw/airborne/uart.h b/sw/airborne/uart.h index 450d4712aa..ecf4535206 100644 --- a/sw/airborne/uart.h +++ b/sw/airborne/uart.h @@ -36,7 +36,7 @@ void uart0_init_tx( void ); -/** uart0_init_rx() is optional but must be called after uart0_init_tx */ +/** uart0_init_rx() is optional but must be called _after_ uart0_init_tx */ void uart0_init_rx( void ); void uart0_transmit( unsigned char data ); @@ -45,7 +45,7 @@ bool_t uart0_check_free_space( uint8_t len); /** Not necessarily defined */ void uart1_init_tx( void ); -/** uart1_init_rx() is optional but must be called after uart1_init_tx */ +/** uart1_init_rx() is optional but must be called _after_ uart1_init_tx */ void uart1_init_rx( void ); void uart1_transmit( unsigned char data ); @@ -54,4 +54,10 @@ bool_t uart1_check_free_space( uint8_t len); #define Uart0Init() { uart0_init_tx(); uart0_init_rx(); } #define Uart1Init() { uart1_init_tx(); uart1_init_rx(); } +#define Uart0CheckFreeSpace(_x) uart0_check_free_space(_x) +#define Uart1CheckFreeSpace(_x) uart1_check_free_space(_x) + +#define Uart0Transmit(_x) uart0_transmit(_x) +#define Uart1Transmit(_x) uart1_transmit(_x) + #endif /* UART_H */ diff --git a/sw/lib/ocaml/xml2h.ml b/sw/lib/ocaml/xml2h.ml index d06df63bdc..828ea50cc8 100644 --- a/sw/lib/ocaml/xml2h.ml +++ b/sw/lib/ocaml/xml2h.ml @@ -71,7 +71,7 @@ let finish = fun h_name -> printf "\n#endif // %s\n" h_name let warning s = - Printf.fprintf stderr "\n##################################################\n"; + Printf.fprintf stderr "##################################################\n"; Printf.fprintf stderr "\n %s\n" s; Printf.fprintf stderr "\n##################################################\n" diff --git a/sw/tools/Makefile b/sw/tools/Makefile index 81cc69bb3b..76b408d629 100644 --- a/sw/tools/Makefile +++ b/sw/tools/Makefile @@ -8,7 +8,7 @@ all: gen_aircraft.out gen_airframe.out gen_calib.out gen_messages.out gen_ubx.ou FP_CMO = fp_syntax.cmo fp_parser.cmo fp_lexer.cmo fp_proc.cmo gen_flight_plan.ml ABS_FP = $(FP_CMO:%=$$PAPARAZZI_SRC/sw/tools/%) -gen_flight_plan.out : $(FP_CMO) +gen_flight_plan.out : $(FP_CMO) ../lib/ocaml/lib-pprz.cma $(OCAMLC) -custom -o $@ ivy-ocaml.cma lib-pprz.cma $^ fp_parser.cmo : fp_parser.cmi fp_syntax.cmi diff --git a/sw/tools/gen_aircraft.ml b/sw/tools/gen_aircraft.ml index 798996cb88..7423cf22a3 100644 --- a/sw/tools/gen_aircraft.ml +++ b/sw/tools/gen_aircraft.ml @@ -43,5 +43,8 @@ let _ = mkdir (aircraft_dir // "sim"); let c = sprintf "make -f Makefile.ac AIRCRAFT=%s AC_ID=%s AIRFRAME=%s RADIO=%s FLIGHT_PLAN=%s TELEMETRY=%s" aircraft (value "ac_id") (value "airframe") (value "radio") (value "flight_plan") (value "telemetry") in - prerr_endline c; + begin (** Quiet is speficied in the Makefile *) + try if Sys.getenv "Q" <> "@" then raise Not_found with + Not_found -> prerr_endline c + end; exit (Sys.command c) diff --git a/sw/tools/gen_flight_plan.ml b/sw/tools/gen_flight_plan.ml index f43f09613e..ab130aa44e 100644 --- a/sw/tools/gen_flight_plan.ml +++ b/sw/tools/gen_flight_plan.ml @@ -545,15 +545,15 @@ let print_dl_settings = fun settings -> if nb_values > 0 then begin right (); lprintf "static uint8_t i;\\\n"; - lprintf "float *var = 0;\\\n"; + lprintf "float var;\\\n"; lprintf "if (i >= %d) i = 0;;\\\n" nb_values; let idx = ref 0 in List.iter (fun s -> let v = ExtXml.attrib s "var" in - lprintf "if (i == %d) var = &%s;\\\n" !idx v; incr idx) + lprintf "if (i == %d) var = %s;\\\n" !idx v; incr idx) settings; - lprintf "DOWNLINK_SEND_DL_VALUE(&i, var);\\\n"; + lprintf "DOWNLINK_SEND_DL_VALUE(&i, &var);\\\n"; lprintf "i++;\\\n"; left () end;