Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
px4fmu.h
Go to the documentation of this file.
1 #ifndef CONFIG_PX4FMU_4_00_H
2 #define CONFIG_PX4FMU_4_00_H
3 
4 #define BOARD_PX4FMU
5 
10 
15 /*
16  * AHB_CLK
17  */
18 #define AHB_CLK STM32_HCLK
19 
20 /*
21  * Onboard LEDs
22  */
23 /* red, on PE12 */
24 #ifndef USE_LED_1
25 #define USE_LED_1 1
26 #endif
27 #define LED_1_GPIO GPIOB
28 #define LED_1_GPIO_PIN GPIO11
29 #define LED_1_GPIO_ON gpio_clear
30 #define LED_1_GPIO_OFF gpio_set
31 #define LED_1_AFIO_REMAP ((void)0)
32 
33 /* green, on PB1 */
34 #ifndef USE_LED_2
35 #define USE_LED_2 1
36 #endif
37 #define LED_2_GPIO GPIOB
38 #define LED_2_GPIO_PIN GPIO1
39 #define LED_2_GPIO_ON gpio_clear
40 #define LED_2_GPIO_OFF gpio_set
41 #define LED_2_AFIO_REMAP ((void)0)
42 
43 /* blue, on PB3 */
44 #ifndef USE_LED_3
45 #define USE_LED_3 1
46 #endif
47 #define LED_3_GPIO GPIOB
48 #define LED_3_GPIO_PIN GPIO3
49 #define LED_3_GPIO_ON gpio_clear
50 #define LED_3_GPIO_OFF gpio_set
51 #define LED_3_AFIO_REMAP ((void)0)
52 
53 /*
54  * ADCs
55  */
56 // VOLT_SENS
57 #ifndef USE_ADC_1
58 #define USE_ADC_1 1
59 #endif
60 #if USE_ADC_1
61 #define AD1_1_CHANNEL ADC_CHANNEL_IN2
62 #define ADC_1 AD1_1
63 #define ADC_1_GPIO_PORT GPIOA
64 #define ADC_1_GPIO_PIN GPIO2
65 #endif
66 
67 // CUR_SENS
68 #ifndef USE_ADC_2
69 #define USE_ADC_2 2
70 #endif
71 #if USE_ADC_2
72 #define AD1_2_CHANNEL ADC_CHANNEL_IN3
73 #define ADC_2 AD1_2
74 #define ADC_2_GPIO_PORT GPIOA
75 #define ADC_2_GPIO_PIN GPIO3
76 #endif
77 
78 // VDD_V5_SENS
79 #if USE_ADC_3
80 #define AD1_3_CHANNEL ADC_CHANNEL_IN4
81 #define ADC_3 AD1_3
82 #define ADC_3_GPIO_PORT GPIOA
83 #define ADC_3_GPIO_PIN GPIO4
84 #endif
85 
86 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
87 #ifndef ADC_CHANNEL_VSUPPLY
88 #define ADC_CHANNEL_VSUPPLY ADC_1
89 #endif
90 
91 /* allow to define ADC_CHANNEL_CURRENT in the airframe file*/
92 #ifndef ADC_CHANNEL_CURRENT
93 #define ADC_CHANNEL_CURRENT ADC_2
94 #endif
95 
96 /* Default powerbrick values */
97 #define DefaultVoltageOfAdc(adc) ((3.3f/4096.0f) * 10.27708149f * adc)
98 #define MilliAmpereOfAdc(adc) ((3.3f/4096.0f) * 36367.51556f * adc)
99 
100 /*
101  * PWM defines TODO
102  */
103 #ifndef USE_PWM0
104 #define USE_PWM0 1
105 #endif
106 #if USE_PWM0
107 #define PWM_SERVO_0 0
108 #define PWM_SERVO_0_GPIO GPIOE
109 #define PWM_SERVO_0_PIN GPIO14
110 #define PWM_SERVO_0_AF GPIO_AF1
111 #define PWM_SERVO_0_DRIVER PWMD1
112 #define PWM_SERVO_0_CHANNEL 3
113 #define PWM_SERVO_0_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
114 #else
115 #define PWM_SERVO_0_ACTIVE PWM_OUTPUT_DISABLED
116 #endif
117 
118 #ifndef USE_PWM1
119 #define USE_PWM1 1
120 #endif
121 #if USE_PWM1
122 #define PWM_SERVO_1 1
123 #define PWM_SERVO_1_GPIO GPIOE
124 #define PWM_SERVO_1_PIN GPIO13
125 #define PWM_SERVO_1_AF GPIO_AF1
126 #define PWM_SERVO_1_DRIVER PWMD1
127 #define PWM_SERVO_1_CHANNEL 2
128 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
129 #else
130 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_DISABLED
131 #endif
132 
133 #ifndef USE_PWM2
134 #define USE_PWM2 1
135 #endif
136 #if USE_PWM2
137 #define PWM_SERVO_2 2
138 #define PWM_SERVO_2_GPIO GPIOE
139 #define PWM_SERVO_2_PIN GPIO11
140 #define PWM_SERVO_2_AF GPIO_AF1
141 #define PWM_SERVO_2_DRIVER PWMD1
142 #define PWM_SERVO_2_CHANNEL 1
143 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
144 #else
145 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_DISABLED
146 #endif
147 
148 #ifndef USE_PWM3
149 #define USE_PWM3 1
150 #endif
151 #if USE_PWM3
152 #define PWM_SERVO_3 3
153 #define PWM_SERVO_3_GPIO GPIOE
154 #define PWM_SERVO_3_PIN GPIO9
155 #define PWM_SERVO_3_AF GPIO_AF1
156 #define PWM_SERVO_3_DRIVER PWMD1
157 #define PWM_SERVO_3_CHANNEL 0
158 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
159 #else
160 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_DISABLED
161 #endif
162 
163 #ifndef USE_PWM4
164 #define USE_PWM4 1
165 #endif
166 #if USE_PWM4
167 #define PWM_SERVO_4 4
168 #define PWM_SERVO_4_GPIO GPIOD
169 #define PWM_SERVO_4_PIN GPIO13
170 #define PWM_SERVO_4_AF GPIO_AF2
171 #define PWM_SERVO_4_DRIVER PWMD4
172 #define PWM_SERVO_4_CHANNEL 1
173 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
174 #else
175 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_DISABLED
176 #endif
177 
178 #ifndef USE_PWM5
179 #define USE_PWM5 1
180 #endif
181 #if USE_PWM5
182 #define PWM_SERVO_5 5
183 #define PWM_SERVO_5_GPIO GPIOD
184 #define PWM_SERVO_5_PIN GPIO14
185 #define PWM_SERVO_5_AF GPIO_AF2
186 #define PWM_SERVO_5_DRIVER PWMD4
187 #define PWM_SERVO_5_CHANNEL 2
188 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
189 #else
190 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_DISABLED
191 #endif
192 
193 
194 #ifdef STM32_PWM_USE_TIM1
195 #define PWM_CONF_TIM1 STM32_PWM_USE_TIM1
196 #else
197 #define PWM_CONF_TIM1 1
198 #endif
199 #define PWM_CONF1_DEF { \
200  PWM_FREQUENCY, \
201  PWM_FREQUENCY/TIM1_SERVO_HZ, \
202  NULL, \
203  { \
204  { PWM_SERVO_3_ACTIVE, NULL }, \
205  { PWM_SERVO_2_ACTIVE, NULL }, \
206  { PWM_SERVO_1_ACTIVE, NULL }, \
207  { PWM_SERVO_0_ACTIVE, NULL }, \
208  }, \
209  0, \
210  0 \
211 }
212 
213 #ifdef STM32_PWM_USE_TIM4
214 #define PWM_CONF_TIM4 STM32_PWM_USE_TIM4
215 #else
216 #define PWM_CONF_TIM4 1
217 #endif
218 #define PWM_CONF4_DEF { \
219  PWM_FREQUENCY, \
220  PWM_FREQUENCY/TIM4_SERVO_HZ, \
221  NULL, \
222  { \
223  { PWM_OUTPUT_DISABLED, NULL }, \
224  { PWM_SERVO_4_ACTIVE, NULL }, \
225  { PWM_SERVO_5_ACTIVE, NULL }, \
226  { PWM_OUTPUT_DISABLED, NULL }, \
227  }, \
228  0, \
229  0 \
230 }
231 
235 #define UART1_GPIO_PORT_TX GPIOB
236 #define UART1_GPIO_TX GPIO6
237 #define UART1_GPIO_PORT_RX GPIOB
238 #define UART1_GPIO_RX GPIO7
239 #define UART1_GPIO_AF 7
240 
241 #define UART2_GPIO_PORT_TX GPIOD
242 #define UART2_GPIO_TX GPIO5
243 #define UART2_GPIO_PORT_RX GPIOD
244 #define UART2_GPIO_RX GPIO6
245 #define UART2_GPIO_AF 7
246 
247 #define UART3_GPIO_PORT_TX GPIOD
248 #define UART3_GPIO_TX GPIO8
249 #define UART3_GPIO_PORT_RX GPIOD
250 #define UART3_GPIO_RX GPIO9
251 #define UART3_GPIO_AF 7
252 
253 #define UART4_GPIO_PORT_TX GPIOA
254 #define UART4_GPIO_TX GPIO0
255 #define UART4_GPIO_PORT_RX GPIOA
256 #define UART4_GPIO_RX GPIO1
257 #define UART4_GPIO_AF 8
258 
259 #define UART6_GPIO_PORT_RX GPIOC
260 #define UART6_GPIO_RX GPIO7
261 #define UART6_GPIO_AF 8
262 
263 #define UART7_GPIO_PORT_TX GPIOE
264 #define UART7_GPIO_TX GPIO8
265 #define UART7_GPIO_PORT_RX GPIOE
266 #define UART7_GPIO_RX GPIO7
267 #define UART7_GPIO_AF 8
268 
269 #define UART8_GPIO_PORT_TX GPIOE
270 #define UART8_GPIO_TX GPIO1
271 #define UART8_GPIO_PORT_RX GPIOE
272 #define UART8_GPIO_RX GPIO0
273 #define UART8_GPIO_AF 8
274 
275 /* Soft binding Spektrum */
276 #define RADIO_CONTROL_POWER_PORT GPIOE
277 #define RADIO_CONTROL_POWER_PIN GPIO4 //SPEKTRUM POWER
278 #define RADIO_CONTROL_POWER_ON gpio_clear // yes, inverted
279 #define RADIO_CONTROL_POWER_OFF gpio_set
280 
281 //A receiver on powered on 3.3v
282 #define PERIPHERAL3V3_ENABLE_PORT GPIOC //VDD_3V3_PERIPHERAL_EN
283 #define PERIPHERAL3V3_ENABLE_PIN GPIO5
284 #define PERIPHERAL3V3_ENABLE_ON gpio_set
285 #define PERIPHERAL3V3_ENABLE_OFF gpio_clear
286 
287 // /**
288 // * PPM radio defines TODO
289 // */
290 // #define RC_PPM_TICKS_PER_USEC 2
291 // #define PPM_TIMER_FREQUENCY 2000000
292 // #define PPM_CHANNEL ICU_CHANNEL_1
293 // #define PPM_TIMER ICUD1
294 
295 // /*
296 // * PWM input TODO
297 // */
298 // // PWM_INPUT 1 on PA8 (also PPM IN)
299 // #define PWM_INPUT1_ICU ICUD1
300 // #define PWM_INPUT1_CHANNEL ICU_CHANNEL_1
301 // // PPM in (aka PA8) is used: not compatible with PPM RC receiver
302 // #define PWM_INPUT1_GPIO_PORT GPIOA
303 // #define PWM_INPUT1_GPIO_PIN GPIO8
304 // #define PWM_INPUT1_GPIO_AF GPIO_AF1
305 
306 
310 #ifndef I2C1_CLOCK_SPEED
311 #define I2C1_CLOCK_SPEED 400000
312 #endif
313 #if I2C1_CLOCK_SPEED == 400000
314 #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
315 #elif I2C1_CLOCK_SPEED == 100000
316 #define I2C1_DUTY_CYCLE STD_DUTY_CYCLE
317 #else
318 #error Invalid I2C1 clock speed
319 #endif
320 #define I2C1_CFG_DEF { \
321  OPMODE_I2C, \
322  I2C1_CLOCK_SPEED, \
323  I2C1_DUTY_CYCLE, \
324  }
325 
326 #ifndef I2C2_CLOCK_SPEED
327 #define I2C2_CLOCK_SPEED 400000
328 #endif
329 #if I2C2_CLOCK_SPEED == 400000
330 #define I2C2_DUTY_CYCLE FAST_DUTY_CYCLE_2
331 #elif I2C2_CLOCK_SPEED == 100000
332 #define I2C2_DUTY_CYCLE STD_DUTY_CYCLE
333 #else
334 #error Invalid I2C2 clock speed
335 #endif
336 #define I2C2_CFG_DEF { \
337  OPMODE_I2C, \
338  I2C2_CLOCK_SPEED, \
339  I2C2_DUTY_CYCLE, \
340  }
341 
342 
348 #define SPI1_GPIO_AF GPIO_AF5
349 #define SPI1_GPIO_PORT_MISO GPIOA
350 #define SPI1_GPIO_MISO GPIO6
351 #define SPI1_GPIO_PORT_MOSI GPIOA
352 #define SPI1_GPIO_MOSI GPIO7
353 #define SPI1_GPIO_PORT_SCK GPIOA
354 #define SPI1_GPIO_SCK GPIO5
355 
356 #define SPI2_GPIO_AF GPIO_AF5
357 #define SPI2_GPIO_PORT_MISO GPIOB
358 #define SPI2_GPIO_MISO GPIO14
359 #define SPI2_GPIO_PORT_MOSI GPIOB
360 #define SPI2_GPIO_MOSI GPIO15
361 #define SPI2_GPIO_PORT_SCK GPIOB
362 #define SPI2_GPIO_SCK GPIO10
363 
364 /* SPI1_SLAVE1 -> slave select pin for the ICM 20609-G*/
365 #define SPI_SELECT_SLAVE0_PORT GPIOC
366 #define SPI_SELECT_SLAVE0_PIN GPIO15
367 /* SPI1_SLAVE1 -> slave select pin for the HMC5983 */
368 #define SPI_SELECT_SLAVE1_PORT GPIOE
369 #define SPI_SELECT_SLAVE1_PIN GPIO15
370 // SPI1_SLAVE2 -> slave select pin for the MPU9250
371 #define SPI_SELECT_SLAVE2_PORT GPIOC
372 #define SPI_SELECT_SLAVE2_PIN GPIO2
373 // SPI1_SLAVE3 -> slave select pin for the ms5611
374 #define SPI_SELECT_SLAVE3_PORT GPIOD
375 #define SPI_SELECT_SLAVE3_PIN GPIO7
376 // SPI1_SLAVE4 -> slave select pin for the FRAM
377 #define SPI_SELECT_SLAVE4_PORT GPIOD
378 #define SPI_SELECT_SLAVE4_PIN GPIO10
379 
386 #ifndef USE_BARO_BOARD
387 #define USE_BARO_BOARD 1
388 #endif
389 
393 #define SDIO_D0_PORT GPIOC
394 #define SDIO_D0_PIN GPIO8
395 #define SDIO_D1_PORT GPIOC
396 #define SDIO_D1_PIN GPIO9
397 #define SDIO_D2_PORT GPIOC
398 #define SDIO_D2_PIN GPIO10
399 #define SDIO_D3_PORT GPIOC
400 #define SDIO_D3_PIN GPIO11
401 #define SDIO_CK_PORT GPIOC
402 #define SDIO_CK_PIN GPIO12
403 #define SDIO_CMD_PORT GPIOD
404 #define SDIO_CMD_PIN GPIO2
405 #define SDIO_AF 12
406 // bat monitoring for file closing
407 #define SDLOG_BAT_ADC ADCD1
408 #define SDLOG_BAT_CHAN AD1_1_CHANNEL
409 // usb led status
410 #define SDLOG_USB_LED 3
411 #define SDLOG_USB_VBUS_PORT GPIOA
412 #define SDLOG_USB_VBUS_PIN GPIO9
413 
414 /*
415  * Actuators for fixedwing
416  */
417  /* Default actuators driver */
418 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
419 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
420 #define ActuatorsDefaultInit() ActuatorsPwmInit()
421 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
422 
423 #endif /* CONFIG_PX4FMU_4_00_H */
424 
board.h