Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
lisa_mx_common.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2013 Piotr Esden-Tempski <piotr@esden.net>
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
23
#ifndef CONFIG_LISA_MX_COMMON_H
24
#define CONFIG_LISA_MX_COMMON_H
25
26
#include "
std.h
"
27
28
#define BOARD_LISA_MX
29
30
/* Lisa/M has a 12MHz external clock and 168MHz internal. */
31
#define EXT_CLK 12000000
32
#define AHB_CLK 168000000
33
34
/*
35
* Onboard LEDs
36
*/
37
38
/* red, on PA8 */
39
#ifndef USE_LED_1
40
#define USE_LED_1 1
41
#endif
42
#define LED_1_GPIO GPIOA
43
#define LED_1_GPIO_PIN GPIO8
44
#define LED_1_GPIO_ON gpio_clear
45
#define LED_1_GPIO_OFF gpio_set
46
#define LED_1_AFIO_REMAP ((void)0)
47
48
/* green, shared with JTAG_TRST */
49
#ifndef USE_LED_2
50
#define USE_LED_2 1
51
#endif
52
#define LED_2_GPIO GPIOB
53
#define LED_2_GPIO_PIN GPIO4
54
#define LED_2_GPIO_ON gpio_clear
55
#define LED_2_GPIO_OFF gpio_set
56
#define LED_2_AFIO_REMAP ((void)0)
57
58
/* green, shared with ADC12 (ADC_6 on connector ANALOG2) */
59
#ifndef USE_LED_3
60
#define USE_LED_3 1
61
#endif
62
#define LED_3_GPIO GPIOC
63
#define LED_3_GPIO_PIN GPIO2
64
#define LED_3_GPIO_ON gpio_clear
65
#define LED_3_GPIO_OFF gpio_set
66
#define LED_3_AFIO_REMAP ((void)0)
67
68
/* red, shared with ADC15 (ADC_4 on connector ANALOG2) */
69
#ifndef USE_LED_4
70
#define USE_LED_4 1
71
#endif
72
#define LED_4_GPIO GPIOC
73
#define LED_4_GPIO_PIN GPIO5
74
#define LED_4_GPIO_ON gpio_clear
75
#define LED_4_GPIO_OFF gpio_set
76
#define LED_4_AFIO_REMAP ((void)0)
77
78
/* green, on PC15 */
79
#ifndef USE_LED_5
80
#define USE_LED_5 1
81
#endif
82
#define LED_5_GPIO GPIOC
83
#define LED_5_GPIO_PIN GPIO15
84
#define LED_5_GPIO_ON gpio_clear
85
#define LED_5_GPIO_OFF gpio_set
86
#define LED_5_AFIO_REMAP ((void)0)
87
88
/*
89
* LEDs not populated by default
90
*/
91
/* PC3, ADC13 on ADC_1 */
92
#define LED_6_GPIO GPIOC
93
#define LED_6_GPIO_PIN GPIO3
94
#define LED_6_GPIO_ON gpio_clear
95
#define LED_6_GPIO_OFF gpio_set
96
#define LED_6_AFIO_REMAP ((void)0)
97
98
/* PC0, ADC10 on ADC_2 */
99
#define LED_7_GPIO GPIOC
100
#define LED_7_GPIO_PIN GPIO0
101
#define LED_7_GPIO_ON gpio_clear
102
#define LED_7_GPIO_OFF gpio_set
103
#define LED_7_AFIO_REMAP ((void)0)
104
105
/* PC1, ADC11 on ADC_3 */
106
#define LED_8_GPIO GPIOC
107
#define LED_8_GPIO_PIN GPIO1
108
#define LED_8_GPIO_ON gpio_clear
109
#define LED_8_GPIO_OFF gpio_set
110
#define LED_8_AFIO_REMAP ((void)0)
111
112
113
/*
114
* not actual LEDS, used as GPIOs
115
*/
116
117
/* PB1, DRDY on EXT SPI connector*/
118
#define LED_BODY_GPIO GPIOB
119
#define LED_BODY_GPIO_PIN GPIO1
120
#define LED_BODY_GPIO_ON gpio_set
121
#define LED_BODY_GPIO_OFF gpio_clear
122
#define LED_BODY_AFIO_REMAP ((void)0)
123
124
/* PC12, on GPIO connector*/
125
#define LED_12_GPIO GPIOC
126
#define LED_12_GPIO_PIN GPIO12
127
#define LED_12_GPIO_ON gpio_clear
128
#define LED_12_GPIO_OFF gpio_set
129
#define LED_12_AFIO_REMAP ((void)0)
130
131
132
/* Default actuators driver */
133
#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
134
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
135
#define ActuatorsDefaultInit() ActuatorsPwmInit()
136
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
137
138
139
/* UART */
140
#if REMAP_UART1
141
#define UART1_GPIO_AF GPIO_AF7
142
#define UART1_GPIO_PORT_RX GPIOB
143
#define UART1_GPIO_RX GPIO7
144
#define UART1_GPIO_PORT_TX GPIOB
145
#define UART1_GPIO_TX GPIO6
146
#else
147
#define UART1_GPIO_AF GPIO_AF7
148
#define UART1_GPIO_PORT_RX GPIOA
149
#define UART1_GPIO_RX GPIO10
150
#define UART1_GPIO_PORT_TX GPIOA
151
#define UART1_GPIO_TX GPIO9
152
#endif
/* REMAP_UART1 */
153
154
#define UART2_GPIO_AF GPIO_AF7
155
#define UART2_GPIO_PORT_RX GPIOA
156
#define UART2_GPIO_RX GPIO3
157
#define UART2_GPIO_PORT_TX GPIOA
158
#define UART2_GPIO_TX GPIO2
159
160
#if REMAP_UART3
// For UART4 we need to remap UART 3
161
#define UART3_GPIO_AF GPIO_AF7
162
#define UART3_GPIO_PORT_RX GPIOB
163
#define UART3_GPIO_RX GPIO11
164
#define UART3_GPIO_PORT_TX GPIOB
165
#define UART3_GPIO_TX GPIO10
166
167
#define UART4_GPIO_AF GPIO_AF8
168
#define UART4_GPIO_PORT_RX GPIOC
169
#define UART4_GPIO_RX GPIO11
170
#define UART4_GPIO_PORT_TX GPIOC
171
#define UART4_GPIO_TX GPIO10
172
173
#else
174
#define UART3_GPIO_AF GPIO_AF7
175
#define UART3_GPIO_PORT_RX GPIOC
176
#define UART3_GPIO_RX GPIO11
177
#define UART3_GPIO_PORT_TX GPIOC
178
#define UART3_GPIO_TX GPIO10
179
#endif
180
181
182
#define UART5_GPIO_AF GPIO_AF8
183
#define UART5_GPIO_PORT_RX GPIOD
184
#define UART5_GPIO_RX GPIO2
185
#define UART5_GPIO_PORT_TX GPIOC
186
#define UART5_GPIO_TX GPIO12
187
188
#define UART6_GPIO_AF GPIO_AF8
189
#define UART6_GPIO_PORT_RX GPIOC
190
#define UART6_GPIO_RX GPIO7
191
#define UART6_GPIO_PORT_TX GPIOC
192
#define UART6_GPIO_TX GPIO6
193
194
/*
195
* Spektrum
196
*/
197
/* The line that is pulled low at power up to initiate the bind process */
198
/* These are not common between versions of lisa/mx and thus defined in the
199
* version specific header files. */
200
/* #define SPEKTRUM_BIND_PIN GPIO0 */
201
/* #define SPEKTRUM_BIND_PIN_PORT GPIOB */
202
203
#define SPEKTRUM_UART1_RCC RCC_USART1
204
#define SPEKTRUM_UART1_BANK GPIOA
205
#define SPEKTRUM_UART1_PIN GPIO10
206
#define SPEKTRUM_UART1_AF GPIO_AF7
207
#define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
208
#define SPEKTRUM_UART1_ISR usart1_isr
209
#define SPEKTRUM_UART1_DEV USART1
210
211
#define SPEKTRUM_UART5_RCC RCC_UART5
212
#define SPEKTRUM_UART5_BANK GPIOD
213
#define SPEKTRUM_UART5_PIN GPIO2
214
#define SPEKTRUM_UART5_AF GPIO_AF8
215
#define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
216
#define SPEKTRUM_UART5_ISR uart5_isr
217
#define SPEKTRUM_UART5_DEV UART5
218
219
/* PPM
220
*
221
* Default is PPM config 2, input on GPIOA1 (Servo pin 6)
222
*/
223
#if USE_PPM
224
#ifndef PPM_CONFIG
225
#define PPM_CONFIG 2
226
#endif
227
228
#if PPM_CONFIG == 1
229
/* input on PA10 (UART1_RX) */
230
#define USE_PPM_TIM1 1
231
#define PPM_CHANNEL TIM_IC3
232
#define PPM_TIMER_INPUT TIM_IC_IN_TI3
233
#define PPM_IRQ NVIC_TIM1_CC_IRQ
234
#define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
235
// Capture/Compare InteruptEnable and InterruptFlag
236
#define PPM_CC_IE TIM_DIER_CC3IE
237
#define PPM_CC_IF TIM_SR_CC3IF
238
#define PPM_GPIO_PORT GPIOA
239
#define PPM_GPIO_PIN GPIO10
240
#define PPM_GPIO_AF GPIO_AF1
241
242
#elif PPM_CONFIG == 2
243
/* input on PA01 (Servo 6 pin) */
244
#define USE_PPM_TIM2 1
245
#define PPM_CHANNEL TIM_IC2
246
#define PPM_TIMER_INPUT TIM_IC_IN_TI2
247
#define PPM_IRQ NVIC_TIM2_IRQ
248
// Capture/Compare InteruptEnable and InterruptFlag
249
#define PPM_CC_IE TIM_DIER_CC2IE
250
#define PPM_CC_IF TIM_SR_CC2IF
251
#define PPM_GPIO_PORT GPIOA
252
#define PPM_GPIO_PIN GPIO1
253
#define PPM_GPIO_AF GPIO_AF1
254
255
// Move default ADC timer
256
#if USE_AD_TIM2
257
#undef USE_AD_TIM2
258
#endif
259
#define USE_AD_TIM1 1
260
261
#else
262
#error "Unknown PPM config"
263
264
#endif
// PPM_CONFIG
265
#endif
// USE_PPM
266
267
/* SPI */
268
#define SPI1_GPIO_AF GPIO_AF5
269
#define SPI1_GPIO_PORT_MISO GPIOA
270
#define SPI1_GPIO_MISO GPIO6
271
#define SPI1_GPIO_PORT_MOSI GPIOA
272
#define SPI1_GPIO_MOSI GPIO7
273
#define SPI1_GPIO_PORT_SCK GPIOA
274
#define SPI1_GPIO_SCK GPIO5
275
276
#define SPI2_GPIO_AF GPIO_AF5
277
#define SPI2_GPIO_PORT_MISO GPIOB
278
#define SPI2_GPIO_MISO GPIO14
279
#define SPI2_GPIO_PORT_MOSI GPIOB
280
#define SPI2_GPIO_MOSI GPIO15
281
#define SPI2_GPIO_PORT_SCK GPIOB
282
#define SPI2_GPIO_SCK GPIO13
283
284
#define SPI_SELECT_SLAVE0_PORT GPIOA
285
#define SPI_SELECT_SLAVE0_PIN GPIO15
286
287
#define SPI_SELECT_SLAVE1_PORT GPIOA
288
#define SPI_SELECT_SLAVE1_PIN GPIO4
289
290
#define SPI_SELECT_SLAVE2_PORT GPIOB
291
#define SPI_SELECT_SLAVE2_PIN GPIO12
292
293
#define SPI_SELECT_SLAVE3_PORT GPIOC
294
#define SPI_SELECT_SLAVE3_PIN GPIO13
295
296
#define SPI_SELECT_SLAVE4_PORT GPIOC
297
#define SPI_SELECT_SLAVE4_PIN GPIO12
298
299
#define SPI_SELECT_SLAVE5_PORT GPIOC
300
#define SPI_SELECT_SLAVE5_PIN GPIO4
301
302
303
#define SPI1_GPIO_PORT_NSS GPIOA
304
#define SPI1_GPIO_NSS GPIO4
305
306
#define SPI2_GPIO_PORT_NSS GPIOB
307
#define SPI2_GPIO_NSS GPIO12
308
309
#define SPI3_GPIO_PORT_NSS GPIOA
310
#define SPI3_GPIO_NSS GPIO15
311
312
/* I2C mapping */
313
#define I2C1_GPIO_PORT GPIOB
314
#define I2C1_GPIO_SCL GPIO6
315
#define I2C1_GPIO_SDA GPIO7
316
317
#define I2C2_GPIO_PORT GPIOB
318
#define I2C2_GPIO_SCL GPIO10
319
#define I2C2_GPIO_SDA GPIO11
320
321
322
/*
323
* ADC
324
*/
325
326
/* Onboard ADCs */
327
/*
328
ADC1 PC3/ADC13
329
ADC2 PC0/ADC10
330
ADC3 PC1/ADC11
331
ADC4 PC5/ADC15
332
ADC6 PC2/ADC12
333
ADC7 PA3/ADC03
334
ADC8 PA0/ADC00
335
BATT PC4/ADC14
336
*/
337
338
/* provide defines that can be used to access the ADC_x in the code or airframe file
339
* these directly map to the index number of the 4 adc channels defined above
340
* 4th (index 3) is used for bat monitoring by default
341
*/
342
#if USE_ADC_1
343
#define AD1_1_CHANNEL 13
344
#define ADC_1 AD1_1
345
#define ADC_1_GPIO_PORT GPIOC
346
#define ADC_1_GPIO_PIN GPIO3
347
#endif
348
349
#if USE_ADC_2
350
#define AD1_2_CHANNEL 10
351
#define ADC_2 AD1_2
352
#define ADC_2_GPIO_PORT GPIOC
353
#define ADC_2_GPIO_PIN GPIO0
354
#endif
355
356
#if USE_ADC_3
357
#define AD1_3_CHANNEL 11
358
#define ADC_3 AD1_3
359
#define ADC_3_GPIO_PORT GPIOC
360
#define ADC_3_GPIO_PIN GPIO1
361
#endif
362
363
#if USE_ADC_4
364
#define AD2_1_CHANNEL 15
365
#define ADC_4 AD2_1
366
#define ADC_4_GPIO_PORT GPIOC
367
#define ADC_4_GPIO_PIN GPIO5
368
#endif
369
370
// Internal ADC for battery enabled by default
371
#ifndef USE_ADC_5
372
#define USE_ADC_5 1
373
#endif
374
#if USE_ADC_5
375
#define AD1_4_CHANNEL 14
376
#define ADC_5 AD1_4
377
#define ADC_5_GPIO_PORT GPIOC
378
#define ADC_5_GPIO_PIN GPIO4
379
#endif
380
381
#if USE_ADC_6
382
#define AD2_2_CHANNEL 12
383
#define ADC_6 AD2_2
384
#define ADC_6_GPIO_PORT GPIOC
385
#define ADC_6_GPIO_PIN GPIO2
386
#endif
387
388
#if USE_ADC_7
389
#define AD2_3_CHANNEL 3
390
#define ADC_4 AD2_3
391
#define ADC_4_GPIO_PORT GPIOA
392
#define ADC_4_GPIO_PIN GPIO3
393
#endif
394
395
#if USE_ADC_8
396
#define AD2_4_CHANNEL 0
397
#define ADC_8 AD2_4
398
#define ADC_8_GPIO_PORT GPIOA
399
#define ADC_8_GPIO_PIN GPIO0
400
#endif
401
402
/* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
403
#ifndef ADC_CHANNEL_VSUPPLY
404
#define ADC_CHANNEL_VSUPPLY ADC_5
405
#endif
406
407
#define DefaultVoltageOfAdc(adc) (0.0045*adc)
408
409
410
/*
411
* PWM
412
*
413
*/
414
#define PWM_USE_TIM3 1
415
#define PWM_USE_TIM5 1
416
417
#define USE_PWM1 1
418
#define USE_PWM2 1
419
#define USE_PWM3 1
420
#define USE_PWM4 1
421
422
#ifndef USE_PWM5
// this allows to disable servo 5 on Lisa MXS
423
#define USE_PWM5 1
424
#endif
425
426
#if (!defined USE_PWM6) && (PPM_CONFIG != 2)
// PWM6 only activated by default if PPM_CONFIG is not 2
427
#define USE_PWM6 1
428
#endif
429
430
#if (USE_PPM && PPM_CONFIG == 2) && USE_PWM6 == 1
431
#warning "You cannot USE_PWM6 and SERVO6 (or equivalent) at the same time"
432
#endif
433
434
#if USE_SERVOS_7AND8
435
#if USE_I2C1
436
#error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
437
#else
438
#define ACTUATORS_PWM_NB 8
439
#define USE_PWM7 1
440
#define USE_PWM8 1
441
#define PWM_USE_TIM4 1
442
#endif
443
#else
444
#define ACTUATORS_PWM_NB 6
445
#endif
446
447
// Servo numbering on LisaM silkscreen/docs starts with 1
448
449
// PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
450
#if USE_PWM1
451
#define PWM_SERVO_1 0
452
#define PWM_SERVO_1_TIMER TIM3
453
#define PWM_SERVO_1_GPIO GPIOC
454
#define PWM_SERVO_1_PIN GPIO6
455
#define PWM_SERVO_1_AF GPIO_AF2
456
#define PWM_SERVO_1_OC TIM_OC1
457
#define PWM_SERVO_1_OC_BIT (1<<0)
458
#else
459
#define PWM_SERVO_1_OC_BIT 0
460
#endif
461
462
#if USE_PWM2
463
#define PWM_SERVO_2 1
464
#define PWM_SERVO_2_TIMER TIM3
465
#define PWM_SERVO_2_GPIO GPIOC
466
#define PWM_SERVO_2_PIN GPIO7
467
#define PWM_SERVO_2_AF GPIO_AF2
468
#define PWM_SERVO_2_OC TIM_OC2
469
#define PWM_SERVO_2_OC_BIT (1<<1)
470
#else
471
#define PWM_SERVO_2_OC_BIT 0
472
#endif
473
474
#if USE_PWM3
475
#define PWM_SERVO_3 2
476
#define PWM_SERVO_3_TIMER TIM3
477
#define PWM_SERVO_3_GPIO GPIOC
478
#define PWM_SERVO_3_PIN GPIO8
479
#define PWM_SERVO_3_AF GPIO_AF2
480
#define PWM_SERVO_3_OC TIM_OC3
481
#define PWM_SERVO_3_OC_BIT (1<<2)
482
#else
483
#define PWM_SERVO_3_OC_BIT 0
484
#endif
485
486
#if USE_PWM4
487
#define PWM_SERVO_4 3
488
#define PWM_SERVO_4_TIMER TIM3
489
#define PWM_SERVO_4_GPIO GPIOC
490
#define PWM_SERVO_4_PIN GPIO9
491
#define PWM_SERVO_4_AF GPIO_AF2
492
#define PWM_SERVO_4_OC TIM_OC4
493
#define PWM_SERVO_4_OC_BIT (1<<3)
494
#else
495
#define PWM_SERVO_4_OC_BIT 0
496
#endif
497
498
#if USE_PWM5
499
#define PWM_SERVO_5 4
500
#define PWM_SERVO_5_TIMER TIM5
501
#define PWM_SERVO_5_GPIO GPIOA
502
#define PWM_SERVO_5_PIN GPIO0
503
#define PWM_SERVO_5_AF GPIO_AF2
504
#define PWM_SERVO_5_OC TIM_OC1
505
#define PWM_SERVO_5_OC_BIT (1<<0)
506
#else
507
#define PWM_SERVO_5_OC_BIT 0
508
#endif
509
510
#if USE_PWM6
511
#define PWM_SERVO_6 5
512
#define PWM_SERVO_6_TIMER TIM5
513
#define PWM_SERVO_6_GPIO GPIOA
514
#define PWM_SERVO_6_PIN GPIO1
515
#define PWM_SERVO_6_AF GPIO_AF2
516
#define PWM_SERVO_6_OC TIM_OC2
517
#define PWM_SERVO_6_OC_BIT (1<<1)
518
#else
519
#define PWM_SERVO_6_OC_BIT 0
520
#endif
521
522
#if USE_PWM7
523
#define PWM_SERVO_7 6
524
#define PWM_SERVO_7_TIMER TIM4
525
#define PWM_SERVO_7_GPIO GPIOB
526
#define PWM_SERVO_7_PIN GPIO6
527
#define PWM_SERVO_7_AF GPIO_AF2
528
#define PWM_SERVO_7_OC TIM_OC1
529
#define PWM_SERVO_7_OC_BIT (1<<0)
530
#else
531
#define PWM_SERVO_7_OC_BIT 0
532
#endif
533
534
#if USE_PWM8
535
#define PWM_SERVO_8 7
536
#define PWM_SERVO_8_TIMER TIM4
537
#define PWM_SERVO_8_GPIO GPIOB
538
#define PWM_SERVO_8_PIN GPIO7
539
#define PWM_SERVO_8_AF GPIO_AF2
540
#define PWM_SERVO_8_OC TIM_OC2
541
#define PWM_SERVO_8_OC_BIT (1<<1)
542
#else
543
#define PWM_SERVO_8_OC_BIT 0
544
#endif
545
546
/* servos 1-4 on TIM3 */
547
#define PWM_TIM3_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
548
/* servos 5-6 on TIM5 */
549
#define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
550
/* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
551
#define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
552
553
554
/* by default activate onboard baro */
555
#ifndef USE_BARO_BOARD
556
#define USE_BARO_BOARD 1
557
#endif
558
559
#endif
/* CONFIG_LISA_MX_COMMON_H */
std.h
sw
airborne
boards
lisa_mx_common.h
Generated on Fri Nov 8 2024 14:10:45 for Paparazzi UAS by
1.9.1