Merge pull request #11714 from VitroidFPV/my-new-code
[betaflight.git] / src / main / target / OMNIBUSF4 / target.h
blob8f5770f9cb5e6b252be20a30698dca698fb0e5d1
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #define USE_TARGET_CONFIG
25 #if defined(OMNIBUSF4SD)
26 #define TARGET_BOARD_IDENTIFIER "OBSD"
27 #elif defined(LUXF4OSD)
28 #define TARGET_BOARD_IDENTIFIER "LUX4"
29 #elif defined(DYSF4PRO)
30 #define TARGET_BOARD_IDENTIFIER "DYS4"
31 #elif defined(XRACERF4)
32 #define TARGET_BOARD_IDENTIFIER "XRF4"
33 #elif defined(EXUAVF4PRO)
34 #define TARGET_BOARD_IDENTIFIER "EXF4"
35 #elif defined(SYNERGYF4)
36 #define TARGET_BOARD_IDENTIFIER "SYN4"
37 #define TARGET_MANUFACTURER_IDENTIFIER "KLEE"
38 #else
39 #define TARGET_BOARD_IDENTIFIER "OBF4"
40 // Example of a manufacturer ID to be persisted as part of the config:
41 #define TARGET_MANUFACTURER_IDENTIFIER "AIRB"
42 #define OMNIBUSF4BASE // For config.c
43 #endif
45 #if defined(LUXF4OSD)
46 #define USBD_PRODUCT_STRING "LuxF4osd"
47 #elif defined(DYSF4PRO)
48 #define USBD_PRODUCT_STRING "DysF4Pro"
49 #elif defined(XRACERF4)
50 #define USBD_PRODUCT_STRING "XRACERF4"
51 #elif defined(EXUAVF4PRO)
52 #define USBD_PRODUCT_STRING "ExuavF4Pro"
53 #elif defined(SYNERGYF4)
54 #define USBD_PRODUCT_STRING "SynergyF4"
55 #else
56 #define USBD_PRODUCT_STRING "OmnibusF4"
57 #endif
59 #define LED0_PIN PB5
60 #define USE_BEEPER
61 #define BEEPER_PIN PB4
62 #define BEEPER_INVERTED
64 #if defined(OMNIBUSF4SD) || defined(DYSF4PRO)
65 #define ENABLE_DSHOT_DMAR DSHOT_DMAR_ON
66 #endif
68 #ifdef OMNIBUSF4SD
69 // These inverter control pins collide with timer channels on CH5 and CH6 pads.
70 // Users of these timers/pads must un-map the inverter assignment explicitly.
71 #define INVERTER_PIN_UART6 PC8 // Omnibus F4 V3 and later
72 #define INVERTER_PIN_UART3 PC9 // Omnibus F4 Pro Corners
73 #elif defined(EXUAVF4PRO)
74 #define INVERTER_PIN_UART6 PC8
75 #else
76 #define INVERTER_PIN_UART1 PC0 // DYS F4 Pro; Omnibus F4 AIO (1st gen) have a FIXED inverter on UART1
77 #endif
80 #define USE_ACC
81 #define USE_ACC_SPI_MPU6000
83 #define USE_GYRO
84 #define USE_GYRO_SPI_MPU6000
86 #define GYRO_1_CS_PIN PA4
87 #define GYRO_1_SPI_INSTANCE SPI1
89 // MPU6000 interrupts
90 #define GYRO_1_EXTI_PIN PC4
92 #if defined(OMNIBUSF4SD)
93 #define GYRO_1_ALIGN CW270_DEG
94 #elif defined(XRACERF4) || defined(EXUAVF4PRO)
95 #define GYRO_1_ALIGN CW90_DEG
96 #elif defined(SYNERGYF4)
97 #define GYRO_1_ALIGN CW0_DEG_FLIP
98 #else
99 #define GYRO_1_ALIGN CW180_DEG
100 #endif
102 // Support for iFlight OMNIBUS F4 V3
103 // Has ICM20608 instead of MPU6000
104 // OMNIBUSF4SD is linked with both MPU6000 and MPU6500 drivers
105 #if defined (OMNIBUSF4SD) || defined(OMNIBUSF4BASE)
106 #define USE_ACC_SPI_MPU6500
107 #define USE_GYRO_SPI_MPU6500
108 #endif
110 // Dummy defines
111 #define GYRO_2_SPI_INSTANCE GYRO_1_SPI_INSTANCE
112 #define GYRO_2_CS_PIN NONE
113 #define GYRO_2_EXTI_PIN NONE
115 #if !defined(SYNERGYF4) //No mag sensor on SYNERGYF4
116 #define USE_MAG
117 #define USE_MAG_HMC5883
118 #define USE_MAG_QMC5883
119 #define USE_MAG_LIS3MDL
120 #define MAG_HMC5883_ALIGN CW90_DEG
121 #endif
123 #if !defined(SYNERGYF4) //No baro sensor on SYNERGYF4
124 #define USE_BARO
125 #if defined(OMNIBUSF4SD)
126 #define USE_BARO_SPI_BMP280
127 #define BARO_SPI_INSTANCE SPI3
128 #define BARO_CS_PIN PB3 // v1
129 #endif
130 #define USE_BARO_BMP085
131 #define USE_BARO_BMP280
132 #define USE_BARO_MS5611
133 #define BARO_I2C_INSTANCE (I2CDEV_2)
135 #if defined(OMNIBUSF4SD)
136 #define DEFAULT_BARO_SPI_BMP280
137 #else
138 #define DEFAULT_BARO_BMP280
139 #endif
140 #endif
142 #define USE_MAX7456
143 #define MAX7456_SPI_INSTANCE SPI3
144 #define MAX7456_SPI_CS_PIN PA15
146 // Globally configure flashfs and drivers for various flash chips
147 #define USE_FLASHFS
148 #define USE_FLASH_M25P16
149 #define USE_FLASH_W25M512
151 #if defined(OMNIBUSF4SD)
152 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
153 #define USE_SDCARD
154 #define USE_SDCARD_SPI
155 #define SDCARD_DETECT_INVERTED
156 #define SDCARD_DETECT_PIN PB7
157 #define SDCARD_SPI_INSTANCE SPI2
158 #define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
159 #define SPI2_TX_DMA_OPT 0 // DMA 1 Stream 4 Channel 0
161 // For variants with SDcard replaced with flash chip
162 #define FLASH_CS_PIN SDCARD_SPI_CS_PIN
163 #define FLASH_SPI_INSTANCE SDCARD_SPI_INSTANCE
165 #elif defined(LUXF4OSD)
166 #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
167 #define FLASH_CS_PIN PB12
168 #define FLASH_SPI_INSTANCE SPI2
170 #else
171 #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
172 #define FLASH_CS_PIN SPI3_NSS_PIN
173 #define FLASH_SPI_INSTANCE SPI3
174 #endif // OMNIBUSF4
176 #ifdef OMNIBUSF4BASE
177 #define USE_RX_SPI
178 #define USE_RX_SPEKTRUM
179 #define USE_RX_SPEKTRUM_TELEMETRY
180 #define RX_CHANNELS_TAER
181 #define DEFAULT_RX_FEATURE FEATURE_RX_SPI
182 #define RX_SPI_DEFAULT_PROTOCOL RX_SPI_CYRF6936_DSM
183 #define RX_SPI_INSTANCE SPI3
184 #define RX_NSS_PIN PD2
185 #define RX_SPI_EXTI_PIN PA0 // instead of rssi input
186 #endif
188 #define USE_VCP
189 #define USE_USB_DETECT
190 #define USB_DETECT_PIN PC5
192 #define USE_UART1
193 #define UART1_RX_PIN PA10
194 #define UART1_TX_PIN PA9
196 #define USE_UART3
197 #define UART3_RX_PIN PB11
198 #define UART3_TX_PIN PB10
200 #if defined(EXUAVF4PRO)
201 #define USE_UART4
202 #define UART4_RX_PIN PA1
203 #define UART4_TX_PIN PA0
204 #endif
206 #define USE_UART6
207 #define UART6_RX_PIN PC7
208 #define UART6_TX_PIN PC6
210 #define USE_SOFTSERIAL1
211 #define USE_SOFTSERIAL2
213 #if defined(EXUAVF4PRO)
214 #define SERIAL_PORT_COUNT 7 // VCP, USART1, USART3, USART4, USART6, SOFTSERIAL x 2
215 #else
216 #define SERIAL_PORT_COUNT 6 // VCP, USART1, USART3, USART6, SOFTSERIAL x 2
217 #endif
219 #define USE_ESCSERIAL
220 #if defined(OMNIBUSF4SD)
221 #define ESCSERIAL_TIMER_TX_PIN PB8 // (Hardware=0)
222 #else
223 #define ESCSERIAL_TIMER_TX_PIN PB14 // (Hardware=0)
224 #endif
226 #define USE_SPI
227 #define USE_SPI_DEVICE_1
229 #if defined(OMNIBUSF4SD) || defined(LUXF4OSD)
230 #define USE_SPI_DEVICE_2
231 #define SPI2_NSS_PIN PB12
232 #define SPI2_SCK_PIN PB13
233 #define SPI2_MISO_PIN PB14
234 #define SPI2_MOSI_PIN PB15
235 #endif
237 #define USE_SPI_DEVICE_3
238 #if defined(OMNIBUSF4SD)
239 #define SPI3_NSS_PIN PA15
240 #else
241 #define SPI3_NSS_PIN PB3
242 #endif
243 #define SPI3_SCK_PIN PC10
244 #define SPI3_MISO_PIN PC11
245 #define SPI3_MOSI_PIN PC12
247 #define USE_I2C
248 #define USE_I2C_DEVICE_2
249 #define I2C2_SCL NONE // PB10, shared with UART3TX
250 #define I2C2_SDA NONE // PB11, shared with UART3RX
251 #if defined(OMNIBUSF4BASE) || defined(OMNIBUSF4SD)
252 #define USE_I2C_DEVICE_3
253 #define I2C3_SCL NONE // PA8, PWM6
254 #define I2C3_SDA NONE // PC9, CH6
255 #endif
256 #define I2C_DEVICE (I2CDEV_2)
258 #define USE_ADC
259 #define ADC_INSTANCE ADC2
260 #define ADC2_DMA_OPT 1 // DMA 2 Stream 3 Channel 1 (compat default)
261 //#define ADC_INSTANCE ADC1
262 //#define ADC1_DMA_OPT 1 // DMA 2 Stream 4 Channel 0 (compat default)
264 #define CURRENT_METER_ADC_PIN PC1 // Direct from CRNT pad (part of onboard sensor for Pro)
265 #define VBAT_ADC_PIN PC2 // 11:1 (10K + 1K) divider
266 #ifdef DYSF4PRO
267 #define RSSI_ADC_PIN PC3 // Direct from RSSI pad
268 #elif defined(OMNIBUSF4BASE)
269 #define RSSI_ADC_PIN NONE
270 #else
271 #define RSSI_ADC_PIN PA0 // Direct from RSSI pad
272 #endif
274 #define USE_TRANSPONDER
276 #define USE_RANGEFINDER
277 #define USE_RANGEFINDER_HCSR04
278 #define RANGEFINDER_HCSR04_TRIGGER_PIN PA1
279 #define RANGEFINDER_HCSR04_ECHO_PIN PA8
280 #define USE_RANGEFINDER_TF
282 #if defined(SYNERGYF4)
283 #define DEFAULT_FEATURES (FEATURE_LED_STRIP | FEATURE_OSD | FEATURE_AIRMODE)
284 #else
285 #define DEFAULT_FEATURES (FEATURE_OSD)
286 #endif
288 #define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
289 #define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
291 #define TARGET_IO_PORTA (0xffff & ~(BIT(14)|BIT(13)))
292 #define TARGET_IO_PORTB (0xffff & ~(BIT(2)))
293 #define TARGET_IO_PORTC (0xffff & ~(BIT(15)|BIT(14)|BIT(13)))
294 #define TARGET_IO_PORTD BIT(2)
296 #if defined(OMNIBUSF4SD) || defined(EXUAVF4PRO)
297 #define USABLE_TIMER_CHANNEL_COUNT 15
298 #define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(5) | TIM_N(10) | TIM_N(12) | TIM_N(8) | TIM_N(9))
299 #else
300 #define USABLE_TIMER_CHANNEL_COUNT 14
301 #define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(5) | TIM_N(8) | TIM_N(12) )
302 #endif
303 #if defined(SYNERGYF4)
304 #define USE_PINIO
305 #define PINIO1_PIN PB15 // VTX power switcher
306 #define USE_PINIOBOX
307 #endif