Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
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
32
#include "board.h"
33
#include <hal.h>
34
35
/*
36
* Concat macro
37
*/
38
#define _CONCAT_BOARD_PARAM(_s1, _s2) _s1 ## _s2
39
#define CONCAT_BOARD_PARAM(_s1, _s2) _CONCAT_BOARD_PARAM(_s1, _s2)
40
41
/*
42
* LEDs
43
*/
44
#if defined(LINE_LED1)
45
#ifndef USE_LED_1
46
#define USE_LED_1 1
47
#endif
48
#define LED_1_GPIO PAL_PORT(LINE_LED1)
49
#define LED_1_GPIO_PIN PAL_PAD(LINE_LED1)
50
#define LED_1_GPIO_ON gpio_clear
51
#define LED_1_GPIO_OFF gpio_set
52
#elif defined(LINE_NLED1)
53
#ifndef USE_LED_1
54
#define USE_LED_1 1
55
#endif
56
#define LED_1_GPIO PAL_PORT(LINE_NLED1)
57
#define LED_1_GPIO_PIN PAL_PAD(LINE_NLED1)
58
#define LED_1_GPIO_ON gpio_set
59
#define LED_1_GPIO_OFF gpio_clear
60
#endif
61
62
#if defined(LINE_LED2)
63
#ifndef USE_LED_2
64
#define USE_LED_2 1
65
#endif
66
#define LED_2_GPIO PAL_PORT(LINE_LED2)
67
#define LED_2_GPIO_PIN PAL_PAD(LINE_LED2)
68
#define LED_2_GPIO_ON gpio_clear
69
#define LED_2_GPIO_OFF gpio_set
70
#elif defined(LINE_NLED2)
71
#ifndef USE_LED_2
72
#define USE_LED_2 1
73
#endif
74
#define LED_2_GPIO PAL_PORT(LINE_NLED2)
75
#define LED_2_GPIO_PIN PAL_PAD(LINE_NLED2)
76
#define LED_2_GPIO_ON gpio_set
77
#define LED_2_GPIO_OFF gpio_clear
78
#endif
79
80
#if defined(LINE_LED3)
81
#ifndef USE_LED_3
82
#define USE_LED_3 1
83
#endif
84
#define LED_3_GPIO PAL_PORT(LINE_LED3)
85
#define LED_3_GPIO_PIN PAL_PAD(LINE_LED3)
86
#define LED_3_GPIO_ON gpio_clear
87
#define LED_3_GPIO_OFF gpio_set
88
#elif defined(LINE_NLED3)
89
#ifndef USE_LED_3
90
#define USE_LED_3 1
91
#endif
92
#define LED_3_GPIO PAL_PORT(LINE_NLED3)
93
#define LED_3_GPIO_PIN PAL_PAD(LINE_NLED3)
94
#define LED_3_GPIO_ON gpio_set
95
#define LED_3_GPIO_OFF gpio_clear
96
#endif
97
98
#if defined(LINE_LED4)
99
#ifndef USE_LED_4
100
#define USE_LED_4 1
101
#endif
102
#define LED_4_GPIO PAL_PORT(LINE_LED4)
103
#define LED_4_GPIO_PIN PAL_PAD(LINE_LED4)
104
#define LED_4_GPIO_ON gpio_clear
105
#define LED_4_GPIO_OFF gpio_set
106
#elif defined(LINE_NLED4)
107
#ifndef USE_LED_4
108
#define USE_LED_4 1
109
#endif
110
#define LED_4_GPIO PAL_PORT(LINE_NLED4)
111
#define LED_4_GPIO_PIN PAL_PAD(LINE_NLED4)
112
#define LED_4_GPIO_ON gpio_set
113
#define LED_4_GPIO_OFF gpio_clear
114
#endif
115
116
#if defined(LINE_LED5)
117
#ifndef USE_LED_5
118
#define USE_LED_5 1
119
#endif
120
#define LED_5_GPIO PAL_PORT(LINE_LED5)
121
#define LED_5_GPIO_PIN PAL_PAD(LINE_LED5)
122
#define LED_5_GPIO_ON gpio_clear
123
#define LED_5_GPIO_OFF gpio_set
124
#elif defined(LINE_NLED5)
125
#ifndef USE_LED_5
126
#define USE_LED_5 1
127
#endif
128
#define LED_5_GPIO PAL_PORT(LINE_NLED5)
129
#define LED_5_GPIO_PIN PAL_PAD(LINE_NLED5)
130
#define LED_5_GPIO_ON gpio_set
131
#define LED_5_GPIO_OFF gpio_clear
132
#endif
133
134
#if defined(LINE_LED6)
135
#ifndef USE_LED_6
136
#define USE_LED_6 1
137
#endif
138
#define LED_6_GPIO PAL_PORT(LINE_LED6)
139
#define LED_6_GPIO_PIN PAL_PAD(LINE_LED6)
140
#define LED_6_GPIO_ON gpio_clear
141
#define LED_6_GPIO_OFF gpio_set
142
#elif defined(LINE_NLED6)
143
#ifndef USE_LED_6
144
#define USE_LED_6 1
145
#endif
146
#define LED_6_GPIO PAL_PORT(LINE_NLED6)
147
#define LED_6_GPIO_PIN PAL_PAD(LINE_NLED6)
148
#define LED_6_GPIO_ON gpio_set
149
#define LED_6_GPIO_OFF gpio_clear
150
#endif
151
152
/*
153
* IMU Heater
154
*/
155
#if defined(LINE_IMU_HEATER)
156
#define IMU_HEATER_GPIO PAL_PORT(LINE_IMU_HEATER)
157
#define IMU_HEATER_GPIO_PIN PAL_PAD(LINE_IMU_HEATER)
158
#endif
159
160
/*
161
* ADCs
162
*/
163
#if defined(LINE_ADC1)
164
#ifndef USE_ADC_1
165
#define USE_ADC_1 1
166
#endif
167
#if USE_ADC_1
168
#if defined(ADC1_ADC_IN)
169
#define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC1_ADC_IN)
170
#elif defined(ADC1_ADC_INP)
171
#define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC1_ADC_INP)
172
#endif
173
#define ADC_1 AD1_1
174
#define ADC_1_GPIO_PORT PAL_PORT(LINE_ADC1)
175
#define ADC_1_GPIO_PIN PAL_PAD(LINE_ADC1)
176
#endif
177
#endif
178
179
#if defined(LINE_ADC2)
180
#ifndef USE_ADC_2
181
#define USE_ADC_2 1
182
#endif
183
#if USE_ADC_2
184
#if defined(ADC2_ADC_IN)
185
#define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC2_ADC_IN)
186
#elif defined(ADC2_ADC_INP)
187
#define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC2_ADC_INP)
188
#endif
189
#define ADC_2 AD1_2
190
#define ADC_2_GPIO_PORT PAL_PORT(LINE_ADC2)
191
#define ADC_2_GPIO_PIN PAL_PAD(LINE_ADC2)
192
#endif
193
#endif
194
195
#if defined(LINE_ADC3)
196
#ifndef USE_ADC_3
197
#define USE_ADC_3 1
198
#endif
199
#if USE_ADC_3
200
#if defined(ADC3_ADC_IN)
201
#define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC3_ADC_IN)
202
#elif defined(ADC3_ADC_INP)
203
#define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC3_ADC_INP)
204
#endif
205
#define ADC_3 AD1_3
206
#define ADC_3_GPIO_PORT PAL_PORT(LINE_ADC3)
207
#define ADC_3_GPIO_PIN PAL_PAD(LINE_ADC3)
208
#endif
209
#endif
210
211
#if defined(LINE_ADC4)
212
#ifndef USE_ADC_4
213
#define USE_ADC_4 1
214
#endif
215
#if USE_ADC_4
216
#if defined(ADC4_ADC_IN)
217
#define AD1_4_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC4_ADC_IN)
218
#elif defined(ADC4_ADC_INP)
219
#define AD1_4_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC4_ADC_INP)
220
#endif
221
#define ADC_4 AD1_4
222
#define ADC_4_GPIO_PORT PAL_PORT(LINE_ADC4)
223
#define ADC_4_GPIO_PIN PAL_PAD(LINE_ADC4)
224
#endif
225
#endif
226
227
#if defined(LINE_ADC5)
228
#ifndef USE_ADC_5
229
#define USE_ADC_5 1
230
#endif
231
#if USE_ADC_5
232
#if defined(ADC5_ADC_IN)
233
#define AD1_5_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC5_ADC_IN)
234
#elif defined(ADC5_ADC_INP)
235
#define AD1_5_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC5_ADC_INP)
236
#endif
237
#define ADC_5 AD1_5
238
#define ADC_5_GPIO_PORT PAL_PORT(LINE_ADC5)
239
#define ADC_5_GPIO_PIN PAL_PAD(LINE_ADC5)
240
#endif
241
#endif
242
243
#if defined(LINE_ADC6)
244
#if USE_ADC_6
245
#if defined(ADC6_ADC_IN)
246
#define AD1_6_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC6_ADC_IN)
247
#elif defined(ADC6_ADC_INP)
248
#define AD1_6_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, ADC6_ADC_INP)
249
#endif
250
#define ADC_6 AD1_6
251
#define ADC_6_GPIO_PORT PAL_PORT(LINE_ADC6)
252
#define ADC_6_GPIO_PIN PAL_PAD(LINE_ADC6)
253
#endif
254
#endif
255
256
/*
257
* PWM defines
258
*/
259
#if defined(LINE_SERVO0)
260
#ifndef USE_PWM0
261
#define USE_PWM0 1
262
#endif
263
#if USE_PWM1
264
#define PWM_SERVO_0 0
265
#define PWM_SERVO_0_GPIO PAL_PORT(LINE_SERVO0)
266
#define PWM_SERVO_0_PIN PAL_PAD(LINE_SERVO0)
267
#define PWM_SERVO_0_AF AF_LINE_SERVO0
268
#define PWM_SERVO_0_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO0_TIM)
269
#define PWM_SERVO_0_CHANNEL (SERVO0_TIM_CH-1)
270
#define PWM_SERVO_0_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO0_TIM)
271
#endif
272
#endif
273
274
#if defined(LINE_SERVO1)
275
#ifndef USE_PWM1
276
#define USE_PWM1 1
277
#endif
278
#if USE_PWM1
279
#define PWM_SERVO_1 1
280
#define PWM_SERVO_1_GPIO PAL_PORT(LINE_SERVO1)
281
#define PWM_SERVO_1_PIN PAL_PAD(LINE_SERVO1)
282
#define PWM_SERVO_1_AF AF_LINE_SERVO1
283
#define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO1_TIM)
284
#define PWM_SERVO_1_CHANNEL (SERVO1_TIM_CH-1)
285
#define PWM_SERVO_1_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO1_TIM)
286
#endif
287
#endif
288
289
#if defined(LINE_SERVO2)
290
#ifndef USE_PWM2
291
#define USE_PWM2 1
292
#endif
293
#if USE_PWM2
294
#define PWM_SERVO_2 2
295
#define PWM_SERVO_2_GPIO PAL_PORT(LINE_SERVO2)
296
#define PWM_SERVO_2_PIN PAL_PAD(LINE_SERVO2)
297
#define PWM_SERVO_2_AF AF_LINE_SERVO2
298
#define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO2_TIM)
299
#define PWM_SERVO_2_CHANNEL (SERVO2_TIM_CH-1)
300
#define PWM_SERVO_2_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO2_TIM)
301
#endif
302
#endif
303
304
#if defined(LINE_SERVO3)
305
#ifndef USE_PWM3
306
#define USE_PWM3 1
307
#endif
308
#if USE_PWM3
309
#define PWM_SERVO_3 3
310
#define PWM_SERVO_3_GPIO PAL_PORT(LINE_SERVO3)
311
#define PWM_SERVO_3_PIN PAL_PAD(LINE_SERVO3)
312
#define PWM_SERVO_3_AF AF_LINE_SERVO3
313
#define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO3_TIM)
314
#define PWM_SERVO_3_CHANNEL (SERVO3_TIM_CH-1)
315
#define PWM_SERVO_3_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO3_TIM)
316
#endif
317
#endif
318
319
#if defined(LINE_SERVO4)
320
#ifndef USE_PWM4
321
#define USE_PWM4 1
322
#endif
323
#if USE_PWM4
324
#define PWM_SERVO_4 4
325
#define PWM_SERVO_4_GPIO PAL_PORT(LINE_SERVO4)
326
#define PWM_SERVO_4_PIN PAL_PAD(LINE_SERVO4)
327
#define PWM_SERVO_4_AF AF_LINE_SERVO4
328
#define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO4_TIM)
329
#define PWM_SERVO_4_CHANNEL (SERVO4_TIM_CH-1)
330
#define PWM_SERVO_4_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO4_TIM)
331
#endif
332
#endif
333
334
#if defined(LINE_SERVO5)
335
#ifndef USE_PWM5
336
#define USE_PWM5 1
337
#endif
338
#if USE_PWM5
339
#define PWM_SERVO_5 5
340
#define PWM_SERVO_5_GPIO PAL_PORT(LINE_SERVO5)
341
#define PWM_SERVO_5_PIN PAL_PAD(LINE_SERVO5)
342
#define PWM_SERVO_5_AF AF_LINE_SERVO5
343
#define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO5_TIM)
344
#define PWM_SERVO_5_CHANNEL (SERVO5_TIM_CH-1)
345
#define PWM_SERVO_5_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO5_TIM)
346
#endif
347
#endif
348
349
#if defined(LINE_SERVO6)
350
#ifndef USE_PWM6
351
#define USE_PWM6 1
352
#endif
353
#if USE_PWM6
354
#define PWM_SERVO_6 6
355
#define PWM_SERVO_6_GPIO PAL_PORT(LINE_SERVO6)
356
#define PWM_SERVO_6_PIN PAL_PAD(LINE_SERVO6)
357
#define PWM_SERVO_6_AF AF_LINE_SERVO6
358
#define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO6_TIM)
359
#define PWM_SERVO_6_CHANNEL (SERVO6_TIM_CH-1)
360
#define PWM_SERVO_6_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO6_TIM)
361
#endif
362
#endif
363
364
#if defined(LINE_SERVO7)
365
#ifndef USE_PWM7
366
#define USE_PWM7 1
367
#endif
368
#if USE_PWM7
369
#define PWM_SERVO_7 7
370
#define PWM_SERVO_7_GPIO PAL_PORT(LINE_SERVO7)
371
#define PWM_SERVO_7_PIN PAL_PAD(LINE_SERVO7)
372
#define PWM_SERVO_7_AF AF_LINE_SERVO7
373
#define PWM_SERVO_7_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO7_TIM)
374
#define PWM_SERVO_7_CHANNEL (SERVO7_TIM_CH-1)
375
#define PWM_SERVO_7_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO7_TIM)
376
#endif
377
#endif
378
379
#if defined(LINE_SERVO8)
380
#ifndef USE_PWM8
381
#define USE_PWM8 1
382
#endif
383
#if USE_PWM8
384
#define PWM_SERVO_8 8
385
#define PWM_SERVO_8_GPIO PAL_PORT(LINE_SERVO8)
386
#define PWM_SERVO_8_PIN PAL_PAD(LINE_SERVO8)
387
#define PWM_SERVO_8_AF AF_LINE_SERVO8
388
#define PWM_SERVO_8_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO8_TIM)
389
#define PWM_SERVO_8_CHANNEL (SERVO8_TIM_CH-1)
390
#define PWM_SERVO_8_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO8_TIM)
391
#endif
392
#endif
393
394
/*
395
* ALARM defines
396
*/
397
#if defined(LINE_ALARM)
398
#define ALARM_GPIO PAL_PORT(LINE_ALARM)
399
#define ALARM_PIN PAL_PAD(LINE_ALARM)
400
#define ALARM_AF AF_LINE_SERVO1
401
#define ALARM_DRIVER CONCAT_BOARD_PARAM(PWMD, ALARM_TIM)
402
#define ALARM_CHANNEL (ALARM_TIM_CH-1)
403
#define ALARM_CONF CONCAT_BOARD_PARAM(pwmcfg, ALARM_TIM)
404
#endif
405
406
/*
407
* PWM input
408
*/
409
#define PWM_INPUT1_ICU CONCAT_BOARD_PARAM(ICUD, PWM_INPUT1_TIM)
410
#define PWM_INPUT1_CHANNEL CONCAT_BOARD_PARAM(ICU_CHANNEL_, PWM_INPUT1_TIM_CH)
411
#define PWM_INPUT1_GPIO_PORT PAL_PORT(LINE_PWM_INPUT1)
412
#define PWM_INPUT1_GPIO_PIN PAL_PAD(LINE_PWM_INPUT1)
413
#define PWM_INPUT1_GPIO_AF AF_LINE_PWM_INPUT1
414
418
#if defined(LINE_UART1_TX)
419
#define UART1_GPIO_PORT_TX PAL_PORT(LINE_UART1_TX)
420
#define UART1_GPIO_TX PAL_PAD(LINE_UART1_TX)
421
#endif
422
#if defined(LINE_UART1_RX)
423
#define UART1_GPIO_PORT_RX PAL_PORT(LINE_UART1_RX)
424
#define UART1_GPIO_RX PAL_PAD(LINE_UART1_RX)
425
#endif
426
#if defined(AF_LINE_UART1_TX)
427
#define UART1_GPIO_AF AF_LINE_UART1_TX
428
#elif defined(AF_LINE_UART1_RX)
429
#define UART1_GPIO_AF AF_LINE_UART1_RX
430
#else
431
#define UART1_GPIO_AF ((void)0)
432
#endif
433
434
#if defined(LINE_UART2_TX)
435
#define UART2_GPIO_PORT_TX PAL_PORT(LINE_UART2_TX)
436
#define UART2_GPIO_TX PAL_PAD(LINE_UART2_TX)
437
#endif
438
#if defined(LINE_UART2_RX)
439
#define UART2_GPIO_PORT_RX PAL_PORT(LINE_UART2_RX)
440
#define UART2_GPIO_RX PAL_PAD(LINE_UART2_RX)
441
#endif
442
#if defined(AF_LINE_UART2_TX)
443
#define UART2_GPIO_AF AF_LINE_UART2_TX
444
#elif defined(AF_LINE_UART2_RX)
445
#define UART2_GPIO_AF AF_LINE_UART2_RX
446
#else
447
#define UART2_GPIO_AF ((void)0)
448
#endif
449
450
#if defined(LINE_UART3_TX)
451
#define UART3_GPIO_PORT_TX PAL_PORT(LINE_UART3_TX)
452
#define UART3_GPIO_TX PAL_PAD(LINE_UART3_TX)
453
#endif
454
#if defined(LINE_UART3_RX)
455
#define UART3_GPIO_PORT_RX PAL_PORT(LINE_UART3_RX)
456
#define UART3_GPIO_RX PAL_PAD(LINE_UART3_RX)
457
#endif
458
#if defined(AF_LINE_UART3_TX)
459
#define UART3_GPIO_AF AF_LINE_UART3_TX
460
#elif defined(AF_LINE_UART3_RX)
461
#define UART3_GPIO_AF AF_LINE_UART3_RX
462
#else
463
#define UART3_GPIO_AF ((void)0)
464
#endif
465
466
#if defined(LINE_UART4_TX)
467
#define UART4_GPIO_PORT_TX PAL_PORT(LINE_UART4_TX)
468
#define UART4_GPIO_TX PAL_PAD(LINE_UART4_TX)
469
#endif
470
#if defined(LINE_UART4_RX)
471
#define UART4_GPIO_PORT_RX PAL_PORT(LINE_UART4_RX)
472
#define UART4_GPIO_RX PAL_PAD(LINE_UART4_RX)
473
#endif
474
#if defined(AF_LINE_UART4_TX)
475
#define UART4_GPIO_AF AF_LINE_UART4_TX
476
#elif defined(AF_LINE_UART4_RX)
477
#define UART4_GPIO_AF AF_LINE_UART4_RX
478
#else
479
#define UART4_GPIO_AF ((void)0)
480
#endif
481
482
#if defined(LINE_UART5_TX)
483
#define UART5_GPIO_PORT_TX PAL_PORT(LINE_UART5_TX)
484
#define UART5_GPIO_TX PAL_PAD(LINE_UART5_TX)
485
#endif
486
#if defined(LINE_UART5_RX)
487
#define UART5_GPIO_PORT_RX PAL_PORT(LINE_UART5_RX)
488
#define UART5_GPIO_RX PAL_PAD(LINE_UART5_RX)
489
#endif
490
#if defined(AF_LINE_UART5_TX)
491
#define UART5_GPIO_AF AF_LINE_UART5_TX
492
#elif defined(AF_LINE_UART5_RX)
493
#define UART5_GPIO_AF AF_LINE_UART5_RX
494
#else
495
#define UART5_GPIO_AF ((void)0)
496
#endif
497
498
#if defined(LINE_UART6_TX)
499
#define UART6_GPIO_PORT_TX PAL_PORT(LINE_UART6_TX)
500
#define UART6_GPIO_TX PAL_PAD(LINE_UART6_TX)
501
#endif
502
#if defined(LINE_UART6_RX)
503
#define UART6_GPIO_PORT_RX PAL_PORT(LINE_UART6_RX)
504
#define UART6_GPIO_RX PAL_PAD(LINE_UART6_RX)
505
#endif
506
#if defined(AF_LINE_UART6_TX)
507
#define UART6_GPIO_AF AF_LINE_UART6_TX
508
#elif defined(AF_LINE_UART6_RX)
509
#define UART6_GPIO_AF AF_LINE_UART6_RX
510
#else
511
#define UART6_GPIO_AF ((void)0)
512
#endif
513
514
#if defined(LINE_UART7_TX)
515
#define UART7_GPIO_PORT_TX PAL_PORT(LINE_UART7_TX)
516
#define UART7_GPIO_TX PAL_PAD(LINE_UART7_TX)
517
#endif
518
#if defined(LINE_UART7_RX)
519
#define UART7_GPIO_PORT_RX PAL_PORT(LINE_UART7_RX)
520
#define UART7_GPIO_RX PAL_PAD(LINE_UART7_RX)
521
#endif
522
#if defined(AF_LINE_UART7_TX)
523
#define UART7_GPIO_AF AF_LINE_UART7_TX
524
#elif defined(AF_LINE_UART7_RX)
525
#define UART7_GPIO_AF AF_LINE_UART7_RX
526
#else
527
#define UART7_GPIO_AF ((void)0)
528
#endif
529
530
#if defined(LINE_UART8_TX)
531
#define UART8_GPIO_PORT_TX PAL_PORT(LINE_UART8_TX)
532
#define UART8_GPIO_TX PAL_PAD(LINE_UART8_TX)
533
#endif
534
#if defined(LINE_UART8_RX)
535
#define UART8_GPIO_PORT_RX PAL_PORT(LINE_UART8_RX)
536
#define UART8_GPIO_RX PAL_PAD(LINE_UART8_RX)
537
#endif
538
#if defined(AF_LINE_UART8_TX)
539
#define UART8_GPIO_AF AF_LINE_UART8_TX
540
#elif defined(AF_LINE_UART8_RX)
541
#define UART8_GPIO_AF AF_LINE_UART8_RX
542
#else
543
#define UART8_GPIO_AF ((void)0)
544
#endif
545
549
// Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
550
#define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
551
552
// Timing register
553
#if defined(STM32F7XX)
554
#define I2C_CFG_100KHZ_TIMINGR (STM32_TIMINGR_PRESC(3U) | STM32_TIMINGR_SCLDEL(8U) | STM32_TIMINGR_SDADEL(1U) | STM32_TIMINGR_SCLH(46U) | STM32_TIMINGR_SCLL(62U))
// 0x30812E3E
555
#define I2C_CFG_400KHZ_TIMINGR (STM32_TIMINGR_PRESC(6U) | STM32_TIMINGR_SCLDEL(0U) | STM32_TIMINGR_SDADEL(0U) | STM32_TIMINGR_SCLH(3U) | STM32_TIMINGR_SCLL(13U))
// 0x6000030D
556
#elif defined(STM32H7XX)
557
#define I2C_CFG_100KHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | STM32_TIMINGR_SCLDEL(7U) | STM32_TIMINGR_SDADEL(0U) | STM32_TIMINGR_SCLH(124U) | STM32_TIMINGR_SCLL(187U))
// 0x00707CBB
558
#define I2C_CFG_400KHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | STM32_TIMINGR_SCLDEL(3U) | STM32_TIMINGR_SDADEL(0U) | STM32_TIMINGR_SCLH(15U) | STM32_TIMINGR_SCLL(56U))
// 0x00300F38
559
#endif
560
561
562
#ifndef I2C1_CLOCK_SPEED
563
#define I2C1_CLOCK_SPEED 400000
564
#endif
565
566
#if I2C1_CLOCK_SPEED == 400000
567
#define I2C1_CFG_DEF { \
568
.timingr = I2C_CFG_400KHZ_TIMINGR, \
569
.cr1 = STM32_CR1_DNF(0), \
570
.cr2 = 0 \
571
}
572
#elif I2C1_CLOCK_SPEED == 100000
573
#define I2C1_CFG_DEF { \
574
.timingr = I2C_CFG_100KHZ_TIMINGR, \
575
.cr1 = STM32_CR1_DNF(0), \
576
.cr2 = 0 \
577
}
578
#else
579
#error "Unknown I2C1 clock speed"
580
#endif
581
582
#ifndef I2C2_CLOCK_SPEED
583
#define I2C2_CLOCK_SPEED 400000
584
#endif
585
586
#if I2C2_CLOCK_SPEED == 400000
587
#define I2C2_CFG_DEF { \
588
.timingr = I2C_CFG_400KHZ_TIMINGR, \
589
.cr1 = STM32_CR1_DNF(0), \
590
.cr2 = 0 \
591
}
592
#elif I2C2_CLOCK_SPEED == 100000
593
#define I2C2_CFG_DEF { \
594
.timingr = I2C_CFG_100KHZ_TIMINGR, \
595
.cr1 = STM32_CR1_DNF(0), \
596
.cr2 = 0 \
597
}
598
#else
599
#error "Unknown I2C2 clock speed"
600
#endif
601
602
#ifndef I2C3_CLOCK_SPEED
603
#define I2C3_CLOCK_SPEED 400000
604
#endif
605
606
#if I2C3_CLOCK_SPEED == 400000
607
#define I2C3_CFG_DEF { \
608
.timingr = I2C_CFG_400KHZ_TIMINGR, \
609
.cr1 = STM32_CR1_DNF(0), \
610
.cr2 = 0 \
611
}
612
#elif I2C3_CLOCK_SPEED == 100000
613
#define I2C3_CFG_DEF { \
614
.timingr = I2C_CFG_100KHZ_TIMINGR, \
615
.cr1 = STM32_CR1_DNF(0), \
616
.cr2 = 0 \
617
}
618
#else
619
#error "Unknown I2C3 clock speed"
620
#endif
621
622
#ifndef I2C4_CLOCK_SPEED
623
#define I2C4_CLOCK_SPEED 400000
624
#endif
625
626
#if I2C4_CLOCK_SPEED == 400000
627
#define I2C4_CFG_DEF { \
628
.timingr = I2C_CFG_400KHZ_TIMINGR, \
629
.cr1 = STM32_CR1_DNF(0), \
630
.cr2 = 0 \
631
}
632
#elif I2C4_CLOCK_SPEED == 100000
633
#define I2C4_CFG_DEF { \
634
.timingr = I2C_CFG_100KHZ_TIMINGR, \
635
.cr1 = STM32_CR1_DNF(0), \
636
.cr2 = 0 \
637
}
638
#else
639
#error "Unknown I2C4 clock speed"
640
#endif
641
645
#if defined(LINE_SPI1_MISO) && defined(LINE_SPI1_MOSI) && defined(LINE_SPI1_SCK)
646
#define SPI1_GPIO_PORT_MISO PAL_PORT(LINE_SPI1_MISO)
647
#define SPI1_GPIO_MISO PAL_PAD(LINE_SPI1_MISO)
648
#define SPI1_GPIO_PORT_MOSI PAL_PORT(LINE_SPI1_MOSI)
649
#define SPI1_GPIO_MOSI PAL_PAD(LINE_SPI1_MOSI)
650
#define SPI1_GPIO_PORT_SCK PAL_PORT(LINE_SPI1_SCK)
651
#define SPI1_GPIO_SCK PAL_PAD(LINE_SPI1_SCK)
652
653
#if defined(AF_LINE_SPI1_SCK)
654
#define SPI1_GPIO_AF AF_LINE_SPI1_SCK
655
#endif
656
#endif
657
658
#if defined(LINE_SPI2_MISO) && defined(LINE_SPI2_MOSI) && defined(LINE_SPI2_SCK)
659
#define SPI2_GPIO_PORT_MISO PAL_PORT(LINE_SPI2_MISO)
660
#define SPI2_GPIO_MISO PAL_PAD(LINE_SPI2_MISO)
661
#define SPI2_GPIO_PORT_MOSI PAL_PORT(LINE_SPI2_MOSI)
662
#define SPI2_GPIO_MOSI PAL_PAD(LINE_SPI2_MOSI)
663
#define SPI2_GPIO_PORT_SCK PAL_PORT(LINE_SPI2_SCK)
664
#define SPI2_GPIO_SCK PAL_PAD(LINE_SPI2_SCK)
665
666
#if defined(AF_LINE_SPI2_SCK)
667
#define SPI2_GPIO_AF AF_LINE_SPI2_SCK
668
#endif
669
#endif
670
671
#if defined(LINE_SPI3_MISO) && defined(LINE_SPI3_MOSI) && defined(LINE_SPI3_SCK)
672
#define SPI3_GPIO_PORT_MISO PAL_PORT(LINE_SPI3_MISO)
673
#define SPI3_GPIO_MISO PAL_PAD(LINE_SPI3_MISO)
674
#define SPI3_GPIO_PORT_MOSI PAL_PORT(LINE_SPI3_MOSI)
675
#define SPI3_GPIO_MOSI PAL_PAD(LINE_SPI3_MOSI)
676
#define SPI3_GPIO_PORT_SCK PAL_PORT(LINE_SPI3_SCK)
677
#define SPI3_GPIO_SCK PAL_PAD(LINE_SPI3_SCK)
678
679
#if defined(AF_LINE_SPI3_SCK)
680
#define SPI3_GPIO_AF AF_LINE_SPI3_SCK
681
#endif
682
#endif
683
684
#if defined(LINE_SPI4_MISO) && defined(LINE_SPI4_MOSI) && defined(LINE_SPI4_SCK)
685
#define SPI4_GPIO_PORT_MISO PAL_PORT(LINE_SPI4_MISO)
686
#define SPI4_GPIO_MISO PAL_PAD(LINE_SPI4_MISO)
687
#define SPI4_GPIO_PORT_MOSI PAL_PORT(LINE_SPI4_MOSI)
688
#define SPI4_GPIO_MOSI PAL_PAD(LINE_SPI4_MOSI)
689
#define SPI4_GPIO_PORT_SCK PAL_PORT(LINE_SPI4_SCK)
690
#define SPI4_GPIO_SCK PAL_PAD(LINE_SPI4_SCK)
691
692
#if defined(AF_LINE_SPI4_SCK)
693
#define SPI4_GPIO_AF AF_LINE_SPI4_SCK
694
#endif
695
#endif
696
697
#if defined(LINE_SPI5_MISO) && defined(LINE_SPI5_MOSI) && defined(LINE_SPI5_SCK)
698
#define SPI5_GPIO_PORT_MISO PAL_PORT(LINE_SPI5_MISO)
699
#define SPI5_GPIO_MISO PAL_PAD(LINE_SPI5_MISO)
700
#define SPI5_GPIO_PORT_MOSI PAL_PORT(LINE_SPI5_MOSI)
701
#define SPI5_GPIO_MOSI PAL_PAD(LINE_SPI5_MOSI)
702
#define SPI5_GPIO_PORT_SCK PAL_PORT(LINE_SPI5_SCK)
703
#define SPI5_GPIO_SCK PAL_PAD(LINE_SPI5_SCK)
704
705
#if defined(AF_LINE_SPI5_SCK)
706
#define SPI5_GPIO_AF AF_LINE_SPI5_SCK
707
#endif
708
#endif
709
710
#if defined(LINE_SPI6_MISO) && defined(LINE_SPI6_MOSI) && defined(LINE_SPI6_SCK)
711
#define SPI6_GPIO_PORT_MISO PAL_PORT(LINE_SPI6_MISO)
712
#define SPI6_GPIO_MISO PAL_PAD(LINE_SPI6_MISO)
713
#define SPI6_GPIO_PORT_MOSI PAL_PORT(LINE_SPI6_MOSI)
714
#define SPI6_GPIO_MOSI PAL_PAD(LINE_SPI6_MOSI)
715
#define SPI6_GPIO_PORT_SCK PAL_PORT(LINE_SPI6_SCK)
716
#define SPI6_GPIO_SCK PAL_PAD(LINE_SPI6_SCK)
717
718
#if defined(AF_LINE_SPI6_SCK)
719
#define SPI6_GPIO_AF AF_LINE_SPI6_SCK
720
#endif
721
#endif
722
726
#if defined(LINE_SPI_SLAVE0)
727
#define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_SPI_SLAVE0)
728
#define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_SPI_SLAVE0)
729
#endif
730
731
#if defined(LINE_SPI_SLAVE1)
732
#define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_SPI_SLAVE1)
733
#define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_SPI_SLAVE1)
734
#endif
735
736
#if defined(LINE_SPI_SLAVE2)
737
#define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_SPI_SLAVE2)
738
#define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_SPI_SLAVE2)
739
#endif
740
741
#if defined(LINE_SPI_SLAVE3)
742
#define SPI_SELECT_SLAVE3_PORT PAL_PORT(LINE_SPI_SLAVE3)
743
#define SPI_SELECT_SLAVE3_PIN PAL_PAD(LINE_SPI_SLAVE3)
744
#endif
745
746
#if defined(LINE_SPI_SLAVE4)
747
#define SPI_SELECT_SLAVE4_PORT PAL_PORT(LINE_SPI_SLAVE4)
748
#define SPI_SELECT_SLAVE4_PIN PAL_PAD(LINE_SPI_SLAVE4)
749
#endif
750
751
#if defined(LINE_SPI_SLAVE5)
752
#define SPI_SELECT_SLAVE5_PORT PAL_PORT(LINE_SPI_SLAVE5)
753
#define SPI_SELECT_SLAVE5_PIN PAL_PAD(LINE_SPI_SLAVE5)
754
#endif
755
756
#if defined(LINE_SPI_SLAVE6)
757
#define SPI_SELECT_SLAVE6_PORT PAL_PORT(LINE_SPI_SLAVE6)
758
#define SPI_SELECT_SLAVE6_PIN PAL_PAD(LINE_SPI_SLAVE6)
759
#endif
760
761
#if defined(LINE_SPI_SLAVE7)
762
#define SPI_SELECT_SLAVE7_PORT PAL_PORT(LINE_SPI_SLAVE7)
763
#define SPI_SELECT_SLAVE7_PIN PAL_PAD(LINE_SPI_SLAVE7)
764
#endif
765
766
#if defined(LINE_SPI_SLAVE8)
767
#define SPI_SELECT_SLAVE8_PORT PAL_PORT(LINE_SPI_SLAVE8)
768
#define SPI_SELECT_SLAVE8_PIN PAL_PAD(LINE_SPI_SLAVE8)
769
#endif
770
771
#if defined(LINE_SPI_SLAVE9)
772
#define SPI_SELECT_SLAVE9_PORT PAL_PORT(LINE_SPI_SLAVE9)
773
#define SPI_SELECT_SLAVE9_PIN PAL_PAD(LINE_SPI_SLAVE9)
774
#endif
775
779
// #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)
780
// #define SDIO_D0_PORT PAL_PORT(LINE_SDIO_D0)
781
// #define SDIO_D0_PIN PAL_PAD(LINE_SDIO_D0)
782
// #define SDIO_D1_PORT PAL_PORT(LINE_SDIO_D1)
783
// #define SDIO_D1_PIN PAL_PAD(LINE_SDIO_D1)
784
// #define SDIO_D2_PORT PAL_PORT(LINE_SDIO_D2)
785
// #define SDIO_D2_PIN PAL_PAD(LINE_SDIO_D2)
786
// #define SDIO_D3_PORT PAL_PORT(LINE_SDIO_D3)
787
// #define SDIO_D3_PIN PAL_PAD(LINE_SDIO_D3)
788
// #define SDIO_CK_PORT PAL_PORT(LINE_SDIO_CK)
789
// #define SDIO_CK_PIN PAL_PAD(LINE_SDIO_CK)
790
// #define SDIO_CMD_PORT PAL_PORT(LINE_SDIO_CMD)
791
// #define SDIO_CMD_PIN PAL_PAD(LINE_SDIO_CMD)
792
793
// #if defined(AF_LINE_SDIO_CMD)
794
// #define SDIO_AF AF_LINE_SDIO_CMD
795
// #else
796
// #define SDIO_AF ((void)0)
797
// #endif
798
// #endif
799
800
#if defined(LINE_USB_VBUS)
801
#define SDLOG_USB_VBUS_PORT PAL_PORT(LINE_USB_VBUS)
802
#define SDLOG_USB_VBUS_PIN PAL_PAD(LINE_USB_VBUS)
803
#define SDLOG_USB_VBUS_BOOT false
804
#endif
805
806
/*
807
* Actuators for fixedwing
808
*/
809
/* Default actuators driver */
810
#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
811
#define ActuatorDefaultSet ActuatorPwmSet
812
#define ActuatorsDefaultInit() ActuatorsPwmInit()
813
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
814
815
#endif
/* ARCH_COMMON_BOARD_H */
sw
airborne
arch
chibios
common_board.h
Generated on Wed Nov 26 2025 21:36:28 for Paparazzi UAS by
1.9.8