Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 #else
191 #error "Unknown PPM config"
192 
193 #endif // PPM_CONFIG
194 
195 /* SPI */
196 #define SPI1_GPIO_AF GPIO_AF5
197 #define SPI1_GPIO_PORT_MISO GPIOA
198 #define SPI1_GPIO_MISO GPIO6
199 #define SPI1_GPIO_PORT_MOSI GPIOA
200 #define SPI1_GPIO_MOSI GPIO7
201 #define SPI1_GPIO_PORT_SCK GPIOA
202 #define SPI1_GPIO_SCK GPIO5
203 
204 #define SPI2_GPIO_AF GPIO_AF5
205 #define SPI2_GPIO_PORT_MISO GPIOB
206 #define SPI2_GPIO_MISO GPIO14
207 #define SPI2_GPIO_PORT_MOSI GPIOB
208 #define SPI2_GPIO_MOSI GPIO15
209 #define SPI2_GPIO_PORT_SCK GPIOB
210 #define SPI2_GPIO_SCK GPIO13
211 
212 #define SPI_SELECT_SLAVE0_PORT GPIOA
213 #define SPI_SELECT_SLAVE0_PIN GPIO15
214 
215 #define SPI_SELECT_SLAVE1_PORT GPIOA
216 #define SPI_SELECT_SLAVE1_PIN GPIO4
217 
218 #define SPI_SELECT_SLAVE2_PORT GPIOB
219 #define SPI_SELECT_SLAVE2_PIN GPIO12
220 
221 #define SPI_SELECT_SLAVE3_PORT GPIOC
222 #define SPI_SELECT_SLAVE3_PIN GPIO13
223 
224 #define SPI_SELECT_SLAVE4_PORT GPIOC
225 #define SPI_SELECT_SLAVE4_PIN GPIO12
226 
227 #define SPI_SELECT_SLAVE5_PORT GPIOC
228 #define SPI_SELECT_SLAVE5_PIN GPIO4
229 
230 #define SPI1_GPIO_PORT_NSS GPIOA
231 #define SPI1_GPIO_NSS GPIO4
232 
233 #define SPI2_GPIO_PORT_NSS GPIOB
234 #define SPI2_GPIO_NSS GPIO12
235 
236 
237 /* I2C mapping */
238 #define I2C1_GPIO_PORT GPIOB
239 #define I2C1_GPIO_SCL GPIO6
240 #define I2C1_GPIO_SDA GPIO7
241 
242 #define I2C2_GPIO_PORT GPIOB
243 #define I2C2_GPIO_SCL GPIO10
244 #define I2C2_GPIO_SDA GPIO11
245 
246 
247 /*
248  * ADC
249  */
250 
251 /* Onboard ADCs */
252 /*
253  ADC1 PC3/ADC13
254  ADC2 PC0/ADC10
255  ADC3 PC1/ADC11
256  ADC4 PC5/ADC15
257  ADC6 PC2/ADC12
258  BATT PC4/ADC14
259 */
260 
261 /* provide defines that can be used to access the ADC_x in the code or airframe file
262  * these directly map to the index number of the 4 adc channels defined above
263  * 4th (index 3) is used for bat monitoring by default
264  */
265 #if USE_ADC_1
266 #define AD1_1_CHANNEL 13
267 #define ADC_1 AD1_1
268 #define ADC_1_GPIO_PORT GPIOC
269 #define ADC_1_GPIO_PIN GPIO3
270 #endif
271 
272 #if USE_ADC_2
273 #define AD1_2_CHANNEL 10
274 #define ADC_2 AD1_2
275 #define ADC_2_GPIO_PORT GPIOC
276 #define ADC_2_GPIO_PIN GPIO0
277 #endif
278 
279 #if USE_ADC_3
280 #define AD1_3_CHANNEL 11
281 #define ADC_3 AD1_3
282 #define ADC_3_GPIO_PORT GPIOC
283 #define ADC_3_GPIO_PIN GPIO1
284 #endif
285 
286 #if USE_ADC_4
287 #define AD2_1_CHANNEL 15
288 #define ADC_4 AD2_1
289 #define ADC_4_GPIO_PORT GPIOC
290 #define ADC_4_GPIO_PIN GPIO5
291 #endif
292 
293 // Internal ADC for battery enabled by default
294 #ifndef USE_ADC_5
295 #define USE_ADC_5 1
296 #endif
297 #if USE_ADC_5
298 #define AD1_4_CHANNEL 14
299 #define ADC_5 AD1_4
300 #define ADC_5_GPIO_PORT GPIOC
301 #define ADC_5_GPIO_PIN GPIO4
302 #endif
303 
304 #if USE_ADC_6
305 #define AD2_2_CHANNEL 12
306 #define ADC_6 AD2_2
307 #define ADC_6_GPIO_PORT GPIOC
308 #define ADC_6_GPIO_PIN GPIO2
309 #endif
310 
311 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
312 #ifndef ADC_CHANNEL_VSUPPLY
313 #define ADC_CHANNEL_VSUPPLY ADC_5
314 #endif
315 
316 #define DefaultVoltageOfAdc(adc) (0.0045*adc)
317 
318 
319 /*
320  * PWM
321  *
322  */
323 #define PWM_USE_TIM3 1
324 #define PWM_USE_TIM5 1
325 
326 #define USE_PWM1 1
327 #define USE_PWM2 1
328 #define USE_PWM3 1
329 #define USE_PWM4 1
330 #define USE_PWM5 1
331 #define USE_PWM6 1
332 
333 #if USE_SERVOS_7AND8
334 #if USE_I2C1
335 #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
336 #else
337 #define ACTUATORS_PWM_NB 8
338 #define USE_PWM7 1
339 #define USE_PWM8 1
340 #define PWM_USE_TIM4 1
341 #define ACTUATORS_PWM_NB 8
342 #endif
343 #else
344 #define ACTUATORS_PWM_NB 6
345 #endif
346 
347 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
348 #if USE_PWM1
349 #define PWM_SERVO_1 0
350 #define PWM_SERVO_1_TIMER TIM3
351 #define PWM_SERVO_1_GPIO GPIOC
352 #define PWM_SERVO_1_PIN GPIO6
353 #define PWM_SERVO_1_AF GPIO_AF2
354 #define PWM_SERVO_1_OC TIM_OC1
355 #define PWM_SERVO_1_OC_BIT (1<<0)
356 #else
357 #define PWM_SERVO_1_OC_BIT 0
358 #endif
359 
360 #if USE_PWM2
361 #define PWM_SERVO_2 1
362 #define PWM_SERVO_2_TIMER TIM3
363 #define PWM_SERVO_2_GPIO GPIOC
364 #define PWM_SERVO_2_PIN GPIO7
365 #define PWM_SERVO_2_AF GPIO_AF2
366 #define PWM_SERVO_2_OC TIM_OC2
367 #define PWM_SERVO_2_OC_BIT (1<<1)
368 #else
369 #define PWM_SERVO_2_OC_BIT 0
370 #endif
371 
372 #if USE_PWM3
373 #define PWM_SERVO_3 2
374 #define PWM_SERVO_3_TIMER TIM3
375 #define PWM_SERVO_3_GPIO GPIOC
376 #define PWM_SERVO_3_PIN GPIO8
377 #define PWM_SERVO_3_AF GPIO_AF2
378 #define PWM_SERVO_3_OC TIM_OC3
379 #define PWM_SERVO_3_OC_BIT (1<<2)
380 #else
381 #define PWM_SERVO_3_OC_BIT 0
382 #endif
383 
384 #if USE_PWM4
385 #define PWM_SERVO_4 3
386 #define PWM_SERVO_4_TIMER TIM3
387 #define PWM_SERVO_4_GPIO GPIOC
388 #define PWM_SERVO_4_PIN GPIO9
389 #define PWM_SERVO_4_AF GPIO_AF2
390 #define PWM_SERVO_4_OC TIM_OC4
391 #define PWM_SERVO_4_OC_BIT (1<<3)
392 #else
393 #define PWM_SERVO_4_OC_BIT 0
394 #endif
395 
396 #if USE_PWM5
397 #define PWM_SERVO_5 4
398 #define PWM_SERVO_5_TIMER TIM5
399 #define PWM_SERVO_5_GPIO GPIOA
400 #define PWM_SERVO_5_PIN GPIO0
401 #define PWM_SERVO_5_AF GPIO_AF2
402 #define PWM_SERVO_5_OC TIM_OC1
403 #define PWM_SERVO_5_OC_BIT (1<<0)
404 #else
405 #define PWM_SERVO_5_OC_BIT 0
406 #endif
407 
408 #if USE_PWM6
409 #define PWM_SERVO_6 5
410 #define PWM_SERVO_6_TIMER TIM5
411 #define PWM_SERVO_6_GPIO GPIOA
412 #define PWM_SERVO_6_PIN GPIO1
413 #define PWM_SERVO_6_AF GPIO_AF2
414 #define PWM_SERVO_6_OC TIM_OC2
415 #define PWM_SERVO_6_OC_BIT (1<<1)
416 #else
417 #define PWM_SERVO_6_OC_BIT 0
418 #endif
419 
420 #if USE_PWM7
421 #define PWM_SERVO_7 6
422 #define PWM_SERVO_7_TIMER TIM4
423 #define PWM_SERVO_7_GPIO GPIOB
424 #define PWM_SERVO_7_PIN GPIO6
425 #define PWM_SERVO_7_AF GPIO_AF2
426 #define PWM_SERVO_7_OC TIM_OC1
427 #define PWM_SERVO_7_OC_BIT (1<<0)
428 #else
429 #define PWM_SERVO_7_OC_BIT 0
430 #endif
431 
432 #if USE_PWM8
433 #define PWM_SERVO_8 7
434 #define PWM_SERVO_8_TIMER TIM4
435 #define PWM_SERVO_8_GPIO GPIOB
436 #define PWM_SERVO_8_PIN GPIO7
437 #define PWM_SERVO_8_AF GPIO_AF2
438 #define PWM_SERVO_8_OC TIM_OC2
439 #define PWM_SERVO_8_OC_BIT (1<<1)
440 #else
441 #define PWM_SERVO_8_OC_BIT 0
442 #endif
443 
444 /* servos 1-4 on TIM3 */
445 #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)
446 /* servos 5-6 on TIM5 */
447 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
448 /* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
449 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
450 
451 
452 /* by default activate onboard baro */
453 #ifndef USE_BARO_BOARD
454 #define USE_BARO_BOARD 1
455 #endif
456 
457 #endif /* CONFIG_ELLE0_1_0_H */