From 000e8bc07c652b9f6bb4ad57e784dfbdf744ae01 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Tue, 7 Oct 2014 15:58:26 +0200 Subject: [PATCH] [radio control] spektrum also usable for intermcu --- conf/airframes/CDW/classix.xml | 4 +- conf/airframes/examples/separate_fbw_ap.xml | 9 ++- conf/boards/classix.makefile | 3 + .../fixedwing/intermcu_can.makefile | 9 ++- .../fixedwing/intermcu_spi.makefile | 6 +- .../fixedwing/intermcu_uart.makefile | 15 ++--- .../shared/radio_control_datalink.makefile | 60 ++++++++++--------- .../shared/radio_control_ppm.makefile | 56 +++++++++-------- .../shared/radio_control_sbus.makefile | 27 ++++++--- .../shared/radio_control_sbus_dual.makefile | 34 +++++++---- .../shared/radio_control_spektrum.makefile | 46 +++++++++----- .../radio_control_superbitrf_rc.makefile | 25 +++++--- .../subsystems/radio_control/spektrum_arch.c | 2 +- sw/airborne/inter_mcu.h | 8 --- sw/airborne/subsystems/radio_control.h | 6 +- 15 files changed, 181 insertions(+), 129 deletions(-) diff --git a/conf/airframes/CDW/classix.xml b/conf/airframes/CDW/classix.xml index 703874ace4..e8bd49ed9b 100644 --- a/conf/airframes/CDW/classix.xml +++ b/conf/airframes/CDW/classix.xml @@ -195,12 +195,9 @@ - - - @@ -212,6 +209,7 @@ + diff --git a/conf/airframes/examples/separate_fbw_ap.xml b/conf/airframes/examples/separate_fbw_ap.xml index 0fbd5590e5..67fcf963b6 100644 --- a/conf/airframes/examples/separate_fbw_ap.xml +++ b/conf/airframes/examples/separate_fbw_ap.xml @@ -253,6 +253,8 @@ + + @@ -260,8 +262,6 @@ - - @@ -270,7 +270,6 @@ - @@ -285,6 +284,10 @@ + + + + diff --git a/conf/boards/classix.makefile b/conf/boards/classix.makefile index a1af2f9b8a..6ad3d6e586 100644 --- a/conf/boards/classix.makefile +++ b/conf/boards/classix.makefile @@ -46,3 +46,6 @@ GPS_BAUD ?= B38400 # e.g. # ACTUATORS ?= actuators_pwm + +# always enable SEPARATE_FBW +SEPARATE_FBW = 1 diff --git a/conf/firmwares/subsystems/fixedwing/intermcu_can.makefile b/conf/firmwares/subsystems/fixedwing/intermcu_can.makefile index f7927f9745..98b09ecad5 100644 --- a/conf/firmwares/subsystems/fixedwing/intermcu_can.makefile +++ b/conf/firmwares/subsystems/fixedwing/intermcu_can.makefile @@ -3,10 +3,15 @@ # InterMCU type CAN ifneq ($(TARGET),sim) + +# make sure that SEPARATE_FBW is configured +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +$(error Using intermcu via CAN, so dual mcu with separate fbw. Please add ) +endif + + $(TARGET).CFLAGS += -DINTER_MCU -DMCU_CAN_LINK $(TARGET).srcs += link_mcu_can.c $(TARGET).srcs += mcu_periph/can.c $(TARGET).srcs += $(SRC_ARCH)/mcu_periph/can_arch.c endif - -SEPARATE_FBW=1 diff --git a/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile b/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile index c44b38f0b8..dc3bd353cd 100644 --- a/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile +++ b/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile @@ -2,6 +2,11 @@ # InterMCU type SPI +# make sure that SEPARATE_FBW is configured +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +$(error Using intermcu via SPI, so dual mcu with separate fbw. Please add ) +endif + ifeq ($(INTER_MCU_SPI),) INTER_MCU_SPI = SPI1 endif @@ -15,4 +20,3 @@ fbw.srcs += $(SRC_FIXEDWING)/link_mcu_spi.c mcu_periph/spi.c $(SRC_ARCH)/mcu_ ap_srcs += $(SRC_FIRMWARE)/fbw_downlink.c ap.CFLAGS += -DMCU_SPI_LINK -DUSE_$(INTER_MCU_SPI) -DSPI_MASTER -DUSE_SPI_$(INTER_MCU_SLAVE) -DUSE_SPI ap.srcs += $(SRC_FIXEDWING)/link_mcu_spi.c mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_arch.c -SEPARATE_FBW = 1 diff --git a/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile b/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile index 5052b65275..0430a139cb 100644 --- a/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile +++ b/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile @@ -2,6 +2,10 @@ # InterMCU type UART +# make sure that SEPARATE_FBW is configured +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +$(error Using intermcu via UART, so dual mcu with separate fbw. Please add ) +endif ifeq ($(TARGET),fbw) ifeq ($(INTERMCU_PORT),none) @@ -19,14 +23,3 @@ ifneq ($(TARGET),sim) $(TARGET).CFLAGS += -DINTER_MCU -DMCU_UART_LINK $(TARGET).srcs += ./link_mcu_usart.c endif - - - -############################# -# CAN: -# fbw.srcs += ./link_mcu_can.c ./mcu_periph/can.c ./arch/stm32/mcu_periph/can_arch.c -# fbw.CFLAGS += -DINTER_MCU -DMCU_CAN_LINK -# $(TARGET).CFLAGS += -DCAN_SJW_TQ=CAN_SJW_1tq -DCAN_BS1_TQ=CAN_BS1_3tq -DCAN_BS2_TQ=CAN_BS2_4tq -DCAN_PRESCALER=12 -DUSE_CAN -DUSE_CAN1 -DUSE_USB_LP_CAN1_RX0_IRQ -DCAN_ERR_RESUME=DISABLE - -SEPARATE_FBW=1 - diff --git a/conf/firmwares/subsystems/shared/radio_control_datalink.makefile b/conf/firmwares/subsystems/shared/radio_control_datalink.makefile index 9a9db15cbd..c8073f26ab 100644 --- a/conf/firmwares/subsystems/shared/radio_control_datalink.makefile +++ b/conf/firmwares/subsystems/shared/radio_control_datalink.makefile @@ -1,36 +1,38 @@ # Hey Emacs, this is a -*- makefile -*- -NORADIO = False - -ifeq ($(BOARD),classix) - ifeq ($(TARGET),ap) - NORADIO = True - endif -endif - RADIO_CONTROL_DATALINK_LED ?= none RADIO_CONTROL_LED ?= none -ifeq ($(NORADIO), False) - ifneq ($(RADIO_CONTROL_DATALINK_LED),none) - RC_CFLAGS += -DRADIO_CONTROL_DATALINK_LED=$(RADIO_CONTROL_DATALINK_LED) - endif - ifneq ($(RADIO_CONTROL_LED),none) - RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) - fbw.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) - endif - $(TARGET).CFLAGS += -DRADIO_CONTROL - $(TARGET).CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/rc_datalink.h\" - $(TARGET).CFLAGS += -DRADIO_CONTROL_TYPE_DATALINK - $(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control.c - $(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control/rc_datalink.c -# arch only with sim target for compatibility (empty functions) - sim.srcs += $(SRC_ARCH)/subsystems/radio_control/rc_datalink.c - - ap.CFLAGS += $(RC_CFLAGS) - ap.srcs += $(RC_SRCS) - - test_radio_control.CFLAGS += $(RC_CFLAGS) - test_radio_control.srcs += $(RC_SRCS) +ifneq ($(RADIO_CONTROL_DATALINK_LED),none) +RC_CFLAGS += -DRADIO_CONTROL_DATALINK_LED=$(RADIO_CONTROL_DATALINK_LED) endif + +ifneq ($(RADIO_CONTROL_LED),none) +RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) +RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) +endif + +RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/rc_datalink.h\" + +RC_FBW_CFLAGS += -DRADIO_CONTROL +RC_FBW_CFLAGS += -DRADIO_CONTROL_TYPE_DATALINK +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control.c +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control/rc_datalink.c + + +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +# Single MCU's run RC on ap target +$(TARGET).CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +$(TARGET).srcs += $(RC_SRCS) +else +# Dual MCU case +fbw.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +fbw.srcs += $(RC_SRCS) +# define RADIO_CONTROL_TYPE for ap in dual_mcu case to get defines +# but don't add source files +ap.CFLAGS += $(RC_CFLAGS) +endif + +# arch only with sim target for compatibility (empty functions) +sim.srcs += $(SRC_ARCH)/subsystems/radio_control/rc_datalink.c diff --git a/conf/firmwares/subsystems/shared/radio_control_ppm.makefile b/conf/firmwares/subsystems/shared/radio_control_ppm.makefile index b045831d8e..605e3a2163 100644 --- a/conf/firmwares/subsystems/shared/radio_control_ppm.makefile +++ b/conf/firmwares/subsystems/shared/radio_control_ppm.makefile @@ -2,37 +2,43 @@ # Makefile for shared radio_control ppm subsystem # -NORADIO = False RADIO_CONTROL_LED ?= none -ifeq ($(BOARD),classix) - ifeq ($(TARGET),ap) - NORADIO = True +ifneq ($(RADIO_CONTROL_LED),none) +RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) +endif + +RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/ppm.h\" + +RC_FBW_CFLAGS += -DRADIO_CONTROL +RC_FBW_CFLAGS += -DRADIO_CONTROL_TYPE_PPM + +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control.c +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control/ppm.c +RC_SRCS += $(SRC_ARCH)/subsystems/radio_control/ppm_arch.c + +ifeq ($(ARCH),stm32) + ifdef RADIO_CONTROL_PPM_PIN + ifeq ($(RADIO_CONTROL_PPM_PIN),$(filter $(RADIO_CONTROL_PPM_PIN),PA_10 UART1_RX)) + $(TARGET).CFLAGS += -DPPM_CONFIG=1 + else ifeq ($(RADIO_CONTROL_PPM_PIN),$(filter $(RADIO_CONTROL_PPM_PIN),PA_01 SERVO6)) + $(TARGET).CFLAGS += -DPPM_CONFIG=2 + endif endif endif -ifeq ($(NORADIO), False) - $(TARGET).CFLAGS += -DRADIO_CONTROL - ifneq ($(RADIO_CONTROL_LED),none) - ap.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) - fbw.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) - test_radio_control.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) - endif - $(TARGET).CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/ppm.h\" - $(TARGET).CFLAGS += -DRADIO_CONTROL_TYPE_PPM - $(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control.c - $(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control/ppm.c - $(TARGET).srcs += $(SRC_ARCH)/subsystems/radio_control/ppm_arch.c - ifeq ($(ARCH),stm32) - ifdef RADIO_CONTROL_PPM_PIN - ifeq ($(RADIO_CONTROL_PPM_PIN),$(filter $(RADIO_CONTROL_PPM_PIN),PA_10 UART1_RX)) - $(TARGET).CFLAGS += -DPPM_CONFIG=1 - else ifeq ($(RADIO_CONTROL_PPM_PIN),$(filter $(RADIO_CONTROL_PPM_PIN),PA_01 SERVO6)) - $(TARGET).CFLAGS += -DPPM_CONFIG=2 - endif - endif - endif +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +# Single MCU's run RC on ap target +$(TARGET).CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +$(TARGET).srcs += $(RC_SRCS) +else +# Dual MCU case +fbw.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +fbw.srcs += $(RC_SRCS) +# define RADIO_CONTROL_TYPE for ap in dual_mcu case to get defines +# but don't add source files +ap.CFLAGS += $(RC_CFLAGS) endif # dummy stuff so you don't have to unload superbitrf.xml settings file for simulators diff --git a/conf/firmwares/subsystems/shared/radio_control_sbus.makefile b/conf/firmwares/subsystems/shared/radio_control_sbus.makefile index 8d977522eb..a0a5911324 100644 --- a/conf/firmwares/subsystems/shared/radio_control_sbus.makefile +++ b/conf/firmwares/subsystems/shared/radio_control_sbus.makefile @@ -8,22 +8,31 @@ ifneq ($(RADIO_CONTROL_LED),none) RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) endif -$(TARGET).CFLAGS += -DRADIO_CONTROL +RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/sbus.h\" + +RC_FBW_CFLAGS += -DRADIO_CONTROL # convert SBUS_PORT to upper and lower case strings: SBUS_PORT_UPPER=$(shell echo $(SBUS_PORT) | tr a-z A-Z) SBUS_PORT_LOWER=$(shell echo $(SBUS_PORT) | tr A-Z a-z) -RC_CFLAGS += -DUSE_$(SBUS_PORT_UPPER) -D$(SBUS_PORT_UPPER)_BAUD=B100000 -RC_CFLAGS += -DSBUS_UART_DEV=$(SBUS_PORT_LOWER) -RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/sbus.h\" -RC_CFLAGS += -DRADIO_CONTROL_TYPE_SBUS +RC_FBW_CFLAGS += -DUSE_$(SBUS_PORT_UPPER) -D$(SBUS_PORT_UPPER)_BAUD=B100000 +RC_FBW_CFLAGS += -DSBUS_UART_DEV=$(SBUS_PORT_LOWER) +RC_FBW_CFLAGS += -DRADIO_CONTROL_TYPE_SBUS RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control.c RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control/sbus.c RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control/sbus_common.c -ap.CFLAGS += $(RC_CFLAGS) -ap.srcs += $(RC_SRCS) -test_radio_control.CFLAGS += $(RC_CFLAGS) -test_radio_control.srcs += $(RC_SRCS) +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +# Single MCU's run RC on ap target +$(TARGET).CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +$(TARGET).srcs += $(RC_SRCS) +else +# Dual MCU case +fbw.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +fbw.srcs += $(RC_SRCS) +# define RADIO_CONTROL_TYPE for ap in dual_mcu case to get defines +# but don't add source files +ap.CFLAGS += $(RC_CFLAGS) +endif diff --git a/conf/firmwares/subsystems/shared/radio_control_sbus_dual.makefile b/conf/firmwares/subsystems/shared/radio_control_sbus_dual.makefile index fadeecd5bf..2a38812ff5 100644 --- a/conf/firmwares/subsystems/shared/radio_control_sbus_dual.makefile +++ b/conf/firmwares/subsystems/shared/radio_control_sbus_dual.makefile @@ -14,8 +14,9 @@ ifneq ($(RADIO_CONTROL_LED),none) ap.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) endif -$(TARGET).CFLAGS += -DRADIO_CONTROL +RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/sbus.h\" +RC_FBW_CFLAGS += -DRADIO_CONTROL # convert SBUS_PORT to upper and lower case strings: SBUS1_PORT_UPPER=$(shell echo $(SBUS1_PORT) | tr a-z A-Z) @@ -23,13 +24,26 @@ SBUS1_PORT_LOWER=$(shell echo $(SBUS1_PORT) | tr A-Z a-z) SBUS2_PORT_UPPER=$(shell echo $(SBUS2_PORT) | tr a-z A-Z) SBUS2_PORT_LOWER=$(shell echo $(SBUS2_PORT) | tr A-Z a-z) -$(TARGET).CFLAGS += -DUSE_$(SBUS1_PORT_UPPER) -D$(SBUS1_PORT_UPPER)_BAUD=B100000 -$(TARGET).CFLAGS += -DUSE_$(SBUS2_PORT_UPPER) -D$(SBUS2_PORT_UPPER)_BAUD=B100000 -$(TARGET).CFLAGS += -DSBUS1_UART_DEV=$(SBUS1_PORT_LOWER) -$(TARGET).CFLAGS += -DSBUS2_UART_DEV=$(SBUS2_PORT_LOWER) -$(TARGET).CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/sbus_dual.h\" -$(TARGET).CFLAGS += -DRADIO_CONTROL_TYPE_SBUS -$(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control.c -$(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control/sbus_dual.c -$(TARGET).srcs += $(SRC_SUBSYSTEMS)/radio_control/sbus_common.c +RC_FBW_CFLAGS += -DUSE_$(SBUS1_PORT_UPPER) -D$(SBUS1_PORT_UPPER)_BAUD=B100000 +RC_FBW_CFLAGS += -DUSE_$(SBUS2_PORT_UPPER) -D$(SBUS2_PORT_UPPER)_BAUD=B100000 +RC_FBW_CFLAGS += -DSBUS1_UART_DEV=$(SBUS1_PORT_LOWER) +RC_FBW_CFLAGS += -DSBUS2_UART_DEV=$(SBUS2_PORT_LOWER) +RC_FBW_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/sbus_dual.h\" +RC_FBW_CFLAGS += -DRADIO_CONTROL_TYPE_SBUS +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control.c +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control/sbus_dual.c +RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control/sbus_common.c + +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +# Single MCU's run RC on ap target +$(TARGET).CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +$(TARGET).srcs += $(RC_SRCS) +else +# Dual MCU case +fbw.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +fbw.srcs += $(RC_SRCS) +# define RADIO_CONTROL_TYPE for ap in dual_mcu case to get defines +# but don't add source files +ap.CFLAGS += $(RC_CFLAGS) +endif diff --git a/conf/firmwares/subsystems/shared/radio_control_spektrum.makefile b/conf/firmwares/subsystems/shared/radio_control_spektrum.makefile index e7af64351e..9ae8199429 100644 --- a/conf/firmwares/subsystems/shared/radio_control_spektrum.makefile +++ b/conf/firmwares/subsystems/shared/radio_control_spektrum.makefile @@ -4,26 +4,29 @@ RADIO_CONTROL_LED ?= none -ifndef RADIO_CONTROL_SPEKTRUM_MODEL -RADIO_CONTROL_SPEKTRUM_MODEL=\"subsystems/radio_control/spektrum_dx7se.h\" -endif - -RC_CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_BIND_IMPL_FUNC=radio_control_spektrum_try_bind -RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/spektrum.h\" -ifeq ($(ARCH), lpc21) -RC_CFLAGS += -DRADIO_CONTROL_SPEKTRUM_MODEL_H=$(RADIO_CONTROL_SPEKTRUM_MODEL) -endif ifneq ($(RADIO_CONTROL_LED),none) RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) endif -RC_CFLAGS += -DRADIO_CONTROL_SPEKTRUM_PRIMARY_PORT=SPEKTRUM_$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT) -RC_CFLAGS += -DOVERRIDE_$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)_IRQ_HANDLER + +RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/spektrum.h\" + +ifeq ($(ARCH), lpc21) +ifndef RADIO_CONTROL_SPEKTRUM_MODEL +RADIO_CONTROL_SPEKTRUM_MODEL=\"subsystems/radio_control/spektrum_dx7se.h\" +endif +RC_CFLAGS += -DRADIO_CONTROL_SPEKTRUM_MODEL_H=$(RADIO_CONTROL_SPEKTRUM_MODEL) +endif + +RC_FBW_CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_BIND_IMPL_FUNC=radio_control_spektrum_try_bind + +RC_FBW_CFLAGS += -DRADIO_CONTROL_SPEKTRUM_PRIMARY_PORT=SPEKTRUM_$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT) +RC_FBW_CFLAGS += -DOVERRIDE_$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)_IRQ_HANDLER # enable the second spektrum port if so configured ifdef USE_SECONDARY_SPEKTRUM_RECEIVER ifneq ($(USE_SECONDARY_SPEKTRUM_RECEIVER),0) -RC_CFLAGS += -DRADIO_CONTROL_SPEKTRUM_SECONDARY_PORT=SPEKTRUM_$(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT) -RC_CFLAGS += -DOVERRIDE_$(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT)_IRQ_HANDLER +RC_FBW_CFLAGS += -DRADIO_CONTROL_SPEKTRUM_SECONDARY_PORT=SPEKTRUM_$(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT) +RC_FBW_CFLAGS += -DOVERRIDE_$(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT)_IRQ_HANDLER endif endif @@ -31,8 +34,19 @@ RC_SRCS += $(SRC_SUBSYSTEMS)/radio_control.c \ $(SRC_SUBSYSTEMS)/radio_control/spektrum.c \ $(SRC_ARCH)/subsystems/radio_control/spektrum_arch.c -$(TARGET).CFLAGS += $(RC_CFLAGS) -$(TARGET).srcs += $(RC_SRCS) -test_radio_control.CFLAGS += $(RC_CFLAGS) +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +# Single MCU's run RC on ap target +$(TARGET).CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +$(TARGET).srcs += $(RC_SRCS) +else +# Dual MCU case +fbw.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +fbw.srcs += $(RC_SRCS) +# define RADIO_CONTROL_TYPE for ap in dual_mcu case to get defines +# but don't add source files +ap.CFLAGS += $(RC_CFLAGS) +endif + +test_radio_control.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) test_radio_control.srcs += $(RC_SRCS) diff --git a/conf/firmwares/subsystems/shared/radio_control_superbitrf_rc.makefile b/conf/firmwares/subsystems/shared/radio_control_superbitrf_rc.makefile index bd409765fc..a4b5c66a61 100644 --- a/conf/firmwares/subsystems/shared/radio_control_superbitrf_rc.makefile +++ b/conf/firmwares/subsystems/shared/radio_control_superbitrf_rc.makefile @@ -3,21 +3,30 @@ # RADIO_CONTROL_LED ?= none - -RC_CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE_SUPERBITRF -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/superbitrf_rc.h\" -RC_CFLAGS += -DUSE_SUPERBITRF -DUSE_SPI2 -DUSE_SPI_SLAVE2 - ifneq ($(RADIO_CONTROL_LED),none) RC_CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) endif +RC_CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/superbitrf_rc.h\" + +RC_FBW_CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE_SUPERBITRF +RC_FBW_CFLAGS += -DUSE_SUPERBITRF -DUSE_SPI2 -DUSE_SPI_SLAVE2 + RC_SRCS += peripherals/cyrf6936.c \ $(SRC_SUBSYSTEMS)/datalink/superbitrf.c\ $(SRC_SUBSYSTEMS)/radio_control.c \ $(SRC_SUBSYSTEMS)/radio_control/superbitrf_rc.c -ap.CFLAGS += $(RC_CFLAGS) -ap.srcs += $(RC_SRCS) -test_radio_control.CFLAGS += $(RC_CFLAGS) -test_radio_control.srcs += $(RC_SRCS) +ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE)) +# Single MCU's run RC on ap target +$(TARGET).CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +$(TARGET).srcs += $(RC_SRCS) +else +# Dual MCU case +fbw.CFLAGS += $(RC_CFLAGS) $(RC_FBW_CFLAGS) +fbw.srcs += $(RC_SRCS) +# define RADIO_CONTROL_TYPE for ap in dual_mcu case to get defines +# but don't add source files +ap.CFLAGS += $(RC_CFLAGS) +endif diff --git a/sw/airborne/arch/sim/subsystems/radio_control/spektrum_arch.c b/sw/airborne/arch/sim/subsystems/radio_control/spektrum_arch.c index 23a3a20f16..19304f2eba 100644 --- a/sw/airborne/arch/sim/subsystems/radio_control/spektrum_arch.c +++ b/sw/airborne/arch/sim/subsystems/radio_control/spektrum_arch.c @@ -28,7 +28,7 @@ #include "subsystems/radio_control.h" #include "subsystems/radio_control/spektrum.h" - +#include "std.h" #include #if USE_NPS diff --git a/sw/airborne/inter_mcu.h b/sw/airborne/inter_mcu.h index ef7f1e3183..660ca33f54 100644 --- a/sw/airborne/inter_mcu.h +++ b/sw/airborne/inter_mcu.h @@ -45,14 +45,6 @@ #include "subsystems/electrical.h" #include "firmwares/fixedwing/main_fbw.h" -#ifndef SINGLE_MCU -// If radio_control defines -#ifdef RADIO_CONTROL_NB_CHANNEL -#undef RADIO_CONTROL_NB_CHANNEL -#endif -#include "generated/radio.h" -#define RADIO_CONTROL_NB_CHANNEL RADIO_CTL_NB -#endif /** Data structure shared by fbw and ap processes */ struct fbw_state { diff --git a/sw/airborne/subsystems/radio_control.h b/sw/airborne/subsystems/radio_control.h index 57ab32eff5..6d0543d6e4 100644 --- a/sw/airborne/subsystems/radio_control.h +++ b/sw/airborne/subsystems/radio_control.h @@ -23,14 +23,14 @@ #ifndef RADIO_CONTROL_H #define RADIO_CONTROL_H -#if defined RADIO_CONTROL - #include "led.h" #include "generated/airframe.h" #include "paparazzi.h" -/* underlying hardware */ +/* underlying hardware, also include if RADIO_CONTROL is not defined for ap in dual mcu case */ #include RADIO_CONTROL_TYPE_H + +#if defined RADIO_CONTROL /* must be defined by underlying hardware */ extern void radio_control_impl_init(void); /* RADIO_CONTROL_NB_CHANNEL has to be defined by the implementation */