diff --git a/conf/airframes/AGGIEAIR/ark_hexa_1-8.xml b/conf/airframes/AGGIEAIR/ark_hexa_1-8.xml index 5c821a98f9..33cdeca6f4 100644 --- a/conf/airframes/AGGIEAIR/ark_hexa_1-8.xml +++ b/conf/airframes/AGGIEAIR/ark_hexa_1-8.xml @@ -9,9 +9,9 @@ ARK RT - + - + diff --git a/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml b/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml index f32da3b197..980b0dfffe 100644 --- a/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml +++ b/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml @@ -9,7 +9,6 @@ - @@ -18,6 +17,7 @@ + diff --git a/conf/airframes/ENAC/quadrotor/ard2_basic.xml b/conf/airframes/ENAC/quadrotor/ard2_basic.xml index c3ad3628ef..fe0138020d 100644 --- a/conf/airframes/ENAC/quadrotor/ard2_basic.xml +++ b/conf/airframes/ENAC/quadrotor/ard2_basic.xml @@ -9,7 +9,6 @@ - @@ -18,6 +17,7 @@ + diff --git a/conf/airframes/ENAC/quadrotor/ard2_basic_adhoc.xml b/conf/airframes/ENAC/quadrotor/ard2_basic_adhoc.xml index c3fb5a0974..374a1db5a0 100644 --- a/conf/airframes/ENAC/quadrotor/ard2_basic_adhoc.xml +++ b/conf/airframes/ENAC/quadrotor/ard2_basic_adhoc.xml @@ -12,7 +12,6 @@ - @@ -21,6 +20,7 @@ + diff --git a/conf/airframes/ENAC/quadrotor/bebop_201.xml b/conf/airframes/ENAC/quadrotor/bebop_201.xml index abb123d0e1..277c6109f9 100644 --- a/conf/airframes/ENAC/quadrotor/bebop_201.xml +++ b/conf/airframes/ENAC/quadrotor/bebop_201.xml @@ -5,7 +5,6 @@ - @@ -16,6 +15,7 @@ + diff --git a/conf/airframes/examples/quadshot_178_pylons.xml b/conf/airframes/examples/quadshot_178_pylons.xml index 13395230bd..79d9ce2933 100644 --- a/conf/airframes/examples/quadshot_178_pylons.xml +++ b/conf/airframes/examples/quadshot_178_pylons.xml @@ -325,12 +325,12 @@ - + - + @@ -344,24 +344,24 @@ - - + + - + - - - - - - + + + + + + - + - + - + diff --git a/conf/firmwares/rotorcraft.makefile b/conf/firmwares/rotorcraft.makefile index 6ed4262d9e..75727f7cc3 100644 --- a/conf/firmwares/rotorcraft.makefile +++ b/conf/firmwares/rotorcraft.makefile @@ -221,5 +221,4 @@ fbw.srcs += $(ns_srcs) ## include $(CFG_SHARED)/nps.makefile nps.srcs += nps/nps_autopilot_rotorcraft.c -nps.srcs += $(SRC_FIRMWARE)/rotorcraft_telemetry.c -nps.srcs += subsystems/datalink/datalink.c $(SRC_FIRMWARE)/rotorcraft_datalink.c + diff --git a/conf/firmwares/setup.makefile b/conf/firmwares/setup.makefile index 6b5a179a7e..3e3e4e34f4 100644 --- a/conf/firmwares/setup.makefile +++ b/conf/firmwares/setup.makefile @@ -112,7 +112,7 @@ setup_actuators.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) SETUP_ACTUATORS_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z) setup_actuators.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(SETUP_ACTUATORS_MODEM_PORT_LOWER) -DPPRZ_UART=$(SETUP_ACTUATORS_MODEM_PORT_LOWER) setup_actuators.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -setup_actuators.srcs += subsystems/datalink/downlink.c pprzlink/src/pprz_transport.c +setup_actuators.srcs += subsystems/datalink/downlink.c pprzlink/src/pprz_transport.c modules/datalink/pprz_dl.c setup_actuators.srcs += subsystems/actuators.c setup_actuators.srcs += $(SRC_FIRMWARE)/setup_actuators.c diff --git a/conf/firmwares/subsystems/fixedwing/autopilot.makefile b/conf/firmwares/subsystems/fixedwing/autopilot.makefile index 935571f6c6..128ce64fec 100644 --- a/conf/firmwares/subsystems/fixedwing/autopilot.makefile +++ b/conf/firmwares/subsystems/fixedwing/autopilot.makefile @@ -236,8 +236,6 @@ ap.srcs += $(ap_srcs) $(ns_srcs) ## include $(CFG_SHARED)/nps.makefile nps.srcs += nps/nps_autopilot_fixedwing.c -nps.srcs += subsystems/datalink/datalink.c $(SRC_FIRMWARE)/fixedwing_datalink.c -nps.srcs += $(SRC_FIRMWARE)/ap_downlink.c $(SRC_FIRMWARE)/fbw_downlink.c # add normal ap and fbw sources nps.CFLAGS += $(fbw_CFLAGS) $(ap_CFLAGS) diff --git a/conf/firmwares/subsystems/fixedwing/telemetry_bluegiga.makefile b/conf/firmwares/subsystems/fixedwing/telemetry_bluegiga.makefile deleted file mode 100644 index 69b8085211..0000000000 --- a/conf/firmwares/subsystems/fixedwing/telemetry_bluegiga.makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -# include shared part for ap -ifeq ($(TARGET),ap) -include $(CFG_SHARED)/telemetry_bluegiga.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/fixedwing_datalink.c $(SRC_FIRMWARE)/ap_downlink.c - -# avoid fbw_telemetry_mode error -ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - -fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - diff --git a/conf/firmwares/subsystems/fixedwing/telemetry_superbitrf.makefile b/conf/firmwares/subsystems/fixedwing/telemetry_superbitrf.makefile deleted file mode 100644 index 95e3daf4be..0000000000 --- a/conf/firmwares/subsystems/fixedwing/telemetry_superbitrf.makefile +++ /dev/null @@ -1,16 +0,0 @@ -# -# The superbitRF module as telemetry downlink/uplink -# -# - -# include shared part for ap -ifeq ($(TARGET),ap) -include $(CFG_SHARED)/telemetry_superbitrf.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/fixedwing_datalink.c $(SRC_FIRMWARE)/ap_downlink.c - -# avoid fbw_telemetry_mode error -ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - -fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c diff --git a/conf/firmwares/subsystems/fixedwing/telemetry_transparent.makefile b/conf/firmwares/subsystems/fixedwing/telemetry_transparent.makefile deleted file mode 100644 index 23ebc09a0d..0000000000 --- a/conf/firmwares/subsystems/fixedwing/telemetry_transparent.makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -# include shared part for ap -ifeq ($(TARGET),ap) -include $(CFG_SHARED)/telemetry_transparent.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/fixedwing_datalink.c $(SRC_FIRMWARE)/ap_downlink.c - -# avoid fbw_telemetry_mode error -ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - -fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - diff --git a/conf/firmwares/subsystems/fixedwing/telemetry_transparent_usb.makefile b/conf/firmwares/subsystems/fixedwing/telemetry_transparent_usb.makefile deleted file mode 100644 index a87201f3c8..0000000000 --- a/conf/firmwares/subsystems/fixedwing/telemetry_transparent_usb.makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -#serial USB (e.g. /dev/ttyACM0) - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_transparent_usb.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/fixedwing_datalink.c $(SRC_FIRMWARE)/ap_downlink.c $(SRC_FIRMWARE)/fbw_downlink.c -# avoid fbw_telemetry_mode error -ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - -fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - diff --git a/conf/firmwares/subsystems/fixedwing/telemetry_w5100.makefile b/conf/firmwares/subsystems/fixedwing/telemetry_w5100.makefile deleted file mode 100644 index 09a2f4f254..0000000000 --- a/conf/firmwares/subsystems/fixedwing/telemetry_w5100.makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -# W5100 ethernet chip. - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_w5100.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/fixedwing_datalink.c $(SRC_FIRMWARE)/ap_downlink.c - -# avoid fbw_telemetry_mode error -ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - -fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c diff --git a/conf/firmwares/subsystems/fixedwing/telemetry_xbee_api.makefile b/conf/firmwares/subsystems/fixedwing/telemetry_xbee_api.makefile deleted file mode 100644 index 07d801e161..0000000000 --- a/conf/firmwares/subsystems/fixedwing/telemetry_xbee_api.makefile +++ /dev/null @@ -1,15 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -# XBee modems in API mode - -# include shared part for ap -ifeq ($(TARGET),ap) -include $(CFG_SHARED)/telemetry_xbee_api.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/fixedwing_datalink.c $(SRC_FIRMWARE)/ap_downlink.c - -# avoid fbw_telemetry_mode error -ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c - -fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_bluegiga.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_bluegiga.makefile deleted file mode 100644 index ba9aae5617..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_bluegiga.makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# The bluegiga module as telemetry downlink/uplink for rotorcraft -# - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_bluegiga.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/rotorcraft_datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_superbitrf.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_superbitrf.makefile deleted file mode 100644 index 27818783a8..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_superbitrf.makefile +++ /dev/null @@ -1,11 +0,0 @@ -# -# The superbitRF module as telemetry downlink/uplink -# - -# include generic part -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_superbitrf.makefile -endif - -# add rotorcraft specific files -ap.srcs += $(SRC_FIRMWARE)/rotorcraft_datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_transparent.makefile deleted file mode 100644 index c5e2418642..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent.makefile +++ /dev/null @@ -1,12 +0,0 @@ -# -# Expected from board file or overriden as xml param : -# -# MODEM_PORT -# MODEM_BAUD -# - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_transparent.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/rotorcraft_datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile deleted file mode 100644 index 9822c3341c..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile +++ /dev/null @@ -1,8 +0,0 @@ - -#serial UDP - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_transparent_udp.makefile -endif - -ap.srcs += subsystems/datalink/datalink.c $(SRC_FIRMWARE)/rotorcraft_datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_usb.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_usb.makefile deleted file mode 100644 index 92ea7ca6b4..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_usb.makefile +++ /dev/null @@ -1,8 +0,0 @@ - -#serial USB (e.g. /dev/ttyACM0) - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_transparent_usb.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/rotorcraft_datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_xbee_api.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_xbee_api.makefile deleted file mode 100644 index 801cb5a159..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_xbee_api.makefile +++ /dev/null @@ -1,13 +0,0 @@ -# XBee modems in API mode -# -# Expected from board file or overriden as xml param : -# -# MODEM_PORT -# MODEM_BAUD -# - -ifeq ($(TARGET), ap) -include $(CFG_SHARED)/telemetry_xbee_api.makefile -endif - -ap.srcs += $(SRC_FIRMWARE)/rotorcraft_datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c diff --git a/conf/firmwares/subsystems/shared/nps.makefile b/conf/firmwares/subsystems/shared/nps.makefile index 347666b973..af06073b9a 100644 --- a/conf/firmwares/subsystems/shared/nps.makefile +++ b/conf/firmwares/subsystems/shared/nps.makefile @@ -62,6 +62,3 @@ endif # for geo mag calculation nps.srcs += math/pprz_geodetic_wmm2015.c -ifeq ($(TARGET), nps) -include $(CFG_SHARED)/telemetry_transparent_udp.makefile -endif diff --git a/conf/firmwares/subsystems/shared/telemetry_bluegiga.makefile b/conf/firmwares/subsystems/shared/telemetry_bluegiga.makefile deleted file mode 100644 index 45e995ae66..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_bluegiga.makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# The bluegiga module as telemetry downlink/uplink -# -# On Lisa-s, the Superbit-RF module can be replaced with a -# bluegiga-bluetooth 4 low power board. This subsystem puts -# the telemetry over this bluetooth 4 link. -# -# Bluegiga is a SPI-slave device without Chip select but with a compulsory DRDY -# -# Required: -# #define BLUEGIGA_SPI_DEV: the SPI device which MUST have a SLAVE mode without chipselect -# -# Optional: (defaults to SUPERBITRF DRDY) -# #define BLUEGIGA_DRDY_GPIO -# #define BLUEGIGA_DRDY_GPIO_PIN - -# Include SPI if not yet included -include $(CFG_SHARED)/spi_master.makefile - -# Set downlink to paparazzi transport over bluegiga protocol over SPI slave -ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=bluegiga_p -ap.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=BLUEGIGA - -BLUEGIGA_SPI_DEV ?= SPI2 -BLUEGIGA_SPI_DEV_LOWER=$(shell echo $(BLUEGIGA_SPI_DEV) | tr A-Z a-z) -ap.CFLAGS += -DUSE_$(BLUEGIGA_SPI_DEV)_SLAVE -DSPI_SLAVE -DBLUEGIGA_SPI_DEV=$(BLUEGIGA_SPI_DEV_LOWER) - -# LED -MODEM_LED ?= none -ifneq ($(MODEM_LED),none) -ap.CFLAGS += -DMODEM_LED=$(MODEM_LED) -endif - -ap.srcs += $(SRC_SUBSYSTEMS)/datalink/downlink.c subsystems/datalink/datalink.c $(SRC_SUBSYSTEMS)/datalink/bluegiga.c -ap.srcs += pprzlink/src/pprz_transport.c $(SRC_SUBSYSTEMS)/datalink/telemetry.c diff --git a/conf/firmwares/subsystems/shared/telemetry_ivy.makefile b/conf/firmwares/subsystems/shared/telemetry_ivy.makefile deleted file mode 100644 index 6236da98d4..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_ivy.makefile +++ /dev/null @@ -1,3 +0,0 @@ -$(TARGET).CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_TRANSPORT=ivy_tp -DDOWNLINK_DEVICE=ivy_tp -$(TARGET).srcs += pprzlink/src/ivy_transport.c -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c subsystems/datalink/telemetry.c diff --git a/conf/firmwares/subsystems/shared/telemetry_superbitrf.makefile b/conf/firmwares/subsystems/shared/telemetry_superbitrf.makefile deleted file mode 100644 index 56a180c4c8..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_superbitrf.makefile +++ /dev/null @@ -1,10 +0,0 @@ -# -# The superbitRF module as telemetry downlink/uplink -# -# - -$(TARGET).CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=superbitrf -$(TARGET).CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=SUPERBITRF - -$(TARGET).srcs += peripherals/cyrf6936.c -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c subsystems/datalink/superbitrf.c pprzlink/src/pprz_transport.c subsystems/datalink/telemetry.c diff --git a/conf/firmwares/subsystems/shared/telemetry_transparent.makefile b/conf/firmwares/subsystems/shared/telemetry_transparent.makefile deleted file mode 100644 index 47f1aca1f1..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_transparent.makefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# Expected from board file or overriden as xml param : -# -# MODEM_PORT -# MODEM_BAUD -# - -PPRZ_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z) -PPRZ_MODEM_PORT_UPPER=$(shell echo $(MODEM_PORT) | tr a-z A-Z) - -$(TARGET).CFLAGS += -DUSE_$(PPRZ_MODEM_PORT_UPPER) -$(TARGET).CFLAGS += -D$(PPRZ_MODEM_PORT_UPPER)_BAUD=$(MODEM_BAUD) - -$(TARGET).CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(PPRZ_MODEM_PORT_LOWER) -DPPRZ_UART=$(PPRZ_MODEM_PORT_LOWER) -$(TARGET).CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c pprzlink/src/pprz_transport.c subsystems/datalink/telemetry.c - diff --git a/conf/firmwares/subsystems/shared/telemetry_transparent_udp.makefile b/conf/firmwares/subsystems/shared/telemetry_transparent_udp.makefile deleted file mode 100644 index 0c6c40041e..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_transparent_udp.makefile +++ /dev/null @@ -1,23 +0,0 @@ - -#serial UDP - -include $(CFG_SHARED)/udp.makefile - -MODEM_DEV ?= UDP0 -MODEM_PORT_OUT ?= 4242 -MODEM_PORT_IN ?= 4243 -MODEM_BROADCAST ?= TRUE - -UDP_MODEM_PORT_LOWER=$(shell echo $(MODEM_DEV) | tr A-Z a-z) -UDP_MODEM_PORT_UPPER=$(shell echo $(MODEM_DEV) | tr a-z A-Z) - -MODEM_CFLAGS = -DUSE_$(UDP_MODEM_PORT_UPPER) -D$(UDP_MODEM_PORT_UPPER)_PORT_OUT=$(MODEM_PORT_OUT) -D$(UDP_MODEM_PORT_UPPER)_PORT_IN=$(MODEM_PORT_IN) -MODEM_CFLAGS += -D$(UDP_MODEM_PORT_UPPER)_BROADCAST=$(MODEM_BROADCAST) -D$(UDP_MODEM_PORT_UPPER)_HOST=$(MODEM_HOST) - -TELEM_CFLAGS = -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(UDP_MODEM_PORT_LOWER) -DPPRZ_UART=$(UDP_MODEM_PORT_LOWER) -TELEM_CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ - - -$(TARGET).CFLAGS += $(MODEM_CFLAGS) $(TELEM_CFLAGS) -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c pprzlink/src/pprz_transport.c subsystems/datalink/telemetry.c - diff --git a/conf/firmwares/subsystems/shared/telemetry_transparent_usb.makefile b/conf/firmwares/subsystems/shared/telemetry_transparent_usb.makefile deleted file mode 100644 index 4ac1679d54..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_transparent_usb.makefile +++ /dev/null @@ -1,20 +0,0 @@ - -#serial USB (e.g. /dev/ttyACM0) - -$(TARGET).CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=usb_serial -DPPRZ_UART=usb_serial -$(TARGET).CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -DUSE_USB_SERIAL -$(TARGET).CFLAGS += -DPERIODIC_TELEMETRY -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c pprzlink/src/pprz_transport.c subsystems/datalink/telemetry.c - -ifeq ($(ARCH), lpc21) -$(TARGET).srcs += $(SRC_ARCH)/usb_ser_hw.c $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c -$(TARGET).srcs += $(SRC_ARCH)/lpcusb/usbstdreq.c $(SRC_ARCH)/lpcusb/usbinit.c -else -ifeq ($(ARCH), stm32) -$(TARGET).srcs += $(SRC_ARCH)/usb_ser_hw.c -else -ifneq ($(ARCH), sim) -$(error telemetry_transparent_usb currently only implemented for the lpc21 and stm32) -endif -endif -endif diff --git a/conf/firmwares/subsystems/shared/telemetry_w5100.makefile b/conf/firmwares/subsystems/shared/telemetry_w5100.makefile deleted file mode 100644 index 83cb26413b..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_w5100.makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -# W5100 ethernet chip. - -W5100_IP ?= "192,168,25,47" -W5100_SUBNET ?= "255,255,255,0" -W5100_MULTICAST_IP ?= "224,1,1,11" -W5100_MULTICAST_PORT ?= "1234" - -$(TARGET).CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=chip0 -$(TARGET).CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=W5100 -$(TARGET).CFLAGS += -DW5100_IP=$(W5100_IP) -DW5100_SUBNET=$(W5100_SUBNET) -DW5100_MULTICAST_IP=$(W5100_MULTICAST_IP) -DW5100_MULTICAST_PORT=$(W5100_MULTICAST_PORT) -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c subsystems/datalink/w5100.c pprzlink/src/pprz_transport.c subsystems/datalink/telemetry.c - -ifeq ($(ARCH), lpc21) -# only an issue of setting the DRDY pin in w5100.c, which is stm32 specific -$(error Not implemented for the LCP21x yet.) -$(TARGET).CFLAGS += -DUSE_SPI1 -# default SPI device for W5100 is already SPI1 -$(TARGET).CFLAGS += -DUSE_SPI_SLAVE0 -$(TARGET).CFLAGS += -DW5100_SLAVE_IDX=0 -else ifeq ($(ARCH), stm32) -# on extra SPI1 connector -$(TARGET).CFLAGS += -DUSE_SPI1 -# default SPI device for W5100 is already SPI1 -# Slave select configuration -# SLAVE1 is SS on external SPI1 connector (PA04) -$(TARGET).CFLAGS += -DUSE_SPI_SLAVE1 -# default slave select for W5100 is already SLAVE1 -#$(TARGET).CFLAGS += -DW5100_SLAVE_IDX=1 -endif diff --git a/conf/firmwares/subsystems/shared/telemetry_xbee_api.makefile b/conf/firmwares/subsystems/shared/telemetry_xbee_api.makefile deleted file mode 100644 index 54552871c7..0000000000 --- a/conf/firmwares/subsystems/shared/telemetry_xbee_api.makefile +++ /dev/null @@ -1,17 +0,0 @@ -# XBee modems in API mode -# -# Expected from board file or overriden as xml param : -# -# MODEM_PORT -# MODEM_BAUD -# - -XBEE_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z) -XBEE_MODEM_PORT_UPPER=$(shell echo $(MODEM_PORT) | tr a-z A-Z) - -$(TARGET).CFLAGS += -DUSE_$(XBEE_MODEM_PORT_UPPER) -$(TARGET).CFLAGS += -D$(XBEE_MODEM_PORT_UPPER)_BAUD=$(MODEM_BAUD) -DXBEE_BAUD=$(MODEM_BAUD) - -$(TARGET).CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(XBEE_MODEM_PORT_LOWER) -DXBEE_UART=$(XBEE_MODEM_PORT_LOWER) -$(TARGET).CFLAGS += -DDOWNLINK_TRANSPORT=xbee_tp -DDATALINK=XBEE -$(TARGET).srcs += subsystems/datalink/downlink.c subsystems/datalink/datalink.c pprzlink/src/xbee_transport.c subsystems/datalink/telemetry.c diff --git a/conf/firmwares/test_chibios.makefile b/conf/firmwares/test_chibios.makefile index da331c3a2d..3290e3f75b 100644 --- a/conf/firmwares/test_chibios.makefile +++ b/conf/firmwares/test_chibios.makefile @@ -67,7 +67,7 @@ COMMON_TEST_CFLAGS += -DUSE_LED # pprz downlink/datalink COMMON_TELEMETRY_CFLAGS = -DDOWNLINK -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -COMMON_TELEMETRY_SRCS = subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c +COMMON_TELEMETRY_SRCS = subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c modules/datalink/pprz_dl.c COMMON_TELEMETRY_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z) COMMON_TELEMETRY_CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) diff --git a/conf/firmwares/test_progs.makefile b/conf/firmwares/test_progs.makefile index d88a435ec8..77f77de7c5 100644 --- a/conf/firmwares/test_progs.makefile +++ b/conf/firmwares/test_progs.makefile @@ -71,7 +71,7 @@ endif # pprz downlink/datalink COMMON_TELEMETRY_CFLAGS = -DDOWNLINK -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -COMMON_TELEMETRY_SRCS = subsystems/datalink/downlink.c pprzlink/src/pprz_transport.c +COMMON_TELEMETRY_SRCS = subsystems/datalink/downlink.c pprzlink/src/pprz_transport.c modules/datalink/pprz_dl.c # check if we are using UDP ifneq (,$(findstring UDP, $(MODEM_DEV))) diff --git a/conf/modules/module.dtd b/conf/modules/module.dtd index d14ca96172..979d127bc3 100644 --- a/conf/modules/module.dtd +++ b/conf/modules/module.dtd @@ -30,7 +30,8 @@ +dir CDATA #IMPLIED +task CDATA #IMPLIED> + + + + + Enable pprzlog binary prototol with downlink message system + + +
+ + + + + + + diff --git a/conf/modules/telemetry_bluegiga.xml b/conf/modules/telemetry_bluegiga.xml new file mode 100644 index 0000000000..0e701ab48b --- /dev/null +++ b/conf/modules/telemetry_bluegiga.xml @@ -0,0 +1,66 @@ + + + + + + Telemetry using PPRZ protocol over Bluegiga modules + + Bluegiga is a SPI-slave device without Chip select but with a compulsory DRDY + + Required: + BLUEGIGA_SPI_DEV: the SPI device which MUST have a SLAVE mode without chipselect + + Optional: (defaults to SUPERBITRF DRDY) + BLUEGIGA_DRDY_GPIO + BLUEGIGA_DRDY_GPIO_PIN + + On Lisa-s, the Superbit-RF module can be replaced with a bluegiga-bluetooth 4 low power board. + This module puts the telemetry over this bluetooth 4 link. + + + + + + + + +
+ +
+ + + + + include $(CFG_SHARED)/spi_master.makefile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_intermcu.xml b/conf/modules/telemetry_intermcu.xml index 6f7c3336f0..571c004264 100644 --- a/conf/modules/telemetry_intermcu.xml +++ b/conf/modules/telemetry_intermcu.xml @@ -1,6 +1,6 @@ - + Telemetry over InterMCU This module transmits Telemetry of the process "InterMCU" from AP to FBW. The FBW then transmits this telemetry further through PPRZ over an UART. diff --git a/conf/modules/telemetry_ivy.xml b/conf/modules/telemetry_ivy.xml new file mode 100644 index 0000000000..dc0b5bdb89 --- /dev/null +++ b/conf/modules/telemetry_ivy.xml @@ -0,0 +1,25 @@ + + + + + + Telemetry using IVY + + +
+ +
+ + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_nps.xml b/conf/modules/telemetry_nps.xml new file mode 100644 index 0000000000..b82f5a6179 --- /dev/null +++ b/conf/modules/telemetry_nps.xml @@ -0,0 +1,56 @@ + + + + + + Telemetry module for NPS simalation + + Currently a simple copy of telemetry UDP but only for target nps + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + include $(CFG_SHARED)/udp.makefile + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_sim.xml b/conf/modules/telemetry_sim.xml new file mode 100644 index 0000000000..7abd64cc54 --- /dev/null +++ b/conf/modules/telemetry_sim.xml @@ -0,0 +1,27 @@ + + + + + + Telemetry using IVY for basic FW simulator + + only a copy of telemetry ivy limited to sim target for now + + +
+ +
+ + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_superbitrf.xml b/conf/modules/telemetry_superbitrf.xml new file mode 100644 index 0000000000..3d73a86bf3 --- /dev/null +++ b/conf/modules/telemetry_superbitrf.xml @@ -0,0 +1,41 @@ + + + + + + Telemetry using PPRZ protocol over SuperbitRF module + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_transparent.xml b/conf/modules/telemetry_transparent.xml index 4347f63d4a..3aeb939346 100644 --- a/conf/modules/telemetry_transparent.xml +++ b/conf/modules/telemetry_transparent.xml @@ -1,16 +1,22 @@ - + Telemetry using PPRZ protocol over UART Currently used as a makefile wrapper over the telemetry_transparent subsystem - + -
+ + +
+ +
+ + @@ -21,6 +27,7 @@ + diff --git a/conf/modules/telemetry_transparent_udp.xml b/conf/modules/telemetry_transparent_udp.xml new file mode 100644 index 0000000000..6a896b59e7 --- /dev/null +++ b/conf/modules/telemetry_transparent_udp.xml @@ -0,0 +1,57 @@ + + + + + + Telemetry using PPRZ protocol over UDP + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + include $(CFG_SHARED)/udp.makefile + + + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_transparent_usb.xml b/conf/modules/telemetry_transparent_usb.xml new file mode 100644 index 0000000000..3010738b4e --- /dev/null +++ b/conf/modules/telemetry_transparent_usb.xml @@ -0,0 +1,49 @@ + + + + + + Telemetry using PPRZ protocol over serial USB (e.g. /dev/ttyACM0) + + + + +
+ +
+ + + + + + + + + + + + + + + + + + ifeq ($(ARCH), lpc21) + $(TARGET).srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c + $(TARGET).srcs += $(SRC_ARCH)/lpcusb/usbstdreq.c $(SRC_ARCH)/lpcusb/usbinit.c + endif + + + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_w5100.xml b/conf/modules/telemetry_w5100.xml new file mode 100644 index 0000000000..20075cb659 --- /dev/null +++ b/conf/modules/telemetry_w5100.xml @@ -0,0 +1,61 @@ + + + + + + Telemetry using PPRZ protocol over W5100 Wifi module + + W5100 is connected with a SPI link to the autopilot + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/conf/modules/telemetry_xbee_api.xml b/conf/modules/telemetry_xbee_api.xml new file mode 100644 index 0000000000..c951b51a85 --- /dev/null +++ b/conf/modules/telemetry_xbee_api.xml @@ -0,0 +1,47 @@ + + + + + + Telemetry using XBEE API protocol over UART + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/sw/airborne/arch/lpc21/subsystems/datalink/audio_telemetry_hw.c b/sw/airborne/arch/lpc21/subsystems/datalink/audio_telemetry_hw.c deleted file mode 100644 index 5d05ba97c9..0000000000 --- a/sw/airborne/arch/lpc21/subsystems/datalink/audio_telemetry_hw.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "audio_telemetry.h" -#include "types.h" -#include "armVIC.h" - -uint8_t audio_telemetry_nb_ovrn; -uint8_t tx_head; -volatile uint8_t tx_tail; -uint8_t tx_buf[ TX_BUF_SIZE ]; -uint8_t ck_a, ck_b; -uint8_t tx_byte; -uint8_t tx_bit_idx; - - -#define NB_STATE 2 -#define NB_PHASE 2 - -static const uint16_t audio_telemetry_sample[NB_STATE][NB_PHASE][SAMPLES_PER_PERIOD] = { - { {512, 1023, 512, 1}, - {512 , 1 , 512 , 1023} - }, - { {512, 874, 1023, 874}, - {512 , 150 , 1 , 150} - } -}; - -static uint8_t audio_telemetry_sample_idx = 0; -static uint8_t audio_telemetry_phase = 0; - - -static inline uint8_t get_next_bit(void) -{ - uint8_t ret; - /* start bit */ - if (tx_bit_idx == 0) { - ret = 0; - } - /* data bits */ - else if (tx_bit_idx < 9) { - ret = tx_byte & 0x01; - tx_byte >>= 1; - } - /* stop_bit */ - else { - ret = 1; - } - tx_bit_idx++; - - if (tx_bit_idx >= 10) { - /* if we have nothing left to transmit */ - if (tx_head == tx_tail) { - /* hack to stay with data = 1 */ - tx_bit_idx--; - } else { - /* else load next byte */ - tx_byte = tx_buf[tx_tail]; - tx_bit_idx = 0; - tx_tail++; - if (tx_tail >= TX_BUF_SIZE) { - tx_tail = 0; - } - } - } - return ret; -} - -void TIMER1_ISR(void) -{ - ISR_ENTRY(); - static uint8_t audio_telemetry_bit; - - DACR = audio_telemetry_sample[audio_telemetry_bit][audio_telemetry_phase][audio_telemetry_sample_idx] << 6; - audio_telemetry_sample_idx++; - if (audio_telemetry_sample_idx == SAMPLES_PER_PERIOD) { - audio_telemetry_sample_idx = 0; - audio_telemetry_phase ^= audio_telemetry_bit; - audio_telemetry_bit = get_next_bit(); - } - - /* clear interrupt */ - T1IR = TIR_MR0I; - VICVectAddr = 0x00000000; - ISR_EXIT(); -} - - - diff --git a/sw/airborne/arch/lpc21/subsystems/datalink/audio_telemetry_hw.h b/sw/airborne/arch/lpc21/subsystems/datalink/audio_telemetry_hw.h deleted file mode 100644 index bbb9a9f01d..0000000000 --- a/sw/airborne/arch/lpc21/subsystems/datalink/audio_telemetry_hw.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef AUDIO_TELEMETRY_HW_H -#define AUDIO_TELEMETRY_HW_H - -#include "LPC21xx.h" -#include BOARD_CONFIG - -void TIMER1_ISR(void) __attribute__((naked)); - -/* T1 prescaler, set T1_CLK to 5MHz, T1_CLK = PCLK / T1PCLK_DIV */ - -#if (PCLK == 15000000) -#define T1_PCLK_DIV 3 -#else - -#if (PCLK == 30000000) -#define T1_PCLK_DIV 6 -#else - -#if (PCLK == 60000000) -#define T1_PCLK_DIV 12 -#else - -#error unknown PCLK frequency -#endif -#endif -#endif - -#define SAMPLES_PER_PERIOD 4 -#define SAMPLE_PERIOD (PCLK/4762/SAMPLES_PER_PERIOD/T1_PCLK_DIV) - -static inline void audio_telemetry_init(void) -{ - /* turn on DAC pins */ - PINSEL1 &= 1 << 19; - PINSEL1 |= ~(1 << 18); - /* reset & disable timer 1 */ - T1TCR = TCR_RESET; - /* set the prescale divider */ - T1PR = T1_PCLK_DIV - 1; - /* select TIMER1 as IRQ */ - VICIntSelect &= ~VIC_BIT(VIC_TIMER1); - /* enable TIMER1 interrupt */ - VICIntEnable = VIC_BIT(VIC_TIMER1); - /* on slot vic slot 1 */ - VICVectCntl1 = VIC_ENABLE | VIC_TIMER1; - /* address of the ISR */ - VICVectAddr1 = (uint32_t)TIMER1_ISR; - /* trigger initial match in a long time from now */ - T1MR0 = SAMPLE_PERIOD; - /* enable interrupt on match register 0 */ - T1MCR |= TMCR_MR0_I | TMCR_MR0_R; - /* enable timer 1 */ - T1TCR = TCR_ENABLE; -} - - -#define AUDIO_TELEMETRY_CHECK_RUNNING() {} - - -#endif /* AUDIO_TELEMETRY_HW_H */ diff --git a/sw/airborne/firmwares/demo/demo_ahrs_actuators.c b/sw/airborne/firmwares/demo/demo_ahrs_actuators.c index cf2faf999e..a77de0e024 100644 --- a/sw/airborne/firmwares/demo/demo_ahrs_actuators.c +++ b/sw/airborne/firmwares/demo/demo_ahrs_actuators.c @@ -105,6 +105,8 @@ static inline void main_init(void) downlink_init(); + modules_init(); + register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AUTOPILOT_VERSION, send_autopilot_version); register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ALIVE, send_alive); register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_COMMANDS, send_commands); @@ -131,13 +133,14 @@ static inline void main_periodic_task(void) RunOnceEvery(10, { LED_PERIODIC();}); RunOnceEvery(PERIODIC_FREQUENCY, { datalink_time++; }); periodic_telemetry_send_Main(DefaultPeriodic, &(DefaultChannel).trans_tx, &(DefaultDevice).device); + + modules_periodic_task(); } static inline void main_event_task(void) { mcu_event(); modules_event_task(); - DatalinkEvent(); } static void send_alive(struct transport_tx *trans, struct link_device *dev) diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index d0516a0836..c1b452c26d 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -68,16 +68,12 @@ PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BO #include "generated/flight_plan.h" // datalink & telemetry -#if DATALINK || SITL -#include "subsystems/datalink/datalink.h" -#include "subsystems/datalink/downlink.h" -#endif #if PERIODIC_TELEMETRY #include "subsystems/datalink/telemetry.h" #endif -#include "subsystems/settings.h" // modules & settings +#include "subsystems/settings.h" #include "generated/modules.h" #include "generated/settings.h" #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1 @@ -208,9 +204,6 @@ void init_ap(void) #if defined MCU_SPI_LINK || defined MCU_UART_LINK || defined MCU_CAN_LINK link_mcu_init(); #endif -#if USE_AUDIO_TELEMETRY - audio_telemetry_init(); -#endif /************ Internal status ***************/ autopilot_init(); @@ -240,11 +233,6 @@ void init_ap(void) downlink_init(); #endif -#if defined AEROCOMM_DATA_PIN - IO0DIR |= _BV(AEROCOMM_DATA_PIN); - IO0SET = _BV(AEROCOMM_DATA_PIN); -#endif - /* set initial trim values. * these are passed to fbw via inter_mcu. */ @@ -689,8 +677,7 @@ void event_task_ap(void) BaroEvent(); #endif - DatalinkEvent(); - + modules_event_task(); #if defined MCU_SPI_LINK || defined MCU_UART_LINK link_mcu_event_task(); @@ -702,8 +689,6 @@ void event_task_ap(void) telecommand_task(); } - modules_event_task(); - #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP if (new_ins_attitude > 0) { attitude_loop(); diff --git a/sw/airborne/firmwares/fixedwing/main_chibios.c b/sw/airborne/firmwares/fixedwing/main_chibios.c index 025323cdee..d27aaa8cde 100644 --- a/sw/airborne/firmwares/fixedwing/main_chibios.c +++ b/sw/airborne/firmwares/fixedwing/main_chibios.c @@ -83,6 +83,7 @@ int main(void) } else { // but we still need downlink to be initialized downlink_init(); + modules_datalink_init(); } #endif diff --git a/sw/airborne/firmwares/rotorcraft/main.c b/sw/airborne/firmwares/rotorcraft/main.c index c2dc884f96..f727808ad9 100644 --- a/sw/airborne/firmwares/rotorcraft/main.c +++ b/sw/airborne/firmwares/rotorcraft/main.c @@ -348,8 +348,6 @@ STATIC_INLINE void main_event(void) /* event functions for mcu peripherals: i2c, usb_serial.. */ mcu_event(); - DatalinkEvent(); - if (autopilot_rc) { RadioControlEvent(autopilot_on_rc_frame); } diff --git a/sw/airborne/firmwares/setup/setup_actuators.c b/sw/airborne/firmwares/setup/setup_actuators.c index 8f8d6b82c1..5385011d7a 100644 --- a/sw/airborne/firmwares/setup/setup_actuators.c +++ b/sw/airborne/firmwares/setup/setup_actuators.c @@ -23,6 +23,7 @@ */ #define DATALINK_C +#define MODULES_C /* PERIODIC_C_MAIN is defined before generated/periodic_telemetry.h * in order to implement telemetry_mode_Main_* @@ -36,10 +37,11 @@ #include "generated/airframe.h" #include "generated/settings.h" +#include "generated/modules.h" #include "subsystems/datalink/datalink.h" #include "subsystems/datalink/downlink.h" - +#include "modules/datalink/pprz_dl.h" #include "mcu.h" #include "mcu_periph/sys_time.h" @@ -71,6 +73,7 @@ static inline void main_init(void) mcu_init(); downlink_init(); + pprz_dl_init(); actuators_init(); uint8_t i; @@ -78,6 +81,8 @@ static inline void main_init(void) //SetServo(i, 1500); } + modules_init(); + mcu_int_enable(); sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); } @@ -92,13 +97,15 @@ static inline void main_periodic(void) LED_PERIODIC(); RunOnceEvery(100, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);}); RunOnceEvery(300, DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, ACTUATORS_NB, actuators)); + + modules_periodic_task(); } static inline void main_event(void) { mcu_event(); - - DatalinkEvent(); + pprz_dl_event(); + modules_event_task(); } diff --git a/sw/airborne/firmwares/wind_tunnel/main.c b/sw/airborne/firmwares/wind_tunnel/main.c index 9338b106b0..9346a19872 100644 --- a/sw/airborne/firmwares/wind_tunnel/main.c +++ b/sw/airborne/firmwares/wind_tunnel/main.c @@ -1,3 +1,6 @@ + +#define MODULES_C + #include "std.h" #include "mcu.h" #include "mcu_periph/sys_time.h" @@ -9,6 +12,7 @@ #include "subsystems/datalink/datalink.h" #include "generated/settings.h" +#include "generated/modules.h" #include "pprzlink/dl_protocol.h" #include "wt_servo.h" @@ -51,6 +55,7 @@ static inline void main_init(void) spi_init(); wt_baro_init(); + modules_init(); mcu_int_enable(); } @@ -60,12 +65,13 @@ static inline void main_periodic_task(void) LED_TOGGLE(1); DOWNLINK_SEND_TAKEOFF(&motor_power); wt_baro_periodic(); + modules_periodic_task(); DOWNLINK_SEND_DEBUG(3, buf_input); } static inline void main_event_task(void) { - DatalinkEvent(); + modules_event_task(); // spi baro if (spi_message_received) { diff --git a/sw/airborne/firmwares/wind_tunnel/main_mb.c b/sw/airborne/firmwares/wind_tunnel/main_mb.c index 5f6d5801e9..0ce0ec18de 100644 --- a/sw/airborne/firmwares/wind_tunnel/main_mb.c +++ b/sw/airborne/firmwares/wind_tunnel/main_mb.c @@ -1,3 +1,5 @@ +#define MODULES_C + #include "std.h" #include "mcu.h" #include "mcu_periph/sys_time.h" @@ -9,6 +11,7 @@ #include "subsystems/datalink/datalink.h" #include "generated/settings.h" +#include "generated/modules.h" #include "pprzlink/dl_protocol.h" #include "i2c.h" @@ -48,6 +51,7 @@ static inline void main_init(void) mb_twi_controller_init(); mb_tacho_init(); + modules_init(); //motor_power = 0; @@ -66,14 +70,12 @@ static inline void main_periodic_task(void) float throttle = (float)wt_servo_motor_power / 1000.; mb_twi_controller_set(throttle); - + modules_periodic_task(); } static inline void main_event_task(void) { - DatalinkEvent(); - - + modules_event_task(); } diff --git a/sw/airborne/modules/datalink/bluegiga_dl.c b/sw/airborne/modules/datalink/bluegiga_dl.c new file mode 100644 index 0000000000..9915dbc96d --- /dev/null +++ b/sw/airborne/modules/datalink/bluegiga_dl.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/bluegiga_dh.c + * \brief Datalink using PPRZ protocol with Bluegiga modules + */ + +#include "modules/datalink/bluegiga_dl.h" +#include "subsystems/datalink/datalink.h" +#include "subsystems/datalink/bluegiga.h" + +struct pprz_transport pprz_bg_tp; + +void bluegiga_dl_init(void) +{ + pprz_transport_init(&pprz_bg_tp); + bluegiga_init(&bluegiga_p); +} + +void bluegiga_dl_event(void) +{ + pprz_check_and_parse(&DOWNLINK_DEVICE.device, &pprz_bg_tp, dl_buffer, &dl_msg_available); + DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_bg_tp.trans_tx, dl_buffer); +} + diff --git a/sw/airborne/modules/datalink/bluegiga_dl.h b/sw/airborne/modules/datalink/bluegiga_dl.h new file mode 100644 index 0000000000..51c7605f52 --- /dev/null +++ b/sw/airborne/modules/datalink/bluegiga_dl.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/bluegiga_dh.h + * \brief Datalink using PPRZ protocol with Bluegiga modules + */ + +#ifndef BLUEGIGA_DL_H +#define BLUEGIGA_DL_H + +#include "pprzlink/pprz_transport.h" +#include "subsystems/datalink/bluegiga.h" + +/** PPRZ transport structure */ +extern struct pprz_transport pprz_bg_tp; + +/** Init function */ +extern void bluegiga_dl_init(void); + +/** Datalink Event */ +extern void bluegiga_dl_event(void); + +#endif /* BLUEGIGA_DL_H */ + diff --git a/sw/airborne/modules/datalink/ivy_dl.c b/sw/airborne/modules/datalink/ivy_dl.c new file mode 100644 index 0000000000..52f15bd3c8 --- /dev/null +++ b/sw/airborne/modules/datalink/ivy_dl.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/ivy_dl.h + * \brief Datalink using IVY protocol + */ + +#include "modules/datalink/ivy_dl.h" +#include "subsystems/datalink/datalink.h" + +struct ivy_transport ivy_tp; + +void ivy_dl_init(void) +{ + ivy_transport_init(&ivy_tp); +} + + diff --git a/sw/airborne/modules/datalink/ivy_dl.h b/sw/airborne/modules/datalink/ivy_dl.h new file mode 100644 index 0000000000..6172846810 --- /dev/null +++ b/sw/airborne/modules/datalink/ivy_dl.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/ivy_dl.h + * \brief Datalink using IVY protocol + */ + +#ifndef IVY_DL_H +#define IVY_DL_H + +#include "pprzlink/ivy_transport.h" + +/** IVY transport structure */ +extern struct ivy_transport ivy_tp; + +/** Init function */ +extern void ivy_dl_init(void); + +#endif /* IVY_DL_H */ + diff --git a/sw/airborne/modules/datalink/pprz_dl.c b/sw/airborne/modules/datalink/pprz_dl.c new file mode 100644 index 0000000000..393d42aa9e --- /dev/null +++ b/sw/airborne/modules/datalink/pprz_dl.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/pprz_dl.h + * \brief Datalink using PPRZ protocol + */ + +#include "modules/datalink/pprz_dl.h" +#include "subsystems/datalink/datalink.h" + +struct pprz_transport pprz_tp; + +void pprz_dl_init(void) +{ + pprz_transport_init(&pprz_tp); +} + +void pprz_dl_event(void) +{ + pprz_check_and_parse(&DOWNLINK_DEVICE.device, &pprz_tp, dl_buffer, &dl_msg_available); + DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_tp.trans_tx, dl_buffer); +} + diff --git a/sw/airborne/modules/datalink/pprz_dl.h b/sw/airborne/modules/datalink/pprz_dl.h new file mode 100644 index 0000000000..f57dcdfc25 --- /dev/null +++ b/sw/airborne/modules/datalink/pprz_dl.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/pprz_dl.h + * \brief Datalink using PPRZ protocol + */ + +#ifndef PPRZ_DL_H +#define PPRZ_DL_H + +#include "pprzlink/pprz_transport.h" + +#include "mcu_periph/uart.h" +#if USE_USB_SERIAL +#include "mcu_periph/usb_serial.h" +#endif +#if USE_UDP +#include "mcu_periph/udp.h" +#endif + +/** PPRZ transport structure */ +extern struct pprz_transport pprz_tp; + +/** Init function */ +extern void pprz_dl_init(void); + +/** Datalink Event */ +extern void pprz_dl_event(void); + +#endif /* PPRZ_DL_H */ + diff --git a/sw/airborne/modules/datalink/xbee_dl.c b/sw/airborne/modules/datalink/xbee_dl.c new file mode 100644 index 0000000000..463a47955d --- /dev/null +++ b/sw/airborne/modules/datalink/xbee_dl.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/xbee_dl.h + * \brief Datalink using XBEE protocol + */ + +#include "modules/datalink/xbee_dl.h" +#include "subsystems/datalink/datalink.h" +#include "mcu.h" +#include "mcu_periph/sys_time.h" +#include "mcu_periph/uart.h" +#include "generated/airframe.h" + +#ifndef XBEE_TYPE +#define XBEE_TYPE XBEE_24 +#endif +#ifndef XBEE_INIT +#define XBEE_INIT "" +#endif + +struct xbee_transport xbee_tp; + +void xbee_dl_init(void) +{ +#if USE_HARD_FAULT_RECOVERY + if (recovering_from_hard_fault) + // in case of hardfault recovery, we want to skip xbee init which as an active wait + xbee_transport_init(&xbee_tp, &((XBEE_UART).device), AC_ID, XBEE_TYPE, XBEE_BAUD, NULL, XBEE_INIT); + else +#endif + xbee_transport_init(&xbee_tp, &((XBEE_UART).device), AC_ID, XBEE_TYPE, XBEE_BAUD, sys_time_usleep, XBEE_INIT); +} + +void xbee_dl_event(void) +{ + xbee_check_and_parse(&(XBEE_UART).device, &xbee_tp, dl_buffer, &dl_msg_available); + DlCheckAndParse(&(XBEE_UART).device, &xbee_tp.trans_tx, dl_buffer); +} + diff --git a/sw/airborne/modules/datalink/xbee_dl.h b/sw/airborne/modules/datalink/xbee_dl.h new file mode 100644 index 0000000000..3fe352faa0 --- /dev/null +++ b/sw/airborne/modules/datalink/xbee_dl.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/datalink/xbee_dl.h + * \brief Datalink using XBEE protocol + */ + +#ifndef XBEE_DL_H +#define XBEE_DL_H + +#include "pprzlink/xbee_transport.h" + +/** XBEE transport structure */ +extern struct xbee_transport xbee_tp; + +/** Init function */ +extern void xbee_dl_init(void); + +/** Datalink Event */ +extern void xbee_dl_event(void); + +#endif /* XBEE_DL_H */ + diff --git a/sw/airborne/modules/loggers/flight_recorder.c b/sw/airborne/modules/loggers/flight_recorder.c index 3eb1ac960a..b6dec34bf4 100644 --- a/sw/airborne/modules/loggers/flight_recorder.c +++ b/sw/airborne/modules/loggers/flight_recorder.c @@ -29,7 +29,7 @@ #include "subsystems/datalink/telemetry.h" #include "subsystems/datalink/downlink.h" -#include "pprzlink/pprzlog_transport.h" +#include "modules/loggers/sdlog_tp.h" #if FLIGHTRECORDER_SDLOG #include "modules/loggers/sdlog_chibios.h" diff --git a/sw/airborne/modules/loggers/sdlog_tp.c b/sw/airborne/modules/loggers/sdlog_tp.c new file mode 100644 index 0000000000..4548f12df2 --- /dev/null +++ b/sw/airborne/modules/loggers/sdlog_tp.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/loggers/sdlog_tp.h + * \brief Initialize pprzlog transport + */ + +#include "modules/loggers/sdlog_tp.h" +#include "mcu_periph/sys_time.h" + +struct pprzlog_transport pprzlog_tp; + +void pprzlog_tp_init(void) +{ + pprzlog_transport_init(&pprzlog_tp, get_sys_time_usec); +} + + diff --git a/sw/airborne/modules/loggers/sdlog_tp.h b/sw/airborne/modules/loggers/sdlog_tp.h new file mode 100644 index 0000000000..7a5e806cf6 --- /dev/null +++ b/sw/airborne/modules/loggers/sdlog_tp.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Gautier Hattenberger + * + * This file is part of paparazzi. + * + * 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, see + * . + * + */ + +/** \file modules/loggers/pprzlog_tp.h + * \brief Initialize pprzlog transport + */ + +#ifndef PPRZLOG_TP_H +#define PPRZLOG_TP_H + +#include "pprzlink/pprzlog_transport.h" + +/** PPRZLOG transport structure */ +extern struct pprzlog_transport pprzlog_tp; + +/** Init function */ +extern void pprzlog_tp_init(void); + +#endif /* PPRZLOG_TP_H */ + diff --git a/sw/airborne/modules/loggers/sdlogger_spi_direct.c b/sw/airborne/modules/loggers/sdlogger_spi_direct.c index a5b5dc668c..569c170f2e 100644 --- a/sw/airborne/modules/loggers/sdlogger_spi_direct.c +++ b/sw/airborne/modules/loggers/sdlogger_spi_direct.c @@ -31,6 +31,7 @@ #include "modules/loggers/sdlogger_spi_direct.h" #include "subsystems/datalink/downlink.h" +#include "modules/loggers/sdlog_tp.h" #include "subsystems/datalink/telemetry.h" #include "led.h" diff --git a/sw/airborne/modules/meteo/meteo_france_DAQ.c b/sw/airborne/modules/meteo/meteo_france_DAQ.c index 39230aaddf..3c3732610a 100644 --- a/sw/airborne/modules/meteo/meteo_france_DAQ.c +++ b/sw/airborne/modules/meteo/meteo_france_DAQ.c @@ -38,6 +38,7 @@ #include "subsystems/datalink/datalink.h" #include "subsystems/datalink/downlink.h" #include "modules/loggers/sdlog_chibios.h" +#include "modules/loggers/sdlog_tp.h" #include "subsystems/gps.h" #include "modules/datalink/extra_pprz_dl.h" diff --git a/sw/airborne/modules/sensors/airspeed_uADC.c b/sw/airborne/modules/sensors/airspeed_uADC.c index 90340b464c..fa5f089673 100644 --- a/sw/airborne/modules/sensors/airspeed_uADC.c +++ b/sw/airborne/modules/sensors/airspeed_uADC.c @@ -37,7 +37,7 @@ #if FLIGHTRECORDER_SDLOG #include "subsystems/datalink/telemetry.h" -#include "pprzlink/pprzlog_transport.h" +#include "modules/loggers/sdlog_tp.h" #include "modules/loggers/sdlog_chibios.h" #endif diff --git a/sw/airborne/subsystems/datalink/Makefile b/sw/airborne/subsystems/datalink/Makefile deleted file mode 100644 index f6a3891f8e..0000000000 --- a/sw/airborne/subsystems/datalink/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright (C) 2013 Gautier Hattenberger -# -# This file is part of paparazzi. -# -# 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. -# - -# -# Export downlink library source code using PPRZ transport protocol -# -# The library as to be compiled by the target application -# after implementing the dl_parse function (for parsing incoming messages) -# - -# Quiet compilation -Q=@ - -TAR= tar -INCLUDES= -I$(PAPARAZZI_SRC)/sw/include -I$(PAPARAZZI_SRC)/sw/airborne - -ifeq ($(PAPARAZZI_HOME),) -PAPARAZZI_HOME=$(PAPARAZZI_SRC) -endif - -# export in $(PAPARAZZI_HOME)/var/export/datalink -EXPORT_ROOT ?= $(PAPARAZZI_HOME)/var/export -EXPORT_DIR = $(EXPORT_ROOT)/datalink - -EXPORT_FILES = \ - downlink.h \ - downlink.c \ - pprz_transport.h \ - pprz_transport.c \ - transport.h \ - datalink.h \ - $(PAPARAZZI_SRC)/sw/include/std.h \ - $(PAPARAZZI_SRC)/sw/include/message_pragmas.h \ - $(PAPARAZZI_HOME)/var/include/messages.h \ - $(PAPARAZZI_HOME)/var/include/dl_protocol.h - -MAKEFILE_EXPORT = pprz_datalink.mk -TAR_EXPORT = pprz_datalink.tar - -all: - @cat README.md - -export_lib: - @echo Exporting datalink lib to $(EXPORT_DIR) - $(Q)test -d $(EXPORT_DIR) || mkdir -p $(EXPORT_DIR) - $(Q)cp $(EXPORT_FILES) $(EXPORT_DIR) - $(Q)cp $(MAKEFILE_EXPORT) $(EXPORT_DIR) - $(Q)cp README.md $(EXPORT_DIR) - $(Q)cd $(EXPORT_ROOT); $(TAR) -cf $(TAR_EXPORT) datalink/* - -clean: - $(Q)rm -rf $(EXPORT_DIR) - -.PHONY: all clean export_lib - diff --git a/sw/airborne/subsystems/datalink/README.md b/sw/airborne/subsystems/datalink/README.md deleted file mode 100644 index d850373558..0000000000 --- a/sw/airborne/subsystems/datalink/README.md +++ /dev/null @@ -1,181 +0,0 @@ -# Datalink library - -Datalink (uplink and downlink) lib using PPRZ protocol -====================================================== - -HOWTO export ------------- - -- Export library: in this folder (`sw/airborne/subsystems/datalink`), type - ~~~ - make export_lib - ~~~ - be sure that you have correctly build the paparazzi project (`make` in the main directory) - -- The default export directory is `${PAPARAZZI_HOME}/var/export`, to change it: - ~~~ - EXPORT_ROOT= make export_lib - ~~~ - -- `make clean` will only remove the export directory - -HOWTO use the datalink library ------------------------------- - -1. Copy the folder `datalink` in the export directory to your project directory (or untar the file `pprz_datalink.tar`) - -2. In your project makefile: - * define the variable `PPRZ_DATALINK_PORT` to your device (ex: `PPRZ_DATALINK_PORT=XXX`) - * define the variable `PPRZ_DATALINK_DIR` to your extract folder - * include the library makefile `include ${PPRZ_DATALINK_DIR}/datalink/pprz_datalink.mk` - * add `PPRZ_DATALINK_CFLAGS` to your cflags - * add `PPRZ_DATALINK_SRCS` to your sources (if your project requires a list of object files, you can use `PPRZ_DATALINK_OBJS` instead) - -3. Device interface - You need to provide an interface to send the data. If your device is named `XXX`, you need to provide the following functions or macros - * `XXXCheckFreeSpace(len)` that return true if your device has enough space for `len` bytes - * `XXXTransmit(c)` that send a single byte `c` using the device `XXX` (or store them in a buffer) - * `XXXSendMessage()` that flushs the bytes to send (if needed) - * `XXXChAvailable()` that returns true new characters are available for reading - * `XXXGetch()` taht returns the next character to parse - - Usually, an UART interface is used for datalink. - -4. Message parsing and includes: - in a C file of you project (for example a file named `datalink.c`), add the following lines: - ~~~{.c} - #define DATALINK_C 1 // this should be placed before the includes - - #inlcude "uart.h" // or change this include to the header of your actual device interface - #include "downlink.h" - - void dl_parse_msg(void) { - - } - ~~~ - You also need to poll for new characters, which means that you have to call the `DatalinkEvent()` function in your main loop. - This function is non-blocking and calls the decoder on each received byte. Finally the `dl_parse_msg` function is called when a complete message is received (checksum is valid). - -Example project for Mbeb dev board -================================== - -Test file `test_dl.cpp` (assuming you already have the Mbed library) -~~~{.c} -#include "mbed.h" - -Ticker daq; -Serial uart1(p9, p10); -DigitalOut led1(LED1); -DigitalOut led2(LED2); - -/**** PPRZ interface ****/ -#define DATALINK_C 1 -#define UartCheckFreeSpace(_len) uart1.writeable() -#define UartTransmit(_c) uart1.putc(_c) -#define UartSendMessage() {} -#define UartChAvailable() uart1.readable() -#define UartGetch() uart1.getc() - -#include "downlink.h" - -void dl_parse_msg(void) { - int msg_id = dl_buffer[1]; - - switch (msg_id) { - case DL_PONG: - led2 =! led2; // toggle led on new PONG message - break; - default: - break; - } - -} -/************************/ - -void cb() -{ - // Toggle led 1 when sending PING - led1 =! led1; - // Send PPRZ message - DOWNLINK_SEND_PING(DefaultChannel, DefaultDevice); -} - -int main() -{ - uart1.baud(57600); // set serial baud rate for PPRZ - led1 = led2 = 0; // turn off all LEDs - - daq.attach(&cb, 1); // callback - - while(1) { - - // Your (non-blocking) code - - // Poll new bytes on uart - DatalinkEvent(); - - } // ~while -} // ~main -~~~ - -With the makefile: -~~~ -# This file was automagically generated by mbed.org with PPRZ datalink library addition - -GCC_BIN = /usr/bin/ -PROJECT = Test_PPRZ_Datalink -OBJECTS = ./test_dl.o -SYS_OBJECTS = ./mbed/LPC1768/GCC_CS/sys.o ./mbed/LPC1768/GCC_CS/cmsis_nvic.o ./mbed/LPC1768/GCC_CS/system_LPC17xx.o ./mbed/LPC1768/GCC_CS/core_cm3.o ./mbed/LPC1768/GCC_CS/startup_LPC17xx.o -INCLUDE_PATHS = -I. -I./mbed -I./mbed/LPC1768 -I./mbed/LPC1768/GCC_CS -LIBRARY_PATHS = -L./mbed/LPC1768/GCC_CS -LIBRARIES = -lmbed -lcapi -LINKER_SCRIPT = ./mbed/LPC1768/GCC_CS/LPC1768.ld - -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -CC_FLAGS = -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -ONLY_C_FLAGS = -std=gnu99 -ONLY_CPP_FLAGS = -std=gnu++98 -CC_SYMBOLS = -DTARGET_LPC1768 -DTOOLCHAIN_GCC_CS -DNDEBUG - - -### PPRZ Datalink ### - -PPRZ_DATALINK_PORT = Uart -PPRZ_DATALINK_DIR = . -include $(PPRZ_DATALINK_DIR)/datalink/pprz_datalink.mk -OBJECTS += $(PPRZ_DATALINK_OBJS) -CC_SYMBOLS += $(PPRZ_DATALINK_CFLAGS) - -##################### - - -AS = $(GCC_BIN)arm-none-eabi-as - -LD = $(GCC_BIN)arm-none-eabi-gcc -LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc - -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy - -all: $(PROJECT).bin - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(OBJECTS) - -.s.o: - $(AS) $(CC_FLAGS) $(CC_SYMBOLS) -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) $(ONLY_C_FLAGS) $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) $(ONLY_CPP_FLAGS) $(INCLUDE_PATHS) -o $@ $< - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - -$(PROJECT).bin: $(PROJECT).elf - $(OBJCOPY) -O binary $< $@ -~~~ diff --git a/sw/airborne/subsystems/datalink/bluegiga.h b/sw/airborne/subsystems/datalink/bluegiga.h index 20b6355653..7fe8614141 100644 --- a/sw/airborne/subsystems/datalink/bluegiga.h +++ b/sw/airborne/subsystems/datalink/bluegiga.h @@ -28,6 +28,7 @@ #define BLUEGIGA_DATA_LINK_H #include "pprzlink/pprzlink_device.h" +#include "pprzlink/pprz_transport.h" #include "subsystems/datalink/datalink.h" /* The different statuses the communication can be in */ diff --git a/sw/airborne/subsystems/datalink/datalink.h b/sw/airborne/subsystems/datalink/datalink.h index 212ffc7e03..ee77d6b070 100644 --- a/sw/airborne/subsystems/datalink/datalink.h +++ b/sw/airborne/subsystems/datalink/datalink.h @@ -96,46 +96,4 @@ static inline void DlCheckAndParse(struct link_device *dev, struct transport_tx } } -#if defined DATALINK && DATALINK == PPRZ - -#define DatalinkEvent() { \ - pprz_check_and_parse(&(PPRZ_UART).device, &pprz_tp, dl_buffer, &dl_msg_available); \ - DlCheckAndParse(&(DOWNLINK_DEVICE).device, &pprz_tp.trans_tx, dl_buffer); \ - } - -#elif defined DATALINK && DATALINK == XBEE - -#define DatalinkEvent() { \ - xbee_check_and_parse(&(XBEE_UART).device, &xbee_tp, dl_buffer, &dl_msg_available); \ - DlCheckAndParse(&(DOWNLINK_DEVICE).device, &xbee_tp.trans_tx, dl_buffer); \ - } - -#elif defined DATALINK && DATALINK == W5100 - -#define DatalinkEvent() { \ - W5100CheckAndParse(W5100, pprz_tp); \ - DlCheckAndParse(&(DOWNLINK_DEVICE).device, &pprz_tp.trans_tx, dl_buffer); \ - } - -#elif defined DATALINK && DATALINK == SUPERBITRF - -#define DatalinkEvent() { \ - SuperbitRFCheckAndParse(); \ - DlCheckAndParse(&(DOWNLINK_DEVICE).device, &pprz_tp.trans_tx, dl_buffer); \ - } - -#elif defined DATALINK && DATALINK == BLUEGIGA - -#define DatalinkEvent() { \ - pprz_check_and_parse(&(DOWNLINK_DEVICE).device, &pprz_tp, dl_buffer, &dl_msg_available); \ - DlCheckAndParse(&(DOWNLINK_DEVICE).device, &pprz_tp.trans_tx, dl_buffer); \ - } - -#else - -// Unknown DATALINK -#define DatalinkEvent() {} - -#endif /* DATALINK == */ - #endif /* DATALINK_H */ diff --git a/sw/airborne/subsystems/datalink/downlink.c b/sw/airborne/subsystems/datalink/downlink.c index ad8af49d76..4f34cb9596 100644 --- a/sw/airborne/subsystems/datalink/downlink.c +++ b/sw/airborne/subsystems/datalink/downlink.c @@ -27,30 +27,11 @@ #include "subsystems/datalink/downlink.h" -#include "generated/airframe.h" // AC_ID is required #if (defined DATALINK) || PERIODIC_TELEMETRY #include "subsystems/datalink/datalink.h" #endif -#if USE_HARD_FAULT_RECOVERY -#include "mcu.h" -#endif - -#if defined SITL && !USE_NPS -struct ivy_transport ivy_tp; -#endif - -#if DATALINK == PPRZ || DATALINK == SUPERBITRF || DATALINK == W5100 || DATALINK == BLUEGIGA -struct pprz_transport pprz_tp; -#endif -#if DATALINK == XBEE -struct xbee_transport xbee_tp; -#endif -#if USE_PPRZLOG -struct pprzlog_transport pprzlog_tp; -#endif - #if PERIODIC_TELEMETRY #include "subsystems/datalink/telemetry.h" #include "mcu_periph/sys_time.h" @@ -91,42 +72,7 @@ void downlink_init(void) (DefaultDevice).device.nb_msgs = 0; #if defined DATALINK - datalink_nb_msgs = 0; - -#if DATALINK == PPRZ || DATALINK == SUPERBITRF || DATALINK == W5100 || DATALINK == BLUEGIGA - pprz_transport_init(&pprz_tp); -#endif -#if DATALINK == XBEE -#ifndef XBEE_TYPE -#define XBEE_TYPE XBEE_24 -#endif -#ifndef XBEE_INIT -#define XBEE_INIT "" -#endif -#if USE_HARD_FAULT_RECOVERY - if (recovering_from_hard_fault) - // in case of hardfault recovery, we want to skip xbee init which as an active wait - xbee_transport_init(&xbee_tp, &((DefaultDevice).device), AC_ID, XBEE_TYPE, XBEE_BAUD, NULL, XBEE_INIT); - else -#endif - xbee_transport_init(&xbee_tp, &((DefaultDevice).device), AC_ID, XBEE_TYPE, XBEE_BAUD, sys_time_usleep, XBEE_INIT); -#endif -#if DATALINK == W5100 - w5100_init(); -#endif -#if DATALINK == BLUEGIGA - bluegiga_init(&bluegiga_p); -#endif - -#endif - -#if USE_PPRZLOG - pprzlog_transport_init(&pprzlog_tp, get_sys_time_usec); -#endif - -#if SITL && !USE_NPS - ivy_transport_init(&ivy_tp); #endif #if PERIODIC_TELEMETRY diff --git a/sw/airborne/subsystems/datalink/downlink.h b/sw/airborne/subsystems/datalink/downlink.h index f2aed5f62b..334e2d9b2f 100644 --- a/sw/airborne/subsystems/datalink/downlink.h +++ b/sw/airborne/subsystems/datalink/downlink.h @@ -35,50 +35,8 @@ #include "pprzlink/messages.h" #include "subsystems/datalink/datalink.h" - -#if defined SITL && !USE_NPS -/** Software In The Loop simulation uses IVY bus directly as the transport layer */ -#include "pprzlink/ivy_transport.h" -extern struct ivy_transport ivy_tp; - -#else /** SITL */ - -#if DATALINK == PPRZ || DATALINK == SUPERBITRF || DATALINK == W5100 || DATALINK == BLUEGIGA -#include "pprzlink/pprz_transport.h" -extern struct pprz_transport pprz_tp; -#endif - -#if USE_PPRZLOG -#include "pprzlink/pprzlog_transport.h" -extern struct pprzlog_transport pprzlog_tp; -#endif - -#if DATALINK == XBEE -#include "pprzlink/xbee_transport.h" -extern struct xbee_transport xbee_tp; -#endif - -#if DATALINK == W5100 -#include "subsystems/datalink/w5100.h" -#endif - -#if DATALINK == BLUEGIGA -#include "subsystems/datalink/bluegiga.h" -#endif - -#if USE_SUPERBITRF -#include "subsystems/datalink/superbitrf.h" -#endif -#if USE_USB_SERIAL -#include "mcu_periph/usb_serial.h" -#endif -#ifdef USE_UDP -#include "mcu_periph/udp.h" -#endif -#include "mcu_periph/uart.h" - -#endif /** !SITL */ - +// FIXME test prog still need some includes here +#include "modules/datalink/pprz_dl.h" #ifndef DefaultChannel #define DefaultChannel DOWNLINK_TRANSPORT diff --git a/sw/airborne/subsystems/datalink/pprz_datalink.mk b/sw/airborne/subsystems/datalink/pprz_datalink.mk deleted file mode 100644 index 80e41406c7..0000000000 --- a/sw/airborne/subsystems/datalink/pprz_datalink.mk +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (C) 2013 Gautier Hattenberger -# -# This file is part of paparazzi. -# -# 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. -# - -# -# PPRZ datalink makefile to include to your project -# -# define PPRZ_DATALINK_DIR variable to your extract folder -# define PPRZ_DATALINK_PORT variable to your UART port -# add PPRZ_DATALINK_CFLAGS to your CFLAGS -# and PPRZ_DATALINK_SRCS to your sources list -# - -PPRZ_DATALINK_CFLAGS = -DPPRZ_DATALINK_EXPORT -I$(PPRZ_DATALINK_DIR)/datalink -PPRZ_DATALINK_CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(PPRZ_DATALINK_PORT) -DPPRZ_UART=$(PPRZ_DATALINK_PORT) -DDOWNLINK_TRANSPORT=PprzTransport -PPRZ_DATALINK_CFLAGS += -DDATALINK=PPRZ -PPRZ_DATALINK_SRCS = $(PPRZ_DATALINK_DIR)/datalink/downlink.c $(PPRZ_DATALINK_DIR)/datalink/pprz_transport.c -PPRZ_DATALINK_OBJS = $(PPRZ_DATALINK_SRCS:.c=.o) - diff --git a/sw/airborne/subsystems/datalink/superbitrf.c b/sw/airborne/subsystems/datalink/superbitrf.c index 65f9c3acd4..eba1ce827c 100644 --- a/sw/airborne/subsystems/datalink/superbitrf.c +++ b/sw/airborne/subsystems/datalink/superbitrf.c @@ -69,6 +69,9 @@ PRINT_CONFIG_VAR(SUPERBITRF_FORCE_DSM2) /* The superbitRF structure */ struct SuperbitRF superbitrf; +/* The pprz transport structure */ +struct pprz_transport pprz_srf_tp; + /* The internal functions */ static inline void superbitrf_radio_to_channels(uint8_t *data, uint8_t nb_channels, bool is_11bit, int16_t *channels); static inline void superbitrf_receive_packet_cb(bool error, uint8_t status, uint8_t packet[]); @@ -271,6 +274,23 @@ void superbitrf_init(void) #endif } +/** + * Initialize datalink part + */ +void superbitrf_dl_init(void) +{ + // Init pprz transport + pprz_transport_init(&pprz_srf_tp); +} + +/** + * The superbitrf datalink event call + */ +void superbitrf_dl_event(void) +{ + DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_srf_tp.trans_tx, dl_buffer); +} + void superbitrf_set_mfg_id(uint32_t id) { superbitrf.bind_mfg_id32 = id; diff --git a/sw/airborne/subsystems/datalink/superbitrf.h b/sw/airborne/subsystems/datalink/superbitrf.h index 25f0d83390..d9e462a59e 100644 --- a/sw/airborne/subsystems/datalink/superbitrf.h +++ b/sw/airborne/subsystems/datalink/superbitrf.h @@ -30,8 +30,8 @@ #include "mcu_periph/gpio.h" #include "peripherals/cyrf6936.h" #include "pprzlink/pprzlink_device.h" -#include "subsystems/datalink/datalink.h" #include "pprzlink/pprz_transport.h" +#include "subsystems/datalink/datalink.h" /* The timings in microseconds */ #define SUPERBITRF_BIND_RECV_TIME 10000 /**< The time to wait for a bind packet on a channel in microseconds */ @@ -122,9 +122,12 @@ struct SuperbitRF { extern struct SuperbitRF superbitrf; extern void superbitrf_init(void); extern void superbitrf_event(void); +extern void superbitrf_dl_init(void); +extern void superbitrf_dl_event(void); extern void superbitrf_set_mfg_id(uint32_t id); extern void superbitrf_set_protocol(uint8_t protocol); -#define SuperbitRFCheckAndParse() { } +/* The pprz transport structure */ +extern struct pprz_transport pprz_srf_tp; #endif /* DATALINK_SUPERBITRF_H */ diff --git a/sw/airborne/subsystems/datalink/w5100.c b/sw/airborne/subsystems/datalink/w5100.c index 684c0a400b..6c77b4bfdc 100644 --- a/sw/airborne/subsystems/datalink/w5100.c +++ b/sw/airborne/subsystems/datalink/w5100.c @@ -86,6 +86,7 @@ #define W5100_DRDY_GPIO_PIN GPIO1 #endif +struct pprz_w5100_tp; struct w5100_periph chip0; uint8_t ck_a, ck_b; uint8_t w5100_rx_buf[W5100_RX_BUFFER_SIZE]; @@ -257,6 +258,9 @@ void w5100_init(void) chip0.device.send_message = (send_message_t) dev_send; chip0.device.char_available = (char_available_t) dev_char_available; chip0.device.get_byte = (get_byte_t) dev_getch; + + // Init PPRZ transport + pprz_transport_init(&pprz_w5100_tp); } void w5100_transmit(uint8_t data) diff --git a/sw/airborne/subsystems/datalink/w5100.h b/sw/airborne/subsystems/datalink/w5100.h index 9eeb468680..41f294c0cb 100644 --- a/sw/airborne/subsystems/datalink/w5100.h +++ b/sw/airborne/subsystems/datalink/w5100.h @@ -29,6 +29,7 @@ #define W5100_H #include "pprzlink/pprzlink_device.h" +#include "pprzlink/pprz_transport.h" #include "subsystems/datalink/datalink.h" #include "generated/airframe.h" @@ -64,6 +65,11 @@ extern uint8_t w5100_rx_buf[W5100_RX_BUFFER_SIZE]; extern struct w5100_periph chip0; +// W5100 is using pprz_transport +// FIXME it should not appear here, this will be fixed with the rx improvements some day... +// W5100 needs a specific read_buffer function +extern struct pprz_w5100_tp; + void w5100_init(void); void w5100_transmit(uint8_t data); void w5100_transmit_buffer(uint8_t *data, uint16_t len); @@ -73,11 +79,6 @@ uint16_t w5100_rx_size(uint8_t _s); bool w5100_ch_available(void); -// W5100 is using pprz_transport -// FIXME it should not appear here, this will be fixed with the rx improvements some day... -// W5100 needs a specific read_buffer function -#include "pprzlink/pprz_transport.h" - static inline void w5100_read_buffer(struct pprz_transport *t) { while (w5100_ch_available()) { @@ -89,8 +90,6 @@ static inline void w5100_read_buffer(struct pprz_transport *t) } } -#define W5100CheckAndParse(_dev, _trans) w5100_check_and_parse(&(_dev).device, &(_trans)) - static inline void w5100_check_and_parse(struct link_device *dev, struct pprz_transport *trans) { if (dev->char_available(dev->periph)) { @@ -102,5 +101,11 @@ static inline void w5100_check_and_parse(struct link_device *dev, struct pprz_tr } } +static inline w5100_event(void) +{ + w5100_check_and_parse(&(W5100).device, &pprz_w5100_tp); + DlCheckAndParse(&(W5100).device, &pprz_w5100_tp.trans_tx, dl_buffer); +} + #endif /* W5100_H */ diff --git a/sw/airborne/subsystems/radio_control/superbitrf_rc.c b/sw/airborne/subsystems/radio_control/superbitrf_rc.c index 638db5efc0..c804fab4fe 100644 --- a/sw/airborne/subsystems/radio_control/superbitrf_rc.c +++ b/sw/airborne/subsystems/radio_control/superbitrf_rc.c @@ -31,14 +31,10 @@ INFO("Radio-Control now follows PPRZ sign convention: this means you might need /** * Initialization */ -//#if DATALINK == SUPERBITRF -//void radio_control_impl_init(void) {} -//#else void radio_control_impl_init(void) { superbitrf_init(); } -//#endif /** normalize superbitrf rc_values to radio values */ static void superbitrf_rc_normalize(int16_t *in, int16_t *out, uint8_t count) diff --git a/sw/airborne/test/mcu_periph/test_adc.c b/sw/airborne/test/mcu_periph/test_adc.c index 35e36a6112..774d623488 100644 --- a/sw/airborne/test/mcu_periph/test_adc.c +++ b/sw/airborne/test/mcu_periph/test_adc.c @@ -45,6 +45,7 @@ static inline void main_init(void) sys_time_register_timer((1. / 100), NULL); downlink_init(); adc_init(); + pprz_dl_init(); #ifdef ADC_0 adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES); diff --git a/sw/airborne/test/peripherals/test_ms2100.c b/sw/airborne/test/peripherals/test_ms2100.c index 52234ed68c..997537efb2 100644 --- a/sw/airborne/test/peripherals/test_ms2100.c +++ b/sw/airborne/test/peripherals/test_ms2100.c @@ -25,6 +25,7 @@ #include "mcu_periph/sys_time.h" #define DATALINK_C #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "peripherals/ms2100.h" #include "led.h" @@ -54,6 +55,7 @@ static inline void main_init(void) ms2100_init(&ms2100, &(MS2100_SPI_DEV), MS2100_SLAVE_IDX); downlink_init(); + pprz_dl_init(); mcu_int_enable(); } diff --git a/sw/airborne/test/subsystems/test_ahrs.c b/sw/airborne/test/subsystems/test_ahrs.c index 3e2f9557f7..e3c4c2ea35 100644 --- a/sw/airborne/test/subsystems/test_ahrs.c +++ b/sw/airborne/test/subsystems/test_ahrs.c @@ -42,6 +42,7 @@ #include "pprzlink/messages.h" #include "subsystems/datalink/downlink.h" #include "subsystems/datalink/telemetry.h" +#include "modules/datalink/pprz_dl.h" #include "subsystems/datalink/datalink.h" #include "generated/settings.h" @@ -78,6 +79,7 @@ static inline void main_init(void) ahrs_aligner_init(); #endif ahrs_init(); + pprz_dl_init(); downlink_init(); mcu_int_enable(); @@ -96,8 +98,8 @@ static inline void main_periodic_task(void) static inline void main_event_task(void) { mcu_event(); + pprz_dl_event(); modules_event_task(); - DatalinkEvent(); } static inline void main_report(void) diff --git a/sw/airborne/test/subsystems/test_imu.c b/sw/airborne/test/subsystems/test_imu.c index 9472465ddd..722f46264a 100644 --- a/sw/airborne/test/subsystems/test_imu.c +++ b/sw/airborne/test/subsystems/test_imu.c @@ -35,6 +35,7 @@ #include "mcu_periph/i2c.h" #include "pprzlink/messages.h" #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "subsystems/imu.h" #include "subsystems/abi.h" @@ -82,6 +83,7 @@ static inline void main_init(void) mcu_int_enable(); downlink_init(); + pprz_dl_init(); AbiBindMsgIMU_GYRO_INT32(ABI_BROADCAST, &gyro_ev, gyro_cb); AbiBindMsgIMU_ACCEL_INT32(ABI_BROADCAST, &accel_ev, accel_cb); diff --git a/sw/airborne/test/subsystems/test_radio_control.c b/sw/airborne/test/subsystems/test_radio_control.c index e6e173948b..67fff2eff7 100644 --- a/sw/airborne/test/subsystems/test_radio_control.c +++ b/sw/airborne/test/subsystems/test_radio_control.c @@ -25,6 +25,7 @@ #include "mcu_periph/sys_time.h" #define DATALINK_C #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "subsystems/radio_control.h" static inline void main_init(void); @@ -50,6 +51,7 @@ static inline void main_init(void) sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); radio_control_init(); downlink_init(); + pprz_dl_init(); mcu_int_enable(); } diff --git a/sw/airborne/test/subsystems/test_settings.c b/sw/airborne/test/subsystems/test_settings.c index 0aae5ff4bf..34dad7adc8 100644 --- a/sw/airborne/test/subsystems/test_settings.c +++ b/sw/airborne/test/subsystems/test_settings.c @@ -34,6 +34,7 @@ #include "mcu_periph/sys_time.h" #include "subsystems/datalink/downlink.h" #include "subsystems/datalink/datalink.h" +#include "modules/datalink/pprz_dl.h" #include "subsystems/settings.h" #include "generated/settings.h" @@ -69,6 +70,7 @@ static inline void main_init(void) mcu_init(); sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); settings_init(); + pprz_dl_init(); mcu_int_enable(); @@ -89,7 +91,7 @@ static inline void main_periodic(void) static inline void main_event(void) { mcu_event(); - DatalinkEvent(); + pprz_dl_event(); } void dl_parse_msg(struct link_device *dev __attribute__((unused)), struct transport_tx *trans __attribute__((unused)), uint8_t *buf) diff --git a/sw/airborne/test/test_actuators_pwm.c b/sw/airborne/test/test_actuators_pwm.c index 37f4ed44c6..e467537225 100644 --- a/sw/airborne/test/test_actuators_pwm.c +++ b/sw/airborne/test/test_actuators_pwm.c @@ -42,6 +42,7 @@ #include "subsystems/datalink/datalink.h" #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "mcu.h" #include "mcu_periph/sys_time.h" @@ -72,6 +73,7 @@ static inline void main_init(void) mcu_init(); sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); downlink_init(); + pprz_dl_init(); ActuatorsPwmInit(); } @@ -85,7 +87,7 @@ static inline void main_periodic(void) static inline void main_event(void) { - DatalinkEvent(); + pprz_dl_event(); } diff --git a/sw/airborne/test/test_baro_board.c b/sw/airborne/test/test_baro_board.c index 6c59483494..9403a41482 100644 --- a/sw/airborne/test/test_baro_board.c +++ b/sw/airborne/test/test_baro_board.c @@ -33,6 +33,7 @@ #define DATALINK_C #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "subsystems/sensors/baro.h" @@ -112,6 +113,7 @@ static inline void main_init(void) mcu_init(); sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); downlink_init(); + pprz_dl_init(); test_baro_board_imu_init(); baro_init(); diff --git a/sw/airborne/test/test_can.c b/sw/airborne/test/test_can.c index 277131ff6b..b8f03dc21d 100644 --- a/sw/airborne/test/test_can.c +++ b/sw/airborne/test/test_can.c @@ -29,6 +29,7 @@ #include "led.h" #define DATALINK_C #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "mcu_periph/can.h" static inline void main_init(void); @@ -70,6 +71,7 @@ static inline void main_init(void) mcu_init(); sys_time_register_timer((0.5 / PERIODIC_FREQUENCY), NULL); downlink_init(); + pprz_dl_init(); ppz_can_init((can_rx_callback_t)main_on_can_msg); } diff --git a/sw/airborne/test/test_datalink.c b/sw/airborne/test/test_datalink.c index cbf6fe66bf..b968bab8d5 100644 --- a/sw/airborne/test/test_datalink.c +++ b/sw/airborne/test/test_datalink.c @@ -30,8 +30,8 @@ #include "mcu.h" #include "mcu_periph/sys_time.h" #include "subsystems/datalink/downlink.h" - #include "subsystems/datalink/datalink.h" +#include "modules/datalink/pprz_dl.h" static inline void main_init(void); static inline void main_periodic(void); @@ -56,6 +56,7 @@ static inline void main_init(void) mcu_init(); sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); downlink_init(); + pprz_dl_init(); } static inline void main_periodic(void) @@ -66,7 +67,7 @@ static inline void main_periodic(void) static inline void main_event(void) { mcu_event(); - DatalinkEvent(); + pprz_dl_event(); } void dl_parse_msg(struct link_device *dev __attribute__((unused)), struct transport_tx *trans __attribute__((unused)), uint8_t *buf) diff --git a/sw/airborne/test/test_manual.c b/sw/airborne/test/test_manual.c index 49875165da..e244b6c82d 100644 --- a/sw/airborne/test/test_manual.c +++ b/sw/airborne/test/test_manual.c @@ -32,6 +32,7 @@ #include "subsystems/datalink/datalink.h" #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "mcu.h" #include "mcu_periph/sys_time.h" @@ -76,6 +77,7 @@ static inline void main_init(void) { mcu_init(); downlink_init(); + pprz_dl_init(); actuators_init(); #if USE_MOTOR_MIXING @@ -104,12 +106,13 @@ static inline void main_periodic(void) RunOnceEvery(100, {DOWNLINK_SEND_RC(DefaultChannel, DefaultDevice, RADIO_CONTROL_NB_CHANNEL, radio_control.values);}); RunOnceEvery(101, {DOWNLINK_SEND_COMMANDS(DefaultChannel, DefaultDevice, COMMANDS_NB, commands);}); RunOnceEvery(102, {DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, ACTUATORS_NB, actuators);}); + } static inline void main_event(void) { mcu_event(); - DatalinkEvent(); + pprz_dl_event(); RadioControlEvent(on_rc_frame); } diff --git a/sw/airborne/test/test_telemetry.c b/sw/airborne/test/test_telemetry.c index 4055e673a9..5dec5fb7cc 100644 --- a/sw/airborne/test/test_telemetry.c +++ b/sw/airborne/test/test_telemetry.c @@ -31,6 +31,7 @@ #include "mcu.h" #include "mcu_periph/sys_time.h" #include "subsystems/datalink/downlink.h" +#include "modules/datalink/pprz_dl.h" #include "led.h" static inline void main_init(void); @@ -57,6 +58,7 @@ static inline void main_init(void) mcu_int_enable(); downlink_init(); + pprz_dl_init(); } static inline void main_periodic(void) diff --git a/sw/tools/generators/gen_modules.ml b/sw/tools/generators/gen_modules.ml index e5b8eb9d79..5b403acd8b 100644 --- a/sw/tools/generators/gen_modules.ml +++ b/sw/tools/generators/gen_modules.ml @@ -116,8 +116,19 @@ let print_status = fun modules -> (Xml.children m)) modules -let print_init_functions = fun modules -> - lprintf out_h "\nstatic inline void modules_init(void) {\n"; +let modules_of_task = fun modules -> + let h = Hashtbl.create 1 in + List.iter (fun m -> + let task = ExtXml.attrib_or_default m "task" "default" in + if Hashtbl.mem h task then + Hashtbl.replace h task (List.append [m] (Hashtbl.find h task)) + else + Hashtbl.add h task [m] + ) modules; + h + +let print_init = fun task modules -> + lprintf out_h "\nstatic inline void modules_%s_init(void) {\n" task; right (); List.iter (fun m -> let module_name = ExtXml.attrib m "name" in @@ -136,13 +147,23 @@ let print_init_functions = fun modules -> left (); lprintf out_h "}\n" -let print_periodic_functions = fun modules -> +let print_init_functions = fun modules -> + let h = modules_of_task modules in + Hashtbl.iter print_init h; + lprintf out_h "\nstatic inline void modules_init(void) {\n"; + right (); + Hashtbl.iter (fun t _ -> lprintf out_h "modules_%s_init();\n" t) h; + left (); + lprintf out_h "}\n" + + +let print_periodic = fun task modules -> let min_period = 1. /. float !freq and max_period = 65536. /. float !freq and min_freq = float !freq /. 65536. and max_freq = float !freq in - lprintf out_h "\nstatic inline void modules_periodic_task(void) {\n"; + lprintf out_h "\nstatic inline void modules_%s_periodic_task(void) {\n" task; right (); (** Computes the required modulos *) let functions_modulo = List.flatten (List.map (fun m -> @@ -247,8 +268,18 @@ let print_periodic_functions = fun modules -> left (); lprintf out_h "}\n" -let print_event_functions = fun modules -> - lprintf out_h "\nstatic inline void modules_event_task(void) {\n"; +let print_periodic_functions = fun modules -> + let h = modules_of_task modules in + Hashtbl.iter print_periodic h; + lprintf out_h "\nstatic inline void modules_periodic_task(void) {\n"; + right (); + Hashtbl.iter (fun t _ -> lprintf out_h "modules_%s_periodic_task();\n" t) h; + left (); + lprintf out_h "}\n" + + +let print_event = fun task modules -> + lprintf out_h "\nstatic inline void modules_%s_event_task(void) {\n" task; right (); List.iter (fun m -> List.iter (fun i -> @@ -260,6 +291,16 @@ let print_event_functions = fun modules -> left (); lprintf out_h "}\n" +let print_event_functions = fun modules -> + let h = modules_of_task modules in + Hashtbl.iter print_event h; + lprintf out_h "\nstatic inline void modules_event_task(void) {\n"; + right (); + Hashtbl.iter (fun t _ -> lprintf out_h "modules_%s_event_task();\n" t) h; + left (); + lprintf out_h "}\n" + + let print_datalink_functions = fun modules -> lprintf out_h "\n#include \"pprzlink/messages.h\"\n"; lprintf out_h "#include \"generated/airframe.h\"\n"; @@ -283,13 +324,10 @@ let parse_modules modules = print_function_freq modules; print_status modules; nl (); - fprintf out_h "#ifdef MODULES_C\n"; print_init_functions modules; print_periodic_functions modules; print_event_functions modules; nl (); - fprintf out_h "#endif // MODULES_C\n"; - nl (); fprintf out_h "#ifdef MODULES_DATALINK_C\n"; print_datalink_functions modules; nl ();