Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 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  ADC1 PC3/ADC13
270  ADC2 PC0/ADC10
271  ADC3 PC1/ADC11
272  ADC4 PC5/ADC15
273  ADC6 PC2/ADC12
274  BATT PC4/ADC14
275 */
276 
277 /* provide defines that can be used to access the ADC_x in the code or airframe file
278  * these directly map to the index number of the 4 adc channels defined above
279  * 4th (index 3) is used for bat monitoring by default
280  */
281 
282 #ifndef USE_ADC_1
283 #define USE_ADC_1 1
284 #endif
285 
286 #if USE_ADC_1
287 #define AD1_1_CHANNEL 14
288 #define ADC_1 AD1_1
289 #define ADC_1_GPIO_PORT GPIOC
290 #define ADC_1_GPIO_PIN GPIO4
291 #endif
292 
293 #if USE_ADC_2
294 #define AD1_2_CHANNEL 15
295 #define ADC_2 AD1_2
296 #define ADC_2_GPIO_PORT GPIOC
297 #define ADC_2_GPIO_PIN GPIO5
298 #endif
299 
300 #if USE_ADC_3
301 #define AD1_3_CHANNEL 0
302 #define ADC_3 AD1_3
303 #define ADC_3_GPIO_PORT GPIOA
304 #define ADC_3_GPIO_PIN GPIO0
305 #endif
306 
307 #if USE_ADC_4
308 #define AD1_4_CHANNEL 1
309 #define ADC_4 AD1_4
310 #define ADC_4_GPIO_PORT GPIOA
311 #define ADC_4_GPIO_PIN GPIO1
312 #endif
313 
314 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
315 #ifndef ADC_CHANNEL_VSUPPLY
316 #define ADC_CHANNEL_VSUPPLY ADC_1
317 #endif
318 
319 #define DefaultVoltageOfAdc(adc) (0.0045*adc)
320 
321 
322 /*
323  * PWM
324  *
325  */
326 #define PWM_USE_TIM3 1
327 #define PWM_USE_TIM5 1
328 
329 #ifndef USE_PWM1
330 #define USE_PWM1 1
331 #endif
332 #ifndef USE_PWM2
333 #define USE_PWM2 1
334 #endif
335 #ifndef USE_PWM3
336 #define USE_PWM3 1
337 #endif
338 #ifndef USE_PWM4
339 #define USE_PWM4 1
340 #endif
341 #ifndef USE_PWM5
342 #define USE_PWM5 1
343 #endif
344 #ifndef USE_PWM6
345 #define USE_PWM6 1
346 #endif
347 
348 #if USE_SERVOS_7AND8
349 #if USE_I2C1
350 #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
351 #else
352 #define ACTUATORS_PWM_NB 8
353 #define USE_PWM7 1
354 #define USE_PWM8 1
355 #define PWM_USE_TIM4 1
356 #define ACTUATORS_PWM_NB 8
357 #endif
358 #else
359 #define ACTUATORS_PWM_NB 6
360 #endif
361 
362 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
363 #if USE_PWM1
364 #define PWM_SERVO_1 0
365 #define PWM_SERVO_1_TIMER TIM3
366 #define PWM_SERVO_1_GPIO GPIOC
367 #define PWM_SERVO_1_PIN GPIO6
368 #define PWM_SERVO_1_AF GPIO_AF2
369 #define PWM_SERVO_1_OC TIM_OC1
370 #define PWM_SERVO_1_OC_BIT (1<<0)
371 #else
372 #define PWM_SERVO_1_OC_BIT 0
373 #endif
374 
375 #if USE_PWM2
376 #define PWM_SERVO_2 1
377 #define PWM_SERVO_2_TIMER TIM3
378 #define PWM_SERVO_2_GPIO GPIOC
379 #define PWM_SERVO_2_PIN GPIO7
380 #define PWM_SERVO_2_AF GPIO_AF2
381 #define PWM_SERVO_2_OC TIM_OC2
382 #define PWM_SERVO_2_OC_BIT (1<<1)
383 #else
384 #define PWM_SERVO_2_OC_BIT 0
385 #endif
386 
387 #if USE_PWM3
388 #define PWM_SERVO_3 2
389 #define PWM_SERVO_3_TIMER TIM3
390 #define PWM_SERVO_3_GPIO GPIOC
391 #define PWM_SERVO_3_PIN GPIO8
392 #define PWM_SERVO_3_AF GPIO_AF2
393 #define PWM_SERVO_3_OC TIM_OC3
394 #define PWM_SERVO_3_OC_BIT (1<<2)
395 #else
396 #define PWM_SERVO_3_OC_BIT 0
397 #endif
398 
399 #if USE_PWM4
400 #define PWM_SERVO_4 3
401 #define PWM_SERVO_4_TIMER TIM3
402 #define PWM_SERVO_4_GPIO GPIOC
403 #define PWM_SERVO_4_PIN GPIO9
404 #define PWM_SERVO_4_AF GPIO_AF2
405 #define PWM_SERVO_4_OC TIM_OC4
406 #define PWM_SERVO_4_OC_BIT (1<<3)
407 #else
408 #define PWM_SERVO_4_OC_BIT 0
409 #endif
410 
411 #if USE_PWM5
412 #define PWM_SERVO_5 4
413 #define PWM_SERVO_5_TIMER TIM5
414 #define PWM_SERVO_5_GPIO GPIOA
415 #define PWM_SERVO_5_PIN GPIO0
416 #define PWM_SERVO_5_AF GPIO_AF2
417 #define PWM_SERVO_5_OC TIM_OC1
418 #define PWM_SERVO_5_OC_BIT (1<<0)
419 #else
420 #define PWM_SERVO_5_OC_BIT 0
421 #endif
422 
423 #if USE_PWM6
424 #define PWM_SERVO_6 5
425 #define PWM_SERVO_6_TIMER TIM5
426 #define PWM_SERVO_6_GPIO GPIOA
427 #define PWM_SERVO_6_PIN GPIO1
428 #define PWM_SERVO_6_AF GPIO_AF2
429 #define PWM_SERVO_6_OC TIM_OC2
430 #define PWM_SERVO_6_OC_BIT (1<<1)
431 #else
432 #define PWM_SERVO_6_OC_BIT 0
433 #endif
434 
435 #if USE_PWM7
436 #define PWM_SERVO_7 6
437 #define PWM_SERVO_7_TIMER TIM4
438 #define PWM_SERVO_7_GPIO GPIOB
439 #define PWM_SERVO_7_PIN GPIO6
440 #define PWM_SERVO_7_AF GPIO_AF2
441 #define PWM_SERVO_7_OC TIM_OC1
442 #define PWM_SERVO_7_OC_BIT (1<<0)
443 #else
444 #define PWM_SERVO_7_OC_BIT 0
445 #endif
446 
447 #if USE_PWM8
448 #define PWM_SERVO_8 7
449 #define PWM_SERVO_8_TIMER TIM4
450 #define PWM_SERVO_8_GPIO GPIOB
451 #define PWM_SERVO_8_PIN GPIO7
452 #define PWM_SERVO_8_AF GPIO_AF2
453 #define PWM_SERVO_8_OC TIM_OC2
454 #define PWM_SERVO_8_OC_BIT (1<<1)
455 #else
456 #define PWM_SERVO_8_OC_BIT 0
457 #endif
458 
459 /* servos 1-4 on TIM3 */
460 #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)
461 /* servos 5-6 on TIM5 */
462 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
463 /* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
464 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
465 
466 
467 /* by default activate onboard baro */
468 #ifndef USE_BARO_BOARD
469 #define USE_BARO_BOARD 1
470 #endif
471 
472 #endif /* CONFIG_ELLE0_1_0_H */