Skip to content

Commit cebc906

Browse files
committed
Refactor OMNIBUSF4 targets into separate directories
Split OMNIBUSF4 mega-target into 4 directories to improve maintainability: - DYSF4: DYSF4PRO, DYSF4PROV2 - OMNIBUSF4: Base OMNIBUSF4 variant only - OMNIBUSF4PRO: OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM - OMNIBUSF4V3_SS: Softserial variants (S6_SS, S5S6_SS, S5_S6_2SS) Each directory now contains only the code relevant to its variants, with irrelevant preprocessor conditionals removed. Changes: - Reduced DYSF4/target.h from 271 to 169 lines (37% reduction) - Reduced preprocessor conditionals from 18 to 4 in DYSF4 files - All 11 targets build successfully and produce identical binaries
1 parent 3c4b8ff commit cebc906

File tree

10 files changed

+789
-10
lines changed

10 files changed

+789
-10
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target_stm32f405xg(DYSF4PRO)
2+
target_stm32f405xg(DYSF4PROV2)

src/main/target/DYSF4/target.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* This file is part of Cleanflight.
3+
*
4+
* Cleanflight is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Cleanflight is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include <stdint.h>
19+
20+
#include <platform.h>
21+
#include "drivers/io.h"
22+
#include "drivers/pwm_mapping.h"
23+
#include "drivers/timer.h"
24+
#include "drivers/bus.h"
25+
26+
timerHardware_t timerHardware[] = {
27+
28+
DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // S1_OUT D1_ST7
29+
DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S2_OUT D1_ST2
30+
DEF_TIM(TIM2, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 1), // S3_OUT D1_ST6
31+
DEF_TIM(TIM2, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0), // S4_OUT D1_ST1
32+
33+
// { TIM9, IO_TAG(PA3), TIM_Channel_2, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM9, TIM_USE_OUTPUT_AUTO }, // MOTOR_3
34+
DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 0), // S5_OUT MOTOR, SERVO or LED
35+
DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0), // S6_OUT
36+
37+
38+
// DEF_TIM(TIM12, CH1, PB14, TIM_USE_PPM, 0, 0), // PPM
39+
DEF_TIM(TIM12, CH2, PB15, TIM_USE_ANY, 0, 0), // S2_IN
40+
DEF_TIM(TIM8, CH1, PC6, TIM_USE_ANY, 0, 0), // S3_IN, UART6_TX
41+
DEF_TIM(TIM8, CH2, PC7, TIM_USE_ANY, 0, 0), // S4_IN, UART6_RX
42+
DEF_TIM(TIM8, CH3, PC8, TIM_USE_ANY, 0, 0), // S5_IN // pad labelled CH5 on OMNIBUSF4PRO
43+
DEF_TIM(TIM8, CH4, PC9, TIM_USE_ANY, 0, 0), // S6_IN // pad labelled CH6 on OMNIBUSF4PRO
44+
45+
};
46+
47+
const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]);

src/main/target/DYSF4/target.h

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
* This file is part of Cleanflight.
3+
*
4+
* Cleanflight is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Cleanflight is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#pragma once
19+
20+
//Same target as OMNIBUSF4PRO with LED strip in M5
21+
//Same target as OMNIBUSF4V3 with softserial in M5 and M6
22+
23+
#if defined(DYSF4PRO)
24+
#define TARGET_BOARD_IDENTIFIER "DYS4"
25+
#elif defined(DYSF4PROV2)
26+
#define TARGET_BOARD_IDENTIFIER "DY42"
27+
#else
28+
#define TARGET_BOARD_IDENTIFIER "OBF4"
29+
#endif
30+
31+
#if defined(DYSF4PRO) || defined(DYSF4PROV2)
32+
#define USBD_PRODUCT_STRING "DysF4Pro"
33+
#else
34+
#define USBD_PRODUCT_STRING "Omnibus F4"
35+
#endif
36+
37+
#define LED0 PB5
38+
39+
#define BEEPER PB4
40+
#define BEEPER_INVERTED
41+
42+
#if defined(DYSF4PROV2)
43+
#define USE_I2C
44+
#define USE_I2C_DEVICE_1
45+
#define I2C1_SCL PB8
46+
#define I2C1_SDA PB9
47+
#define I2C_EXT_BUS BUS_I2C1
48+
#else
49+
#define USE_I2C
50+
#define USE_I2C_DEVICE_2
51+
#define I2C_DEVICE_2_SHARES_UART3
52+
#define I2C_EXT_BUS BUS_I2C2
53+
#endif
54+
55+
#define UG2864_I2C_BUS I2C_EXT_BUS
56+
57+
#define MPU6000_CS_PIN PA4
58+
#define MPU6000_SPI_BUS BUS_SPI1
59+
60+
#define USE_IMU_MPU6000
61+
#define IMU_MPU6000_ALIGN CW180_DEG
62+
63+
// Support for OMNIBUS F4 PRO CORNER - it has ICM20608 instead of MPU6000
64+
65+
#define USE_MAG
66+
#define MAG_I2C_BUS I2C_EXT_BUS
67+
#define USE_MAG_ALL
68+
69+
#define TEMPERATURE_I2C_BUS I2C_EXT_BUS
70+
71+
#define USE_BARO
72+
73+
#define BARO_I2C_BUS I2C_EXT_BUS
74+
#define USE_BARO_BMP085
75+
#define USE_BARO_BMP280
76+
#define USE_BARO_MS5611
77+
78+
#define PITOT_I2C_BUS I2C_EXT_BUS
79+
80+
#define USE_RANGEFINDER
81+
#define RANGEFINDER_I2C_BUS I2C_EXT_BUS
82+
83+
#define USE_VCP
84+
#define VBUS_SENSING_PIN PC5
85+
#define VBUS_SENSING_ENABLED
86+
87+
88+
#define USE_UART1
89+
#define UART1_RX_PIN PA10
90+
#define UART1_TX_PIN PA9
91+
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
92+
93+
#define USE_UART3
94+
#define UART3_RX_PIN PB11
95+
#define UART3_TX_PIN PB10
96+
97+
#define USE_UART6
98+
#define UART6_RX_PIN PC7
99+
#define UART6_TX_PIN PC6
100+
101+
#define USE_SOFTSERIAL1
102+
#define SOFTSERIAL_1_RX_PIN PC8 // pad labelled CH5 on OMNIBUSF4PRO
103+
#define SOFTSERIAL_1_TX_PIN PC9 // pad labelled CH6 on OMNIBUSF4PRO
104+
105+
#define SERIAL_PORT_COUNT 5 // VCP, USART1, USART3, USART6, SOFTSERIAL1
106+
107+
#define DEFAULT_RX_TYPE RX_TYPE_SERIAL
108+
#define SERIALRX_PROVIDER SERIALRX_SBUS
109+
#define SERIALRX_UART SERIAL_PORT_USART1
110+
111+
#define USE_SPI
112+
113+
#define USE_SPI_DEVICE_1
114+
115+
116+
#define USE_SPI_DEVICE_3
117+
#define SPI3_NSS_PIN PB3
118+
#define SPI3_SCK_PIN PC10
119+
#define SPI3_MISO_PIN PC11
120+
#define SPI3_MOSI_PIN PC12
121+
122+
#define USE_MAX7456
123+
#define MAX7456_SPI_BUS BUS_SPI3
124+
#define MAX7456_CS_PIN PA15
125+
126+
#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
127+
#define M25P16_CS_PIN SPI3_NSS_PIN
128+
#define M25P16_SPI_BUS BUS_SPI3
129+
#define USE_FLASHFS
130+
#define USE_FLASH_M25P16
131+
132+
#define USE_ADC
133+
#define ADC_CHANNEL_1_PIN PC1
134+
#define ADC_CHANNEL_2_PIN PC2
135+
136+
#ifdef DYSF4PRO
137+
#define ADC_CHANNEL_3_PIN PC3
138+
#else
139+
#define ADC_CHANNEL_3_PIN PA0
140+
#endif
141+
142+
#define CURRENT_METER_ADC_CHANNEL ADC_CHN_1
143+
#define VBAT_ADC_CHANNEL ADC_CHN_2
144+
#define RSSI_ADC_CHANNEL ADC_CHN_3
145+
146+
#define SENSORS_SET (SENSOR_ACC|SENSOR_MAG|SENSOR_BARO)
147+
148+
#define USE_LED_STRIP
149+
#define WS2811_PIN PA1
150+
151+
#define DISABLE_RX_PWM_FEATURE
152+
#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX | FEATURE_VBAT | FEATURE_OSD)
153+
154+
#define USE_SPEKTRUM_BIND
155+
#define BIND_PIN PB11 // USART3 RX
156+
157+
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
158+
159+
// Number of available PWM outputs
160+
#define MAX_PWM_OUTPUT_PORTS 6
161+
#define TARGET_MOTOR_COUNT 6
162+
#define USE_DSHOT
163+
#define USE_ESC_SENSOR
164+
165+
#define TARGET_IO_PORTA 0xffff
166+
#define TARGET_IO_PORTB 0xffff
167+
#define TARGET_IO_PORTC 0xffff
168+
#define TARGET_IO_PORTD 0xffff
169+
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
target_stm32f405xg(DYSF4PRO)
2-
target_stm32f405xg(DYSF4PROV2)
31
target_stm32f405xg(OMNIBUSF4)
4-
# the OMNIBUSF4SD has an SDCARD instead of flash, a BMP280 baro and therefore a slightly different ppm/pwm and SPI mapping
5-
target_stm32f405xg(OMNIBUSF4PRO)
6-
target_stm32f405xg(OMNIBUSF4V3_S5_S6_2SS)
7-
target_stm32f405xg(OMNIBUSF4V3_S5S6_SS)
8-
target_stm32f405xg(OMNIBUSF4V3_S6_SS)
9-
# OMNIBUSF4V3 is a (almost identical) variant of OMNIBUSF4PRO target,
10-
# except for an inverter on UART6.
11-
target_stm32f405xg(OMNIBUSF4V3)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# OMNIBUSF4PRO has SD card, BMP280 baro
2+
target_stm32f405xg(OMNIBUSF4PRO)
3+
# OMNIBUSF4V3 is similar to PRO but with UART6 inverter
4+
target_stm32f405xg(OMNIBUSF4V3)
5+
target_stm32f405xg(OMNIBUSF4V3_ICM SKIP_RELEASES)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* This file is part of Cleanflight.
3+
*
4+
* Cleanflight is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Cleanflight is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include <stdint.h>
19+
20+
#include <platform.h>
21+
#include "drivers/io.h"
22+
#include "drivers/pwm_mapping.h"
23+
#include "drivers/timer.h"
24+
#include "drivers/bus.h"
25+
26+
timerHardware_t timerHardware[] = {
27+
28+
DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // S1_OUT D1_ST7
29+
DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S2_OUT D1_ST2
30+
DEF_TIM(TIM2, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 1), // S3_OUT D1_ST6
31+
DEF_TIM(TIM2, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0), // S4_OUT D1_ST1
32+
33+
// { TIM9, IO_TAG(PA3), TIM_Channel_2, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM9, TIM_USE_OUTPUT_AUTO }, // MOTOR_3
34+
#if (defined(OMNIBUSF4PRO) || defined(OMNIBUSF4V3)) && !(defined(OMNIBUSF4PRO_LEDSTRIPM5) || defined(OMNIBUSF4V3_S6_SS) || defined(OMNIBUSF4V3_S5S6_SS) || defined(OMNIBUSF4V3_S5_S6_2SS))
35+
36+
DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 0), // S5_OUT
37+
DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0), // S6_OUT
38+
#else
39+
DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 0), // S5_OUT MOTOR, SERVO or LED
40+
DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0), // S6_OUT
41+
#endif
42+
43+
#if (defined(OMNIBUSF4PRO) || defined(OMNIBUSF4V3))
44+
DEF_TIM(TIM4, CH1, PB6, TIM_USE_LED, 0, 0), // LED strip for F4 V2 / F4-Pro-0X and later (RCD_CS for F4)
45+
#endif
46+
47+
#if defined(OMNIBUSF4PRO) || defined(OMNIBUSF4V3)
48+
// DEF_TIM(TIM10, CH1, PB8, TIM_USE_PPM, 0, 0), // PPM
49+
DEF_TIM(TIM4, CH4, PB9, TIM_USE_ANY, 0, 0), // S2_IN
50+
#else
51+
// DEF_TIM(TIM12, CH1, PB14, TIM_USE_PPM, 0, 0), // PPM
52+
DEF_TIM(TIM12, CH2, PB15, TIM_USE_ANY, 0, 0), // S2_IN
53+
#endif
54+
DEF_TIM(TIM8, CH1, PC6, TIM_USE_ANY, 0, 0), // S3_IN, UART6_TX
55+
DEF_TIM(TIM8, CH2, PC7, TIM_USE_ANY, 0, 0), // S4_IN, UART6_RX
56+
DEF_TIM(TIM8, CH3, PC8, TIM_USE_ANY, 0, 0), // S5_IN // pad labelled CH5 on OMNIBUSF4PRO
57+
DEF_TIM(TIM8, CH4, PC9, TIM_USE_ANY, 0, 0), // S6_IN // pad labelled CH6 on OMNIBUSF4PRO
58+
59+
};
60+
61+
const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]);

0 commit comments

Comments
 (0)