Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
openpilot_revo_nano.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_NANO_H
24#define CONFIG_OPENPILOT_REVO_NANO_H
25
26/* Some info about this board can be found at:
27 * https://librepilot.atlassian.net/wiki/display/LPDOC/OpenPilot+Revolution+Nano
28 */
29
30
31/* OpenPilot Revo Nano has a STM32F411 with 8MHz external clock and up to 100MHz internal.
32 * Libopencm3 doesn't explicitly support the STM32F41x yet,
33 * but using the 84MHz clock setup from the STM32F401 should work...
34 */
35#define EXT_CLK 8000000
36#define AHB_CLK 84000000
37
38/*
39 * Onboard LEDs
40 */
41
42/* blue, on PC14 */
43#ifndef USE_LED_1
44#define USE_LED_1 1
45#endif
46#define LED_1_GPIO GPIOC
47#define LED_1_GPIO_PIN GPIO14
48#define LED_1_GPIO_ON gpio_clear
49#define LED_1_GPIO_OFF gpio_set
50#define LED_1_AFIO_REMAP ((void)0)
51
52/* orange, on PC13 */
53#ifndef USE_LED_2
54#define USE_LED_2 1
55#endif
56#define LED_2_GPIO GPIOC
57#define LED_2_GPIO_PIN GPIO13
58#define LED_2_GPIO_ON gpio_clear
59#define LED_2_GPIO_OFF gpio_set
60#define LED_2_AFIO_REMAP ((void)0)
61
62
63/* Default actuators driver */
64#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
65#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
66#define ActuatorsDefaultInit() ActuatorsPwmInit()
67#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
68
69
70/* UART */
71/* Flexi port, shared with I2C1 */
72#define UART1_GPIO_AF GPIO_AF7
73#define UART1_GPIO_PORT_RX GPIOB
74#define UART1_GPIO_RX GPIO7
75#define UART1_GPIO_PORT_TX GPIOB
76#define UART1_GPIO_TX GPIO6
77
78/* Main port */
79#define UART2_GPIO_AF GPIO_AF7
80#define UART2_GPIO_PORT_RX GPIOA
81#define UART2_GPIO_RX GPIO3
82#define UART2_GPIO_PORT_TX GPIOA
83#define UART2_GPIO_TX GPIO2
84
85
86/*
87 * Spektrum
88 */
89/* The line that is pulled low at power up to initiate the bind process */
90#define SPEKTRUM_BIND_PIN GPIO0
91#define SPEKTRUM_BIND_PIN_PORT GPIOB
92
93#define SPEKTRUM_UART2_RCC RCC_USART2
94#define SPEKTRUM_UART2_BANK GPIOA
95#define SPEKTRUM_UART2_PIN GPIO3
96#define SPEKTRUM_UART2_AF GPIO_AF7
97#define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
98#define SPEKTRUM_UART2_ISR usart2_isr
99#define SPEKTRUM_UART2_DEV USART2
100
101/* S.Bus inverter control on PC15 */
102#define RC_POLARITY_GPIO_PORT GPIOC
103#define RC_POLARITY_GPIO_PIN GPIO15
104
105
106/* PPM
107 *
108 * PPM sum in is on FlexIO pin 4 (blue)
109 */
110
111/* input on PB1 */
112#define USE_PPM_TIM3 1
113#define PPM_CHANNEL TIM_IC4
114#define PPM_TIMER_INPUT TIM_IC_IN_TI4
115#define PPM_IRQ NVIC_TIM3_IRQ
116// Capture/Compare InteruptEnable and InterruptFlag
117#define PPM_CC_IE TIM_DIER_CC4IE
118#define PPM_CC_IF TIM_SR_CC4IF
119#define PPM_GPIO_PORT GPIOB
120#define PPM_GPIO_PIN GPIO1
121#define PPM_GPIO_AF GPIO_AF2
122
123
124/* SPI */
125/* MPU9250 */
126#define SPI2_GPIO_AF GPIO_AF5
127#define SPI2_GPIO_PORT_MISO GPIOB
128#define SPI2_GPIO_MISO GPIO14
129#define SPI2_GPIO_PORT_MOSI GPIOB
130#define SPI2_GPIO_MOSI GPIO15
131#define SPI2_GPIO_PORT_SCK GPIOB
132#define SPI2_GPIO_SCK GPIO13
133#define SPI2_GPIO_PORT_NSS GPIOB
134#define SPI2_GPIO_NSS GPIO12
135
136/* MPU9250 select */
137#define SPI_SELECT_SLAVE0_PORT GPIOB
138#define SPI_SELECT_SLAVE0_PIN GPIO12
139
140
141
142/* I2C mapping */
143/* I2C1 on flexi port shared with UART1 */
144#define I2C1_GPIO_PORT GPIOB
145#define I2C1_GPIO_SCL GPIO6
146#define I2C1_GPIO_SDA GPIO7
147
148/* I2C3 for baro and flash */
149#define I2C3_GPIO_PORT_SCL GPIOA
150#define I2C3_GPIO_SCL GPIO8
151#define I2C3_GPIO_PORT_SDA GPIOB
152#define I2C3_GPIO_SDA GPIO4
153#define I2C3_GPIO_SDA_AF GPIO_AF9
154
155/*
156 * ADC
157 */
158/* not tested, channels and ADx_1 not correct yet */
159
160#ifndef USE_ADC_1
161#define USE_ADC_1 0
162#endif
163
164/* Pin 4 on FlexIO, blue */
165#if USE_ADC_0
166#define AD1_0_CHANNEL 12
167#define ADC_0 AD1_1
168#define ADC_0_GPIO_PORT GPIOB
169#define ADC_0_GPIO_PIN GPIO1
170#endif
171
172/* Pin 5 on FlexIO, yellow */
173#if USE_ADC_1
174#define AD1_1_CHANNEL 12
175#define ADC_1 AD1_1
176#define ADC_1_GPIO_PORT GPIOB
177#define ADC_1_GPIO_PIN GPIO0
178#endif
179
180/* pin 6 on FlexIO, green */
181#if USE_ADC_2
182#define AD1_2_CHANNEL 11
183#define ADC_2 AD1_2
184#define ADC_2_GPIO_PORT GPIOA
185#define ADC_2_GPIO_PIN GPIO7
186#endif
187
188/* pin 7 on FlexIO, orange */
189#if USE_ADC_3
190#define AD1_3_CHANNEL 11
191#define ADC_3 AD1_2
192#define ADC_3_GPIO_PORT GPIOA
193#define ADC_3_GPIO_PIN GPIO6
194#endif
195
196/* pin 8 on FlexIO, violet */
197#if USE_ADC_4
198#define AD1_4_CHANNEL 11
199#define ADC_4 AD1_2
200#define ADC_4_GPIO_PORT GPIOA
201#define ADC_4_GPIO_PIN GPIO5
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/* no voltage divider on board, adjust VoltageOfAdc in airframe file */
210#define DefaultVoltageOfAdc(adc) (0.0045*adc)
211
212
213/*
214 * PWM
215 *
216 */
217#define PWM_USE_TIM1 1
218#define PWM_USE_TIM2 1
219#define PWM_USE_TIM4 1
220#define PWM_USE_TIM5 1
221
222#define USE_PWM1 1
223#define USE_PWM2 1
224#define USE_PWM3 1
225#define USE_PWM4 1
226#define USE_PWM5 1
227#define USE_PWM6 1
228
229
230#define ACTUATORS_PWM_NB 6
231
232
233// PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
234#if USE_PWM1
235#define PWM_SERVO_1 0
236#define PWM_SERVO_1_TIMER TIM1
237#define PWM_SERVO_1_GPIO GPIOA
238#define PWM_SERVO_1_PIN GPIO10
239#define PWM_SERVO_1_AF GPIO_AF1
240#define PWM_SERVO_1_OC TIM_OC3
241#define PWM_SERVO_1_OC_BIT (1<<2)
242#else
243#define PWM_SERVO_1_OC_BIT 0
244#endif
245
246#if USE_PWM2
247#define PWM_SERVO_2 1
248#define PWM_SERVO_2_TIMER TIM2
249#define PWM_SERVO_2_GPIO GPIOB
250#define PWM_SERVO_2_PIN GPIO3
251#define PWM_SERVO_2_AF GPIO_AF1
252#define PWM_SERVO_2_OC TIM_OC2
253#define PWM_SERVO_2_OC_BIT (1<<1)
254#else
255#define PWM_SERVO_2_OC_BIT 0
256#endif
257
258#if USE_PWM3
259#define PWM_SERVO_3 2
260#define PWM_SERVO_3_TIMER TIM4
261#define PWM_SERVO_3_GPIO GPIOB
262#define PWM_SERVO_3_PIN GPIO8
263#define PWM_SERVO_3_AF GPIO_AF2
264#define PWM_SERVO_3_OC TIM_OC3
265#define PWM_SERVO_3_OC_BIT (1<<2)
266#else
267#define PWM_SERVO_3_OC_BIT 0
268#endif
269
270#if USE_PWM4
271#define PWM_SERVO_4 3
272#define PWM_SERVO_4_TIMER TIM4
273#define PWM_SERVO_4_GPIO GPIOB
274#define PWM_SERVO_4_PIN GPIO9
275#define PWM_SERVO_4_AF GPIO_AF2
276#define PWM_SERVO_4_OC TIM_OC4
277#define PWM_SERVO_4_OC_BIT (1<<3)
278#else
279#define PWM_SERVO_4_OC_BIT 0
280#endif
281
282#if USE_PWM5
283#define PWM_SERVO_5 4
284#define PWM_SERVO_5_TIMER TIM5
285#define PWM_SERVO_5_GPIO GPIOA
286#define PWM_SERVO_5_PIN GPIO0
287#define PWM_SERVO_5_AF GPIO_AF2
288#define PWM_SERVO_5_OC TIM_OC1
289#define PWM_SERVO_5_OC_BIT (1<<0)
290#else
291#define PWM_SERVO_5_OC_BIT 0
292#endif
293
294#if USE_PWM6
295#define PWM_SERVO_6 5
296#define PWM_SERVO_6_TIMER TIM5
297#define PWM_SERVO_6_GPIO GPIOA
298#define PWM_SERVO_6_PIN GPIO1
299#define PWM_SERVO_6_AF GPIO_AF2
300#define PWM_SERVO_6_OC TIM_OC2
301#define PWM_SERVO_6_OC_BIT (1<<1)
302#else
303#define PWM_SERVO_6_OC_BIT 0
304#endif
305
306
307/* servo 1 on TIM1 */
308#define PWM_TIM1_CHAN_MASK (PWM_SERVO_1_OC_BIT)
309/* servo 2 on TIM2 */
310#define PWM_TIM2_CHAN_MASK (PWM_SERVO_2_OC_BIT)
311/* servos 3-4 on TIM4 */
312#define PWM_TIM4_CHAN_MASK (PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
313/* servos 5-6 on TIM5 */
314#define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
315
316
317/* by default activate onboard baro */
318#ifndef USE_BARO_BOARD
319#define USE_BARO_BOARD 1
320#endif
321
322#endif /* CONFIG_OPENPILOT_REVO_NANO_H */