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