Paparazzi UAS  v5.15_devel-99-g2ff7410
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 /* PPM
125  *
126  * Default is PPM config 2, input on GPIOA1 (Servo pin 6)
127  */
128 
129 #ifndef PPM_CONFIG
130 #define PPM_CONFIG 2
131 #endif
132 
133 #if PPM_CONFIG == 1
134 /* input on PA10 (UART1_RX) */
135 #define USE_PPM_TIM1 1
136 #define PPM_CHANNEL TIM_IC3
137 #define PPM_TIMER_INPUT TIM_IC_IN_TI3
138 #define PPM_IRQ NVIC_TIM1_CC_IRQ
139 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
140 // Capture/Compare InteruptEnable and InterruptFlag
141 #define PPM_CC_IE TIM_DIER_CC3IE
142 #define PPM_CC_IF TIM_SR_CC3IF
143 #define PPM_GPIO_PORT GPIOA
144 #define PPM_GPIO_PIN GPIO10
145 #define PPM_GPIO_AF GPIO_AF1
146 
147 #elif PPM_CONFIG == 2
148 /* input on PA01 (Servo 6 pin) */
149 #define USE_PPM_TIM2 1
150 #define PPM_CHANNEL TIM_IC2
151 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
152 #define PPM_IRQ NVIC_TIM2_IRQ
153 // Capture/Compare InteruptEnable and InterruptFlag
154 #define PPM_CC_IE TIM_DIER_CC2IE
155 #define PPM_CC_IF TIM_SR_CC2IF
156 #define PPM_GPIO_PORT GPIOA
157 #define PPM_GPIO_PIN GPIO1
158 #define PPM_GPIO_AF GPIO_AF1
159 
160 // Move default ADC timer
161 #if USE_AD_TIM2
162 #undef USE_AD_TIM2
163 #endif
164 #define USE_AD_TIM1 1
165 
166 #elif PPM_CONFIG == 3
167 #if USE_SERVOS_7AND8
168 #error "You cannot USE_SERVOS_7AND8 and PPM input on PB07 (SERVO8) at the same time"
169 #endif
170 /* input on PB07 (Servo 8 pin) */
171 #define USE_PPM_TIM4 1
172 #define PPM_CHANNEL TIM_IC2
173 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
174 #define PPM_IRQ NVIC_TIM4_IRQ
175 // Capture/Compare InteruptEnable and InterruptFlag
176 #define PPM_CC_IE TIM_DIER_CC2IE
177 #define PPM_CC_IF TIM_SR_CC2IF
178 #define PPM_GPIO_PORT GPIOB
179 #define PPM_GPIO_PIN GPIO7
180 #define PPM_GPIO_AF GPIO_AF2
181 
182 #else
183 #error "Unknown PPM config"
184 
185 #endif // PPM_CONFIG
186 
187 /* SPI */
188 #define SPI1_GPIO_AF GPIO_AF5
189 #define SPI1_GPIO_PORT_MISO GPIOA
190 #define SPI1_GPIO_MISO GPIO6
191 #define SPI1_GPIO_PORT_MOSI GPIOA
192 #define SPI1_GPIO_MOSI GPIO7
193 #define SPI1_GPIO_PORT_SCK GPIOA
194 #define SPI1_GPIO_SCK GPIO5
195 
196 #define SPI2_GPIO_AF GPIO_AF5
197 #define SPI2_GPIO_PORT_MISO GPIOB
198 #define SPI2_GPIO_MISO GPIO14
199 #define SPI2_GPIO_PORT_MOSI GPIOB
200 #define SPI2_GPIO_MOSI GPIO15
201 #define SPI2_GPIO_PORT_SCK GPIOB
202 #define SPI2_GPIO_SCK GPIO13
203 
204 #define SPI_SELECT_SLAVE0_PORT GPIOA
205 #define SPI_SELECT_SLAVE0_PIN GPIO15
206 
207 #define SPI_SELECT_SLAVE1_PORT GPIOA
208 #define SPI_SELECT_SLAVE1_PIN GPIO4
209 
210 #define SPI_SELECT_SLAVE2_PORT GPIOB
211 #define SPI_SELECT_SLAVE2_PIN GPIO12
212 
213 #define SPI_SELECT_SLAVE3_PORT GPIOC
214 #define SPI_SELECT_SLAVE3_PIN GPIO13
215 
216 #define SPI_SELECT_SLAVE4_PORT GPIOC
217 #define SPI_SELECT_SLAVE4_PIN GPIO12
218 
219 #define SPI_SELECT_SLAVE5_PORT GPIOC
220 #define SPI_SELECT_SLAVE5_PIN GPIO4
221 
222 #define SPI1_GPIO_PORT_NSS GPIOA
223 #define SPI1_GPIO_NSS GPIO4
224 
225 #define SPI2_GPIO_PORT_NSS GPIOB
226 #define SPI2_GPIO_NSS GPIO12
227 
228 
229 /* I2C mapping */
230 #define I2C1_GPIO_PORT GPIOB
231 #define I2C1_GPIO_SCL GPIO6
232 #define I2C1_GPIO_SDA GPIO7
233 
234 #define I2C2_GPIO_PORT GPIOB
235 #define I2C2_GPIO_SCL GPIO10
236 #define I2C2_GPIO_SDA GPIO11
237 
238 
239 /*
240  * ADC
241  */
242 
243 /* Onboard ADCs */
244 
245 /* provide defines that can be used to access the ADC_x in the code or airframe file
246  * these directly map to the index number of the 4 adc channels defined above
247  * 4th (index 3) is used for bat monitoring by default
248  */
249 
250 #ifndef USE_ADC_1
251 #define USE_ADC_1 1
252 #endif
253 
254 #if USE_ADC_1
255 #define AD1_1_CHANNEL 14
256 #define ADC_1 AD1_1
257 #define ADC_1_GPIO_PORT GPIOC
258 #define ADC_1_GPIO_PIN GPIO4
259 #endif
260 
261 #if USE_ADC_2
262 #define AD1_2_CHANNEL 15
263 #define ADC_2 AD1_2
264 #define ADC_2_GPIO_PORT GPIOC
265 #define ADC_2_GPIO_PIN GPIO5
266 #endif
267 
268 #if USE_ADC_3
269 #define AD1_3_CHANNEL 0
270 #define ADC_3 AD1_3
271 #define ADC_3_GPIO_PORT GPIOA
272 #define ADC_3_GPIO_PIN GPIO0
273 #endif
274 
275 #if USE_ADC_4
276 #define AD1_4_CHANNEL 1
277 #define ADC_4 AD1_4
278 #define ADC_4_GPIO_PORT GPIOA
279 #define ADC_4_GPIO_PIN GPIO1
280 #endif
281 
282 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
283 #ifndef ADC_CHANNEL_VSUPPLY
284 #define ADC_CHANNEL_VSUPPLY ADC_1
285 #endif
286 
287 #define DefaultVoltageOfAdc(adc) (0.0045*adc)
288 
289 
290 /*
291  * PWM
292  *
293  */
294 #define PWM_USE_TIM3 1
295 #define PWM_USE_TIM5 1
296 
297 #ifndef USE_PWM1
298 #define USE_PWM1 1
299 #endif
300 #ifndef USE_PWM2
301 #define USE_PWM2 1
302 #endif
303 #ifndef USE_PWM3
304 #define USE_PWM3 1
305 #endif
306 #ifndef USE_PWM4
307 #define USE_PWM4 1
308 #endif
309 #ifndef USE_PWM5
310 #define USE_PWM5 1
311 #endif
312 #ifndef USE_PWM6
313 #define USE_PWM6 1
314 #endif
315 
316 #if USE_SERVOS_7AND8
317 #if USE_I2C1
318 #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
319 #else
320 #define ACTUATORS_PWM_NB 8
321 #define USE_PWM7 1
322 #define USE_PWM8 1
323 #define PWM_USE_TIM4 1
324 #define ACTUATORS_PWM_NB 8
325 #endif
326 #else
327 #define ACTUATORS_PWM_NB 6
328 #endif
329 
330 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
331 #if USE_PWM1
332 #define PWM_SERVO_1 0
333 #define PWM_SERVO_1_TIMER TIM3
334 #define PWM_SERVO_1_GPIO GPIOC
335 #define PWM_SERVO_1_PIN GPIO6
336 #define PWM_SERVO_1_AF GPIO_AF2
337 #define PWM_SERVO_1_OC TIM_OC1
338 #define PWM_SERVO_1_OC_BIT (1<<0)
339 #else
340 #define PWM_SERVO_1_OC_BIT 0
341 #endif
342 
343 #if USE_PWM2
344 #define PWM_SERVO_2 1
345 #define PWM_SERVO_2_TIMER TIM3
346 #define PWM_SERVO_2_GPIO GPIOC
347 #define PWM_SERVO_2_PIN GPIO7
348 #define PWM_SERVO_2_AF GPIO_AF2
349 #define PWM_SERVO_2_OC TIM_OC2
350 #define PWM_SERVO_2_OC_BIT (1<<1)
351 #else
352 #define PWM_SERVO_2_OC_BIT 0
353 #endif
354 
355 #if USE_PWM3
356 #define PWM_SERVO_3 2
357 #define PWM_SERVO_3_TIMER TIM3
358 #define PWM_SERVO_3_GPIO GPIOC
359 #define PWM_SERVO_3_PIN GPIO8
360 #define PWM_SERVO_3_AF GPIO_AF2
361 #define PWM_SERVO_3_OC TIM_OC3
362 #define PWM_SERVO_3_OC_BIT (1<<2)
363 #else
364 #define PWM_SERVO_3_OC_BIT 0
365 #endif
366 
367 #if USE_PWM4
368 #define PWM_SERVO_4 3
369 #define PWM_SERVO_4_TIMER TIM3
370 #define PWM_SERVO_4_GPIO GPIOC
371 #define PWM_SERVO_4_PIN GPIO9
372 #define PWM_SERVO_4_AF GPIO_AF2
373 #define PWM_SERVO_4_OC TIM_OC4
374 #define PWM_SERVO_4_OC_BIT (1<<3)
375 #else
376 #define PWM_SERVO_4_OC_BIT 0
377 #endif
378 
379 #if USE_PWM5
380 #define PWM_SERVO_5 4
381 #define PWM_SERVO_5_TIMER TIM5
382 #define PWM_SERVO_5_GPIO GPIOA
383 #define PWM_SERVO_5_PIN GPIO0
384 #define PWM_SERVO_5_AF GPIO_AF2
385 #define PWM_SERVO_5_OC TIM_OC1
386 #define PWM_SERVO_5_OC_BIT (1<<0)
387 #else
388 #define PWM_SERVO_5_OC_BIT 0
389 #endif
390 
391 #if USE_PWM6
392 #define PWM_SERVO_6 5
393 #define PWM_SERVO_6_TIMER TIM5
394 #define PWM_SERVO_6_GPIO GPIOA
395 #define PWM_SERVO_6_PIN GPIO1
396 #define PWM_SERVO_6_AF GPIO_AF2
397 #define PWM_SERVO_6_OC TIM_OC2
398 #define PWM_SERVO_6_OC_BIT (1<<1)
399 #else
400 #define PWM_SERVO_6_OC_BIT 0
401 #endif
402 
403 #if USE_PWM7
404 #define PWM_SERVO_7 6
405 #define PWM_SERVO_7_TIMER TIM4
406 #define PWM_SERVO_7_GPIO GPIOB
407 #define PWM_SERVO_7_PIN GPIO6
408 #define PWM_SERVO_7_AF GPIO_AF2
409 #define PWM_SERVO_7_OC TIM_OC1
410 #define PWM_SERVO_7_OC_BIT (1<<0)
411 #else
412 #define PWM_SERVO_7_OC_BIT 0
413 #endif
414 
415 #if USE_PWM8
416 #define PWM_SERVO_8 7
417 #define PWM_SERVO_8_TIMER TIM4
418 #define PWM_SERVO_8_GPIO GPIOB
419 #define PWM_SERVO_8_PIN GPIO7
420 #define PWM_SERVO_8_AF GPIO_AF2
421 #define PWM_SERVO_8_OC TIM_OC2
422 #define PWM_SERVO_8_OC_BIT (1<<1)
423 #else
424 #define PWM_SERVO_8_OC_BIT 0
425 #endif
426 
427 /* servos 1-4 on TIM3 */
428 #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)
429 /* servos 5-6 on TIM5 */
430 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
431 /* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
432 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
433 
434 
435 /* by default activate onboard baro */
436 #ifndef USE_BARO_BOARD
437 #define USE_BARO_BOARD 1
438 #endif
439 
440 #endif /* CONFIG_ELLE0_1_0_H */