Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
openpilot_revo_1.0.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Felix Ruess <felix.ruess@gmail.com
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_OPENPILOT_REVO_1_0_H
24 #define CONFIG_OPENPILOT_REVO_1_0_H
25 
26 #define BOARD_REVO
27 
28 /* OpenPilot Revo has a 8MHz external clock and 168MHz internal. */
29 #define EXT_CLK 8000000
30 #define AHB_CLK 168000000
31 
32 /*
33  * Onboard LEDs
34  */
35 
36 /* STAT blue, on PB5 */
37 #ifndef USE_LED_1
38 #define USE_LED_1 1
39 #endif
40 #define LED_1_GPIO GPIOB
41 #define LED_1_GPIO_PIN GPIO5
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 /* WARN red, on PB4 */
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 
57 /* Default actuators driver */
58 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
59 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
60 #define ActuatorsDefaultInit() ActuatorsPwmInit()
61 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
62 
63 
64 /* UART */
65 /* Main Port */
66 #define UART1_GPIO_AF GPIO_AF7
67 #define UART1_GPIO_PORT_RX GPIOA
68 #define UART1_GPIO_RX GPIO10
69 #define UART1_GPIO_PORT_TX GPIOA
70 #define UART1_GPIO_TX GPIO9
71 
72 #define UART2_GPIO_AF GPIO_AF7
73 #define UART2_GPIO_PORT_RX GPIOA
74 #define UART2_GPIO_RX GPIO3
75 #define UART2_GPIO_PORT_TX GPIOA
76 #define UART2_GPIO_TX GPIO2
77 
78 #define UART3_GPIO_AF GPIO_AF7
79 #define UART3_GPIO_PORT_RX GPIOC
80 #define UART3_GPIO_RX GPIO11
81 #define UART3_GPIO_PORT_TX GPIOC
82 #define UART3_GPIO_TX GPIO10
83 
84 #define UART5_GPIO_AF GPIO_AF8
85 #define UART5_GPIO_PORT_RX GPIOD
86 #define UART5_GPIO_RX GPIO2
87 #define UART5_GPIO_PORT_TX GPIOC
88 #define UART5_GPIO_TX GPIO12
89 
90 /*
91  * Spektrum
92  */
93 /* The line that is pulled low at power up to initiate the bind process */
94 #define SPEKTRUM_BIND_PIN GPIO0
95 #define SPEKTRUM_BIND_PIN_PORT GPIOB
96 
97 #define SPEKTRUM_UART1_RCC RCC_USART1
98 #define SPEKTRUM_UART1_BANK GPIOA
99 #define SPEKTRUM_UART1_PIN GPIO10
100 #define SPEKTRUM_UART1_AF GPIO_AF7
101 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
102 #define SPEKTRUM_UART1_ISR usart1_isr
103 #define SPEKTRUM_UART1_DEV USART1
104 
105 #define SPEKTRUM_UART2_RCC RCC_USART2
106 #define SPEKTRUM_UART2_BANK GPIOA
107 #define SPEKTRUM_UART2_PIN GPIO3
108 #define SPEKTRUM_UART2_AF GPIO_AF7
109 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
110 #define SPEKTRUM_UART2_ISR usart2_isr
111 #define SPEKTRUM_UART2_DEV USART2
112 
113 #define SPEKTRUM_UART5_RCC RCC_UART5
114 #define SPEKTRUM_UART5_BANK GPIOD
115 #define SPEKTRUM_UART5_PIN GPIO2
116 #define SPEKTRUM_UART5_AF GPIO_AF8
117 #define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
118 #define SPEKTRUM_UART5_ISR uart5_isr
119 #define SPEKTRUM_UART5_DEV UART5
120 
121 /* PPM
122  *
123  * Default is PPM config 2, input on GPIOA1 (Servo pin 6)
124  */
125 
126 #ifndef PPM_CONFIG
127 #define PPM_CONFIG 2
128 #endif
129 
130 #if PPM_CONFIG == 1
131 /* input on PA10 (UART1_RX) */
132 #define USE_PPM_TIM1 1
133 #define PPM_CHANNEL TIM_IC3
134 #define PPM_TIMER_INPUT TIM_IC_IN_TI3
135 #define PPM_IRQ NVIC_TIM1_CC_IRQ
136 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
137 // Capture/Compare InteruptEnable and InterruptFlag
138 #define PPM_CC_IE TIM_DIER_CC3IE
139 #define PPM_CC_IF TIM_SR_CC3IF
140 #define PPM_GPIO_PORT GPIOA
141 #define PPM_GPIO_PIN GPIO10
142 #define PPM_GPIO_AF GPIO_AF1
143 
144 #elif PPM_CONFIG == 2
145 /* input on PA01 (Servo 6 pin) */
146 #define USE_PPM_TIM2 1
147 #define PPM_CHANNEL TIM_IC2
148 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
149 #define PPM_IRQ NVIC_TIM2_IRQ
150 // Capture/Compare InteruptEnable and InterruptFlag
151 #define PPM_CC_IE TIM_DIER_CC2IE
152 #define PPM_CC_IF TIM_SR_CC2IF
153 #define PPM_GPIO_PORT GPIOA
154 #define PPM_GPIO_PIN GPIO1
155 #define PPM_GPIO_AF GPIO_AF1
156 
157 // Move default ADC timer
158 #if USE_AD_TIM2
159 #undef USE_AD_TIM2
160 #endif
161 #define USE_AD_TIM1 1
162 
163 #else
164 #error "Unknown PPM config"
165 
166 #endif // PPM_CONFIG
167 
168 /* SPI */
169 /* MPU6000 */
170 #define SPI1_GPIO_AF GPIO_AF5
171 #define SPI1_GPIO_PORT_MISO GPIOA
172 #define SPI1_GPIO_MISO GPIO6
173 #define SPI1_GPIO_PORT_MOSI GPIOA
174 #define SPI1_GPIO_MOSI GPIO7
175 #define SPI1_GPIO_PORT_SCK GPIOA
176 #define SPI1_GPIO_SCK GPIO5
177 #define SPI1_GPIO_PORT_NSS GPIOA
178 #define SPI1_GPIO_NSS GPIO4
179 
180 /* flash and RFM22B-S2 modem */
181 #define SPI3_GPIO_AF GPIO_AF5
182 #define SPI3_GPIO_PORT_MISO GPIOC
183 #define SPI3_GPIO_MISO GPIO11
184 #define SPI3_GPIO_PORT_MOSI GPIOC
185 #define SPI3_GPIO_MOSI GPIO12
186 #define SPI3_GPIO_PORT_SCK GPIOC
187 #define SPI3_GPIO_SCK GPIO10
188 /* modem CS */
189 #define SPI3_GPIO_PORT_NSS GPIOA
190 #define SPI3_GPIO_NSS GPIO15
191 
192 /* MODEM select */
193 #define SPI_SELECT_SLAVE0_PORT GPIOA
194 #define SPI_SELECT_SLAVE0_PIN GPIO15
195 
196 /* external flash chip select */
197 #define SPI_SELECT_SLAVE1_PORT GPIOB
198 #define SPI_SELECT_SLAVE1_PIN GPIO3
199 
200 /* MPU6000 select */
201 #define SPI_SELECT_SLAVE2_PORT GPIOA
202 #define SPI_SELECT_SLAVE2_PIN GPIO4
203 
204 
205 /* I2C mapping */
206 /* HMC5883L mag on I2C1 with DRDY on PB7 */
207 /* MS5611 baro on I2C1 */
208 #define I2C1_GPIO_PORT GPIOB
209 #define I2C1_GPIO_SCL GPIO8
210 #define I2C1_GPIO_SDA GPIO9
211 
212 
213 /*
214  * ADC
215  */
216 
217 /* Onboard ADCs */
218 /*
219  ADC1 PC3/ADC13
220  ADC2 PC0/ADC10
221  ADC3 PC1/ADC11
222  ADC4 PC5/ADC15
223  ADC6 PC2/ADC12
224  BATT PC4/ADC14
225 */
226 
227 /* provide defines that can be used to access the ADC_x in the code or airframe file
228  * these directly map to the index number of the 4 adc channels defined above
229  * 4th (index 3) is used for bat monitoring by default
230  */
231 
232 #ifndef USE_ADC_1
233 #define USE_ADC_1 1
234 #endif
235 
236 /* Voltage on Pwr/Sen/Sonar CONN3 */
237 #if USE_ADC_1
238 #define AD1_1_CHANNEL 12
239 #define ADC_1 AD1_1
240 #define ADC_1_GPIO_PORT GPIOC
241 #define ADC_1_GPIO_PIN GPIO2
242 #endif
243 
244 /* Current on Pwr/Sen/Sonar CONN3 */
245 #if USE_ADC_2
246 #define AD1_2_CHANNEL 11
247 #define ADC_2 AD1_2
248 #define ADC_2_GPIO_PORT GPIOC
249 #define ADC_2_GPIO_PIN GPIO1
250 #endif
251 
252 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
253 #ifndef ADC_CHANNEL_VSUPPLY
254 #define ADC_CHANNEL_VSUPPLY ADC_1
255 #endif
256 
257 /* no voltage divider on board, adjust VoltageOfAdc in airframe file */
258 #define DefaultVoltageOfAdc(adc) (0.0045*adc)
259 
260 
261 /*
262  * PWM
263  *
264  */
265 #define PWM_USE_TIM3 1
266 #define PWM_USE_TIM5 1
267 
268 #define USE_PWM1 1
269 #define USE_PWM2 1
270 #define USE_PWM3 1
271 #define USE_PWM4 1
272 #define USE_PWM5 1
273 #define USE_PWM6 1
274 
275 #if USE_SERVOS_7AND8
276 #if USE_I2C1
277 #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
278 #else
279 #define ACTUATORS_PWM_NB 8
280 #define USE_PWM7 1
281 #define USE_PWM8 1
282 #define PWM_USE_TIM4 1
283 #define ACTUATORS_PWM_NB 8
284 #endif
285 #else
286 #define ACTUATORS_PWM_NB 6
287 #endif
288 
289 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
290 #if USE_PWM1
291 #define PWM_SERVO_1 0
292 #define PWM_SERVO_1_TIMER TIM3
293 #define PWM_SERVO_1_GPIO GPIOB
294 #define PWM_SERVO_1_PIN GPIO0
295 #define PWM_SERVO_1_AF GPIO_AF2
296 #define PWM_SERVO_1_OC TIM_OC3
297 #define PWM_SERVO_1_OC_BIT (1<<2)
298 #else
299 #define PWM_SERVO_1_OC_BIT 0
300 #endif
301 
302 #if USE_PWM2
303 #define PWM_SERVO_2 1
304 #define PWM_SERVO_2_TIMER TIM3
305 #define PWM_SERVO_2_GPIO GPIOB
306 #define PWM_SERVO_2_PIN GPIO1
307 #define PWM_SERVO_2_AF GPIO_AF2
308 #define PWM_SERVO_2_OC TIM_OC4
309 #define PWM_SERVO_2_OC_BIT (1<<3)
310 #else
311 #define PWM_SERVO_2_OC_BIT 0
312 #endif
313 
314 #if USE_PWM3
315 #define PWM_SERVO_3 2
316 #define PWM_SERVO_3_TIMER TIM9
317 #define PWM_SERVO_3_GPIO GPIOA
318 #define PWM_SERVO_3_PIN GPIO3
319 #define PWM_SERVO_3_AF GPIO_AF2
320 #define PWM_SERVO_3_OC TIM_OC2
321 #define PWM_SERVO_3_OC_BIT (1<<1)
322 #else
323 #define PWM_SERVO_3_OC_BIT 0
324 #endif
325 
326 #if USE_PWM4
327 #define PWM_SERVO_4 3
328 #define PWM_SERVO_4_TIMER TIM2
329 #define PWM_SERVO_4_GPIO GPIOA
330 #define PWM_SERVO_4_PIN GPIO2
331 #define PWM_SERVO_4_AF GPIO_AF2
332 #define PWM_SERVO_4_OC TIM_OC3
333 #define PWM_SERVO_4_OC_BIT (1<<2)
334 #else
335 #define PWM_SERVO_4_OC_BIT 0
336 #endif
337 
338 #if USE_PWM5
339 #define PWM_SERVO_5 4
340 #define PWM_SERVO_5_TIMER TIM5
341 #define PWM_SERVO_5_GPIO GPIOA
342 #define PWM_SERVO_5_PIN GPIO1
343 #define PWM_SERVO_5_AF GPIO_AF2
344 #define PWM_SERVO_5_OC TIM_OC2
345 #define PWM_SERVO_5_OC_BIT (1<<1)
346 #else
347 #define PWM_SERVO_5_OC_BIT 0
348 #endif
349 
350 #if USE_PWM6
351 #define PWM_SERVO_6 5
352 #define PWM_SERVO_6_TIMER TIM5
353 #define PWM_SERVO_6_GPIO GPIOA
354 #define PWM_SERVO_6_PIN GPIO0
355 #define PWM_SERVO_6_AF GPIO_AF2
356 #define PWM_SERVO_6_OC TIM_OC1
357 #define PWM_SERVO_6_OC_BIT (1<<0)
358 #else
359 #define PWM_SERVO_6_OC_BIT 0
360 #endif
361 
362 
363 
364 /* servos 1-2 on TIM3 */
365 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT)
366 /* servos 3 on TIM9 */
367 #define PWM_TIM9_CHAN_MASK (PWM_SERVO_3_OC_BIT)
368 /* servos 4 on TIM2 */
369 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_4_OC_BIT)
370 /* servos 5-6 on TIM5 */
371 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
372 
373 
374 /* by default activate onboard baro */
375 #ifndef USE_BARO_BOARD
376 #define USE_BARO_BOARD 1
377 #endif
378 
379 #endif /* CONFIG_OPENPILOT_REVO_1_0_H */