FIX: SPI Pins, and I2C pins should be configured in config.h (#12484)
[betaflight.git] / src / main / target / common_defaults_post.h
blob8758d1e3713f0ca2c95bf60879483ab34a5c7ebf
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 // pg/max7456
23 #ifndef DEBUG_MODE
24 #define DEBUG_MODE DEBUG_NONE
25 #endif
27 #ifndef I2C1_CLOCKSPEED
28 #define I2C1_CLOCKSPEED 800
29 #endif
30 #ifndef I2C2_CLOCKSPEED
31 #define I2C2_CLOCKSPEED 800
32 #endif
33 #ifndef I2C3_CLOCKSPEED
34 #define I2C3_CLOCKSPEED 800
35 #endif
36 #ifndef I2C4_CLOCKSPEED
37 #define I2C4_CLOCKSPEED 800
38 #endif
40 // Default values for internal pullup
42 #if defined(USE_I2C_PULLUP)
43 #define I2C1_PULLUP true
44 #define I2C2_PULLUP true
45 #define I2C3_PULLUP true
46 #define I2C4_PULLUP true
47 #else
48 #define I2C1_PULLUP false
49 #define I2C2_PULLUP false
50 #define I2C3_PULLUP false
51 #define I2C4_PULLUP false
52 #endif
54 // Extracted from rx/rx.c and rx/rx.h
56 #define RX_MAPPABLE_CHANNEL_COUNT 8
58 #ifndef RX_SPI_DEFAULT_PROTOCOL
59 #define RX_SPI_DEFAULT_PROTOCOL 0
60 #endif
61 #ifndef SERIALRX_PROVIDER
62 #define SERIALRX_PROVIDER 0
63 #endif
65 #define RX_MIN_USEC 885
66 #define RX_MAX_USEC 2115
67 #define RX_MID_USEC 1500
69 #ifndef SPEKTRUM_BIND_PIN
70 #define SPEKTRUM_BIND_PIN NONE
71 #endif
73 #ifndef BINDPLUG_PIN
74 #define BINDPLUG_PIN NONE
75 #endif
77 #ifdef USE_RX_SPI
78 #if !defined(RX_SPI_INSTANCE)
79 #define RX_SPI_INSTANCE NULL
80 #endif
82 #if !defined(RX_NSS_PIN)
83 #define RX_NSS_PIN NONE
84 #endif
86 #ifndef RX_SPI_LED_PIN
87 #define RX_SPI_LED_PIN NONE
88 #endif
90 #if !defined(RX_SPI_EXTI_PIN)
91 #define RX_SPI_EXTI_PIN NONE
92 #endif
94 #if !defined(RX_SPI_BIND_PIN)
95 #define RX_SPI_BIND_PIN NONE
96 #endif
98 #endif
100 // Previously there was logic here to default GYRO_1_CUSTOM_ALIGN and GYRO_2_CUSTOM_ALIGN
101 // to CUSTOM_ALIGN_CW0_DEG if they weren't defined in the target. The defaulting logic
102 // has been moved to pg/gyrodev.c to set the custom alignment based on the sensor alignment
103 // if a custom alignment is not applied in the target.
105 #ifdef USE_VCP
106 #ifndef USB_DETECT_PIN
107 #define USB_DETECT_PIN NONE
108 #endif
109 #ifndef USB_MSC_BUTTON_PIN
110 #define USB_MSC_BUTTON_PIN NONE
111 #endif
112 #if !defined(MSC_BUTTON_IPU)
113 #define MSC_BUTTON_IPU true
114 #endif
115 #endif
117 #ifdef USE_TIMER_MGMT
118 #ifndef MAX_TIMER_PINMAP_COUNT
119 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
120 #endif
121 #endif
123 #if defined(USE_UART1) || defined(USE_UART2) || defined(USE_UART3) || defined(USE_UART4) || defined(USE_UART5) || defined(USE_UART6) || defined(USE_UART7) || defined(USE_UART8)
124 #define USE_UART
125 #endif
127 #ifdef USE_UART
128 #if defined(INVERTER_PIN_UART1) || defined(INVERTER_PIN_UART2) || defined(INVERTER_PIN_UART3) || defined(INVERTER_PIN_UART4) || defined(INVERTER_PIN_UART5) || defined(INVERTER_PIN_UART6)
129 #define USE_INVERTER
130 #endif
131 #endif
133 #ifndef DEFAULT_MIXER
134 #define DEFAULT_MIXER MIXER_QUADX
135 #endif
137 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
138 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
139 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
140 #endif
141 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
142 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
143 #endif
144 #endif
146 // Mag
147 #if defined(USE_MAG)
148 #ifndef MAG_SPI_INSTANCE
149 #define MAG_SPI_INSTANCE NULL
150 #endif
151 #ifndef MAG_CS_PIN
152 #define MAG_CS_PIN NONE
153 #endif
154 #ifndef MAG_I2C_INSTANCE
155 #define MAG_I2C_INSTANCE I2C_DEVICE
156 #endif
157 #endif
159 #ifndef MAG_INT_EXTI
160 #define MAG_INT_EXTI NONE
161 #endif
163 // Baro
164 #if defined(USE_BARO)
165 #ifndef BARO_SPI_INSTANCE
166 #define BARO_SPI_INSTANCE NULL
167 #endif
168 #ifndef BARO_CS_PIN
169 #define BARO_CS_PIN NONE
170 #endif
171 #ifndef BARO_I2C_INSTANCE
172 #define BARO_I2C_INSTANCE I2C_DEVICE
173 #endif
174 #ifndef BARO_XCLR_PIN
175 #define BARO_XCLR_PIN NONE
176 #endif
177 #endif
179 #ifdef USE_ADC
181 #if !defined(ADC1_DMA_OPT)
182 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
183 #endif
184 #if !defined(ADC2_DMA_OPT)
185 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
186 #endif
187 #if !defined(ADC3_DMA_OPT)
188 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
189 #endif
190 #if !defined(ADC4_DMA_OPT)
191 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
192 #endif
193 #if !defined(ADC5_DMA_OPT)
194 #define ADC5_DMA_OPT (DMA_OPT_UNUSED)
195 #endif
197 #endif // USE_ADC
199 #ifdef USE_SPI
200 #ifdef USE_SPI_DEVICE_1
201 #ifndef SPI1_TX_DMA_OPT
202 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
203 #endif
204 #ifndef SPI1_RX_DMA_OPT
205 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
206 #endif
207 #endif
208 #ifdef USE_SPI_DEVICE_2
209 #ifndef SPI2_TX_DMA_OPT
210 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
211 #endif
212 #ifndef SPI2_RX_DMA_OPT
213 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
214 #endif
215 #endif
216 #ifdef USE_SPI_DEVICE_3
217 #ifndef SPI3_TX_DMA_OPT
218 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
219 #endif
220 #ifndef SPI3_RX_DMA_OPT
221 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
222 #endif
223 #endif
224 #ifdef USE_SPI_DEVICE_4
225 #ifndef SPI4_TX_DMA_OPT
226 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
227 #endif
228 #ifndef SPI4_RX_DMA_OPT
229 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
230 #endif
231 #endif
232 #ifdef USE_SPI_DEVICE_5
233 #ifndef SPI5_TX_DMA_OPT
234 #define SPI5_TX_DMA_OPT (DMA_OPT_UNUSED)
235 #endif
236 #ifndef SPI5_RX_DMA_OPT
237 #define SPI5_RX_DMA_OPT (DMA_OPT_UNUSED)
238 #endif
239 #endif
240 #ifdef USE_SPI_DEVICE_6
241 #ifndef SPI6_TX_DMA_OPT
242 #define SPI6_TX_DMA_OPT (DMA_OPT_UNUSED)
243 #endif
244 #ifndef SPI6_RX_DMA_OPT
245 #define SPI6_RX_DMA_OPT (DMA_OPT_UNUSED)
246 #endif
247 #endif
248 #endif
250 #ifdef USE_UART1
251 #ifndef UART1_TX_DMA_OPT
252 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
253 #endif
254 #ifndef UART1_RX_DMA_OPT
255 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
256 #endif
257 #endif
259 #ifdef USE_UART2
260 #ifndef UART2_TX_DMA_OPT
261 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
262 #endif
263 #ifndef UART2_RX_DMA_OPT
264 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
265 #endif
266 #endif
268 #ifdef USE_UART3
269 #ifndef UART3_TX_DMA_OPT
270 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
271 #endif
272 #ifndef UART3_RX_DMA_OPT
273 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
274 #endif
275 #endif
277 #ifdef USE_UART4
278 #ifndef UART4_TX_DMA_OPT
279 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
280 #endif
281 #ifndef UART4_RX_DMA_OPT
282 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
283 #endif
284 #endif
286 #ifdef USE_UART5
287 #ifndef UART5_TX_DMA_OPT
288 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
289 #endif
290 #ifndef UART5_RX_DMA_OPT
291 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
292 #endif
293 #endif
295 #ifdef USE_UART6
296 #ifndef UART6_TX_DMA_OPT
297 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
298 #endif
299 #ifndef UART6_RX_DMA_OPT
300 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
301 #endif
302 #endif
304 #ifdef USE_UART7
305 #ifndef UART7_TX_DMA_OPT
306 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
307 #endif
308 #ifndef UART7_RX_DMA_OPT
309 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
310 #endif
311 #endif
313 #ifdef USE_UART8
314 #ifndef UART8_TX_DMA_OPT
315 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
316 #endif
317 #ifndef UART8_RX_DMA_OPT
318 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
319 #endif
320 #endif
322 #ifdef USE_UART9
323 #ifndef UART9_TX_DMA_OPT
324 #define UART9_TX_DMA_OPT (DMA_OPT_UNUSED)
325 #endif
326 #ifndef UART9_RX_DMA_OPT
327 #define UART9_RX_DMA_OPT (DMA_OPT_UNUSED)
328 #endif
329 #endif
331 #ifdef USE_UART10
332 #ifndef UART10_TX_DMA_OPT
333 #define UART10_TX_DMA_OPT (DMA_OPT_UNUSED)
334 #endif
335 #ifndef UART10_RX_DMA_OPT
336 #define UART10_RX_DMA_OPT (DMA_OPT_UNUSED)
337 #endif
338 #endif
340 #ifndef RTC6705_CS_PIN
341 #define RTC6705_CS_PIN NONE
342 #endif
344 #ifndef RTC6705_POWER_PIN
345 #define RTC6705_POWER_PIN NONE
346 #endif
348 #ifndef RTC6705_SPICLK_PIN
349 #define RTC6705_SPICLK_PIN NONE
350 #endif
352 #ifndef RTC6705_SPI_SDO_PIN
353 #define RTC6705_SPI_SDO_PIN NONE
354 #endif
356 #ifndef RTC6705_SPI_INSTANCE
357 #define RTC6705_SPI_INSTANCE NULL
358 #endif
360 #if defined(USE_QUAD_MIXER_ONLY)
361 #define MAX_SUPPORTED_MOTORS 4
362 #define MAX_SUPPORTED_SERVOS 1
363 #else
364 #ifndef MAX_SUPPORTED_MOTORS
365 #define MAX_SUPPORTED_MOTORS 8
366 #endif
367 #define MAX_SUPPORTED_SERVOS 8
368 #endif