Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
opa_ftd_1.0.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freek van Tienen <freek.v.tienen@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_OPA_FTD_1_0_H
24 #define CONFIG_OPA_FTD_1_0_H
25 
26 #define BOARD_OPA_FTD
27 
28 /* OPA/FTD has a 12MHz external clock and 168MHz internal. */
29 #define EXT_CLK 12000000
30 #define AHB_CLK 168000000
31 
32 /*
33  * Power control
34  */
35 
36 /* MCU power */
37 #define MCU_PWR GPIOB
38 #define MCU_PWR_PIN GPIO5
39 #define MCU_PWR_ON gpio_set
40 #define MCU_PWR_OFF gpio_clear
41 
42 /* Autopilot power */
43 #define AP_PWR GPIOB
44 #define AP_PWR_PIN GPIO0
45 #define AP_PWR_ON gpio_set
46 #define AP_PWR_OFF gpio_clear
47 
48 /* Main power (25V) */
49 #define MAIN_PWR GPIOC
50 #define MAIN_PWR_PIN GPIO12
51 #define MAIN_PWR_ON gpio_set
52 #define MAIN_PWR_OFF gpio_clear
53 
54 /* Balancer power */
55 #define BAL_PWR GPIOC
56 #define BAL_PWR_PIN GPIO2
57 #define BAL_PWR_ON gpio_set
58 #define BAL_PWR_OFF gpio_clear
59 
60 /*
61  * Buttons
62  */
63 
64 /* E-Stop button */
65 #define BTN_ESTOP GPIOB
66 #define BTN_ESTOP_PIN GPIO12
67 
68 /* Arming button */
69 #define BTN_ARMING GPIOB
70 #define BTN_ARMING_PIN GPIO14
71 
72 /* On/Off button */
73 #define BTN_ON GPIOC
74 #define BTN_ON_PIN GPIO1
75 
76 /*
77  * Onboard LEDs
78  */
79 
80 /* Status (red), on PA8 */
81 #ifndef USE_LED_1
82 #define USE_LED_1 1
83 #endif
84 #define LED_1_GPIO GPIOA
85 #define LED_1_GPIO_PIN GPIO8
86 #define LED_1_GPIO_ON gpio_set
87 #define LED_1_GPIO_OFF gpio_clear
88 #define LED_1_AFIO_REMAP ((void)0)
89 
90 /* RC (green), on PC5 */
91 #ifndef USE_LED_2
92 #define USE_LED_2 1
93 #endif
94 #define LED_2_GPIO GPIOC
95 #define LED_2_GPIO_PIN GPIO5
96 #define LED_2_GPIO_ON gpio_set
97 #define LED_2_GPIO_OFF gpio_clear
98 #define LED_2_AFIO_REMAP ((void)0)
99 
100 /* Status LED ext, PB13 */
101 #ifndef USE_LED_3
102 #define USE_LED_3 1
103 #endif
104 #define LED_3_GPIO GPIOB
105 #define LED_3_GPIO_PIN GPIO13
106 #define LED_3_GPIO_ON gpio_set
107 #define LED_3_GPIO_OFF gpio_clear
108 #define LED_3_AFIO_REMAP ((void)0)
109 
110 
111 /* Default actuators driver */
112 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
113 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
114 #define ActuatorsDefaultInit() ActuatorsPwmInit()
115 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
116 
117 
118 /* UART */
119 #define UART1_GPIO_AF GPIO_AF7
120 #define UART1_GPIO_PORT_RX GPIOA
121 #define UART1_GPIO_RX GPIO10
122 
123 #define UART2_GPIO_AF GPIO_AF7
124 #define UART2_GPIO_PORT_RX GPIOA
125 #define UART2_GPIO_RX GPIO3
126 #define UART2_GPIO_PORT_TX GPIOA
127 #define UART2_GPIO_TX GPIO2
128 
129 #define UART3_GPIO_AF GPIO_AF7
130 #define UART3_GPIO_PORT_RX GPIOB
131 #define UART3_GPIO_RX GPIO11
132 #define UART3_GPIO_PORT_TX GPIOB
133 #define UART3_GPIO_TX GPIO10
134 
135 #define UART4_GPIO_AF GPIO_AF8
136 #define UART4_GPIO_PORT_RX GPIOC
137 #define UART4_GPIO_RX GPIO11
138 #define UART4_GPIO_PORT_TX GPIOC
139 #define UART4_GPIO_TX GPIO10
140 
141 #define UART5_GPIO_AF GPIO_AF8
142 #define UART5_GPIO_PORT_RX GPIOD
143 #define UART5_GPIO_RX GPIO2
144 
145 /*
146  * Spektrum
147  */
148 /* Define power pin */
149 #define RADIO_CONTROL_POWER_PORT GPIOC
150 #define RADIO_CONTROL_POWER_PIN GPIO13
151 #define RADIO_CONTROL_POWER_ON gpio_set
152 #define RADIO_CONTROL_POWER_OFF gpio_clear
153 
154 /* The line that is pulled low at power up to initiate the bind process */
155 #define SPEKTRUM_BIND_PIN GPIO2
156 #define SPEKTRUM_BIND_PIN_PORT GPIOB
157 
158 #define SPEKTRUM_UART1_RCC RCC_USART1
159 #define SPEKTRUM_UART1_BANK GPIOA
160 #define SPEKTRUM_UART1_PIN GPIO10
161 #define SPEKTRUM_UART1_AF GPIO_AF7
162 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
163 #define SPEKTRUM_UART1_ISR usart1_isr
164 #define SPEKTRUM_UART1_DEV USART1
165 
166 #define SPEKTRUM_UART5_RCC RCC_UART5
167 #define SPEKTRUM_UART5_BANK GPIOD
168 #define SPEKTRUM_UART5_PIN GPIO2
169 #define SPEKTRUM_UART5_AF GPIO_AF8
170 #define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
171 #define SPEKTRUM_UART5_ISR uart5_isr
172 #define SPEKTRUM_UART5_DEV UART5
173 
174 /* SPI */
175 #define SPI1_GPIO_AF GPIO_AF5
176 #define SPI1_GPIO_PORT_MISO GPIOA
177 #define SPI1_GPIO_MISO GPIO6
178 #define SPI1_GPIO_PORT_MOSI GPIOA
179 #define SPI1_GPIO_MOSI GPIO7
180 #define SPI1_GPIO_PORT_SCK GPIOA
181 #define SPI1_GPIO_SCK GPIO5
182 #define SPI1_GPIO_PORT_NSS GPIOA
183 #define SPI1_GPIO_NSS GPIO4
184 
185 #define SPI_SELECT_SLAVE0_PORT GPIOA
186 #define SPI_SELECT_SLAVE0_PIN GPIO4
187 
188 
189 /*
190  * ADC
191  */
192 
193 /* BATT PC4/ADC14 */
194 #ifndef USE_ADC_1
195 #define USE_ADC_1 1
196 #endif
197 #if USE_ADC_1
198 #define AD1_1_CHANNEL 14
199 #define ADC_1 AD1_1
200 #define ADC_1_GPIO_PORT GPIOC
201 #define ADC_1_GPIO_PIN GPIO4
202 #endif
203 
204 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
205 #ifndef ADC_CHANNEL_VSUPPLY
206 #define ADC_CHANNEL_VSUPPLY ADC_1
207 #endif
208 
209 
210 // Default: 10k / 2k2 ->
211 // #define DefaultVoltageOfAdc(adc) (0.00446777*adc)
212 
213 // Opa-FBW: 10k / 4k7
214 #define DefaultVoltageOfAdc(adc) (00.00252*adc)
215 
216 
217 /*
218  * PWM
219  *
220  */
221 #define PWM_USE_TIM3 1
222 #define PWM_USE_TIM4 1
223 #define PWM_USE_TIM5 1
224 
225 #define USE_PWM1 1
226 #define USE_PWM2 1
227 #define USE_PWM3 1
228 #define USE_PWM4 1
229 #define USE_PWM5 1
230 #define USE_PWM6 1
231 #define USE_PWM7 1
232 #define USE_PWM8 1
233 #define USE_PWM9 1
234 #define USE_PWM10 1
235 #define ACTUATORS_PWM_NB 10
236 
237 
238 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
239 #if USE_PWM1
240 #define PWM_SERVO_1 0
241 #define PWM_SERVO_1_TIMER TIM3
242 #define PWM_SERVO_1_GPIO GPIOC
243 #define PWM_SERVO_1_PIN GPIO6
244 #define PWM_SERVO_1_AF GPIO_AF2
245 #define PWM_SERVO_1_OC TIM_OC1
246 #define PWM_SERVO_1_OC_BIT (1<<0)
247 #else
248 #define PWM_SERVO_1_OC_BIT 0
249 #endif
250 
251 #if USE_PWM2
252 #define PWM_SERVO_2 1
253 #define PWM_SERVO_2_TIMER TIM3
254 #define PWM_SERVO_2_GPIO GPIOC
255 #define PWM_SERVO_2_PIN GPIO7
256 #define PWM_SERVO_2_AF GPIO_AF2
257 #define PWM_SERVO_2_OC TIM_OC2
258 #define PWM_SERVO_2_OC_BIT (1<<1)
259 #else
260 #define PWM_SERVO_2_OC_BIT 0
261 #endif
262 
263 #if USE_PWM3
264 #define PWM_SERVO_3 2
265 #define PWM_SERVO_3_TIMER TIM3
266 #define PWM_SERVO_3_GPIO GPIOC
267 #define PWM_SERVO_3_PIN GPIO8
268 #define PWM_SERVO_3_AF GPIO_AF2
269 #define PWM_SERVO_3_OC TIM_OC3
270 #define PWM_SERVO_3_OC_BIT (1<<2)
271 #else
272 #define PWM_SERVO_3_OC_BIT 0
273 #endif
274 
275 #if USE_PWM4
276 #define PWM_SERVO_4 3
277 #define PWM_SERVO_4_TIMER TIM3
278 #define PWM_SERVO_4_GPIO GPIOC
279 #define PWM_SERVO_4_PIN GPIO9
280 #define PWM_SERVO_4_AF GPIO_AF2
281 #define PWM_SERVO_4_OC TIM_OC4
282 #define PWM_SERVO_4_OC_BIT (1<<3)
283 #else
284 #define PWM_SERVO_4_OC_BIT 0
285 #endif
286 
287 #if USE_PWM5
288 #define PWM_SERVO_5 4
289 #define PWM_SERVO_5_TIMER TIM5
290 #define PWM_SERVO_5_GPIO GPIOA
291 #define PWM_SERVO_5_PIN GPIO0
292 #define PWM_SERVO_5_AF GPIO_AF2
293 #define PWM_SERVO_5_OC TIM_OC1
294 #define PWM_SERVO_5_OC_BIT (1<<0)
295 #else
296 #define PWM_SERVO_5_OC_BIT 0
297 #endif
298 
299 #if USE_PWM6
300 #define PWM_SERVO_6 5
301 #define PWM_SERVO_6_TIMER TIM5
302 #define PWM_SERVO_6_GPIO GPIOA
303 #define PWM_SERVO_6_PIN GPIO1
304 #define PWM_SERVO_6_AF GPIO_AF2
305 #define PWM_SERVO_6_OC TIM_OC2
306 #define PWM_SERVO_6_OC_BIT (1<<1)
307 #else
308 #define PWM_SERVO_6_OC_BIT 0
309 #endif
310 
311 #if USE_PWM7
312 #define PWM_SERVO_7 6
313 #define PWM_SERVO_7_TIMER TIM4
314 #define PWM_SERVO_7_GPIO GPIOB
315 #define PWM_SERVO_7_PIN GPIO6
316 #define PWM_SERVO_7_AF GPIO_AF2
317 #define PWM_SERVO_7_OC TIM_OC1
318 #define PWM_SERVO_7_OC_BIT (1<<0)
319 #else
320 #define PWM_SERVO_7_OC_BIT 0
321 #endif
322 
323 #if USE_PWM8
324 #define PWM_SERVO_8 7
325 #define PWM_SERVO_8_TIMER TIM4
326 #define PWM_SERVO_8_GPIO GPIOB
327 #define PWM_SERVO_8_PIN GPIO7
328 #define PWM_SERVO_8_AF GPIO_AF2
329 #define PWM_SERVO_8_OC TIM_OC2
330 #define PWM_SERVO_8_OC_BIT (1<<1)
331 #else
332 #define PWM_SERVO_8_OC_BIT 0
333 #endif
334 
335 #if USE_PWM9
336 #define PWM_SERVO_9 8
337 #define PWM_SERVO_9_TIMER TIM4
338 #define PWM_SERVO_9_GPIO GPIOB
339 #define PWM_SERVO_9_PIN GPIO8
340 #define PWM_SERVO_9_AF GPIO_AF2
341 #define PWM_SERVO_9_OC TIM_OC3
342 #define PWM_SERVO_9_OC_BIT (1<<2)
343 #else
344 #define PWM_SERVO_9_OC_BIT 0
345 #endif
346 
347 #if USE_PWM10
348 #define PWM_SERVO_10 9
349 #define PWM_SERVO_10_TIMER TIM4
350 #define PWM_SERVO_10_GPIO GPIOB
351 #define PWM_SERVO_10_PIN GPIO9
352 #define PWM_SERVO_10_AF GPIO_AF2
353 #define PWM_SERVO_10_OC TIM_OC4
354 #define PWM_SERVO_10_OC_BIT (1<<3)
355 #else
356 #define PWM_SERVO_10_OC_BIT 0
357 #endif
358 
359 /* servos 1-4 on TIM3 */
360 #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)
361 /* servos 5-6 on TIM5 */
362 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
363 /* servos 7-10 on TIM4 */
364 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT|PWM_SERVO_9_OC_BIT|PWM_SERVO_10_OC_BIT)
365 
366 #endif /* CONFIG_OPA_FTD_1_0_H */