Add Winbond 25Q128 flash driver
[betaflight.git] / src / main / target / OMNIBUSF4 / target.h
blob26fa2e6292b2a2dc3ddf2a1759720b28cfa5cb88
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
79 #define USE_EXTI
81 #define USE_ACC
82 #define USE_ACC_SPI_MPU6000
84 #define USE_GYRO
85 #define USE_GYRO_SPI_MPU6000
87 #define GYRO_1_CS_PIN PA4
88 #define GYRO_1_SPI_INSTANCE SPI1
90 // MPU6000 interrupts
91 #define USE_GYRO_EXTI
92 #define GYRO_1_EXTI_PIN PC4
93 #define USE_MPU_DATA_READY_SIGNAL
95 #if defined(OMNIBUSF4SD)
96 #define GYRO_1_ALIGN CW270_DEG
97 #elif defined(XRACERF4) || defined(EXUAVF4PRO)
98 #define GYRO_1_ALIGN CW90_DEG
99 #elif defined(SYNERGYF4)
100 #define GYRO_1_ALIGN CW0_DEG_FLIP
101 #else
102 #define GYRO_1_ALIGN CW180_DEG
103 #endif
105 // Support for iFlight OMNIBUS F4 V3
106 // Has ICM20608 instead of MPU6000
107 // OMNIBUSF4SD is linked with both MPU6000 and MPU6500 drivers
108 #if defined (OMNIBUSF4SD) || defined(OMNIBUSF4BASE)
109 #define USE_ACC_SPI_MPU6500
110 #define USE_GYRO_SPI_MPU6500
111 #endif
113 // Dummy defines
114 #define GYRO_2_SPI_INSTANCE GYRO_1_SPI_INSTANCE
115 #define GYRO_2_CS_PIN NONE
116 #define GYRO_2_EXTI_PIN NONE
118 #if !defined(SYNERGYF4) //No mag sensor on SYNERGYF4
119 #define USE_MAG
120 #define USE_MAG_HMC5883
121 #define USE_MAG_QMC5883
122 #define USE_MAG_LIS3MDL
123 #define MAG_HMC5883_ALIGN CW90_DEG
124 #endif
126 #if !defined(SYNERGYF4) //No baro sensor on SYNERGYF4
127 #define USE_BARO
128 #if defined(OMNIBUSF4SD)
129 #define USE_BARO_SPI_BMP280
130 #define BARO_SPI_INSTANCE SPI3
131 #define BARO_CS_PIN PB3 // v1
132 #endif
133 #define USE_BARO_BMP085
134 #define USE_BARO_BMP280
135 #define USE_BARO_MS5611
136 #define BARO_I2C_INSTANCE (I2CDEV_2)
138 #if defined(OMNIBUSF4SD)
139 #define DEFAULT_BARO_SPI_BMP280
140 #else
141 #define DEFAULT_BARO_BMP280
142 #endif
143 #endif
145 #define USE_MAX7456
146 #define MAX7456_SPI_INSTANCE SPI3
147 #define MAX7456_SPI_CS_PIN PA15
149 // Globally configure flashfs and drivers for various flash chips
150 #define USE_FLASHFS
151 #define USE_FLASH_M25P16
152 #define USE_FLASH_W25M512
154 #if defined(OMNIBUSF4SD)
155 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
156 #define USE_SDCARD
157 #define USE_SDCARD_SPI
158 #define SDCARD_DETECT_INVERTED
159 #define SDCARD_DETECT_PIN PB7
160 #define SDCARD_SPI_INSTANCE SPI2
161 #define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
162 #define SPI2_TX_DMA_OPT 0 // DMA 1 Stream 4 Channel 0
164 // For variants with SDcard replaced with flash chip
165 #define FLASH_CS_PIN SDCARD_SPI_CS_PIN
166 #define FLASH_SPI_INSTANCE SDCARD_SPI_INSTANCE
168 #elif defined(LUXF4OSD)
169 #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
170 #define FLASH_CS_PIN PB12
171 #define FLASH_SPI_INSTANCE SPI2
173 #else
174 #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
175 #define FLASH_CS_PIN SPI3_NSS_PIN
176 #define FLASH_SPI_INSTANCE SPI3
177 #endif // OMNIBUSF4
179 #ifdef OMNIBUSF4BASE
180 #define USE_RX_SPI
181 #define USE_RX_SPEKTRUM
182 #define USE_RX_SPEKTRUM_TELEMETRY
183 #define RX_CHANNELS_TAER
184 #define DEFAULT_RX_FEATURE FEATURE_RX_SPI
185 #define RX_SPI_DEFAULT_PROTOCOL RX_SPI_CYRF6936_DSM
186 #define RX_SPI_INSTANCE SPI3
187 #define RX_NSS_PIN PD2
188 #define RX_SPI_EXTI_PIN PA0 // instead of rssi input
189 #endif
191 #define USE_VCP
192 #define USE_USB_DETECT
193 #define USB_DETECT_PIN PC5
195 #define USE_UART1
196 #define UART1_RX_PIN PA10
197 #define UART1_TX_PIN PA9
199 #define USE_UART3
200 #define UART3_RX_PIN PB11
201 #define UART3_TX_PIN PB10
203 #if defined(EXUAVF4PRO)
204 #define USE_UART4
205 #define UART4_RX_PIN PA1
206 #define UART4_TX_PIN PA0
207 #endif
209 #define USE_UART6
210 #define UART6_RX_PIN PC7
211 #define UART6_TX_PIN PC6
213 #define USE_SOFTSERIAL1
214 #define USE_SOFTSERIAL2
216 #if defined(EXUAVF4PRO)
217 #define SERIAL_PORT_COUNT 7 // VCP, USART1, USART3, USART4, USART6, SOFTSERIAL x 2
218 #else
219 #define SERIAL_PORT_COUNT 6 // VCP, USART1, USART3, USART6, SOFTSERIAL x 2
220 #endif
222 #define USE_ESCSERIAL
223 #if defined(OMNIBUSF4SD)
224 #define ESCSERIAL_TIMER_TX_PIN PB8 // (Hardware=0)
225 #else
226 #define ESCSERIAL_TIMER_TX_PIN PB14 // (Hardware=0)
227 #endif
229 #define USE_SPI
230 #define USE_SPI_DEVICE_1
232 #if defined(OMNIBUSF4SD) || defined(LUXF4OSD)
233 #define USE_SPI_DEVICE_2
234 #define SPI2_NSS_PIN PB12
235 #define SPI2_SCK_PIN PB13
236 #define SPI2_MISO_PIN PB14
237 #define SPI2_MOSI_PIN PB15
238 #endif
240 #define USE_SPI_DEVICE_3
241 #if defined(OMNIBUSF4SD)
242 #define SPI3_NSS_PIN PA15
243 #else
244 #define SPI3_NSS_PIN PB3
245 #endif
246 #define SPI3_SCK_PIN PC10
247 #define SPI3_MISO_PIN PC11
248 #define SPI3_MOSI_PIN PC12
250 #define USE_I2C
251 #define USE_I2C_DEVICE_2
252 #define I2C2_SCL NONE // PB10, shared with UART3TX
253 #define I2C2_SDA NONE // PB11, shared with UART3RX
254 #if defined(OMNIBUSF4BASE) || defined(OMNIBUSF4SD)
255 #define USE_I2C_DEVICE_3
256 #define I2C3_SCL NONE // PA8, PWM6
257 #define I2C3_SDA NONE // PC9, CH6
258 #endif
259 #define I2C_DEVICE (I2CDEV_2)
261 #define USE_ADC
262 #define ADC_INSTANCE ADC2
263 #define ADC2_DMA_OPT 1 // DMA 2 Stream 3 Channel 1 (compat default)
264 //#define ADC_INSTANCE ADC1
265 //#define ADC1_DMA_OPT 1 // DMA 2 Stream 4 Channel 0 (compat default)
267 #define CURRENT_METER_ADC_PIN PC1 // Direct from CRNT pad (part of onboard sensor for Pro)
268 #define VBAT_ADC_PIN PC2 // 11:1 (10K + 1K) divider
269 #ifdef DYSF4PRO
270 #define RSSI_ADC_PIN PC3 // Direct from RSSI pad
271 #elif defined(OMNIBUSF4BASE)
272 #define RSSI_ADC_PIN NONE
273 #else
274 #define RSSI_ADC_PIN PA0 // Direct from RSSI pad
275 #endif
277 #define USE_TRANSPONDER
279 #define USE_RANGEFINDER
280 #define USE_RANGEFINDER_HCSR04
281 #define RANGEFINDER_HCSR04_TRIGGER_PIN PA1
282 #define RANGEFINDER_HCSR04_ECHO_PIN PA8
283 #define USE_RANGEFINDER_TF
285 #if defined(SYNERGYF4)
286 #define DEFAULT_FEATURES (FEATURE_LED_STRIP | FEATURE_OSD | FEATURE_AIRMODE)
287 #else
288 #define DEFAULT_FEATURES (FEATURE_OSD)
289 #endif
291 #define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
292 #define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
294 #define TARGET_IO_PORTA (0xffff & ~(BIT(14)|BIT(13)))
295 #define TARGET_IO_PORTB (0xffff & ~(BIT(2)))
296 #define TARGET_IO_PORTC (0xffff & ~(BIT(15)|BIT(14)|BIT(13)))
297 #define TARGET_IO_PORTD BIT(2)
299 #if defined(OMNIBUSF4SD) || defined(EXUAVF4PRO)
300 #define USABLE_TIMER_CHANNEL_COUNT 15
301 #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))
302 #else
303 #define USABLE_TIMER_CHANNEL_COUNT 14
304 #define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(5) | TIM_N(8) | TIM_N(12) )
305 #endif
306 #if defined(SYNERGYF4)
307 #define USE_PINIO
308 #define PINIO1_PIN PB15 // VTX power switcher
309 #define USE_PINIOBOX
310 #endif