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
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 //STM32F4
8 #define EXT_CLK 24000000
9 #define AHB_CLK 168000000
10 
11 /*
12  * Onboard LEDs
13  */
14 /* red, 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 //OK // conector telem1
29 #define UART2_GPIO_AF GPIO_AF7
30 #define UART2_GPIO_PORT_RX GPIOD
31 #define UART2_GPIO_RX GPIO6
32 #define UART2_GPIO_PORT_TX GPIOD
33 #define UART2_GPIO_TX GPIO5
34 //#define UART2_CTS PD3
35 //#define UART2_RTS PD4
36 
37 //OK-2 //conector telem2
38 #define UART3_GPIO_AF GPIO_AF7
39 #define UART3_GPIO_PORT_RX GPIOD
40 #define UART3_GPIO_RX GPIO9
41 #define UART3_GPIO_PORT_TX GPIOD
42 #define UART3_GPIO_TX GPIO8
43 //CTS - P11
44 //RTS - P12
45 
46 //OK-2 // GPS
47 #define UART4_GPIO_AF GPIO_AF8
48 #define UART4_GPIO_PORT_RX GPIOA
49 #define UART4_GPIO_RX GPIO1
50 #define UART4_GPIO_PORT_TX GPIOA
51 #define UART4_GPIO_TX GPIO0
52 
53 //OK-2 debug ligado no processador IO
54 #define UART6_GPIO_AF GPIO_AF8
55 #define UART6_GPIO_PORT_RX GPIOC
56 #define UART6_GPIO_RX GPIO7
57 #define UART6_GPIO_PORT_TX GPIOC
58 #define UART6_GPIO_TX GPIO6
59 
60 //OK-2 //conector serial5
61 #define UART7_GPIO_AF GPIO_AF8
62 #define UART7_GPIO_PORT_RX GPIOE
63 #define UART7_GPIO_RX GPIO7
64 #define UART7_GPIO_PORT_TX GPIOE
65 #define UART7_GPIO_TX GPIO8
66 
67 //OK-2 //conector serial4
68 #define UART8_GPIO_AF GPIO_AF8
69 #define UART8_GPIO_PORT_RX GPIOE
70 #define UART8_GPIO_RX GPIO0
71 #define UART8_GPIO_PORT_TX GPIOE
72 #define UART8_GPIO_TX GPIO1
73 
74 /*
75  * SPI
76  */
77 
78 /* SPI1 for MPU and accel/gyro if populated */
79 //OK-2
80 #define SPI1_GPIO_AF GPIO_AF5
81 #define SPI1_GPIO_PORT_MISO GPIOA
82 #define SPI1_GPIO_MISO GPIO6
83 #define SPI1_GPIO_PORT_MOSI GPIOA
84 #define SPI1_GPIO_MOSI GPIO7
85 #define SPI1_GPIO_PORT_SCK GPIOA
86 #define SPI1_GPIO_SCK GPIO5
87 
88 /* SPI2 for FRAM */
89 //OK-2
90 #define SPI2_GPIO_AF GPIO_AF5
91 #define SPI2_GPIO_PORT_MISO GPIOB
92 #define SPI2_GPIO_MISO GPIO14
93 #define SPI2_GPIO_PORT_MOSI GPIOB
94 #define SPI2_GPIO_MOSI GPIO15
95 #define SPI2_GPIO_PORT_SCK GPIOB
96 #define SPI2_GPIO_SCK GPIO13
97 
98 /* SPI4 Ext SPI connector */
99 //OK-2
100 #define SPI4_GPIO_AF GPIO_AF5
101 #define SPI4_GPIO_PORT_MISO GPIOE
102 #define SPI4_GPIO_MISO GPIO5
103 #define SPI4_GPIO_PORT_MOSI GPIOE
104 #define SPI4_GPIO_MOSI GPIO6
105 #define SPI4_GPIO_PORT_SCK GPIOE
106 #define SPI4_GPIO_SCK GPIO2
107 
108 /*
109  * SPI slave pin declaration
110  */
111 /* GYRO_CS on SPI1 */
112 //OK-2
113 #define SPI_SELECT_SLAVE0_PORT GPIOC
114 #define SPI_SELECT_SLAVE0_PIN GPIO13
115 
116 /* ACCEL_MAG_CS on SPI1 */
117 //OK-2
118 #define SPI_SELECT_SLAVE1_PORT GPIOC
119 #define SPI_SELECT_SLAVE1_PIN GPIO15
120 
121 /* MPU_CS on SPI1 */
122 //OK-2
123 #define SPI_SELECT_SLAVE2_PORT GPIOC
124 #define SPI_SELECT_SLAVE2_PIN GPIO2
125 
126 /* BARO_CS on SPI1 */
127 //OK-2
128 #define SPI_SELECT_SLAVE3_PORT GPIOD
129 #define SPI_SELECT_SLAVE3_PIN GPIO7
130 
131 /* FRAM_CS on SPI2 */
132 //OK-2
133 #define SPI_SELECT_SLAVE4_PORT GPIOD
134 #define SPI_SELECT_SLAVE4_PIN GPIO10
135 
136 /* SPI3 NSS on microSD connector */
137 /*
138 #define SPI_SELECT_SLAVE3_PORT GPIOA
139 #define SPI_SELECT_SLAVE3_PIN GPIO4
140 */
141 
142 // SDIO on microSD connector
143 //#define SDIO_AF GPIO_AF12
144 // SDIO_D0 pc8
145 // SDIO_D1 pc9
146 // SDIO_D2 pc10
147 // SDIO_D3 pc11
148 // SDIO_CK pc12
149 // SDIO_CMD pd2
150 
151 /* Onboard ADCs */
152 #define USE_AD_TIM5 1
153 
154 /* provide defines that can be used to access the ADC_x in the code or airframe file
155  * these directly map to the index number of the 4 adc channels defined above
156  * 4th (index 3) is used for bat monitoring by default
157  */
158 
159 //#if USE_ADC_1
160 //#define AD1_1_CHANNEL 11
161 //#define ADC_1 AD1_1
162 //#define ADC_1_GPIO_PORT GPIOC
163 //#define ADC_1_GPIO_PIN GPIO1
164 //#endif
165 /*
166 #if USE_ADC_2
167 #define AD1_2_CHANNEL 12
168 #define ADC_2 AD1_2
169 #define ADC_2_GPIO_PORT GPIOC
170 #define ADC_2_GPIO_PIN GPIO2
171 #endif
172 */
173 
174 //OK current sens
175 #if USE_ADC_3
176 #define AD1_3_CHANNEL 3
177 #define ADC_3 AD1_3
178 #define ADC_3_GPIO_PORT GPIOA
179 #define ADC_3_GPIO_PIN GPIO3
180 #endif
181 #define MilliAmpereOfAdc(adc)((float)adc) * (3.3f / 4096.0f) * (90.0f / 5.0f)
182 
183 // Internal ADC for battery enabled by default
184 #ifndef USE_ADC_4
185 #define USE_ADC_4 1
186 #endif
187 #if USE_ADC_4
188 #define AD1_4_CHANNEL 2
189 #define ADC_4 AD1_4
190 #define ADC_4_GPIO_PORT GPIOA
191 #define ADC_4_GPIO_PIN GPIO2
192 #endif
193 
194 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
195 #ifndef ADC_CHANNEL_VSUPPLY
196 #define ADC_CHANNEL_VSUPPLY ADC_4
197 #endif
198 #define DefaultVoltageOfAdc(adc) (0.00975f*adc) // value comes from px4 code sensors.cpp _parameters.battery_voltage_scaling = 0.0082f; Manual calib on iris = 0.0096...
199 
200 
201 /*
202  * I2C mapping
203  */
204 //OK
205 #define I2C1_GPIO_PORT GPIOB
206 #define I2C1_GPIO_SCL GPIO8
207 #define I2C1_GPIO_SDA GPIO9
208 
209 //OK
210 #define I2C2_GPIO_PORT GPIOB
211 #define I2C2_GPIO_SCL GPIO10
212 #define I2C2_GPIO_SDA GPIO11
213 
214 /*
215 #define I2C3_GPIO_PORT_SCL GPIOA
216 #define I2C3_GPIO_SCL GPIO8
217 #define I2C3_GPIO_PORT_SDA GPIOC
218 #define I2C3_GPIO_SDA GPIO9
219 */
220 
221 /* Activate onboard baro by default */
222 #ifndef USE_BARO_BOARD
223 #define USE_BARO_BOARD 1
224 #endif
225 
226 
227 /* Default actuators driver */
228 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
229 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
230 #define ActuatorsDefaultInit() ActuatorsPwmInit()
231 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
232 
233 /* PWM */
234 #define PWM_USE_TIM1 1
235 #define PWM_USE_TIM4 1
236 
237 #define USE_PWM1 1
238 #define USE_PWM2 1
239 #define USE_PWM3 1
240 #define USE_PWM4 1
241 #define USE_PWM5 1
242 #define USE_PWM6 1
243 //#define USE_BUZZER 1
244 
245 // Servo numbering on the PX4 starts with 1
246 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
247 
248 //servo AUX1
249 #if USE_PWM1
250 #define PWM_SERVO_1 0
251 #define PWM_SERVO_1_TIMER TIM1
252 #define PWM_SERVO_1_GPIO GPIOE
253 #define PWM_SERVO_1_PIN GPIO14
254 #define PWM_SERVO_1_AF GPIO_AF1
255 #define PWM_SERVO_1_OC TIM_OC4
256 #define PWM_SERVO_1_OC_BIT (1<<3)
257 #else
258 #define PWM_SERVO_1_OC_BIT 0
259 #endif
260 
261 //servo AUX2
262 #if USE_PWM2
263 #define PWM_SERVO_2 1
264 #define PWM_SERVO_2_TIMER TIM1
265 #define PWM_SERVO_2_GPIO GPIOE
266 #define PWM_SERVO_2_PIN GPIO13
267 #define PWM_SERVO_2_AF GPIO_AF1
268 #define PWM_SERVO_2_OC TIM_OC3
269 #define PWM_SERVO_2_OC_BIT (1<<2)
270 #else
271 #define PWM_SERVO_2_OC_BIT 0
272 #endif
273 
274 //servo AUX3
275 #if USE_PWM3
276 #define PWM_SERVO_3 2 //#define PWM_SERVO_3_IDX 2
277 #define PWM_SERVO_3_TIMER TIM1
278 #define PWM_SERVO_3_GPIO GPIOE
279 #define PWM_SERVO_3_PIN GPIO11
280 #define PWM_SERVO_3_AF GPIO_AF1
281 #define PWM_SERVO_3_OC TIM_OC2
282 #define PWM_SERVO_3_OC_BIT (1<<1)
283 #else
284 #define PWM_SERVO_3_OC_BIT 0
285 #endif
286 
287 //servo AUX4
288 #if USE_PWM4
289 #define PWM_SERVO_4 3
290 #define PWM_SERVO_4_TIMER TIM1
291 #define PWM_SERVO_4_GPIO GPIOE
292 #define PWM_SERVO_4_PIN GPIO9
293 #define PWM_SERVO_4_AF GPIO_AF1
294 #define PWM_SERVO_4_OC TIM_OC1
295 #define PWM_SERVO_4_OC_BIT (1<<0)
296 #else
297 #define PWM_SERVO_4_OC_BIT 0
298 #endif
299 
300 //servo AUX5
301 #if USE_PWM5
302 #define PWM_SERVO_5 4
303 #define PWM_SERVO_5_TIMER TIM4
304 #define PWM_SERVO_5_GPIO GPIOD
305 #define PWM_SERVO_5_PIN GPIO13
306 #define PWM_SERVO_5_AF GPIO_AF2
307 #define PWM_SERVO_5_OC TIM_OC2
308 #define PWM_SERVO_5_OC_BIT (1<<1)
309 #else
310 #define PWM_SERVO_5_OC_BIT 0
311 #endif
312 
313 //servo AUX6
314 #if USE_PWM6
315 #define PWM_SERVO_6 5
316 #define PWM_SERVO_6_TIMER TIM4
317 #define PWM_SERVO_6_GPIO GPIOD
318 #define PWM_SERVO_6_PIN GPIO14
319 #define PWM_SERVO_6_AF GPIO_AF2
320 #define PWM_SERVO_6_OC TIM_OC3
321 #define PWM_SERVO_6_OC_BIT (1<<2)
322 #else
323 #define PWM_SERVO_6_OC_BIT 0
324 #endif
325 
326 //Buzzer (alarm)
327 #if USE_BUZZER
328 #define PWM_BUZZER
329 #define PWM_BUZZER_TIMER TIM2
330 #define PWM_BUZZER_GPIO GPIOA
331 #define PWM_BUZZER_PIN GPIO15
332 #define PWM_BUZZER_AF GPIO_AF1
333 #define PWM_BUZZER_OC TIM_OC1
334 #define PWM_BUZZER_OC_BIT (1<<0)
335 #else
336 #define PWM_BUZZER_OC_BIT 0
337 #endif
338 
339 #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)
340 #define PWM_TIM2_CHAN_MASK (PWM_BUZZER_OC_BIT)
341 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
342 
343 #endif /* CONFIG_PX4FMU_2_4_H */