Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
navstik_1.0.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 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_NAVSTIK_1_0_H
24 #define CONFIG_NAVSTIK_1_0_H
25 
26 /* Navstik has a 12MHz external clock and 168MHz internal. */
27 #define EXT_CLK 25000000
28 #define AHB_CLK 168000000
29 
30 /*
31  * Onboard LEDs
32  */
33 
34 /* red, on PA8 */
35 #ifndef USE_LED_1
36 #define USE_LED_1 1
37 #endif
38 #define LED_1_GPIO GPIOC
39 #define LED_1_GPIO_PIN GPIO4
40 #define LED_1_GPIO_ON gpio_set
41 #define LED_1_GPIO_OFF gpio_clear
42 #define LED_1_AFIO_REMAP ((void)0)
43 
44 /* green, shared with JTAG_TRST */
45 #ifndef USE_LED_2
46 #define USE_LED_2 1
47 #endif
48 #define LED_2_GPIO GPIOC
49 #define LED_2_GPIO_PIN GPIO5
50 #define LED_2_GPIO_ON gpio_set
51 #define LED_2_GPIO_OFF gpio_clear
52 #define LED_2_AFIO_REMAP ((void)0)
53 
54 
55 /*
56  * not actual LEDS, used as GPIOs
57  */
58 #define GPS_POWER_GPIO GPIOA,GPIO4
59 #define IMU_POWER_GPIO GPIOC,GPIO15
60 
61 /* Default actuators driver */
62 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
63 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
64 #define ActuatorsDefaultInit() ActuatorsPwmInit()
65 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
66 
67 
68 /* UART */
69 #define UART1_GPIO_AF GPIO_AF7
70 #define UART1_GPIO_PORT_RX GPIOB
71 #define UART1_GPIO_RX GPIO7
72 #define UART1_GPIO_PORT_TX GPIOB
73 #define UART1_GPIO_TX GPIO6
74 
75 #define UART2_GPIO_AF GPIO_AF7
76 #define UART2_GPIO_PORT_RX GPIOA
77 #define UART2_GPIO_RX GPIO3
78 #define UART2_GPIO_PORT_TX GPIOA
79 #define UART2_GPIO_TX GPIO2
80 
81 #define UART5_GPIO_AF GPIO_AF8
82 #define UART5_GPIO_PORT_RX GPIOD
83 #define UART5_GPIO_RX GPIO2
84 #define UART5_GPIO_PORT_TX GPIOC
85 #define UART5_GPIO_TX GPIO12
86 
87 #define UART6_GPIO_AF GPIO_AF8
88 #define UART6_GPIO_PORT_RX GPIOC
89 #define UART6_GPIO_RX GPIO7
90 #define UART6_GPIO_PORT_TX GPIOC
91 #define UART6_GPIO_TX GPIO6
92 
93 /*
94  * Spektrum
95  */
96 /* The line that is pulled low at power up to initiate the bind process */
97 #define SPEKTRUM_BIND_PIN GPIO6
98 #define SPEKTRUM_BIND_PIN_PORT GPIOC
99 #define SPEKTRUM_BIND_PIN_HIGH 1
100 
101 #define SPEKTRUM_UART6_RCC RCC_USART6
102 #define SPEKTRUM_UART6_BANK GPIOC
103 #define SPEKTRUM_UART6_PIN GPIO7
104 #define SPEKTRUM_UART6_AF GPIO_AF8
105 #define SPEKTRUM_UART6_IRQ NVIC_USART6_IRQ
106 #define SPEKTRUM_UART6_ISR usart6_isr
107 #define SPEKTRUM_UART6_DEV USART6
108 
109 /*
110  * PPM
111  */
112 
113 /* input on PC6 (Spektrum Tx) */
114 #define USE_PPM_TIM8 8
115 #define PPM_CHANNEL TIM_IC3
116 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
117 #define PPM_IRQ NVIC_TIM3_CC_IRQ
118 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
119 // Capture/Compare InteruptEnable and InterruptFlag
120 #define PPM_CC_IE TIM_DIER_CC2IE
121 #define PPM_CC_IF TIM_SR_CC2IF
122 #define PPM_GPIO_PORT GPIOC
123 #define PPM_GPIO_PIN GPIO7
124 #define PPM_GPIO_AF GPIO_AF8
125 
126 /* SPI */
127 #define SPI1_GPIO_AF GPIO_AF5
128 #define SPI1_GPIO_PORT_MISO GPIOA
129 #define SPI1_GPIO_MISO GPIO6
130 #define SPI1_GPIO_PORT_MOSI GPIOA
131 #define SPI1_GPIO_MOSI GPIO7
132 #define SPI1_GPIO_PORT_SCK GPIOA
133 #define SPI1_GPIO_SCK GPIO5
134 
135 #define SPI2_GPIO_AF GPIO_AF5
136 #define SPI2_GPIO_PORT_MISO GPIOB
137 #define SPI2_GPIO_MISO GPIO14
138 #define SPI2_GPIO_PORT_MOSI GPIOB
139 #define SPI2_GPIO_MOSI GPIO15
140 #define SPI2_GPIO_PORT_SCK GPIOB
141 #define SPI2_GPIO_SCK GPIO13
142 
143 #define SPI_SELECT_SLAVE0_PORT GPIOA
144 #define SPI_SELECT_SLAVE0_PIN GPIO15
145 
146 #define SPI_SELECT_SLAVE1_PORT GPIOA
147 #define SPI_SELECT_SLAVE1_PIN GPIO4
148 
149 #define SPI_SELECT_SLAVE2_PORT GPIOB
150 #define SPI_SELECT_SLAVE2_PIN GPIO12
151 
152 #define SPI_SELECT_SLAVE3_PORT GPIOC
153 #define SPI_SELECT_SLAVE3_PIN GPIO13
154 
155 #define SPI_SELECT_SLAVE4_PORT GPIOC
156 #define SPI_SELECT_SLAVE4_PIN GPIO12
157 
158 #define SPI_SELECT_SLAVE5_PORT GPIOC
159 #define SPI_SELECT_SLAVE5_PIN GPIO4
160 
161 
162 /* I2C mapping */
163 #define I2C1_GPIO_PORT GPIOB
164 #define I2C1_GPIO_SCL GPIO8
165 #define I2C1_GPIO_SDA GPIO9
166 
167 #define I2C3_GPIO_PORT_SCL GPIOA
168 #define I2C3_GPIO_SCL GPIO8
169 #define I2C3_GPIO_PORT_SDA GPIOC
170 #define I2C3_GPIO_SDA GPIO9
171 
172 
173 /*
174  * ADC
175  */
176 
177 /* Onboard ADCs */
178 /*
179  BATT_volt PC1/ADC123 (ADC123_IN11)
180  BATT_current PA1/ADC123 (ADC123_IN1)
181 */
182 
183 // Internal ADC for battery enabled by default
184 #ifndef USE_ADC_1
185 #define USE_ADC_1 1
186 #endif
187 #if USE_ADC_1
188 #define AD1_1_CHANNEL 11
189 #define ADC_1 AD1_1
190 #define ADC_1_GPIO_PORT GPIOC
191 #define ADC_1_GPIO_PIN GPIO1
192 #endif
193 
194 #ifndef USE_ADC_2
195 #define USE_ADC_2 1
196 #endif
197 #if USE_ADC_2
198 #define AD1_2_CHANNEL 1
199 #define ADC_2 AD1_2
200 #define ADC_2_GPIO_PORT GPIOA
201 #define ADC_2_GPIO_PIN GPIO1
202 #endif
203 
204 /* allow to define ADC_CHANNEL_VSUPPLY and ADC_CHANNEL_CURRENT in the airframe file*/
205 #ifndef ADC_CHANNEL_VSUPPLY
206 #define ADC_CHANNEL_VSUPPLY ADC_1
207 #endif
208 #ifndef ADC_CHANNEL_CURRENT
209 #define ADC_CHANNEL_CURRENT ADC_2
210 #endif
211 
212 #define DefaultVoltageOfAdc(adc) (0.00382*adc)
213 #define DefaultMilliAmpereOfAdc(adc) (0.42497*adc)
214 
215 
216 /*
217  * PWM
218  *
219  */
220 #define PWM_USE_TIM1 1
221 #define PWM_USE_TIM2 2
222 #define PWM_USE_TIM3 3
223 #define PWM_USE_TIM8 8
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 
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 TIM3
237 #define PWM_SERVO_1_GPIO GPIOB
238 #define PWM_SERVO_1_PIN GPIO5
239 #define PWM_SERVO_1_AF GPIO_AF2
240 #define PWM_SERVO_1_OC TIM_OC2
241 #define PWM_SERVO_1_OC_BIT (1<<1)
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 TIM1
249 #define PWM_SERVO_2_GPIO GPIOA
250 #define PWM_SERVO_2_PIN GPIO10
251 #define PWM_SERVO_2_AF GPIO_AF1
252 #define PWM_SERVO_2_OC TIM_OC3
253 #define PWM_SERVO_2_OC_BIT (1<<2)
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 TIM8
261 #define PWM_SERVO_3_GPIO GPIOC
262 #define PWM_SERVO_3_PIN GPIO8
263 #define PWM_SERVO_3_AF GPIO_AF3
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 TIM2
273 #define PWM_SERVO_4_GPIO GPIOB
274 #define PWM_SERVO_4_PIN GPIO11
275 #define PWM_SERVO_4_AF GPIO_AF1
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 TIM3
285 #define PWM_SERVO_5_GPIO GPIOB
286 #define PWM_SERVO_5_PIN GPIO1
287 #define PWM_SERVO_5_AF GPIO_AF2
288 #define PWM_SERVO_5_OC TIM_OC4
289 #define PWM_SERVO_5_OC_BIT (1<<3)
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 TIM3
297 #define PWM_SERVO_6_GPIO GPIOB
298 #define PWM_SERVO_6_PIN GPIO0
299 #define PWM_SERVO_6_AF GPIO_AF2
300 #define PWM_SERVO_6_OC TIM_OC3
301 #define PWM_SERVO_6_OC_BIT (1<<2)
302 #else
303 #define PWM_SERVO_6_OC_BIT 0
304 #endif
305 
306 /* servo 2 on TIM1 */
307 #define PWM_TIM1_CHAN_MASK (PWM_SERVO_2_OC_BIT)
308 /* servo 4 on TIM2 */
309 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_4_OC_BIT)
310 /* servos 1,5,6 on TIM3 */
311 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
312 /* servo 3 on TIM8 */
313 #define PWM_TIM8_CHAN_MASK (PWM_SERVO_3_OC_BIT)
314 
315 /* by default activate onboard baro */
316 #ifndef USE_BARO_BOARD
317 #define USE_BARO_BOARD 1
318 #endif
319 
320 #endif /* CONFIG_NAVSTIK_1_0_H */