Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
px4fmu_2.4.h
Go to the documentation of this file.
1 #ifndef CONFIG_PX4FMU_2_4_H
2 #define CONFIG_PX4FMU_2_4_H
3 
4 #define BOARD_PX4FMU_v2
5 
6 /* Pixhawk board (PX4FMUv2 has a 24MHz external clock and 168MHz internal. */
7 #define EXT_CLK 24000000
8 #define AHB_CLK 168000000
9 
10 
11 /*
12  * Onboard LEDs
13  */
14 /* red/amber , on PE12 */
15 #ifndef USE_LED_1
16 #define USE_LED_1 1
17 #endif
18 #define LED_1_GPIO GPIOE
19 #define LED_1_GPIO_PIN GPIO12
20 #define LED_1_GPIO_ON gpio_clear
21 #define LED_1_GPIO_OFF gpio_set
22 #define LED_1_AFIO_REMAP ((void)0)
23 
24 /*
25  * UART
26  */
27 /*
28 #define UART1_GPIO_AF GPIO_AF7
29 #define UART1_GPIO_PORT_RX GPIOA
30 #define UART1_GPIO_RX GPIO9
31 #define UART1_GPIO_PORT_TX GPIOA
32 #define UART1_GPIO_TX GPIO10
33 */
34 
35 //OK // conector telem1
36 #define UART2_GPIO_AF GPIO_AF7
37 #define UART2_GPIO_PORT_RX GPIOD
38 #define UART2_GPIO_RX GPIO6
39 #define UART2_GPIO_PORT_TX GPIOD
40 #define UART2_GPIO_TX GPIO5
41 //#define UART2_CTS PD3
42 //#define UART2_RTS PD4
43 
44 //OK-2 //conector telem2
45 #define UART3_GPIO_AF GPIO_AF7
46 #define UART3_GPIO_PORT_RX GPIOD
47 #define UART3_GPIO_RX GPIO9
48 #define UART3_GPIO_PORT_TX GPIOD
49 #define UART3_GPIO_TX GPIO8
50 //CTS - P11
51 //RTS - P12
52 
53 //OK-2 // GPS
54 #define UART4_GPIO_AF GPIO_AF8
55 #define UART4_GPIO_PORT_RX GPIOA
56 #define UART4_GPIO_RX GPIO1
57 #define UART4_GPIO_PORT_TX GPIOA
58 #define UART4_GPIO_TX GPIO0
59 
60 //OK-2 debug ligado no processador IO
61 #define UART6_GPIO_AF GPIO_AF8
62 #define UART6_GPIO_PORT_RX GPIOC
63 #define UART6_GPIO_RX GPIO7
64 #define UART6_GPIO_PORT_TX GPIOC
65 #define UART6_GPIO_TX GPIO6
66 
67 //OK-2 //conector serial5
68 #define UART7_GPIO_AF GPIO_AF8
69 #define UART7_GPIO_PORT_RX GPIOE
70 #define UART7_GPIO_RX GPIO7
71 #define UART7_GPIO_PORT_TX GPIOE
72 #define UART7_GPIO_TX GPIO8
73 
74 //OK-2 //conector serial4
75 #define UART8_GPIO_AF GPIO_AF8
76 #define UART8_GPIO_PORT_RX GPIOE
77 #define UART8_GPIO_RX GPIO0
78 #define UART8_GPIO_PORT_TX GPIOE
79 #define UART8_GPIO_TX GPIO1
80 
81 /*
82  * SPI
83  */
84 
85 /* SPI1 for MPU and accel/gyro if populated */
86 //OK-2
87 #define SPI1_GPIO_AF GPIO_AF5
88 #define SPI1_GPIO_PORT_MISO GPIOA
89 #define SPI1_GPIO_MISO GPIO6
90 #define SPI1_GPIO_PORT_MOSI GPIOA
91 #define SPI1_GPIO_MOSI GPIO7
92 #define SPI1_GPIO_PORT_SCK GPIOA
93 #define SPI1_GPIO_SCK GPIO5
94 
95 /* SPI2 for FRAM */
96 //OK-2
97 #define SPI2_GPIO_AF GPIO_AF5
98 #define SPI2_GPIO_PORT_MISO GPIOB
99 #define SPI2_GPIO_MISO GPIO14
100 #define SPI2_GPIO_PORT_MOSI GPIOB
101 #define SPI2_GPIO_MOSI GPIO15
102 #define SPI2_GPIO_PORT_SCK GPIOB
103 #define SPI2_GPIO_SCK GPIO13
104 
105 /* SPI4 Ext SPI connector */
106 //OK-2
107 #define SPI4_GPIO_AF GPIO_AF5
108 #define SPI4_GPIO_PORT_MISO GPIOE
109 #define SPI4_GPIO_MISO GPIO5
110 #define SPI4_GPIO_PORT_MOSI GPIOE
111 #define SPI4_GPIO_MOSI GPIO6
112 #define SPI4_GPIO_PORT_SCK GPIOE
113 #define SPI4_GPIO_SCK GPIO2
114 
115 /*
116  * SPI slave pin declaration
117  */
118 /* GYRO_CS on SPI1 */
119 //OK-2
120 #define SPI_SELECT_SLAVE0_PORT GPIOC
121 #define SPI_SELECT_SLAVE0_PIN GPIO13
122 
123 /* ACCEL_MAG_CS on SPI1 */
124 //OK-2
125 #define SPI_SELECT_SLAVE1_PORT GPIOC
126 #define SPI_SELECT_SLAVE1_PIN GPIO15
127 
128 /* MPU_CS on SPI1 */
129 //OK-2
130 #define SPI_SELECT_SLAVE2_PORT GPIOC
131 #define SPI_SELECT_SLAVE2_PIN GPIO2
132 
133 /* BARO_CS on SPI1 */
134 //OK-2
135 #define SPI_SELECT_SLAVE3_PORT GPIOD
136 #define SPI_SELECT_SLAVE3_PIN GPIO7
137 
138 /* FRAM_CS on SPI2 */
139 //OK-2
140 #define SPI_SELECT_SLAVE4_PORT GPIOD
141 #define SPI_SELECT_SLAVE4_PIN GPIO10
142 
143 /* SPI3 NSS on microSD connector */
144 /*
145 #define SPI_SELECT_SLAVE3_PORT GPIOA
146 #define SPI_SELECT_SLAVE3_PIN GPIO4
147 */
148 
149 // SDIO on microSD connector
150 //#define SDIO_AF GPIO_AF12
151 // SDIO_D0 pc8
152 // SDIO_D1 pc9
153 // SDIO_D2 pc10
154 // SDIO_D3 pc11
155 // SDIO_CK pc12
156 // SDIO_CMD pd2
157 
158 /* Onboard ADCs */
159 #define USE_AD_TIM4 1
160 
161 #define BOARD_ADC_CHANNEL_1 11
162 #define BOARD_ADC_CHANNEL_2 12
163 #define BOARD_ADC_CHANNEL_3 13
164 #define BOARD_ADC_CHANNEL_4 10
165 
166 /* provide defines that can be used to access the ADC_x in the code or airframe file
167  * these directly map to the index number of the 4 adc channels defined above
168  * 4th (index 3) is used for bat monitoring by default
169  */
170 
171 #if USE_ADC_1
172 #define AD1_1_CHANNEL 11
173 #define ADC_1 AD1_1
174 #define ADC_1_GPIO_PORT GPIOC
175 #define ADC_1_GPIO_PIN GPIO1
176 #endif
177 /*
178 #if USE_ADC_2
179 #define AD1_2_CHANNEL 12
180 #define ADC_2 AD1_2
181 #define ADC_2_GPIO_PORT GPIOC
182 #define ADC_2_GPIO_PIN GPIO2
183 #endif
184 */
185 
186 //OK current sens
187 #if USE_ADC_3
188 #define AD1_3_CHANNEL 13
189 #define ADC_3 AD1_3
190 #define ADC_3_GPIO_PORT GPIOA
191 #define ADC_3_GPIO_PIN GPIO3
192 #endif
193 
194 // Internal ADC for battery enabled by default
195 #ifndef USE_ADC_4
196 #define USE_ADC_4 1
197 #endif
198 #if USE_ADC_4
199 #define AD1_4_CHANNEL 10
200 #define ADC_4 AD1_4
201 #define ADC_4_GPIO_PORT GPIOA
202 #define ADC_4_GPIO_PIN GPIO2
203 #endif
204 
205 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
206 #ifndef ADC_CHANNEL_VSUPPLY
207 #define ADC_CHANNEL_VSUPPLY ADC_4
208 #endif
209 #define DefaultVoltageOfAdc(adc) (0.006185*adc)
210 
211 
212 /*
213  * I2C mapping
214  */
215 //OK
216 #define I2C1_GPIO_PORT GPIOB
217 #define I2C1_GPIO_SCL GPIO8
218 #define I2C1_GPIO_SDA GPIO9
219 
220 //OK
221 #define I2C2_GPIO_PORT GPIOB
222 #define I2C2_GPIO_SCL GPIO10
223 #define I2C2_GPIO_SDA GPIO11
224 
225 /*
226 #define I2C3_GPIO_PORT_SCL GPIOA
227 #define I2C3_GPIO_SCL GPIO8
228 #define I2C3_GPIO_PORT_SDA GPIOC
229 #define I2C3_GPIO_SDA GPIO9
230 */
231 
232 /*
233  * PPM
234  */
235 
236 
237 #define USE_PPM_TIM1 1
238 
239 #define PPM_CHANNEL TIM_IC1
240 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
241 #define PPM_IRQ NVIC_TIM1_CC_IRQ
242 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
243 // Capture/Compare InteruptEnable and InterruptFlag
244 #define PPM_CC_IE TIM_DIER_CC1IE
245 #define PPM_CC_IF TIM_SR_CC1IF
246 #define PPM_GPIO_PORT GPIOA
247 #define PPM_GPIO_PIN GPIO10
248 #define PPM_GPIO_AF GPIO_AF1
249 
250 /*
251  * Spektrum
252  */
253 /* The line that is pulled low at power up to initiate the bind process */
254 /* GPIO_EXT1 on PX4FMU */
255 
256 /*
257 #define SPEKTRUM_BIND_PIN GPIO4
258 #define SPEKTRUM_BIND_PIN_PORT GPIOC
259 */
260 /*
261 #define SPEKTRUM_UART2_RCC RCC_USART2
262 #define SPEKTRUM_UART2_BANK GPIOA
263 #define SPEKTRUM_UART2_PIN GPIO3
264 #define SPEKTRUM_UART2_AF GPIO_AF7
265 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
266 #define SPEKTRUM_UART2_ISR usart2_isr
267 #define SPEKTRUM_UART2_DEV USART2
268 */
269 
270 
271 /* Activate onboard baro by default */
272 #ifndef USE_BARO_BOARD
273 #define USE_BARO_BOARD 1
274 #endif
275 
276 
277 /* Default actuators driver */
278 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
279 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
280 #define ActuatorsDefaultInit() ActuatorsPwmInit()
281 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
282 
283 /* PWM */
284 #define PWM_USE_TIM1 1
285 #define PWM_USE_TIM4 1
286 
287 #define USE_PWM1 1
288 #define USE_PWM2 1
289 #define USE_PWM3 1
290 #define USE_PWM4 1
291 #define USE_PWM5 1
292 #define USE_PWM6 1
293 
294 // Servo numbering on the PX4 starts with 1
295 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
296 
297 //servo AUX1
298 #if USE_PWM1
299 #define PWM_SERVO_1 0
300 #define PWM_SERVO_1_TIMER TIM1
301 #define PWM_SERVO_1_GPIO GPIOE
302 #define PWM_SERVO_1_PIN GPIO14
303 #define PWM_SERVO_1_AF GPIO_AF1
304 #define PWM_SERVO_1_OC TIM_OC4
305 #define PWM_SERVO_1_OC_BIT (1<<3)
306 #else
307 #define PWM_SERVO_1_OC_BIT 0
308 #endif
309 
310 //servo AUX2
311 #if USE_PWM2
312 #define PWM_SERVO_2 1
313 #define PWM_SERVO_2_TIMER TIM1
314 #define PWM_SERVO_2_GPIO GPIOE
315 #define PWM_SERVO_2_PIN GPIO13
316 #define PWM_SERVO_2_AF GPIO_AF1
317 #define PWM_SERVO_2_OC TIM_OC3
318 #define PWM_SERVO_2_OC_BIT (1<<2)
319 #else
320 #define PWM_SERVO_2_OC_BIT 0
321 #endif
322 
323 //servo AUX3
324 #if USE_PWM3
325 #define PWM_SERVO_3 2 //#define PWM_SERVO_3_IDX 2
326 #define PWM_SERVO_3_TIMER TIM1
327 #define PWM_SERVO_3_GPIO GPIOE
328 #define PWM_SERVO_3_PIN GPIO11
329 #define PWM_SERVO_3_AF GPIO_AF1
330 #define PWM_SERVO_3_OC TIM_OC2
331 #define PWM_SERVO_3_OC_BIT (1<<1)
332 #else
333 #define PWM_SERVO_3_OC_BIT 0
334 #endif
335 
336 //servo AUX4
337 #if USE_PWM4
338 #define PWM_SERVO_4 3
339 #define PWM_SERVO_4_TIMER TIM1
340 #define PWM_SERVO_4_GPIO GPIOE
341 #define PWM_SERVO_4_PIN GPIO9
342 #define PWM_SERVO_4_AF GPIO_AF1
343 #define PWM_SERVO_4_OC TIM_OC1
344 #define PWM_SERVO_4_OC_BIT (1<<0)
345 #else
346 #define PWM_SERVO_4_OC_BIT 0
347 #endif
348 
349 //servo AUX5
350 #if USE_PWM5
351 #define PWM_SERVO_5 4
352 #define PWM_SERVO_5_TIMER TIM4
353 #define PWM_SERVO_5_GPIO GPIOD
354 #define PWM_SERVO_5_PIN GPIO13
355 #define PWM_SERVO_5_AF GPIO_AF2
356 #define PWM_SERVO_5_OC TIM_OC2
357 #define PWM_SERVO_5_OC_BIT (1<<1)
358 #else
359 #define PWM_SERVO_5_OC_BIT 0
360 #endif
361 
362 //servo AUX6
363 #if USE_PWM6
364 #define PWM_SERVO_6 5
365 #define PWM_SERVO_6_TIMER TIM4
366 #define PWM_SERVO_6_GPIO GPIOD
367 #define PWM_SERVO_6_PIN GPIO14
368 #define PWM_SERVO_6_AF GPIO_AF2
369 #define PWM_SERVO_6_OC TIM_OC3
370 #define PWM_SERVO_6_OC_BIT (1<<2)
371 #else
372 #define PWM_SERVO_6_OC_BIT 0
373 #endif
374 
375 //Buzzer
376 /*
377 #if USE_BUZZER
378 #define PWM_BUZZER
379 #define PWM_BUZZER_TIMER TIM2
380 #define PWM_BUZZER_GPIO GPIOA
381 #define PWM_BUZZER_PIN GPIO15
382 #define PWM_BUZZER_AF GPIO_AF1
383 #define PWM_BUZZER_OC TIM_OC1
384 #define PWM_BUZZER_OC_BIT (1<<0)
385 #else
386 #define PWM_BUZZER_OC_BIT 0
387 #endif
388 */
389 
390 
391 #define PWM_TIM1_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
392 //#define PWM_TIM2_CHAN_MASK (PWM_BUZZER_OC_BIT)
393 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
394 
395 #endif /* CONFIG_PX4FMU_2_4_H */