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