Paparazzi UAS
v7.0_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
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_SERVO1)
260
#ifndef USE_PWM1
261
#define USE_PWM1 1
262
#endif
263
#if USE_PWM1
264
#define PWM_SERVO_1 0
265
#define PWM_SERVO_1_GPIO PAL_PORT(LINE_SERVO1)
266
#define PWM_SERVO_1_PIN PAL_PAD(LINE_SERVO1)
267
#define PWM_SERVO_1_AF AF_LINE_SERVO1
268
#define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO1_TIM)
269
#define PWM_SERVO_1_CHANNEL (SERVO1_TIM_CH-1)
270
#define PWM_SERVO_1_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO1_TIM)
271
#endif
272
#endif
273
274
#if defined(LINE_SERVO2)
275
#ifndef USE_PWM2
276
#define USE_PWM2 1
277
#endif
278
#if USE_PWM2
279
#define PWM_SERVO_2 1
280
#define PWM_SERVO_2_GPIO PAL_PORT(LINE_SERVO2)
281
#define PWM_SERVO_2_PIN PAL_PAD(LINE_SERVO2)
282
#define PWM_SERVO_2_AF AF_LINE_SERVO2
283
#define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO2_TIM)
284
#define PWM_SERVO_2_CHANNEL (SERVO2_TIM_CH-1)
285
#define PWM_SERVO_2_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO2_TIM)
286
#endif
287
#endif
288
289
#if defined(LINE_SERVO3)
290
#ifndef USE_PWM3
291
#define USE_PWM3 1
292
#endif
293
#if USE_PWM3
294
#define PWM_SERVO_3 2
295
#define PWM_SERVO_3_GPIO PAL_PORT(LINE_SERVO3)
296
#define PWM_SERVO_3_PIN PAL_PAD(LINE_SERVO3)
297
#define PWM_SERVO_3_AF AF_LINE_SERVO3
298
#define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO3_TIM)
299
#define PWM_SERVO_3_CHANNEL (SERVO3_TIM_CH-1)
300
#define PWM_SERVO_3_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO3_TIM)
301
#endif
302
#endif
303
304
#if defined(LINE_SERVO4)
305
#ifndef USE_PWM4
306
#define USE_PWM4 1
307
#endif
308
#if USE_PWM4
309
#define PWM_SERVO_4 3
310
#define PWM_SERVO_4_GPIO PAL_PORT(LINE_SERVO4)
311
#define PWM_SERVO_4_PIN PAL_PAD(LINE_SERVO4)
312
#define PWM_SERVO_4_AF AF_LINE_SERVO4
313
#define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO4_TIM)
314
#define PWM_SERVO_4_CHANNEL (SERVO4_TIM_CH-1)
315
#define PWM_SERVO_4_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO4_TIM)
316
#endif
317
#endif
318
319
#if defined(LINE_SERVO5)
320
#ifndef USE_PWM5
321
#define USE_PWM5 1
322
#endif
323
#if USE_PWM5
324
#define PWM_SERVO_5 4
325
#define PWM_SERVO_5_GPIO PAL_PORT(LINE_SERVO5)
326
#define PWM_SERVO_5_PIN PAL_PAD(LINE_SERVO5)
327
#define PWM_SERVO_5_AF AF_LINE_SERVO5
328
#define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO5_TIM)
329
#define PWM_SERVO_5_CHANNEL (SERVO5_TIM_CH-1)
330
#define PWM_SERVO_5_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO5_TIM)
331
#endif
332
#endif
333
334
#if defined(LINE_SERVO6)
335
#ifndef USE_PWM6
336
#define USE_PWM6 1
337
#endif
338
#if USE_PWM6
339
#define PWM_SERVO_6 5
340
#define PWM_SERVO_6_GPIO PAL_PORT(LINE_SERVO6)
341
#define PWM_SERVO_6_PIN PAL_PAD(LINE_SERVO6)
342
#define PWM_SERVO_6_AF AF_LINE_SERVO6
343
#define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO6_TIM)
344
#define PWM_SERVO_6_CHANNEL (SERVO6_TIM_CH-1)
345
#define PWM_SERVO_6_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO6_TIM)
346
#endif
347
#endif
348
349
#if defined(LINE_SERVO7)
350
#ifndef USE_PWM7
351
#define USE_PWM7 1
352
#endif
353
#if USE_PWM7
354
#define PWM_SERVO_7 6
355
#define PWM_SERVO_7_GPIO PAL_PORT(LINE_SERVO7)
356
#define PWM_SERVO_7_PIN PAL_PAD(LINE_SERVO7)
357
#define PWM_SERVO_7_AF AF_LINE_SERVO7
358
#define PWM_SERVO_7_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO7_TIM)
359
#define PWM_SERVO_7_CHANNEL (SERVO7_TIM_CH-1)
360
#define PWM_SERVO_7_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO7_TIM)
361
#endif
362
#endif
363
364
#if defined(LINE_SERVO8)
365
#ifndef USE_PWM8
366
#define USE_PWM8 1
367
#endif
368
#if USE_PWM8
369
#define PWM_SERVO_8 7
370
#define PWM_SERVO_8_GPIO PAL_PORT(LINE_SERVO8)
371
#define PWM_SERVO_8_PIN PAL_PAD(LINE_SERVO8)
372
#define PWM_SERVO_8_AF AF_LINE_SERVO8
373
#define PWM_SERVO_8_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO8_TIM)
374
#define PWM_SERVO_8_CHANNEL (SERVO8_TIM_CH-1)
375
#define PWM_SERVO_8_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO8_TIM)
376
#endif
377
#endif
378
379
/*
380
* ALARM defines
381
*/
382
#if defined(LINE_ALARM)
383
#define ALARM_GPIO PAL_PORT(LINE_ALARM)
384
#define ALARM_PIN PAL_PAD(LINE_ALARM)
385
#define ALARM_AF AF_LINE_SERVO1
386
#define ALARM_DRIVER CONCAT_BOARD_PARAM(PWMD, ALARM_TIM)
387
#define ALARM_CHANNEL (ALARM_TIM_CH-1)
388
#define ALARM_CONF CONCAT_BOARD_PARAM(pwmcfg, ALARM_TIM)
389
#endif
390
391
/*
392
* PWM input
393
*/
394
#define PWM_INPUT1_ICU CONCAT_BOARD_PARAM(ICUD, PWM_INPUT1_TIM)
395
#define PWM_INPUT1_CHANNEL CONCAT_BOARD_PARAM(ICU_CHANNEL_, PWM_INPUT1_TIM_CH)
396
#define PWM_INPUT1_GPIO_PORT PAL_PORT(LINE_PWM_INPUT1)
397
#define PWM_INPUT1_GPIO_PIN PAL_PAD(LINE_PWM_INPUT1)
398
#define PWM_INPUT1_GPIO_AF AF_LINE_PWM_INPUT1
399
403
#if defined(LINE_UART1_TX)
404
#define UART1_GPIO_PORT_TX PAL_PORT(LINE_UART1_TX)
405
#define UART1_GPIO_TX PAL_PAD(LINE_UART1_TX)
406
#endif
407
#if defined(LINE_UART1_RX)
408
#define UART1_GPIO_PORT_RX PAL_PORT(LINE_UART1_RX)
409
#define UART1_GPIO_RX PAL_PAD(LINE_UART1_RX)
410
#endif
411
#if defined(AF_LINE_UART1_TX)
412
#define UART1_GPIO_AF AF_LINE_UART1_TX
413
#elif defined(AF_LINE_UART1_RX)
414
#define UART1_GPIO_AF AF_LINE_UART1_RX
415
#else
416
#define UART1_GPIO_AF ((void)0)
417
#endif
418
419
#if defined(LINE_UART2_TX)
420
#define UART2_GPIO_PORT_TX PAL_PORT(LINE_UART2_TX)
421
#define UART2_GPIO_TX PAL_PAD(LINE_UART2_TX)
422
#endif
423
#if defined(LINE_UART2_RX)
424
#define UART2_GPIO_PORT_RX PAL_PORT(LINE_UART2_RX)
425
#define UART2_GPIO_RX PAL_PAD(LINE_UART2_RX)
426
#endif
427
#if defined(AF_LINE_UART2_TX)
428
#define UART2_GPIO_AF AF_LINE_UART2_TX
429
#elif defined(AF_LINE_UART2_RX)
430
#define UART2_GPIO_AF AF_LINE_UART2_RX
431
#else
432
#define UART2_GPIO_AF ((void)0)
433
#endif
434
435
#if defined(LINE_UART3_TX)
436
#define UART3_GPIO_PORT_TX PAL_PORT(LINE_UART3_TX)
437
#define UART3_GPIO_TX PAL_PAD(LINE_UART3_TX)
438
#endif
439
#if defined(LINE_UART3_RX)
440
#define UART3_GPIO_PORT_RX PAL_PORT(LINE_UART3_RX)
441
#define UART3_GPIO_RX PAL_PAD(LINE_UART3_RX)
442
#endif
443
#if defined(AF_LINE_UART3_TX)
444
#define UART3_GPIO_AF AF_LINE_UART3_TX
445
#elif defined(AF_LINE_UART3_RX)
446
#define UART3_GPIO_AF AF_LINE_UART3_RX
447
#else
448
#define UART3_GPIO_AF ((void)0)
449
#endif
450
451
#if defined(LINE_UART4_TX)
452
#define UART4_GPIO_PORT_TX PAL_PORT(LINE_UART4_TX)
453
#define UART4_GPIO_TX PAL_PAD(LINE_UART4_TX)
454
#endif
455
#if defined(LINE_UART4_RX)
456
#define UART4_GPIO_PORT_RX PAL_PORT(LINE_UART4_RX)
457
#define UART4_GPIO_RX PAL_PAD(LINE_UART4_RX)
458
#endif
459
#if defined(AF_LINE_UART4_TX)
460
#define UART4_GPIO_AF AF_LINE_UART4_TX
461
#elif defined(AF_LINE_UART4_RX)
462
#define UART4_GPIO_AF AF_LINE_UART4_RX
463
#else
464
#define UART4_GPIO_AF ((void)0)
465
#endif
466
467
#if defined(LINE_UART5_TX)
468
#define UART5_GPIO_PORT_TX PAL_PORT(LINE_UART5_TX)
469
#define UART5_GPIO_TX PAL_PAD(LINE_UART5_TX)
470
#endif
471
#if defined(LINE_UART5_RX)
472
#define UART5_GPIO_PORT_RX PAL_PORT(LINE_UART5_RX)
473
#define UART5_GPIO_RX PAL_PAD(LINE_UART5_RX)
474
#endif
475
#if defined(AF_LINE_UART5_TX)
476
#define UART5_GPIO_AF AF_LINE_UART5_TX
477
#elif defined(AF_LINE_UART5_RX)
478
#define UART5_GPIO_AF AF_LINE_UART5_RX
479
#else
480
#define UART5_GPIO_AF ((void)0)
481
#endif
482
483
#if defined(LINE_UART6_TX)
484
#define UART6_GPIO_PORT_TX PAL_PORT(LINE_UART6_TX)
485
#define UART6_GPIO_TX PAL_PAD(LINE_UART6_TX)
486
#endif
487
#if defined(LINE_UART6_RX)
488
#define UART6_GPIO_PORT_RX PAL_PORT(LINE_UART6_RX)
489
#define UART6_GPIO_RX PAL_PAD(LINE_UART6_RX)
490
#endif
491
#if defined(AF_LINE_UART6_TX)
492
#define UART6_GPIO_AF AF_LINE_UART6_TX
493
#elif defined(AF_LINE_UART6_RX)
494
#define UART6_GPIO_AF AF_LINE_UART6_RX
495
#else
496
#define UART6_GPIO_AF ((void)0)
497
#endif
498
499
#if defined(LINE_UART7_TX)
500
#define UART7_GPIO_PORT_TX PAL_PORT(LINE_UART7_TX)
501
#define UART7_GPIO_TX PAL_PAD(LINE_UART7_TX)
502
#endif
503
#if defined(LINE_UART7_RX)
504
#define UART7_GPIO_PORT_RX PAL_PORT(LINE_UART7_RX)
505
#define UART7_GPIO_RX PAL_PAD(LINE_UART7_RX)
506
#endif
507
#if defined(AF_LINE_UART7_TX)
508
#define UART7_GPIO_AF AF_LINE_UART7_TX
509
#elif defined(AF_LINE_UART7_RX)
510
#define UART7_GPIO_AF AF_LINE_UART7_RX
511
#else
512
#define UART7_GPIO_AF ((void)0)
513
#endif
514
515
#if defined(LINE_UART8_TX)
516
#define UART8_GPIO_PORT_TX PAL_PORT(LINE_UART8_TX)
517
#define UART8_GPIO_TX PAL_PAD(LINE_UART8_TX)
518
#endif
519
#if defined(LINE_UART8_RX)
520
#define UART8_GPIO_PORT_RX PAL_PORT(LINE_UART8_RX)
521
#define UART8_GPIO_RX PAL_PAD(LINE_UART8_RX)
522
#endif
523
#if defined(AF_LINE_UART8_TX)
524
#define UART8_GPIO_AF AF_LINE_UART8_TX
525
#elif defined(AF_LINE_UART8_RX)
526
#define UART8_GPIO_AF AF_LINE_UART8_RX
527
#else
528
#define UART8_GPIO_AF ((void)0)
529
#endif
530
534
// Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
535
#define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
536
537
// Timing register
538
#if defined(STM32F7XX)
539
#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
540
#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
541
#elif defined(STM32H7XX)
542
#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
543
#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
544
#endif
545
546
547
#ifndef I2C1_CLOCK_SPEED
548
#define I2C1_CLOCK_SPEED 400000
549
#endif
550
551
#if I2C1_CLOCK_SPEED == 400000
552
#define I2C1_CFG_DEF { \
553
.timingr = I2C_CFG_400KHZ_TIMINGR, \
554
.cr1 = STM32_CR1_DNF(0), \
555
.cr2 = 0 \
556
}
557
#elif I2C1_CLOCK_SPEED == 100000
558
#define I2C1_CFG_DEF { \
559
.timingr = I2C_CFG_100KHZ_TIMINGR, \
560
.cr1 = STM32_CR1_DNF(0), \
561
.cr2 = 0 \
562
}
563
#else
564
#error "Unknown I2C1 clock speed"
565
#endif
566
567
#ifndef I2C2_CLOCK_SPEED
568
#define I2C2_CLOCK_SPEED 400000
569
#endif
570
571
#if I2C2_CLOCK_SPEED == 400000
572
#define I2C2_CFG_DEF { \
573
.timingr = I2C_CFG_400KHZ_TIMINGR, \
574
.cr1 = STM32_CR1_DNF(0), \
575
.cr2 = 0 \
576
}
577
#elif I2C2_CLOCK_SPEED == 100000
578
#define I2C2_CFG_DEF { \
579
.timingr = I2C_CFG_100KHZ_TIMINGR, \
580
.cr1 = STM32_CR1_DNF(0), \
581
.cr2 = 0 \
582
}
583
#else
584
#error "Unknown I2C2 clock speed"
585
#endif
586
587
#ifndef I2C3_CLOCK_SPEED
588
#define I2C3_CLOCK_SPEED 400000
589
#endif
590
591
#if I2C3_CLOCK_SPEED == 400000
592
#define I2C3_CFG_DEF { \
593
.timingr = I2C_CFG_400KHZ_TIMINGR, \
594
.cr1 = STM32_CR1_DNF(0), \
595
.cr2 = 0 \
596
}
597
#elif I2C3_CLOCK_SPEED == 100000
598
#define I2C3_CFG_DEF { \
599
.timingr = I2C_CFG_100KHZ_TIMINGR, \
600
.cr1 = STM32_CR1_DNF(0), \
601
.cr2 = 0 \
602
}
603
#else
604
#error "Unknown I2C3 clock speed"
605
#endif
606
607
#ifndef I2C4_CLOCK_SPEED
608
#define I2C4_CLOCK_SPEED 400000
609
#endif
610
611
#if I2C4_CLOCK_SPEED == 400000
612
#define I2C4_CFG_DEF { \
613
.timingr = I2C_CFG_400KHZ_TIMINGR, \
614
.cr1 = STM32_CR1_DNF(0), \
615
.cr2 = 0 \
616
}
617
#elif I2C4_CLOCK_SPEED == 100000
618
#define I2C4_CFG_DEF { \
619
.timingr = I2C_CFG_100KHZ_TIMINGR, \
620
.cr1 = STM32_CR1_DNF(0), \
621
.cr2 = 0 \
622
}
623
#else
624
#error "Unknown I2C4 clock speed"
625
#endif
626
630
#if defined(LINE_SPI1_MISO) && defined(LINE_SPI1_MOSI) && defined(LINE_SPI1_SCK)
631
#define SPI1_GPIO_PORT_MISO PAL_PORT(LINE_SPI1_MISO)
632
#define SPI1_GPIO_MISO PAL_PAD(LINE_SPI1_MISO)
633
#define SPI1_GPIO_PORT_MOSI PAL_PORT(LINE_SPI1_MOSI)
634
#define SPI1_GPIO_MOSI PAL_PAD(LINE_SPI1_MOSI)
635
#define SPI1_GPIO_PORT_SCK PAL_PORT(LINE_SPI1_SCK)
636
#define SPI1_GPIO_SCK PAL_PAD(LINE_SPI1_SCK)
637
638
#if defined(AF_LINE_SPI1_SCK)
639
#define SPI1_GPIO_AF AF_LINE_SPI1_SCK
640
#endif
641
#endif
642
643
#if defined(LINE_SPI2_MISO) && defined(LINE_SPI2_MOSI) && defined(LINE_SPI2_SCK)
644
#define SPI2_GPIO_PORT_MISO PAL_PORT(LINE_SPI2_MISO)
645
#define SPI2_GPIO_MISO PAL_PAD(LINE_SPI2_MISO)
646
#define SPI2_GPIO_PORT_MOSI PAL_PORT(LINE_SPI2_MOSI)
647
#define SPI2_GPIO_MOSI PAL_PAD(LINE_SPI2_MOSI)
648
#define SPI2_GPIO_PORT_SCK PAL_PORT(LINE_SPI2_SCK)
649
#define SPI2_GPIO_SCK PAL_PAD(LINE_SPI2_SCK)
650
651
#if defined(AF_LINE_SPI2_SCK)
652
#define SPI2_GPIO_AF AF_LINE_SPI2_SCK
653
#endif
654
#endif
655
656
#if defined(LINE_SPI3_MISO) && defined(LINE_SPI3_MOSI) && defined(LINE_SPI3_SCK)
657
#define SPI3_GPIO_PORT_MISO PAL_PORT(LINE_SPI3_MISO)
658
#define SPI3_GPIO_MISO PAL_PAD(LINE_SPI3_MISO)
659
#define SPI3_GPIO_PORT_MOSI PAL_PORT(LINE_SPI3_MOSI)
660
#define SPI3_GPIO_MOSI PAL_PAD(LINE_SPI3_MOSI)
661
#define SPI3_GPIO_PORT_SCK PAL_PORT(LINE_SPI3_SCK)
662
#define SPI3_GPIO_SCK PAL_PAD(LINE_SPI3_SCK)
663
664
#if defined(AF_LINE_SPI3_SCK)
665
#define SPI3_GPIO_AF AF_LINE_SPI3_SCK
666
#endif
667
#endif
668
669
#if defined(LINE_SPI4_MISO) && defined(LINE_SPI4_MOSI) && defined(LINE_SPI4_SCK)
670
#define SPI4_GPIO_PORT_MISO PAL_PORT(LINE_SPI4_MISO)
671
#define SPI4_GPIO_MISO PAL_PAD(LINE_SPI4_MISO)
672
#define SPI4_GPIO_PORT_MOSI PAL_PORT(LINE_SPI4_MOSI)
673
#define SPI4_GPIO_MOSI PAL_PAD(LINE_SPI4_MOSI)
674
#define SPI4_GPIO_PORT_SCK PAL_PORT(LINE_SPI4_SCK)
675
#define SPI4_GPIO_SCK PAL_PAD(LINE_SPI4_SCK)
676
677
#if defined(AF_LINE_SPI4_SCK)
678
#define SPI4_GPIO_AF AF_LINE_SPI4_SCK
679
#endif
680
#endif
681
682
#if defined(LINE_SPI5_MISO) && defined(LINE_SPI5_MOSI) && defined(LINE_SPI5_SCK)
683
#define SPI5_GPIO_PORT_MISO PAL_PORT(LINE_SPI5_MISO)
684
#define SPI5_GPIO_MISO PAL_PAD(LINE_SPI5_MISO)
685
#define SPI5_GPIO_PORT_MOSI PAL_PORT(LINE_SPI5_MOSI)
686
#define SPI5_GPIO_MOSI PAL_PAD(LINE_SPI5_MOSI)
687
#define SPI5_GPIO_PORT_SCK PAL_PORT(LINE_SPI5_SCK)
688
#define SPI5_GPIO_SCK PAL_PAD(LINE_SPI5_SCK)
689
690
#if defined(AF_LINE_SPI5_SCK)
691
#define SPI5_GPIO_AF AF_LINE_SPI5_SCK
692
#endif
693
#endif
694
695
#if defined(LINE_SPI6_MISO) && defined(LINE_SPI6_MOSI) && defined(LINE_SPI6_SCK)
696
#define SPI6_GPIO_PORT_MISO PAL_PORT(LINE_SPI6_MISO)
697
#define SPI6_GPIO_MISO PAL_PAD(LINE_SPI6_MISO)
698
#define SPI6_GPIO_PORT_MOSI PAL_PORT(LINE_SPI6_MOSI)
699
#define SPI6_GPIO_MOSI PAL_PAD(LINE_SPI6_MOSI)
700
#define SPI6_GPIO_PORT_SCK PAL_PORT(LINE_SPI6_SCK)
701
#define SPI6_GPIO_SCK PAL_PAD(LINE_SPI6_SCK)
702
703
#if defined(AF_LINE_SPI6_SCK)
704
#define SPI6_GPIO_AF AF_LINE_SPI6_SCK
705
#endif
706
#endif
707
711
#if defined(LINE_SPI_SLAVE0)
712
#define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_SPI_SLAVE0)
713
#define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_SPI_SLAVE0)
714
#endif
715
716
#if defined(LINE_SPI_SLAVE1)
717
#define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_SPI_SLAVE1)
718
#define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_SPI_SLAVE1)
719
#endif
720
721
#if defined(LINE_SPI_SLAVE2)
722
#define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_SPI_SLAVE2)
723
#define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_SPI_SLAVE2)
724
#endif
725
726
#if defined(LINE_SPI_SLAVE3)
727
#define SPI_SELECT_SLAVE3_PORT PAL_PORT(LINE_SPI_SLAVE3)
728
#define SPI_SELECT_SLAVE3_PIN PAL_PAD(LINE_SPI_SLAVE3)
729
#endif
730
731
#if defined(LINE_SPI_SLAVE4)
732
#define SPI_SELECT_SLAVE4_PORT PAL_PORT(LINE_SPI_SLAVE4)
733
#define SPI_SELECT_SLAVE4_PIN PAL_PAD(LINE_SPI_SLAVE4)
734
#endif
735
736
#if defined(LINE_SPI_SLAVE5)
737
#define SPI_SELECT_SLAVE5_PORT PAL_PORT(LINE_SPI_SLAVE5)
738
#define SPI_SELECT_SLAVE5_PIN PAL_PAD(LINE_SPI_SLAVE5)
739
#endif
740
741
#if defined(LINE_SPI_SLAVE6)
742
#define SPI_SELECT_SLAVE6_PORT PAL_PORT(LINE_SPI_SLAVE6)
743
#define SPI_SELECT_SLAVE6_PIN PAL_PAD(LINE_SPI_SLAVE6)
744
#endif
745
746
#if defined(LINE_SPI_SLAVE7)
747
#define SPI_SELECT_SLAVE7_PORT PAL_PORT(LINE_SPI_SLAVE7)
748
#define SPI_SELECT_SLAVE7_PIN PAL_PAD(LINE_SPI_SLAVE7)
749
#endif
750
751
#if defined(LINE_SPI_SLAVE8)
752
#define SPI_SELECT_SLAVE8_PORT PAL_PORT(LINE_SPI_SLAVE8)
753
#define SPI_SELECT_SLAVE8_PIN PAL_PAD(LINE_SPI_SLAVE8)
754
#endif
755
759
// #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)
760
// #define SDIO_D0_PORT PAL_PORT(LINE_SDIO_D0)
761
// #define SDIO_D0_PIN PAL_PAD(LINE_SDIO_D0)
762
// #define SDIO_D1_PORT PAL_PORT(LINE_SDIO_D1)
763
// #define SDIO_D1_PIN PAL_PAD(LINE_SDIO_D1)
764
// #define SDIO_D2_PORT PAL_PORT(LINE_SDIO_D2)
765
// #define SDIO_D2_PIN PAL_PAD(LINE_SDIO_D2)
766
// #define SDIO_D3_PORT PAL_PORT(LINE_SDIO_D3)
767
// #define SDIO_D3_PIN PAL_PAD(LINE_SDIO_D3)
768
// #define SDIO_CK_PORT PAL_PORT(LINE_SDIO_CK)
769
// #define SDIO_CK_PIN PAL_PAD(LINE_SDIO_CK)
770
// #define SDIO_CMD_PORT PAL_PORT(LINE_SDIO_CMD)
771
// #define SDIO_CMD_PIN PAL_PAD(LINE_SDIO_CMD)
772
773
// #if defined(AF_LINE_SDIO_CMD)
774
// #define SDIO_AF AF_LINE_SDIO_CMD
775
// #else
776
// #define SDIO_AF ((void)0)
777
// #endif
778
// #endif
779
780
#if defined(LINE_USB_VBUS)
781
#define SDLOG_USB_VBUS_PORT PAL_PORT(LINE_USB_VBUS)
782
#define SDLOG_USB_VBUS_PIN PAL_PAD(LINE_USB_VBUS)
783
#define SDLOG_USB_VBUS_BOOT false
784
#endif
785
786
/*
787
* Actuators for fixedwing
788
*/
789
/* Default actuators driver */
790
#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
791
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
792
#define ActuatorsDefaultInit() ActuatorsPwmInit()
793
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
794
795
#endif
/* ARCH_COMMON_BOARD_H */
sw
airborne
arch
chibios
common_board.h
Generated on Thu Dec 5 2024 13:05:29 for Paparazzi UAS by
1.9.1