Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
matekF765-WING.h
Go to the documentation of this file.
1 #ifndef CONFIG_MATEK_F765_WING_H
2 #define CONFIG_MATEK_F765_WING_H
3 
4 #define BOARD_MATEK_F765_WING
5 
9 #include "board.h"
10 
15 /*
16  * AHB_CLK
17  */
18 #define AHB_CLK STM32_HCLK
19 
20 /*
21  * Concat macro
22  */
23 #define _CONCAT_BOARD_PARAM(_s1, _s2) _s1 ## _s2
24 #define CONCAT_BOARD_PARAM(_s1, _s2) _CONCAT_BOARD_PARAM(_s1, _s2)
25 
26 /*
27  * LEDs
28  */
29 /* blue, 1 on LED_ON, 0 on LED_OFF */
30 #ifndef USE_LED_1
31 #define USE_LED_1 1
32 #endif
33 #define LED_1_GPIO PAL_PORT(LINE_LED1)
34 #define LED_1_GPIO_PIN PAL_PAD(LINE_LED1)
35 #define LED_1_GPIO_ON gpio_set
36 #define LED_1_GPIO_OFF gpio_clear
37 
38 /* greeg, 1 on LED_ON, 0 on LED_OFF */
39 #ifndef USE_LED_2
40 #define USE_LED_2 1
41 #endif
42 #define LED_2_GPIO PAL_PORT(LINE_LED2)
43 #define LED_2_GPIO_PIN PAL_PAD(LINE_LED2)
44 #define LED_2_GPIO_ON gpio_set
45 #define LED_2_GPIO_OFF gpio_clear
46 
47 /*
48  * ADCs
49  */
50 // AIRSPEED
51 #if USE_ADC_1
52 #define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AIRSPEED_ADC_IN)
53 #define ADC_1 AD1_1
54 #define ADC_1_GPIO_PORT PAL_PORT(LINE_AIRSPEED)
55 #define ADC_1_GPIO_PIN PAL_PAD(LINE_AIRSPEED)
56 #endif
57 
58 // RSSI
59 #if USE_ADC_2
60 #define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, RSSI_ADC_IN)
61 #define ADC_2 AD1_2
62 #define ADC_2_GPIO_PORT PAL_PORT(LINE_RSSI)
63 #define ADC_2_GPIO_PIN PAL_PAD(LINE_RSSI)
64 #endif
65 
66 // VBAT enabled by default
67 #ifndef USE_ADC_3
68 #define USE_ADC_3 1
69 #endif
70 #if USE_ADC_3
71 #define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, VBAT_MEAS_ADC_IN)
72 #define ADC_3 AD1_3
73 #define ADC_3_GPIO_PORT PAL_PORT(LINE_VBAT_MEAS)
74 #define ADC_3_GPIO_PIN PAL_PAD(LINE_VBAT_MEAS)
75 #endif
76 
77 // CURRENT
78 #if USE_ADC_4
79 #define AD1_4_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, CURRENT_MEAS_ADC_IN)
80 #define ADC_4 AD1_4
81 #define ADC_4_GPIO_PORT PAL_PORT(LINE_CURRENT_MEAS)
82 #define ADC_4_GPIO_PIN PAL_PAD(LINE_CURRENT_MEAS)
83 #endif
84 
85 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
86 #ifndef ADC_CHANNEL_VSUPPLY
87 #define ADC_CHANNEL_VSUPPLY ADC_3
88 #endif
89 
90 /*
91  * R1 = 1k
92  * R2 = 10k
93  * adc * (3.3 / 2^12) * ((R1 + R2) / R1)
94  */
95 #define VBAT_R1 1000.0f
96 #define VBAT_R2 10000.0f
97 #define DefaultVoltageOfAdc(adc) ((3.3f/4096.0f)*((VBAT_R1+VBAT_R2)/VBAT_R1)*adc)
98 
99 /*
100  * current sensor: 132A, 3.3V 12bits ADC -> 40 A/V -> 40000 * 3.3/2^12 mA/ADC
101  */
102 #define DefaultMilliAmpereOfAdc(adc) ((40000.f*3.3f/4096.f)*adc)
103 
104 /*
105  * PWM defines
106  */
107 
108 #ifndef USE_PWM1
109 #define USE_PWM1 1
110 #endif
111 #if USE_PWM1
112 #define PWM_SERVO_1 1
113 #define PWM_SERVO_1_GPIO PAL_PORT(LINE_S1)
114 #define PWM_SERVO_1_PIN PAL_PAD(LINE_S1)
115 #define PWM_SERVO_1_AF AF_S1
116 #define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, S1_TIM)
117 #define PWM_SERVO_1_CHANNEL (S1_TIM_CH-1)
118 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
119 #else
120 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_DISABLED
121 #endif
122 
123 #ifndef USE_PWM2
124 #define USE_PWM2 1
125 #endif
126 #if USE_PWM2
127 #define PWM_SERVO_2 2
128 #define PWM_SERVO_2_GPIO PAL_PORT(LINE_S2)
129 #define PWM_SERVO_2_PIN PAL_PAD(LINE_S2)
130 #define PWM_SERVO_2_AF AF_S2
131 #define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, S2_TIM)
132 #define PWM_SERVO_2_CHANNEL (S2_TIM_CH-1)
133 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
134 #else
135 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_DISABLED
136 #endif
137 
138 #ifndef USE_PWM3
139 #define USE_PWM3 1
140 #endif
141 #if USE_PWM3
142 #define PWM_SERVO_3 3
143 #define PWM_SERVO_3_GPIO PAL_PORT(LINE_S3)
144 #define PWM_SERVO_3_PIN PAL_PAD(LINE_S3)
145 #define PWM_SERVO_3_AF AF_S3
146 #define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, S3_TIM)
147 #define PWM_SERVO_3_CHANNEL (S3_TIM_CH-1)
148 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
149 #else
150 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_DISABLED
151 #endif
152 
153 #ifndef USE_PWM4
154 #define USE_PWM4 1
155 #endif
156 #if USE_PWM4
157 #define PWM_SERVO_4 4
158 #define PWM_SERVO_4_GPIO PAL_PORT(LINE_S4)
159 #define PWM_SERVO_4_PIN PAL_PAD(LINE_S4)
160 #define PWM_SERVO_4_AF AF_S4
161 #define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, S4_TIM)
162 #define PWM_SERVO_4_CHANNEL (S4_TIM_CH-1)
163 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
164 #else
165 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_DISABLED
166 #endif
167 
168 #ifndef USE_PWM5
169 #define USE_PWM5 1
170 #endif
171 #if USE_PWM5
172 #define PWM_SERVO_5 5
173 #define PWM_SERVO_5_GPIO PAL_PORT(LINE_S5)
174 #define PWM_SERVO_5_PIN PAL_PAD(LINE_S5)
175 #define PWM_SERVO_5_AF AF_S5
176 #define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, S5_TIM)
177 #define PWM_SERVO_5_CHANNEL (S5_TIM_CH-1)
178 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
179 #else
180 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_DISABLED
181 #endif
182 
183 #ifndef USE_PWM6
184 #define USE_PWM6 1
185 #endif
186 #if USE_PWM6
187 #define PWM_SERVO_6 6
188 #define PWM_SERVO_6_GPIO PAL_PORT(LINE_S6)
189 #define PWM_SERVO_6_PIN PAL_PAD(LINE_S6)
190 #define PWM_SERVO_6_AF AF_S6
191 #define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, S6_TIM)
192 #define PWM_SERVO_6_CHANNEL (S6_TIM_CH-1)
193 #define PWM_SERVO_6_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
194 #else
195 #define PWM_SERVO_6_ACTIVE PWM_OUTPUT_DISABLED
196 #endif
197 
198 #ifndef USE_PWM7
199 #define USE_PWM7 1
200 #endif
201 #if USE_PWM7
202 #define PWM_SERVO_7 7
203 #define PWM_SERVO_7_GPIO PAL_PORT(LINE_S7)
204 #define PWM_SERVO_7_PIN PAL_PAD(LINE_S7)
205 #define PWM_SERVO_7_AF AF_S7
206 #define PWM_SERVO_7_DRIVER CONCAT_BOARD_PARAM(PWMD, S7_TIM)
207 #define PWM_SERVO_7_CHANNEL (S7_TIM_CH-1)
208 #define PWM_SERVO_7_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
209 #else
210 #define PWM_SERVO_7_ACTIVE PWM_OUTPUT_DISABLED
211 #endif
212 
213 #ifndef USE_PWM8
214 #define USE_PWM8 1
215 #endif
216 #if USE_PWM8
217 #define PWM_SERVO_8 8
218 #define PWM_SERVO_8_GPIO PAL_PORT(LINE_S8)
219 #define PWM_SERVO_8_PIN PAL_PAD(LINE_S8)
220 #define PWM_SERVO_8_AF AF_S8
221 #define PWM_SERVO_8_DRIVER CONCAT_BOARD_PARAM(PWMD, S8_TIM)
222 #define PWM_SERVO_8_CHANNEL (S8_TIM_CH-1)
223 #define PWM_SERVO_8_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
224 #else
225 #define PWM_SERVO_8_ACTIVE PWM_OUTPUT_DISABLED
226 #endif
227 
228 #ifndef USE_PWM9
229 #define USE_PWM9 1
230 #endif
231 #if USE_PWM9
232 #define PWM_SERVO_9 9
233 #define PWM_SERVO_9_GPIO PAL_PORT(LINE_S9)
234 #define PWM_SERVO_9_PIN PAL_PAD(LINE_S9)
235 #define PWM_SERVO_9_AF AF_S9
236 #define PWM_SERVO_9_DRIVER CONCAT_BOARD_PARAM(PWMD, S9_TIM)
237 #define PWM_SERVO_9_CHANNEL (S9_TIM_CH-1)
238 #define PWM_SERVO_9_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
239 #else
240 #define PWM_SERVO_9_ACTIVE PWM_OUTPUT_DISABLED
241 #endif
242 
243 #ifndef USE_PWM10
244 #define USE_PWM10 1
245 #endif
246 #if USE_PWM10
247 #define PWM_SERVO_10 10
248 #define PWM_SERVO_10_GPIO PAL_PORT(LINE_S10)
249 #define PWM_SERVO_10_PIN PAL_PAD(LINE_S10)
250 #define PWM_SERVO_10_AF AF_S10
251 #define PWM_SERVO_10_DRIVER CONCAT_BOARD_PARAM(PWMD, S10_TIM)
252 #define PWM_SERVO_10_CHANNEL (S10_TIM_CH-1)
253 #define PWM_SERVO_10_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
254 #else
255 #define PWM_SERVO_10_ACTIVE PWM_OUTPUT_DISABLED
256 #endif
257 
258 #ifndef USE_PWM11
259 #define USE_PWM11 0
260 #endif
261 #if USE_PWM11
262 #define PWM_SERVO_11 11
263 #define PWM_SERVO_11_GPIO PAL_PORT(LINE_S11)
264 #define PWM_SERVO_11_PIN PAL_PAD(LINE_S11)
265 #define PWM_SERVO_11_AF AF_S11
266 #define PWM_SERVO_11_DRIVER CONCAT_BOARD_PARAM(PWMD, S11_TIM)
267 #define PWM_SERVO_11_CHANNEL (S11_TIM_CH-1)
268 #define PWM_SERVO_11_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
269 #else
270 #define PWM_SERVO_11_ACTIVE PWM_OUTPUT_DISABLED
271 #endif
272 
273 #ifndef USE_PWM12
274 #define USE_PWM12 0
275 #endif
276 #if USE_PWM12
277 #define PWM_SERVO_12 12
278 #define PWM_SERVO_12_GPIO PAL_PORT(LINE_S12)
279 #define PWM_SERVO_12_PIN PAL_PAD(LINE_S12)
280 #define PWM_SERVO_12_AF AF_12
281 #define PWM_SERVO_12_DRIVER CONCAT_BOARD_PARAM(PWMD, S12_TIM)
282 #define PWM_SERVO_12_CHANNEL (S12_TIM_CH-1)
283 #define PWM_SERVO_12_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
284 #else
285 #define PWM_SERVO_12_ACTIVE PWM_OUTPUT_DISABLED
286 #endif
287 
288 // servo index starting at 1 + regular servos + aux servos
289 // so NB = 1+10+2
290 #define ACTUATORS_PWM_NB 13
291 
292 
293 #ifdef STM32_PWM_USE_TIM2
294 #define PWM_CONF_TIM2 STM32_PWM_USE_TIM2
295 #else
296 #define PWM_CONF_TIM2 1
297 #endif
298 #define PWM_CONF2_DEF { \
299  PWM_FREQUENCY, \
300  PWM_FREQUENCY/TIM2_SERVO_HZ, \
301  NULL, \
302  { \
303  { PWM_SERVO_1_ACTIVE, NULL }, \
304  { PWM_SERVO_2_ACTIVE, NULL }, \
305  { PWM_OUTPUT_DISABLED, NULL }, \
306  { PWM_OUTPUT_DISABLED, NULL }, \
307  }, \
308  0, \
309  0 \
310 }
311 
312 #ifdef STM32_PWM_USE_TIM4
313 #define PWM_CONF_TIM4 STM32_PWM_USE_TIM4
314 #else
315 #define PWM_CONF_TIM4 1
316 #endif
317 #define PWM_CONF4_DEF { \
318  PWM_FREQUENCY, \
319  PWM_FREQUENCY/TIM4_SERVO_HZ, \
320  NULL, \
321  { \
322  { PWM_SERVO_7_ACTIVE, NULL }, \
323  { PWM_SERVO_8_ACTIVE, NULL }, \
324  { PWM_SERVO_9_ACTIVE, NULL }, \
325  { PWM_SERVO_10_ACTIVE, NULL }, \
326  }, \
327  0, \
328  0 \
329 }
330 
331 #ifdef STM32_PWM_USE_TIM5
332 #define PWM_CONF_TIM5 STM32_PWM_USE_TIM5
333 #else
334 #define PWM_CONF_TIM5 1
335 #endif
336 #define PWM_CONF5_DEF { \
337  PWM_FREQUENCY, \
338  PWM_FREQUENCY/TIM5_SERVO_HZ, \
339  NULL, \
340  { \
341  { PWM_OUTPUT_DISABLED, NULL }, \
342  { PWM_OUTPUT_DISABLED, NULL }, \
343  { PWM_SERVO_3_ACTIVE, NULL }, \
344  { PWM_SERVO_4_ACTIVE, NULL }, \
345  }, \
346  0, \
347  0 \
348 }
349 
350 #ifdef STM32_PWM_USE_TIM8
351 #define PWM_CONF_TIM8 STM32_PWM_USE_TIM8
352 #else
353 #define PWM_CONF_TIM8 1
354 #endif
355 #define PWM_CONF8_DEF { \
356  PWM_FREQUENCY, \
357  PWM_FREQUENCY/TIM8_SERVO_HZ, \
358  NULL, \
359  { \
360  { PWM_OUTPUT_DISABLED, NULL }, \
361  { PWM_SERVO_5_ACTIVE, NULL }, \
362  { PWM_SERVO_6_ACTIVE, NULL }, \
363  { PWM_OUTPUT_DISABLED, NULL }, \
364  }, \
365  0, \
366  0 \
367 }
368 
369 #ifdef STM32_PWM_USE_TIM9
370 #define PWM_CONF_TIM9 STM32_PWM_USE_TIM9
371 #else
372 #define PWM_CONF_TIM9 1
373 #endif
374 #define PWM_CONF9_DEF { \
375  PWM_FREQUENCY, \
376  PWM_FREQUENCY/TIM9_SERVO_HZ, \
377  NULL, \
378  { \
379  { PWM_SERVO_11_ACTIVE, NULL }, \
380  { PWM_SERVO_12_ACTIVE, NULL }, \
381  { PWM_OUTPUT_DISABLED, NULL }, \
382  { PWM_OUTPUT_DISABLED, NULL }, \
383  }, \
384  0, \
385  0 \
386 }
387 
391 #ifndef DSHOT_TELEMETRY_DEV
392 #define DSHOT_TELEMETRY_DEV NULL
393 #endif
394 
395 #ifndef USE_DSHOT_TIM4
396 #define USE_DSHOT_TIM4 1
397 #endif
398 
399 #if USE_DSHOT_TIM4 // Servo 7, 8, 9, 10 on TIM4
400 
401 // Servo B1, B2, B3, B4 on TM4 are primary DSHOT connector
402 #define DSHOT_SERVO_7 1
403 #define DSHOT_SERVO_7_GPIO PAL_PORT(LINE_S7)
404 #define DSHOT_SERVO_7_PIN PAL_PAD(LINE_S7)
405 #define DSHOT_SERVO_7_AF AF_S7
406 #define DSHOT_SERVO_7_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S7_TIM)
407 #define DSHOT_SERVO_7_CHANNEL S7_TIM_CH
408 
409 #define DSHOT_SERVO_8 2
410 #define DSHOT_SERVO_8_GPIO PAL_PORT(LINE_S8)
411 #define DSHOT_SERVO_8_PIN PAL_PAD(LINE_S8)
412 #define DSHOT_SERVO_8_AF AF_S8
413 #define DSHOT_SERVO_8_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S8_TIM)
414 #define DSHOT_SERVO_8_CHANNEL S8_TIM_CH
415 
416 #define DSHOT_SERVO_9 3
417 #define DSHOT_SERVO_9_GPIO PAL_PORT(LINE_S9)
418 #define DSHOT_SERVO_9_PIN PAL_PAD(LINE_S9)
419 #define DSHOT_SERVO_9_AF AF_S9
420 #define DSHOT_SERVO_9_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S9_TIM)
421 #define DSHOT_SERVO_9_CHANNEL S9_TIM_CH
422 
423 #define DSHOT_SERVO_10 4
424 #define DSHOT_SERVO_10_GPIO PAL_PORT(LINE_S10)
425 #define DSHOT_SERVO_10_PIN PAL_PAD(LINE_S10)
426 #define DSHOT_SERVO_10_AF AF_S10
427 #define DSHOT_SERVO_10_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S10_TIM)
428 #define DSHOT_SERVO_10_CHANNEL S10_TIM_CH
429 
430 #define DSHOT_CONF_TIM4 1
431 #define DSHOT_CONF4_DEF { \
432  .dma_stream = STM32_PWM4_UP_DMA_STREAM, \
433  .dma_channel = STM32_PWM4_UP_DMA_CHANNEL, \
434  .pwmp = &PWMD4, \
435  .tlm_sd = DSHOT_TELEMETRY_DEV, \
436  .dma_buf = &dshot4DmaBuffer, \
437  .dcache_memory_in_use = false \
438 }
439 
440 #endif
441 
445 #define UART7_GPIO_PORT_TX PAL_PORT(LINE_UART7_TX)
446 #define UART7_GPIO_TX PAL_PAD(LINE_UART7_TX)
447 #define UART7_GPIO_PORT_RX PAL_PORT(LINE_UART7_RX)
448 #define UART7_GPIO_RX PAL_PAD(LINE_UART7_RX)
449 #define UART7_GPIO_AF AF_UART7_TX
450 #ifndef UART7_HW_FLOW_CONTROL
451 #define UART7_HW_FLOW_CONTROL FALSE
452 #endif
453 
459 #define UART2_GPIO_PORT_TX PAL_PORT(LINE_UART2_TX)
460 #define UART2_GPIO_TX PAL_PAD(LINE_UART2_TX)
461 #define UART2_GPIO_PORT_RX PAL_PORT(LINE_UART2_RX)
462 #define UART2_GPIO_RX PAL_PAD(LINE_UART2_RX)
463 #define UART2_GPIO_AF AF_UART2_TX
464 
465 #define UART3_GPIO_PORT_TX PAL_PORT(LINE_UART3_TX)
466 #define UART3_GPIO_TX PAL_PAD(LINE_UART3_TX)
467 #define UART3_GPIO_PORT_RX PAL_PORT(LINE_UART3_RX)
468 #define UART3_GPIO_RX PAL_PAD(LINE_UART3_RX)
469 #define UART3_GPIO_AF AF_UART3_TX
470 
475 #define UART8_GPIO_PORT_TX PAL_PORT(LINE_UART8_TX)
476 #define UART8_GPIO_TX PAL_PAD(LINE_UART8_TX)
477 #define UART8_GPIO_PORT_RX PAL_PORT(LINE_UART8_RX)
478 #define UART8_GPIO_RX PAL_PAD(LINE_UART8_RX)
479 #define UART8_GPIO_AF AF_UART8_TX
480 
485 #define USE_UART6_RX TRUE
486 #define USE_UART6_TX FALSE
487 #define UART6_GPIO_PORT_RX PAL_PORT(LINE_RC1)
488 #define UART6_GPIO_RX PAL_PAD(LINE_RC1)
489 #define UART6_GPIO_AF RC1_USART_AF
490 
491 /* The line that is pulled low at power up to initiate the bind process
492  * PB1: AUXb4
493  */
494 #define SPEKTRUM_BIND_PIN PAL_PORT(LINE_XXX)
495 #define SPEKTRUM_BIND_PIN_PORT PAL_PAD(LINE_XXX)
496 
497 // no wait with chibios as the RTC oscillator takes longer to stabilize
498 #define SPEKTRUM_BIND_WAIT 30000
499 
505 #define RC_PPM_TICKS_PER_USEC 6
506 #define PPM_TIMER_FREQUENCY 6000000
507 #define PPM_CHANNEL CONCAT_BOARD_PARAM(ICU_CHANNEL_, RC2_TIM_CH)
508 #define PPM_TIMER CONCAT_BOARD_PARAM(ICUD, RC2_TIM)
509 
510 /*
511  * PWM input
512  */
513 // PWM_INPUT 1
514 #define PWM_INPUT1_ICU ICUD1
515 #define PWM_INPUT1_CHANNEL ICU_CHANNEL_1
516 #define PWM_INPUT1_GPIO_PORT PAL_PORT(LINE_LED_WS2812)
517 #define PWM_INPUT1_GPIO_PIN PAL_PAD(LINE_LED_WS2812)
518 #define PWM_INPUT1_GPIO_AF AF_LED_WS2812
519 
523 // Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
524 #define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
525 // Timing register
526 #define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
527  STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
528  STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
529 #define I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(1U) | \
530  STM32_TIMINGR_SCLDEL(9U) | STM32_TIMINGR_SDADEL(0U) | \
531  STM32_TIMINGR_SCLH(105U) | STM32_TIMINGR_SCLL(153U))
532 
533 
534 #ifndef I2C1_CLOCK_SPEED
535 #define I2C1_CLOCK_SPEED 400000
536 #endif
537 
538 #if I2C1_CLOCK_SPEED == 400000
539 #define I2C1_CFG_DEF { \
540  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
541  .cr1 = STM32_CR1_DNF(0), \
542  .cr2 = 0 \
543 }
544 #elif I2C1_CLOCK_SPEED == 100000
545 #define I2C1_CFG_DEF { \
546  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
547  .cr1 = STM32_CR1_DNF(0), \
548  .cr2 = 0 \
549 }
550 #else
551 #error "Unknown I2C1 clock speed"
552 #endif
553 
554 #ifndef I2C2_CLOCK_SPEED
555 #define I2C2_CLOCK_SPEED 400000
556 #endif
557 
558 #if I2C2_CLOCK_SPEED == 400000
559 #define I2C2_CFG_DEF { \
560  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
561  .cr1 = STM32_CR1_DNF(0), \
562  .cr2 = 0 \
563 }
564 #elif I2C2_CLOCK_SPEED == 100000
565 #define I2C2_CFG_DEF { \
566  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
567  .cr1 = STM32_CR1_DNF(0), \
568  .cr2 = 0 \
569 }
570 #else
571 #error "Unknown I2C2 clock speed"
572 #endif
573 
578 // Internal SPI (IMU1)
579 #define SPI3_GPIO_AF AF_SPI3_CLK
580 #define SPI3_GPIO_PORT_MISO PAL_PORT(LINE_SPI3_MISO)
581 #define SPI3_GPIO_MISO PAL_PAD(LINE_SPI3_MISO)
582 #define SPI3_GPIO_PORT_MOSI PAL_PORT(LINE_SPI3_MOSI)
583 #define SPI3_GPIO_MOSI PAL_PAD(LINE_SPI3_MOSI)
584 #define SPI3_GPIO_PORT_SCK PAL_PORT(LINE_SPI3_CLK)
585 #define SPI3_GPIO_SCK PAL_PAD(LINE_SPI3_CLK)
586 
587 // Internal SPI (IMU2)
588 #define SPI1_GPIO_AF AF_SPI1_CLK
589 #define SPI1_GPIO_PORT_MISO PAL_PORT(LINE_SPI1_MISO)
590 #define SPI1_GPIO_MISO PAL_PAD(LINE_SPI1_MISO)
591 #define SPI1_GPIO_PORT_MOSI PAL_PORT(LINE_SPI1_MOSI)
592 #define SPI1_GPIO_MOSI PAL_PAD(LINE_SPI1_MOSI)
593 #define SPI1_GPIO_PORT_SCK PAL_PORT(LINE_SPI1_CLK)
594 #define SPI1_GPIO_SCK PAL_PAD(LINE_SPI1_CLK)
595 
596 // Internal SPI (OSD)
597 #define SPI2_GPIO_AF AF_SPI2_CLK
598 #define SPI2_GPIO_PORT_MISO PAL_PORT(LINE_SPI2_MISO)
599 #define SPI2_GPIO_MISO PAL_PAD(LINE_SPI2_MISO)
600 #define SPI2_GPIO_PORT_MOSI PAL_PORT(LINE_SPI2_MOSI)
601 #define SPI2_GPIO_MOSI PAL_PAD(LINE_SPI2_MOSI)
602 #define SPI2_GPIO_PORT_SCK PAL_PORT(LINE_SPI2_CLK)
603 #define SPI2_GPIO_SCK PAL_PAD(LINE_SPI2_CLK)
604 
605 // External SPI
606 #define SPI4_GPIO_AF AF_SPI4_INTERNAL_CLK
607 #define SPI4_GPIO_PORT_MISO PAL_PORT(LINE_SPI4_INTERNAL_MISO)
608 #define SPI4_GPIO_MISO PAL_PAD(LINE_SPI4_INTERNAL_MISO)
609 #define SPI4_GPIO_PORT_MOSI PAL_PORT(LINE_SPI4_INTERNAL_MOSI)
610 #define SPI4_GPIO_MOSI PAL_PAD(LINE_SPI4_INTERNAL_MOSI)
611 #define SPI4_GPIO_PORT_SCK PAL_PORT(LINE_SPI4_INTERNAL_CLK)
612 #define SPI4_GPIO_SCK PAL_PAD(LINE_SPI4_INTERNAL_CLK)
613 
614 // SLAVE0 on SPI4 connector
615 #define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_SPI4_CS)
616 #define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_SPI4_CS)
617 // SLAVE1 on S11
618 #define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_S11)
619 #define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_S11)
620 // SLAVE2 on S12
621 #define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_S11)
622 #define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_S12)
623 // SLAVE3 on IMU1 (MPU6000)
624 #define SPI_SELECT_SLAVE3_PORT PAL_PORT(LINE_IMU1_CS)
625 #define SPI_SELECT_SLAVE3_PIN PAL_PAD(LINE_IMU1_CS)
626 // SLAVE4 on IMU2 (ICM20602)
627 #define SPI_SELECT_SLAVE4_PORT PAL_PORT(LINE_IMU2_CS)
628 #define SPI_SELECT_SLAVE4_PIN PAL_PAD(LINE_IMU2_CS)
629 // SLAVE5 on OSD
630 #define SPI_SELECT_SLAVE5_PORT PAL_PORT(LINE_OSD_CS)
631 #define SPI_SELECT_SLAVE5_PIN PAL_PAD(LINE_OSD_CS)
632 
639 #ifndef USE_BARO_BOARD
640 #define USE_BARO_BOARD 0
641 #endif
642 
646 #define SDIO_D0_PORT PAL_PORT(LINE_SDMMC1_D0)
647 #define SDIO_D0_PIN PAL_PAD(LINE_SDMMC1_D0)
648 #define SDIO_D1_PORT PAL_PORT(LINE_SDMMC1_D1)
649 #define SDIO_D1_PIN PAL_PAD(LINE_SDMMC1_D1)
650 #define SDIO_D2_PORT PAL_PORT(LINE_SDMMC1_D2)
651 #define SDIO_D2_PIN PAL_PAD(LINE_SDMMC1_D2)
652 #define SDIO_D3_PORT PAL_PORT(LINE_SDMMC1_D3)
653 #define SDIO_D3_PIN PAL_PAD(LINE_SDMMC1_D3)
654 #define SDIO_CK_PORT PAL_PORT(LINE_SDMMC1_CK)
655 #define SDIO_CK_PIN PAL_PAD(LINE_SDMMC1_CK)
656 #define SDIO_CMD_PORT PAL_PORT(LINE_SDMMC1_CMD)
657 #define SDIO_CMD_PIN PAL_PAD(LINE_SDMMC1_CMD)
658 #define SDIO_AF AF_SDMMC1_CK
659 // bat monitoring for file closing
660 #define SDLOG_BAT_ADC CONCAT_BOARD_PARAM(ADCD, VBAT_MEAS_ADC)
661 #define SDLOG_BAT_CHAN CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, VBAT_MEAS_ADC_IN)
662 // usb led status
663 #define SDLOG_USB_LED 2
664 //#define SDLOG_USB_VBUS_PORT PAL_PORT(LINE_USB_VBUS) // FIXME
665 //#define SDLOG_USB_VBUS_PIN PAL_PAD(LINE_USB_VBUS)
666 
667 
668 /*
669  * Actuators for fixedwing
670  */
671  /* Default actuators driver */
672 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
673 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
674 #define ActuatorsDefaultInit() ActuatorsPwmInit()
675 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
676 
680 #define WS2812D1_GPIO PAL_PORT(LINE_LED_WS2812)
681 #define WS2812D1_PIN PAL_PAD(LINE_LED_WS2812)
682 #define WS2812D1_AF AF_LED_WS2812
683 #define WS2812D1_CFG_DEF { \
684  .dma_stream = STM32_PWM1_UP_DMA_STREAM, \
685  .dma_channel = STM32_PWM1_UP_DMA_CHANNEL, \
686  .dma_priority = STM32_PWM1_UP_DMA_PRIORITY, \
687  .pwm_channel = 0, \
688  .pwmp = &PWMD1 \
689 }
690 
691 #endif /* CONFIG_MATEK_F765_WING_H */
692 
board.h