Paparazzi UAS
v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
common_board.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Freek van Tienen <freek.v.tienen@gmail.com>
3
*
4
* This file is part of Paparazzi.
5
*
6
* Paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* Paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with Paparazzi; see the file COPYING. If not, write to
18
* the Free Software Foundation, 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
20
*
21
*/
22
27
#ifndef ARCH_COMMON_BOARD_H
28
#define ARCH_COMMON_BOARD_H
29
32
#include "board.h"
33
34
/*
35
* Concat macro
36
*/
37
#define _CONCAT_BOARD_PARAM(_s1, _s2) _s1 ## _s2
38
#define CONCAT_BOARD_PARAM(_s1, _s2) _CONCAT_BOARD_PARAM(_s1, _s2)
39
40
/*
41
* LEDs
42
*/
43
#if defined(LINE_LED1)
44
#ifndef USE_LED_1
45
#define USE_LED_1 1
46
#endif
47
#define LED_1_GPIO PAL_PORT(LINE_LED1)
48
#define LED_1_GPIO_PIN PAL_PAD(LINE_LED1)
49
#define LED_1_GPIO_ON gpio_clear
50
#define LED_1_GPIO_OFF gpio_set
51
#endif
52
53
#if defined(LINE_LED2)
54
#ifndef USE_LED_2
55
#define USE_LED_2 1
56
#endif
57
#define LED_2_GPIO PAL_PORT(LINE_LED2)
58
#define LED_2_GPIO_PIN PAL_PAD(LINE_LED2)
59
#define LED_2_GPIO_ON gpio_clear
60
#define LED_2_GPIO_OFF gpio_set
61
#endif
62
63
#if defined(LINE_LED3)
64
#ifndef USE_LED_3
65
#define USE_LED_3 1
66
#endif
67
#define LED_3_GPIO PAL_PORT(LINE_LED3)
68
#define LED_3_GPIO_PIN PAL_PAD(LINE_LED3)
69
#define LED_3_GPIO_ON gpio_clear
70
#define LED_3_GPIO_OFF gpio_set
71
#endif
72
73
#if defined(LINE_LED4)
74
#ifndef USE_LED_4
75
#define USE_LED_4 1
76
#endif
77
#define LED_4_GPIO PAL_PORT(LINE_LED4)
78
#define LED_4_GPIO_PIN PAL_PAD(LINE_LED4)
79
#define LED_4_GPIO_ON gpio_clear
80
#define LED_4_GPIO_OFF gpio_set
81
#endif
82
83
/*
84
* ADCs
85
*/
86
#if defined(LINE_ADC1)
87
#ifndef USE_ADC_1
88
#define USE_ADC_1 1
89
#endif
90
#if USE_ADC_1
91
#if defined(ADC1_ADC_IN)
92
#define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC1_ADC_IN)
93
#elif defined(ADC1_ADC_INP)
94
#define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC1_ADC_INP)
95
#endif
96
#define ADC_1 AD1_1
97
#define ADC_1_GPIO_PORT PAL_PORT(LINE_ADC1)
98
#define ADC_1_GPIO_PIN PAL_PAD(LINE_ADC1)
99
#endif
100
#endif
101
102
#if defined(LINE_ADC2)
103
#ifndef USE_ADC_2
104
#define USE_ADC_2 1
105
#endif
106
#if USE_ADC_2
107
#if defined(ADC2_ADC_IN)
108
#define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC2_ADC_IN)
109
#elif defined(ADC2_ADC_INP)
110
#define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC2_ADC_INP)
111
#endif
112
#define ADC_2 AD1_2
113
#define ADC_2_GPIO_PORT PAL_PORT(LINE_ADC2)
114
#define ADC_2_GPIO_PIN PAL_PAD(LINE_ADC2)
115
#endif
116
#endif
117
118
#if defined(LINE_ADC3)
119
#ifndef USE_ADC_3
120
#define USE_ADC_3 1
121
#endif
122
#if USE_ADC_3
123
#if defined(ADC3_ADC_IN)
124
#define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC3_ADC_IN)
125
#elif defined(ADC3_ADC_INP)
126
#define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC3_ADC_INP)
127
#endif
128
#define ADC_3 AD1_3
129
#define ADC_3_GPIO_PORT PAL_PORT(LINE_ADC3)
130
#define ADC_3_GPIO_PIN PAL_PAD(LINE_ADC3)
131
#endif
132
#endif
133
134
#if defined(LINE_ADC4)
135
#ifndef USE_ADC_4
136
#define USE_ADC_4 1
137
#endif
138
#if USE_ADC_4
139
#if defined(ADC4_ADC_IN)
140
#define AD1_4_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC4_ADC_IN)
141
#elif defined(ADC4_ADC_INP)
142
#define AD1_4_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC4_ADC_INP)
143
#endif
144
#define ADC_4 AD1_4
145
#define ADC_4_GPIO_PORT PAL_PORT(LINE_ADC4)
146
#define ADC_4_GPIO_PIN PAL_PAD(LINE_ADC4)
147
#endif
148
#endif
149
150
#if defined(LINE_ADC5)
151
#ifndef USE_ADC_5
152
#define USE_ADC_5 1
153
#endif
154
#if USE_ADC_5
155
#if defined(ADC5_ADC_IN)
156
#define AD1_5_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC5_ADC_IN)
157
#elif defined(ADC5_ADC_INP)
158
#define AD1_5_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC5_ADC_INP)
159
#endif
160
#define ADC_5 AD1_5
161
#define ADC_5_GPIO_PORT PAL_PORT(LINE_ADC5)
162
#define ADC_5_GPIO_PIN PAL_PAD(LINE_ADC5)
163
#endif
164
#endif
165
166
#if defined(LINE_ADC6)
167
#if USE_ADC_6
168
#if defined(ADC6_ADC_IN)
169
#define AD1_6_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC6_ADC_IN)
170
#elif defined(ADC6_ADC_INP)
171
#define AD1_6_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC6_ADC_INP)
172
#endif
173
#define ADC_6 AD1_6
174
#define ADC_6_GPIO_PORT PAL_PORT(LINE_ADC6)
175
#define ADC_6_GPIO_PIN PAL_PAD(LINE_ADC6)
176
#endif
177
#endif
178
179
/*
180
* PWM defines
181
*/
182
#if defined(LINE_SERVO1)
183
#ifndef USE_PWM1
184
#define USE_PWM1 1
185
#endif
186
#if USE_PWM1
187
#define PWM_SERVO_1 0
188
#define PWM_SERVO_1_GPIO PAL_PORT(LINE_SERVO1)
189
#define PWM_SERVO_1_PIN PAL_PAD(LINE_SERVO1)
190
#define PWM_SERVO_1_AF AF_LINE_SERVO1
191
#define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO1_TIM)
192
#define PWM_SERVO_1_CHANNEL (SERVO1_TIM_CH-1)
193
#define PWM_SERVO_1_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO1_TIM)
194
#endif
195
#endif
196
197
#if defined(LINE_SERVO2)
198
#ifndef USE_PWM2
199
#define USE_PWM2 1
200
#endif
201
#if USE_PWM2
202
#define PWM_SERVO_2 1
203
#define PWM_SERVO_2_GPIO PAL_PORT(LINE_SERVO2)
204
#define PWM_SERVO_2_PIN PAL_PAD(LINE_SERVO2)
205
#define PWM_SERVO_2_AF AF_LINE_SERVO2
206
#define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO2_TIM)
207
#define PWM_SERVO_2_CHANNEL (SERVO2_TIM_CH-1)
208
#define PWM_SERVO_2_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO2_TIM)
209
#endif
210
#endif
211
212
#if defined(LINE_SERVO3)
213
#ifndef USE_PWM3
214
#define USE_PWM3 1
215
#endif
216
#if USE_PWM3
217
#define PWM_SERVO_3 2
218
#define PWM_SERVO_3_GPIO PAL_PORT(LINE_SERVO3)
219
#define PWM_SERVO_3_PIN PAL_PAD(LINE_SERVO3)
220
#define PWM_SERVO_3_AF AF_LINE_SERVO3
221
#define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO3_TIM)
222
#define PWM_SERVO_3_CHANNEL (SERVO3_TIM_CH-1)
223
#define PWM_SERVO_3_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO3_TIM)
224
#endif
225
#endif
226
227
#if defined(LINE_SERVO4)
228
#ifndef USE_PWM4
229
#define USE_PWM4 1
230
#endif
231
#if USE_PWM4
232
#define PWM_SERVO_4 3
233
#define PWM_SERVO_4_GPIO PAL_PORT(LINE_SERVO4)
234
#define PWM_SERVO_4_PIN PAL_PAD(LINE_SERVO4)
235
#define PWM_SERVO_4_AF AF_LINE_SERVO4
236
#define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO4_TIM)
237
#define PWM_SERVO_4_CHANNEL (SERVO4_TIM_CH-1)
238
#define PWM_SERVO_4_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO4_TIM)
239
#endif
240
#endif
241
242
#if defined(LINE_SERVO5)
243
#ifndef USE_PWM5
244
#define USE_PWM5 1
245
#endif
246
#if USE_PWM5
247
#define PWM_SERVO_5 4
248
#define PWM_SERVO_5_GPIO PAL_PORT(LINE_SERVO5)
249
#define PWM_SERVO_5_PIN PAL_PAD(LINE_SERVO5)
250
#define PWM_SERVO_5_AF AF_LINE_SERVO5
251
#define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO5_TIM)
252
#define PWM_SERVO_5_CHANNEL (SERVO5_TIM_CH-1)
253
#define PWM_SERVO_5_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO5_TIM)
254
#endif
255
#endif
256
257
#if defined(LINE_SERVO6)
258
#ifndef USE_PWM6
259
#define USE_PWM6 1
260
#endif
261
#if USE_PWM6
262
#define PWM_SERVO_6 5
263
#define PWM_SERVO_6_GPIO PAL_PORT(LINE_SERVO6)
264
#define PWM_SERVO_6_PIN PAL_PAD(LINE_SERVO6)
265
#define PWM_SERVO_6_AF AF_LINE_SERVO6
266
#define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO6_TIM)
267
#define PWM_SERVO_6_CHANNEL (SERVO6_TIM_CH-1)
268
#define PWM_SERVO_6_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO6_TIM)
269
#endif
270
#endif
271
272
#if defined(LINE_SERVO7)
273
#ifndef USE_PWM7
274
#define USE_PWM7 1
275
#endif
276
#if USE_PWM7
277
#define PWM_SERVO_7 6
278
#define PWM_SERVO_7_GPIO PAL_PORT(LINE_SERVO7)
279
#define PWM_SERVO_7_PIN PAL_PAD(LINE_SERVO7)
280
#define PWM_SERVO_7_AF AF_LINE_SERVO7
281
#define PWM_SERVO_7_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO7_TIM)
282
#define PWM_SERVO_7_CHANNEL (SERVO7_TIM_CH-1)
283
#define PWM_SERVO_7_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO7_TIM)
284
#endif
285
#endif
286
287
#if defined(LINE_SERVO8)
288
#ifndef USE_PWM8
289
#define USE_PWM8 1
290
#endif
291
#if USE_PWM8
292
#define PWM_SERVO_8 7
293
#define PWM_SERVO_8_GPIO PAL_PORT(LINE_SERVO8)
294
#define PWM_SERVO_8_PIN PAL_PAD(LINE_SERVO8)
295
#define PWM_SERVO_8_AF AF_LINE_SERVO8
296
#define PWM_SERVO_8_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO8_TIM)
297
#define PWM_SERVO_8_CHANNEL (SERVO8_TIM_CH-1)
298
#define PWM_SERVO_8_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO8_TIM)
299
#endif
300
#endif
301
305
#if defined(LINE_UART1_TX)
306
#define UART1_GPIO_PORT_TX PAL_PORT(LINE_UART1_TX)
307
#define UART1_GPIO_TX PAL_PAD(LINE_UART1_TX)
308
#endif
309
#if defined(LINE_UART1_RX)
310
#define UART1_GPIO_PORT_RX PAL_PORT(LINE_UART1_RX)
311
#define UART1_GPIO_RX PAL_PAD(LINE_UART1_RX)
312
#endif
313
#if defined(AF_LINE_UART1_TX)
314
#define UART1_GPIO_AF AF_LINE_UART1_TX
315
#elif defined(AF_LINE_UART1_RX)
316
#define UART1_GPIO_AF AF_LINE_UART1_RX
317
#else
318
#define UART1_GPIO_AF ((void)0)
319
#endif
320
321
#if defined(LINE_UART2_TX)
322
#define UART2_GPIO_PORT_TX PAL_PORT(LINE_UART2_TX)
323
#define UART2_GPIO_TX PAL_PAD(LINE_UART2_TX)
324
#endif
325
#if defined(LINE_UART2_RX)
326
#define UART2_GPIO_PORT_RX PAL_PORT(LINE_UART2_RX)
327
#define UART2_GPIO_RX PAL_PAD(LINE_UART2_RX)
328
#endif
329
#if defined(AF_LINE_UART2_TX)
330
#define UART2_GPIO_AF AF_LINE_UART2_TX
331
#elif defined(AF_LINE_UART2_RX)
332
#define UART2_GPIO_AF AF_LINE_UART2_RX
333
#else
334
#define UART2_GPIO_AF ((void)0)
335
#endif
336
337
#if defined(LINE_UART3_TX)
338
#define UART3_GPIO_PORT_TX PAL_PORT(LINE_UART3_TX)
339
#define UART3_GPIO_TX PAL_PAD(LINE_UART3_TX)
340
#endif
341
#if defined(LINE_UART3_RX)
342
#define UART3_GPIO_PORT_RX PAL_PORT(LINE_UART3_RX)
343
#define UART3_GPIO_RX PAL_PAD(LINE_UART3_RX)
344
#endif
345
#if defined(AF_LINE_UART3_TX)
346
#define UART3_GPIO_AF AF_LINE_UART3_TX
347
#elif defined(AF_LINE_UART3_RX)
348
#define UART3_GPIO_AF AF_LINE_UART3_RX
349
#else
350
#define UART3_GPIO_AF ((void)0)
351
#endif
352
353
#if defined(LINE_UART4_TX)
354
#define UART4_GPIO_PORT_TX PAL_PORT(LINE_UART4_TX)
355
#define UART4_GPIO_TX PAL_PAD(LINE_UART4_TX)
356
#endif
357
#if defined(LINE_UART4_RX)
358
#define UART4_GPIO_PORT_RX PAL_PORT(LINE_UART4_RX)
359
#define UART4_GPIO_RX PAL_PAD(LINE_UART4_RX)
360
#endif
361
#if defined(AF_LINE_UART4_TX)
362
#define UART4_GPIO_AF AF_LINE_UART4_TX
363
#elif defined(AF_LINE_UART4_RX)
364
#define UART4_GPIO_AF AF_LINE_UART4_RX
365
#else
366
#define UART4_GPIO_AF ((void)0)
367
#endif
368
369
#if defined(LINE_UART5_TX)
370
#define UART5_GPIO_PORT_TX PAL_PORT(LINE_UART5_TX)
371
#define UART5_GPIO_TX PAL_PAD(LINE_UART5_TX)
372
#endif
373
#if defined(LINE_UART5_RX)
374
#define UART5_GPIO_PORT_RX PAL_PORT(LINE_UART5_RX)
375
#define UART5_GPIO_RX PAL_PAD(LINE_UART5_RX)
376
#endif
377
#if defined(AF_LINE_UART5_TX)
378
#define UART5_GPIO_AF AF_LINE_UART5_TX
379
#elif defined(AF_LINE_UART5_RX)
380
#define UART5_GPIO_AF AF_LINE_UART5_RX
381
#else
382
#define UART5_GPIO_AF ((void)0)
383
#endif
384
385
#if defined(LINE_UART6_TX)
386
#define UART6_GPIO_PORT_TX PAL_PORT(LINE_UART6_TX)
387
#define UART6_GPIO_TX PAL_PAD(LINE_UART6_TX)
388
#endif
389
#if defined(LINE_UART6_RX)
390
#define UART6_GPIO_PORT_RX PAL_PORT(LINE_UART6_RX)
391
#define UART6_GPIO_RX PAL_PAD(LINE_UART6_RX)
392
#endif
393
#if defined(AF_LINE_UART6_TX)
394
#define UART6_GPIO_AF AF_LINE_UART6_TX
395
#elif defined(AF_LINE_UART6_RX)
396
#define UART6_GPIO_AF AF_LINE_UART6_RX
397
#else
398
#define UART6_GPIO_AF ((void)0)
399
#endif
400
401
#if defined(LINE_UART7_TX)
402
#define UART7_GPIO_PORT_TX PAL_PORT(LINE_UART7_TX)
403
#define UART7_GPIO_TX PAL_PAD(LINE_UART7_TX)
404
#endif
405
#if defined(LINE_UART7_RX)
406
#define UART7_GPIO_PORT_RX PAL_PORT(LINE_UART7_RX)
407
#define UART7_GPIO_RX PAL_PAD(LINE_UART7_RX)
408
#endif
409
#if defined(AF_LINE_UART7_TX)
410
#define UART7_GPIO_AF AF_LINE_UART7_TX
411
#elif defined(AF_LINE_UART7_RX)
412
#define UART7_GPIO_AF AF_LINE_UART7_RX
413
#else
414
#define UART7_GPIO_AF ((void)0)
415
#endif
416
417
#if defined(LINE_UART8_TX)
418
#define UART8_GPIO_PORT_TX PAL_PORT(LINE_UART8_TX)
419
#define UART8_GPIO_TX PAL_PAD(LINE_UART8_TX)
420
#endif
421
#if defined(LINE_UART8_RX)
422
#define UART8_GPIO_PORT_RX PAL_PORT(LINE_UART8_RX)
423
#define UART8_GPIO_RX PAL_PAD(LINE_UART8_RX)
424
#endif
425
#if defined(AF_LINE_UART8_TX)
426
#define UART8_GPIO_AF AF_LINE_UART8_TX
427
#elif defined(AF_LINE_UART8_RX)
428
#define UART8_GPIO_AF AF_LINE_UART8_RX
429
#else
430
#define UART8_GPIO_AF ((void)0)
431
#endif
432
436
// Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
437
#define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
438
// Timing register
439
#define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
440
STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
441
STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
442
#define I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(1U) | \
443
STM32_TIMINGR_SCLDEL(9U) | STM32_TIMINGR_SDADEL(0U) | \
444
STM32_TIMINGR_SCLH(105U) | STM32_TIMINGR_SCLL(153U))
445
446
447
#ifndef I2C1_CLOCK_SPEED
448
#define I2C1_CLOCK_SPEED 400000
449
#endif
450
451
#if I2C1_CLOCK_SPEED == 400000
452
#define I2C1_CFG_DEF { \
453
.timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
454
.cr1 = STM32_CR1_DNF(0), \
455
.cr2 = 0 \
456
}
457
#elif I2C1_CLOCK_SPEED == 100000
458
#define I2C1_CFG_DEF { \
459
.timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
460
.cr1 = STM32_CR1_DNF(0), \
461
.cr2 = 0 \
462
}
463
#else
464
#error "Unknown I2C1 clock speed"
465
#endif
466
467
468
#ifndef I2C2_CLOCK_SPEED
469
#define I2C2_CLOCK_SPEED 400000
470
#endif
471
472
#if I2C2_CLOCK_SPEED == 400000
473
#define I2C2_CFG_DEF { \
474
.timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
475
.cr1 = STM32_CR1_DNF(0), \
476
.cr2 = 0 \
477
}
478
#elif I2C2_CLOCK_SPEED == 100000
479
#define I2C2_CFG_DEF { \
480
.timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
481
.cr1 = STM32_CR1_DNF(0), \
482
.cr2 = 0 \
483
}
484
#else
485
#error "Unknown I2C2 clock speed"
486
#endif
487
488
#ifndef I2C3_CLOCK_SPEED
489
#define I2C3_CLOCK_SPEED 400000
490
#endif
491
492
#if I2C3_CLOCK_SPEED == 400000
493
#define I2C3_CFG_DEF { \
494
.timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
495
.cr1 = STM32_CR1_DNF(0), \
496
.cr2 = 0 \
497
}
498
#elif I2C3_CLOCK_SPEED == 100000
499
#define I2C3_CFG_DEF { \
500
.timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
501
.cr1 = STM32_CR1_DNF(0), \
502
.cr2 = 0 \
503
}
504
#else
505
#error "Unknown I2C3 clock speed"
506
#endif
507
508
#ifndef I2C4_CLOCK_SPEED
509
#define I2C4_CLOCK_SPEED 400000
510
#endif
511
512
#if I2C4_CLOCK_SPEED == 400000
513
#define I2C4_CFG_DEF { \
514
.timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
515
.cr1 = STM32_CR1_DNF(0), \
516
.cr2 = 0 \
517
}
518
#elif I2C4_CLOCK_SPEED == 100000
519
#define I2C4_CFG_DEF { \
520
.timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
521
.cr1 = STM32_CR1_DNF(0), \
522
.cr2 = 0 \
523
}
524
#else
525
#error "Unknown I2C4 clock speed"
526
#endif
527
531
#if defined(LINE_SPI1_MISO) && defined(LINE_SPI1_MOSI) && defined(LINE_SPI1_SCK)
532
#define SPI1_GPIO_PORT_MISO PAL_PORT(LINE_SPI1_MISO)
533
#define SPI1_GPIO_MISO PAL_PAD(LINE_SPI1_MISO)
534
#define SPI1_GPIO_PORT_MOSI PAL_PORT(LINE_SPI1_MOSI)
535
#define SPI1_GPIO_MOSI PAL_PAD(LINE_SPI1_MOSI)
536
#define SPI1_GPIO_PORT_SCK PAL_PORT(LINE_SPI1_SCK)
537
#define SPI1_GPIO_SCK PAL_PAD(LINE_SPI1_SCK)
538
539
#if defined(AF_LINE_SPI1_SCK)
540
#define SPI1_GPIO_AF AF_LINE_SPI1_SCK
541
#endif
542
#endif
543
544
#if defined(LINE_SPI2_MISO) && defined(LINE_SPI2_MOSI) && defined(LINE_SPI2_SCK)
545
#define SPI2_GPIO_PORT_MISO PAL_PORT(LINE_SPI2_MISO)
546
#define SPI2_GPIO_MISO PAL_PAD(LINE_SPI2_MISO)
547
#define SPI2_GPIO_PORT_MOSI PAL_PORT(LINE_SPI2_MOSI)
548
#define SPI2_GPIO_MOSI PAL_PAD(LINE_SPI2_MOSI)
549
#define SPI2_GPIO_PORT_SCK PAL_PORT(LINE_SPI2_SCK)
550
#define SPI2_GPIO_SCK PAL_PAD(LINE_SPI2_SCK)
551
552
#if defined(AF_LINE_SPI2_SCK)
553
#define SPI2_GPIO_AF AF_LINE_SPI2_SCK
554
#endif
555
#endif
556
557
#if defined(LINE_SPI3_MISO) && defined(LINE_SPI3_MOSI) && defined(LINE_SPI3_SCK)
558
#define SPI3_GPIO_PORT_MISO PAL_PORT(LINE_SPI3_MISO)
559
#define SPI3_GPIO_MISO PAL_PAD(LINE_SPI3_MISO)
560
#define SPI3_GPIO_PORT_MOSI PAL_PORT(LINE_SPI3_MOSI)
561
#define SPI3_GPIO_MOSI PAL_PAD(LINE_SPI3_MOSI)
562
#define SPI3_GPIO_PORT_SCK PAL_PORT(LINE_SPI3_SCK)
563
#define SPI3_GPIO_SCK PAL_PAD(LINE_SPI3_SCK)
564
565
#if defined(AF_LINE_SPI3_SCK)
566
#define SPI3_GPIO_AF AF_LINE_SPI3_SCK
567
#endif
568
#endif
569
570
#if defined(LINE_SPI4_MISO) && defined(LINE_SPI4_MOSI) && defined(LINE_SPI4_SCK)
571
#define SPI4_GPIO_PORT_MISO PAL_PORT(LINE_SPI4_MISO)
572
#define SPI4_GPIO_MISO PAL_PAD(LINE_SPI4_MISO)
573
#define SPI4_GPIO_PORT_MOSI PAL_PORT(LINE_SPI4_MOSI)
574
#define SPI4_GPIO_MOSI PAL_PAD(LINE_SPI4_MOSI)
575
#define SPI4_GPIO_PORT_SCK PAL_PORT(LINE_SPI4_SCK)
576
#define SPI4_GPIO_SCK PAL_PAD(LINE_SPI4_SCK)
577
578
#if defined(AF_LINE_SPI4_SCK)
579
#define SPI4_GPIO_AF AF_LINE_SPI4_SCK
580
#endif
581
#endif
582
583
#if defined(LINE_SPI5_MISO) && defined(LINE_SPI5_MOSI) && defined(LINE_SPI5_SCK)
584
#define SPI5_GPIO_PORT_MISO PAL_PORT(LINE_SPI5_MISO)
585
#define SPI5_GPIO_MISO PAL_PAD(LINE_SPI5_MISO)
586
#define SPI5_GPIO_PORT_MOSI PAL_PORT(LINE_SPI5_MOSI)
587
#define SPI5_GPIO_MOSI PAL_PAD(LINE_SPI5_MOSI)
588
#define SPI5_GPIO_PORT_SCK PAL_PORT(LINE_SPI5_SCK)
589
#define SPI5_GPIO_SCK PAL_PAD(LINE_SPI5_SCK)
590
591
#if defined(AF_LINE_SPI5_SCK)
592
#define SPI5_GPIO_AF AF_LINE_SPI5_SCK
593
#endif
594
#endif
595
596
#if defined(LINE_SPI6_MISO) && defined(LINE_SPI6_MOSI) && defined(LINE_SPI6_SCK)
597
#define SPI6_GPIO_PORT_MISO PAL_PORT(LINE_SPI6_MISO)
598
#define SPI6_GPIO_MISO PAL_PAD(LINE_SPI6_MISO)
599
#define SPI6_GPIO_PORT_MOSI PAL_PORT(LINE_SPI6_MOSI)
600
#define SPI6_GPIO_MOSI PAL_PAD(LINE_SPI6_MOSI)
601
#define SPI6_GPIO_PORT_SCK PAL_PORT(LINE_SPI6_SCK)
602
#define SPI6_GPIO_SCK PAL_PAD(LINE_SPI6_SCK)
603
604
#if defined(AF_LINE_SPI6_SCK)
605
#define SPI6_GPIO_AF AF_LINE_SPI6_SCK
606
#endif
607
#endif
608
612
#if defined(LINE_SPI_SLAVE0)
613
#define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_SPI_SLAVE0)
614
#define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_SPI_SLAVE0)
615
#endif
616
617
#if defined(LINE_SPI_SLAVE1)
618
#define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_SPI_SLAVE1)
619
#define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_SPI_SLAVE1)
620
#endif
621
622
#if defined(LINE_SPI_SLAVE2)
623
#define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_SPI_SLAVE2)
624
#define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_SPI_SLAVE2)
625
#endif
626
627
#if defined(LINE_SPI_SLAVE3)
628
#define SPI_SELECT_SLAVE3_PORT PAL_PORT(LINE_SPI_SLAVE3)
629
#define SPI_SELECT_SLAVE3_PIN PAL_PAD(LINE_SPI_SLAVE3)
630
#endif
631
632
#if defined(LINE_SPI_SLAVE4)
633
#define SPI_SELECT_SLAVE4_PORT PAL_PORT(LINE_SPI_SLAVE4)
634
#define SPI_SELECT_SLAVE4_PIN PAL_PAD(LINE_SPI_SLAVE4)
635
#endif
636
637
#if defined(LINE_SPI_SLAVE5)
638
#define SPI_SELECT_SLAVE5_PORT PAL_PORT(LINE_SPI_SLAVE5)
639
#define SPI_SELECT_SLAVE5_PIN PAL_PAD(LINE_SPI_SLAVE5)
640
#endif
641
642
#if defined(LINE_SPI_SLAVE6)
643
#define SPI_SELECT_SLAVE6_PORT PAL_PORT(LINE_SPI_SLAVE6)
644
#define SPI_SELECT_SLAVE6_PIN PAL_PAD(LINE_SPI_SLAVE6)
645
#endif
646
647
#if defined(LINE_SPI_SLAVE7)
648
#define SPI_SELECT_SLAVE7_PORT PAL_PORT(LINE_SPI_SLAVE7)
649
#define SPI_SELECT_SLAVE7_PIN PAL_PAD(LINE_SPI_SLAVE7)
650
#endif
651
652
#if defined(LINE_SPI_SLAVE8)
653
#define SPI_SELECT_SLAVE8_PORT PAL_PORT(LINE_SPI_SLAVE8)
654
#define SPI_SELECT_SLAVE8_PIN PAL_PAD(LINE_SPI_SLAVE8)
655
#endif
656
660
#if defined(LINE_SDIO_D0) && defined(LINE_SDIO_D1) && defined(LINE_SDIO_D2) && defined(LINE_SDIO_D3) && defined(LINE_SDIO_CK) && defined(LINE_SDIO_CMD)
661
#define SDIO_D0_PORT PAL_PORT(LINE_SDIO_D0)
662
#define SDIO_D0_PIN PAL_PAD(LINE_SDIO_D0)
663
#define SDIO_D1_PORT PAL_PORT(LINE_SDIO_D1)
664
#define SDIO_D1_PIN PAL_PAD(LINE_SDIO_D1)
665
#define SDIO_D2_PORT PAL_PORT(LINE_SDIO_D2)
666
#define SDIO_D2_PIN PAL_PAD(LINE_SDIO_D2)
667
#define SDIO_D3_PORT PAL_PORT(LINE_SDIO_D3)
668
#define SDIO_D3_PIN PAL_PAD(LINE_SDIO_D3)
669
#define SDIO_CK_PORT PAL_PORT(LINE_SDIO_CK)
670
#define SDIO_CK_PIN PAL_PAD(LINE_SDIO_CK)
671
#define SDIO_CMD_PORT PAL_PORT(LINE_SDIO_CMD)
672
#define SDIO_CMD_PIN PAL_PAD(LINE_SDIO_CMD)
673
674
#if defined(AF_LINE_SDIO_CMD)
675
#define SDIO_AF AF_LINE_SDIO_CMD
676
#else
677
#define SDIO_AF ((void)0)
678
#endif
679
#endif
680
681
#if defined(LINE_USB_VBUS)
682
#define SDLOG_USB_VBUS_PORT PAL_PORT(LINE_USB_VBUS)
683
#define SDLOG_USB_VBUS_PIN PAL_PAD(LINE_USB_VBUS)
684
#define SDLOG_USB_VBUS_BOOT false
685
#endif
686
687
/*
688
* Actuators for fixedwing
689
*/
690
/* Default actuators driver */
691
#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
692
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
693
#define ActuatorsDefaultInit() ActuatorsPwmInit()
694
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
695
696
#endif
/* ARCH_COMMON_BOARD_H */
sw
airborne
arch
chibios
common_board.h
Generated on Fri Jul 29 2022 14:10:22 for Paparazzi UAS by
1.8.17