Paparazzi UAS
v5.12_stable-4-g9b43e9b
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
elle0_common.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2015 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_ELLE0_COMMON_H
24
#define CONFIG_ELLE0_COMMON_H
25
26
#define BOARD_ELLE0
27
28
/* ELLE0 has a 25MHz external clock and 168MHz internal. */
29
#define EXT_CLK 25000000
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
/* orange, on PC2 */
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
/*
67
* not actual LEDS, used as GPIOs
68
*/
69
70
/* PB1, DRDY on EXT SPI connector*/
71
#define LED_BODY_GPIO GPIOB
72
#define LED_BODY_GPIO_PIN GPIO1
73
#define LED_BODY_GPIO_ON gpio_set
74
#define LED_BODY_GPIO_OFF gpio_clear
75
#define LED_BODY_AFIO_REMAP ((void)0)
76
77
/* PC12, on GPIO connector*/
78
#define LED_12_GPIO GPIOC
79
#define LED_12_GPIO_PIN GPIO12
80
#define LED_12_GPIO_ON gpio_clear
81
#define LED_12_GPIO_OFF gpio_set
82
#define LED_12_AFIO_REMAP ((void)0)
83
84
85
/* Default actuators driver */
86
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
87
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
88
#define ActuatorsDefaultInit() ActuatorsPwmInit()
89
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
90
91
92
/* UART */
93
#define UART1_GPIO_AF GPIO_AF7
94
#define UART1_GPIO_PORT_RX GPIOA
95
#define UART1_GPIO_RX GPIO10
96
#define UART1_GPIO_PORT_TX GPIOA
97
#define UART1_GPIO_TX GPIO9
98
99
#define UART2_GPIO_AF GPIO_AF7
100
#define UART2_GPIO_PORT_RX GPIOA
101
#define UART2_GPIO_RX GPIO3
102
#define UART2_GPIO_PORT_TX GPIOA
103
#define UART2_GPIO_TX GPIO2
104
105
#define UART3_GPIO_AF GPIO_AF7
106
#define UART3_GPIO_PORT_RX GPIOC
107
#define UART3_GPIO_RX GPIO11
108
#define UART3_GPIO_PORT_TX GPIOC
109
#define UART3_GPIO_TX GPIO10
110
111
#define UART5_GPIO_AF GPIO_AF8
112
#define UART5_GPIO_PORT_RX GPIOD
113
#define UART5_GPIO_RX GPIO2
114
#define UART5_GPIO_PORT_TX GPIOC
115
#define UART5_GPIO_TX GPIO12
116
117
/*
118
* Spektrum
119
*/
120
/* The line that is pulled low at power up to initiate the bind process */
121
#define SPEKTRUM_BIND_PIN GPIO0
122
#define SPEKTRUM_BIND_PIN_PORT GPIOB
123
124
#define SPEKTRUM_UART1_RCC RCC_USART1
125
#define SPEKTRUM_UART1_BANK GPIOA
126
#define SPEKTRUM_UART1_PIN GPIO10
127
#define SPEKTRUM_UART1_AF GPIO_AF7
128
#define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
129
#define SPEKTRUM_UART1_ISR usart1_isr
130
#define SPEKTRUM_UART1_DEV USART1
131
132
#define SPEKTRUM_UART2_RCC RCC_USART2
133
#define SPEKTRUM_UART2_BANK GPIOA
134
#define SPEKTRUM_UART2_PIN GPIO3
135
#define SPEKTRUM_UART2_AF GPIO_AF7
136
#define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
137
#define SPEKTRUM_UART2_ISR usart2_isr
138
#define SPEKTRUM_UART2_DEV USART2
139
140
#define SPEKTRUM_UART5_RCC RCC_UART5
141
#define SPEKTRUM_UART5_BANK GPIOD
142
#define SPEKTRUM_UART5_PIN GPIO2
143
#define SPEKTRUM_UART5_AF GPIO_AF8
144
#define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
145
#define SPEKTRUM_UART5_ISR uart5_isr
146
#define SPEKTRUM_UART5_DEV UART5
147
148
/* PPM
149
*
150
* Default is PPM config 2, input on GPIOA1 (Servo pin 6)
151
*/
152
153
#ifndef PPM_CONFIG
154
#define PPM_CONFIG 2
155
#endif
156
157
#if PPM_CONFIG == 1
158
/* input on PA10 (UART1_RX) */
159
#define USE_PPM_TIM1 1
160
#define PPM_CHANNEL TIM_IC3
161
#define PPM_TIMER_INPUT TIM_IC_IN_TI3
162
#define PPM_IRQ NVIC_TIM1_CC_IRQ
163
#define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
164
// Capture/Compare InteruptEnable and InterruptFlag
165
#define PPM_CC_IE TIM_DIER_CC3IE
166
#define PPM_CC_IF TIM_SR_CC3IF
167
#define PPM_GPIO_PORT GPIOA
168
#define PPM_GPIO_PIN GPIO10
169
#define PPM_GPIO_AF GPIO_AF1
170
171
#elif PPM_CONFIG == 2
172
/* input on PA01 (Servo 6 pin) */
173
#define USE_PPM_TIM2 1
174
#define PPM_CHANNEL TIM_IC2
175
#define PPM_TIMER_INPUT TIM_IC_IN_TI2
176
#define PPM_IRQ NVIC_TIM2_IRQ
177
// Capture/Compare InteruptEnable and InterruptFlag
178
#define PPM_CC_IE TIM_DIER_CC2IE
179
#define PPM_CC_IF TIM_SR_CC2IF
180
#define PPM_GPIO_PORT GPIOA
181
#define PPM_GPIO_PIN GPIO1
182
#define PPM_GPIO_AF GPIO_AF1
183
184
// Move default ADC timer
185
#if USE_AD_TIM2
186
#undef USE_AD_TIM2
187
#endif
188
#define USE_AD_TIM1 1
189
190
#elif PPM_CONFIG == 3
191
#if USE_SERVOS_7AND8
192
#error "You cannot USE_SERVOS_7AND8 and PPM input on PB07 (SERVO8) at the same time"
193
#endif
194
/* input on PB07 (Servo 8 pin) */
195
#define USE_PPM_TIM4 1
196
#define PPM_CHANNEL TIM_IC2
197
#define PPM_TIMER_INPUT TIM_IC_IN_TI2
198
#define PPM_IRQ NVIC_TIM4_IRQ
199
// Capture/Compare InteruptEnable and InterruptFlag
200
#define PPM_CC_IE TIM_DIER_CC2IE
201
#define PPM_CC_IF TIM_SR_CC2IF
202
#define PPM_GPIO_PORT GPIOB
203
#define PPM_GPIO_PIN GPIO7
204
#define PPM_GPIO_AF GPIO_AF2
205
206
#else
207
#error "Unknown PPM config"
208
209
#endif // PPM_CONFIG
210
211
/* SPI */
212
#define SPI1_GPIO_AF GPIO_AF5
213
#define SPI1_GPIO_PORT_MISO GPIOA
214
#define SPI1_GPIO_MISO GPIO6
215
#define SPI1_GPIO_PORT_MOSI GPIOA
216
#define SPI1_GPIO_MOSI GPIO7
217
#define SPI1_GPIO_PORT_SCK GPIOA
218
#define SPI1_GPIO_SCK GPIO5
219
220
#define SPI2_GPIO_AF GPIO_AF5
221
#define SPI2_GPIO_PORT_MISO GPIOB
222
#define SPI2_GPIO_MISO GPIO14
223
#define SPI2_GPIO_PORT_MOSI GPIOB
224
#define SPI2_GPIO_MOSI GPIO15
225
#define SPI2_GPIO_PORT_SCK GPIOB
226
#define SPI2_GPIO_SCK GPIO13
227
228
#define SPI_SELECT_SLAVE0_PORT GPIOA
229
#define SPI_SELECT_SLAVE0_PIN GPIO15
230
231
#define SPI_SELECT_SLAVE1_PORT GPIOA
232
#define SPI_SELECT_SLAVE1_PIN GPIO4
233
234
#define SPI_SELECT_SLAVE2_PORT GPIOB
235
#define SPI_SELECT_SLAVE2_PIN GPIO12
236
237
#define SPI_SELECT_SLAVE3_PORT GPIOC
238
#define SPI_SELECT_SLAVE3_PIN GPIO13
239
240
#define SPI_SELECT_SLAVE4_PORT GPIOC
241
#define SPI_SELECT_SLAVE4_PIN GPIO12
242
243
#define SPI_SELECT_SLAVE5_PORT GPIOC
244
#define SPI_SELECT_SLAVE5_PIN GPIO4
245
246
#define SPI1_GPIO_PORT_NSS GPIOA
247
#define SPI1_GPIO_NSS GPIO4
248
249
#define SPI2_GPIO_PORT_NSS GPIOB
250
#define SPI2_GPIO_NSS GPIO12
251
252
253
/* I2C mapping */
254
#define I2C1_GPIO_PORT GPIOB
255
#define I2C1_GPIO_SCL GPIO6
256
#define I2C1_GPIO_SDA GPIO7
257
258
#define I2C2_GPIO_PORT GPIOB
259
#define I2C2_GPIO_SCL GPIO10
260
#define I2C2_GPIO_SDA GPIO11
261
262
263
/*
264
* ADC
265
*/
266
267
/* Onboard ADCs */
268
269
/* provide defines that can be used to access the ADC_x in the code or airframe file
270
* these directly map to the index number of the 4 adc channels defined above
271
* 4th (index 3) is used for bat monitoring by default
272
*/
273
274
#ifndef USE_ADC_1
275
#define USE_ADC_1 1
276
#endif
277
278
#if USE_ADC_1
279
#define AD1_1_CHANNEL 14
280
#define ADC_1 AD1_1
281
#define ADC_1_GPIO_PORT GPIOC
282
#define ADC_1_GPIO_PIN GPIO4
283
#endif
284
285
#if USE_ADC_2
286
#define AD1_2_CHANNEL 15
287
#define ADC_2 AD1_2
288
#define ADC_2_GPIO_PORT GPIOC
289
#define ADC_2_GPIO_PIN GPIO5
290
#endif
291
292
#if USE_ADC_3
293
#define AD1_3_CHANNEL 0
294
#define ADC_3 AD1_3
295
#define ADC_3_GPIO_PORT GPIOA
296
#define ADC_3_GPIO_PIN GPIO0
297
#endif
298
299
#if USE_ADC_4
300
#define AD1_4_CHANNEL 1
301
#define ADC_4 AD1_4
302
#define ADC_4_GPIO_PORT GPIOA
303
#define ADC_4_GPIO_PIN GPIO1
304
#endif
305
306
/* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
307
#ifndef ADC_CHANNEL_VSUPPLY
308
#define ADC_CHANNEL_VSUPPLY ADC_1
309
#endif
310
311
#define DefaultVoltageOfAdc(adc) (0.0045*adc)
312
313
314
/*
315
* PWM
316
*
317
*/
318
#define PWM_USE_TIM3 1
319
#define PWM_USE_TIM5 1
320
321
#ifndef USE_PWM1
322
#define USE_PWM1 1
323
#endif
324
#ifndef USE_PWM2
325
#define USE_PWM2 1
326
#endif
327
#ifndef USE_PWM3
328
#define USE_PWM3 1
329
#endif
330
#ifndef USE_PWM4
331
#define USE_PWM4 1
332
#endif
333
#ifndef USE_PWM5
334
#define USE_PWM5 1
335
#endif
336
#ifndef USE_PWM6
337
#define USE_PWM6 1
338
#endif
339
340
#if USE_SERVOS_7AND8
341
#if USE_I2C1
342
#error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
343
#else
344
#define ACTUATORS_PWM_NB 8
345
#define USE_PWM7 1
346
#define USE_PWM8 1
347
#define PWM_USE_TIM4 1
348
#define ACTUATORS_PWM_NB 8
349
#endif
350
#else
351
#define ACTUATORS_PWM_NB 6
352
#endif
353
354
// PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
355
#if USE_PWM1
356
#define PWM_SERVO_1 0
357
#define PWM_SERVO_1_TIMER TIM3
358
#define PWM_SERVO_1_GPIO GPIOC
359
#define PWM_SERVO_1_PIN GPIO6
360
#define PWM_SERVO_1_AF GPIO_AF2
361
#define PWM_SERVO_1_OC TIM_OC1
362
#define PWM_SERVO_1_OC_BIT (1<<0)
363
#else
364
#define PWM_SERVO_1_OC_BIT 0
365
#endif
366
367
#if USE_PWM2
368
#define PWM_SERVO_2 1
369
#define PWM_SERVO_2_TIMER TIM3
370
#define PWM_SERVO_2_GPIO GPIOC
371
#define PWM_SERVO_2_PIN GPIO7
372
#define PWM_SERVO_2_AF GPIO_AF2
373
#define PWM_SERVO_2_OC TIM_OC2
374
#define PWM_SERVO_2_OC_BIT (1<<1)
375
#else
376
#define PWM_SERVO_2_OC_BIT 0
377
#endif
378
379
#if USE_PWM3
380
#define PWM_SERVO_3 2
381
#define PWM_SERVO_3_TIMER TIM3
382
#define PWM_SERVO_3_GPIO GPIOC
383
#define PWM_SERVO_3_PIN GPIO8
384
#define PWM_SERVO_3_AF GPIO_AF2
385
#define PWM_SERVO_3_OC TIM_OC3
386
#define PWM_SERVO_3_OC_BIT (1<<2)
387
#else
388
#define PWM_SERVO_3_OC_BIT 0
389
#endif
390
391
#if USE_PWM4
392
#define PWM_SERVO_4 3
393
#define PWM_SERVO_4_TIMER TIM3
394
#define PWM_SERVO_4_GPIO GPIOC
395
#define PWM_SERVO_4_PIN GPIO9
396
#define PWM_SERVO_4_AF GPIO_AF2
397
#define PWM_SERVO_4_OC TIM_OC4
398
#define PWM_SERVO_4_OC_BIT (1<<3)
399
#else
400
#define PWM_SERVO_4_OC_BIT 0
401
#endif
402
403
#if USE_PWM5
404
#define PWM_SERVO_5 4
405
#define PWM_SERVO_5_TIMER TIM5
406
#define PWM_SERVO_5_GPIO GPIOA
407
#define PWM_SERVO_5_PIN GPIO0
408
#define PWM_SERVO_5_AF GPIO_AF2
409
#define PWM_SERVO_5_OC TIM_OC1
410
#define PWM_SERVO_5_OC_BIT (1<<0)
411
#else
412
#define PWM_SERVO_5_OC_BIT 0
413
#endif
414
415
#if USE_PWM6
416
#define PWM_SERVO_6 5
417
#define PWM_SERVO_6_TIMER TIM5
418
#define PWM_SERVO_6_GPIO GPIOA
419
#define PWM_SERVO_6_PIN GPIO1
420
#define PWM_SERVO_6_AF GPIO_AF2
421
#define PWM_SERVO_6_OC TIM_OC2
422
#define PWM_SERVO_6_OC_BIT (1<<1)
423
#else
424
#define PWM_SERVO_6_OC_BIT 0
425
#endif
426
427
#if USE_PWM7
428
#define PWM_SERVO_7 6
429
#define PWM_SERVO_7_TIMER TIM4
430
#define PWM_SERVO_7_GPIO GPIOB
431
#define PWM_SERVO_7_PIN GPIO6
432
#define PWM_SERVO_7_AF GPIO_AF2
433
#define PWM_SERVO_7_OC TIM_OC1
434
#define PWM_SERVO_7_OC_BIT (1<<0)
435
#else
436
#define PWM_SERVO_7_OC_BIT 0
437
#endif
438
439
#if USE_PWM8
440
#define PWM_SERVO_8 7
441
#define PWM_SERVO_8_TIMER TIM4
442
#define PWM_SERVO_8_GPIO GPIOB
443
#define PWM_SERVO_8_PIN GPIO7
444
#define PWM_SERVO_8_AF GPIO_AF2
445
#define PWM_SERVO_8_OC TIM_OC2
446
#define PWM_SERVO_8_OC_BIT (1<<1)
447
#else
448
#define PWM_SERVO_8_OC_BIT 0
449
#endif
450
451
/* servos 1-4 on TIM3 */
452
#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)
453
/* servos 5-6 on TIM5 */
454
#define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
455
/* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
456
#define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
457
458
459
/* by default activate onboard baro */
460
#ifndef USE_BARO_BOARD
461
#define USE_BARO_BOARD 1
462
#endif
463
464
#endif
/* CONFIG_ELLE0_1_0_H */
sw
airborne
boards
elle0_common.h
Generated on Sat Feb 9 2019 06:43:48 for Paparazzi UAS by
1.8.8