Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 SPI2_GPIO_AF GPIO_AF5
128 #define SPI2_GPIO_PORT_MISO GPIOC
129 #define SPI2_GPIO_MISO GPIO2
130 #define SPI2_GPIO_PORT_MOSI GPIOC
131 #define SPI2_GPIO_MOSI GPIO3
132 #define SPI2_GPIO_PORT_SCK GPIOB
133 #define SPI2_GPIO_SCK GPIO10
134 
135 #define SPI_SELECT_SLAVE0_PORT GPIOA
136 #define SPI_SELECT_SLAVE0_PIN GPIO0
137 
138 #define SPI_SELECT_SLAVE1_PORT GPIOA
139 #define SPI_SELECT_SLAVE1_PIN GPIO5
140 
141 
142 /* I2C mapping */
143 #define I2C1_GPIO_PORT GPIOB
144 #define I2C1_GPIO_SCL GPIO8
145 #define I2C1_GPIO_SDA GPIO9
146 
147 #define I2C3_GPIO_PORT_SCL GPIOA
148 #define I2C3_GPIO_SCL GPIO8
149 #define I2C3_GPIO_PORT_SDA GPIOC
150 #define I2C3_GPIO_SDA GPIO9
151 
152 
153 /*
154  * ADC
155  */
156 
157 /* Onboard ADCs */
158 /*
159  BATT_volt PC1/ADC123 (ADC123_IN11)
160  BATT_current PA1/ADC123 (ADC123_IN1)
161 */
162 
163 // Internal ADC for battery enabled by default
164 #ifndef USE_ADC_1
165 #define USE_ADC_1 1
166 #endif
167 #if USE_ADC_1
168 #define AD1_1_CHANNEL 11
169 #define ADC_1 AD1_1
170 #define ADC_1_GPIO_PORT GPIOC
171 #define ADC_1_GPIO_PIN GPIO1
172 #endif
173 
174 #ifndef USE_ADC_2
175 #define USE_ADC_2 1
176 #endif
177 #if USE_ADC_2
178 #define AD1_2_CHANNEL 1
179 #define ADC_2 AD1_2
180 #define ADC_2_GPIO_PORT GPIOA
181 #define ADC_2_GPIO_PIN GPIO1
182 #endif
183 
184 /* allow to define ADC_CHANNEL_VSUPPLY and ADC_CHANNEL_CURRENT in the airframe file*/
185 #ifndef ADC_CHANNEL_VSUPPLY
186 #define ADC_CHANNEL_VSUPPLY ADC_1
187 #endif
188 #ifndef ADC_CHANNEL_CURRENT
189 #define ADC_CHANNEL_CURRENT ADC_2
190 #endif
191 
192 #define DefaultVoltageOfAdc(adc) (0.00382*adc)
193 #define DefaultMilliAmpereOfAdc(adc) (0.42497*adc)
194 
195 
196 /*
197  * PWM
198  *
199  */
200 #define PWM_USE_TIM1 1
201 #define PWM_USE_TIM2 2
202 #define PWM_USE_TIM3 3
203 #define PWM_USE_TIM8 8
204 
205 #define USE_PWM1 1
206 #define USE_PWM2 1
207 #define USE_PWM3 1
208 #define USE_PWM4 1
209 #define USE_PWM5 1
210 #define USE_PWM6 1
211 
212 
213 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
214 #if USE_PWM1
215 #define PWM_SERVO_1 0
216 #define PWM_SERVO_1_TIMER TIM3
217 #define PWM_SERVO_1_GPIO GPIOB
218 #define PWM_SERVO_1_PIN GPIO5
219 #define PWM_SERVO_1_AF GPIO_AF2
220 #define PWM_SERVO_1_OC TIM_OC2
221 #define PWM_SERVO_1_OC_BIT (1<<1)
222 #else
223 #define PWM_SERVO_1_OC_BIT 0
224 #endif
225 
226 #if USE_PWM2
227 #define PWM_SERVO_2 1
228 #define PWM_SERVO_2_TIMER TIM1
229 #define PWM_SERVO_2_GPIO GPIOA
230 #define PWM_SERVO_2_PIN GPIO10
231 #define PWM_SERVO_2_AF GPIO_AF1
232 #define PWM_SERVO_2_OC TIM_OC3
233 #define PWM_SERVO_2_OC_BIT (1<<2)
234 #else
235 #define PWM_SERVO_2_OC_BIT 0
236 #endif
237 
238 #if USE_PWM3
239 #define PWM_SERVO_3 2
240 #define PWM_SERVO_3_TIMER TIM8
241 #define PWM_SERVO_3_GPIO GPIOC
242 #define PWM_SERVO_3_PIN GPIO8
243 #define PWM_SERVO_3_AF GPIO_AF3
244 #define PWM_SERVO_3_OC TIM_OC3
245 #define PWM_SERVO_3_OC_BIT (1<<2)
246 #else
247 #define PWM_SERVO_3_OC_BIT 0
248 #endif
249 
250 #if USE_PWM4
251 #define PWM_SERVO_4 3
252 #define PWM_SERVO_4_TIMER TIM2
253 #define PWM_SERVO_4_GPIO GPIOB
254 #define PWM_SERVO_4_PIN GPIO11
255 #define PWM_SERVO_4_AF GPIO_AF1
256 #define PWM_SERVO_4_OC TIM_OC4
257 #define PWM_SERVO_4_OC_BIT (1<<3)
258 #else
259 #define PWM_SERVO_4_OC_BIT 0
260 #endif
261 
262 #if USE_PWM5
263 #define PWM_SERVO_5 4
264 #define PWM_SERVO_5_TIMER TIM3
265 #define PWM_SERVO_5_GPIO GPIOB
266 #define PWM_SERVO_5_PIN GPIO1
267 #define PWM_SERVO_5_AF GPIO_AF2
268 #define PWM_SERVO_5_OC TIM_OC4
269 #define PWM_SERVO_5_OC_BIT (1<<3)
270 #else
271 #define PWM_SERVO_5_OC_BIT 0
272 #endif
273 
274 #if USE_PWM6
275 #define PWM_SERVO_6 5
276 #define PWM_SERVO_6_TIMER TIM3
277 #define PWM_SERVO_6_GPIO GPIOB
278 #define PWM_SERVO_6_PIN GPIO0
279 #define PWM_SERVO_6_AF GPIO_AF2
280 #define PWM_SERVO_6_OC TIM_OC3
281 #define PWM_SERVO_6_OC_BIT (1<<2)
282 #else
283 #define PWM_SERVO_6_OC_BIT 0
284 #endif
285 
286 /* servo 2 on TIM1 */
287 #define PWM_TIM1_CHAN_MASK (PWM_SERVO_2_OC_BIT)
288 /* servo 4 on TIM2 */
289 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_4_OC_BIT)
290 /* servos 1,5,6 on TIM3 */
291 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
292 /* servo 3 on TIM8 */
293 #define PWM_TIM8_CHAN_MASK (PWM_SERVO_3_OC_BIT)
294 
295 /* by default activate onboard baro */
296 #ifndef USE_BARO_BOARD
297 #define USE_BARO_BOARD 1
298 #endif
299 
300 #endif /* CONFIG_NAVSTIK_1_0_H */