Paparazzi UAS
v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
px4fmu_4.0.h
Go to the documentation of this file.
1
#ifndef CONFIG_PX4FMU_4_0_H
2
#define CONFIG_PX4FMU_4_0_H
3
4
#define BOARD_PX4FMU_V4
5
6
/* PX4FMU_V4 a.k.a. Pixracer board has a 24MHz external clock and 168MHz internal. */
7
8
/* STM32F4 STM32F427VIT6 */
9
#define EXT_CLK 24000000
10
#define AHB_CLK 168000000
11
12
//#define STM32F4 //to debug ADC on F4 does no work
13
//#define ADC_SAMPLE_TIME ADC_SMPR_SMP_56CYC //to debug ADC on F4 does no work
14
15
/* On PCB there is a Multicolor LED */
16
17
/* Red */
18
#ifndef USE_LED_1
19
#define USE_LED_1 1
20
#endif
21
#define LED_1_GPIO GPIOB
22
#define LED_1_GPIO_PIN GPIO11
23
#define LED_1_GPIO_ON gpio_clear
24
#define LED_1_GPIO_OFF gpio_set
25
#define LED_1_AFIO_REMAP ((void)0)
26
27
/* Green */
28
#ifndef USE_LED_2
29
#define USE_LED_2 1
30
#endif
31
#define LED_2_GPIO GPIOB
32
#define LED_2_GPIO_PIN GPIO1
33
#define LED_2_GPIO_ON gpio_clear
34
#define LED_2_GPIO_OFF gpio_set
35
#define LED_2_AFIO_REMAP ((void)0)
36
37
/* Blue */
38
#ifndef USE_LED_3
39
#define USE_LED_3 1
40
#endif
41
#define LED_3_GPIO GPIOB
42
#define LED_3_GPIO_PIN GPIO3
43
#define LED_3_GPIO_ON gpio_clear
44
#define LED_3_GPIO_OFF gpio_set
45
#define LED_3_AFIO_REMAP ((void)0)
46
47
/* On PCB other LEDs */
48
/* The Green Pixracer Power LED in not controllable, not on a MCU pin */
49
50
/* UART SCHTUFFFF*/
51
52
/* -WiFi ESP Connector, it is just a serial port*/
53
//TODO: Test
54
#define UART1_GPIO_AF GPIO_AF7
55
#define UART1_GPIO_PORT_RX GPIOB
56
#define UART1_GPIO_RX GPIO7
57
#define UART1_GPIO_PORT_TX GPIOB
58
#define UART1_GPIO_TX GPIO6
59
60
/* -TELEM1 Connector */
61
#define UART2_GPIO_AF GPIO_AF7
62
#define UART2_GPIO_PORT_RX GPIOD
63
#define UART2_GPIO_RX GPIO6
64
#define UART2_GPIO_PORT_TX GPIOD
65
#define UART2_GPIO_TX GPIO5
66
#define UART2_GPIO_PORT_CTS GPIOD
67
#define UART2_GPIO_CTS GPIO3
68
#define UART2_GPIO_PORT_RTS GPIOD
69
#define UART2_GPIO_RTS GPIO4
70
71
/* -TELEM2 Connector */
72
#define UART3_GPIO_AF GPIO_AF7
73
#define UART3_GPIO_PORT_RX GPIOD
74
#define UART3_GPIO_RX GPIO9
75
#define UART3_GPIO_PORT_TX GPIOD
76
#define UART3_GPIO_TX GPIO8
77
#define UART3_GPIO_PORT_CTS GPIOD
78
#define UART3_GPIO_CTS GPIO11
79
#define UART3_GPIO_PORT_RTS GPIOD
80
#define UART3_GPIO_RTS GPIO12
81
82
/* -GPS Connector */
83
#define UART4_GPIO_AF GPIO_AF8
84
#define UART4_GPIO_PORT_RX GPIOA
85
#define UART4_GPIO_RX GPIO1
86
#define UART4_GPIO_PORT_TX GPIOA
87
#define UART4_GPIO_TX GPIO0
88
89
/* e.g. for a Spektrum satellite receiver rx only)*/
90
#define UART6_GPIO_AF GPIO_AF8
91
#define UART6_GPIO_PORT_RX GPIOC
92
#define UART6_GPIO_RX GPIO7
93
94
/* Serial Debugging Connector, not used with PPRZ as of now, use JTAG, can be put to other good use */
95
#define UART7_GPIO_AF GPIO_AF8
96
#define UART7_GPIO_PORT_RX GPIOE
97
#define UART7_GPIO_RX GPIO7
98
#define UART7_GPIO_PORT_TX GPIOE
99
#define UART7_GPIO_TX GPIO8
100
101
/* Connector -FRS FrSky */
102
//TODO: Test
103
#define UART8_GPIO_AF GPIO_AF8
104
#define UART8_GPIO_PORT_RX GPIOE
105
#define UART8_GPIO_RX GPIO0
106
#define UART8_GPIO_PORT_TX GPIOE
107
#define UART8_GPIO_TX GPIO1
108
109
/* Soft binding Spektrum */
110
//TODO: Test and or FIXME:
111
#define RADIO_CONTROL_POWER_PORT GPIOE
112
#define RADIO_CONTROL_POWER_PIN GPIO4 //SPEKTRUM POWER
113
#define RADIO_CONTROL_POWER_ON gpio_clear // yes, inverted
114
#define RADIO_CONTROL_POWER_OFF gpio_set
115
116
//A receiver on powered on 3.3v
117
#define PERIPHERAL3V3_ENABLE_PORT GPIOC //VDD_3V3_PERIPHERAL_EN
118
#define PERIPHERAL3V3_ENABLE_PIN GPIO5
119
#define PERIPHERAL3V3_ENABLE_ON gpio_set
120
#define PERIPHERAL3V3_ENABLE_OFF gpio_clear
121
122
/* Turn SBUS invert */
123
//TODO: Test
124
#define RC_POLARITY_GPIO_PORT GPIOC
125
#define RC_POLARITY_GPIO_PIN GPIO13
126
127
#define SPEKTRUM_UART6_RCC RCC_USART6
128
#define SPEKTRUM_UART6_BANK GPIOC
129
#define SPEKTRUM_UART6_PIN GPIO7
130
#define SPEKTRUM_UART6_AF GPIO_AF8
131
#define SPEKTRUM_UART6_IRQ NVIC_USART6_IRQ
132
#define SPEKTRUM_UART6_ISR usart6_isr
133
#define SPEKTRUM_UART6_DEV USART6
134
135
/* SPI */
136
137
/* SPI1 for MPU and extra accel/gyro/mag */
138
#define SPI1_GPIO_AF GPIO_AF5
139
#define SPI1_GPIO_PORT_MISO GPIOA
140
#define SPI1_GPIO_MISO GPIO6
141
#define SPI1_GPIO_PORT_MOSI GPIOA
142
#define SPI1_GPIO_MOSI GPIO7
143
#define SPI1_GPIO_PORT_SCK GPIOA
144
#define SPI1_GPIO_SCK GPIO5
145
146
/* SPI2 for FRAM, connects to BARO */
147
#define SPI2_GPIO_AF GPIO_AF5
148
#define SPI2_GPIO_PORT_MISO GPIOB
149
#define SPI2_GPIO_MISO GPIO14
150
#define SPI2_GPIO_PORT_MOSI GPIOB
151
#define SPI2_GPIO_MOSI GPIO15
152
#define SPI2_GPIO_PORT_SCK GPIOB
153
#define SPI2_GPIO_SCK GPIO10
154
155
/*
156
* SPI slave pin declaration
157
*/
158
159
/* note :
160
Active-Low Push-Pull Data-Ready Output. DRDY goes low when a new conversion result is available in the data register.
161
When a read-operation of an RTD resistance data register occurs, DRDY returns high.
162
*/
163
/*
164
* SPI slave pin declaration
165
*/
166
167
//So use best spec'd sensors as second or ref the other or determine it on task type?
168
/* EXTRA ACC_GYRO_CS on SPI1 ICM 20609-G*/
169
// TODO: Make it useful
170
#define SPI_SELECT_SLAVE0_PORT GPIOC
171
#define SPI_SELECT_SLAVE0_PIN GPIO15
172
173
/* EXTRA_MAG_CS on SPI1 HMC5983*/
174
//See https://docs.google.com/spreadsheets/d/1gVlKZBvRNTXldoxTXwipGaaHmtF9DNPaftDrzKA47mM/edit#gid=0
175
#define SPI_SELECT_SLAVE1_PORT GPIOE
176
#define SPI_SELECT_SLAVE1_PIN GPIO15
177
178
/* MDL */
179
// FIXME: Test n fix or emoveal
180
//#define SPI_SELECT_SLAVE1_PORT GPIOE
181
//#define SPI_SELECT_SLAVE1_PIN GPIO15
182
183
/* MPU_9250_CS on SPI1 */
184
#define SPI_SELECT_SLAVE2_PORT GPIOC
185
#define SPI_SELECT_SLAVE2_PIN GPIO2
186
187
/* MS5611 BARO_CS on SPI2 - FRAM*/
188
#define SPI_SELECT_SLAVE3_PORT GPIOD
189
#define SPI_SELECT_SLAVE3_PIN GPIO7
190
191
/* FRAM on SPI2 */
192
#define SPI_SELECT_SLAVE4_PORT GPIOD
193
#define SPI_SELECT_SLAVE4_PIN GPIO10
194
195
/* SPI3 NSS on microSD connector */
196
//FIXME: not tested
197
//#define SPI_SELECT_SLAVE5_PORT GPIOA
198
//#define SPI_SELECT_SLAVE5_PIN GPIO4
199
200
201
/* SDIO to microSD card connector */
202
//FIXME: Fix and test
203
#define SDIO_AF GPIO_AF12
204
#define SDIO_D0_PORT GPIOC
205
#define SDIO_D0_PIN GPIO8
206
#define SDIO_D1_PORT GPIOC
207
#define SDIO_D1_PIN GPIO9
208
#define SDIO_D2_PORT GPIOC
209
#define SDIO_D2_PIN GPIO10
210
#define SDIO_D3_PORT GPIOC
211
#define SDIO_D3_PIN GPIO11
212
#define SDIO_CK_PORT GPIOC
213
#define SDIO_CK_PIN GPIO12
214
#define SDIO_CMD_PORT GPIOD
215
#define SDIO_CMD_PIN GPIO2
216
217
/* Onboard ADCs */
218
#if USE_AD_TIM2
219
#undef USE_AD_TIM2 // timer2 is used by the buzzer
220
#endif
221
#define USE_AD_TIM3 1
222
223
// Internal ADC for voltage level measurement
225
#ifndef USE_ADC_1
226
#define USE_ADC_1 1
227
#endif
228
229
#if USE_ADC_1
230
#define AD1_1_CHANNEL 4 //ADC12_IN4
231
#define ADC_1 AD1_1
232
#define ADC_1_GPIO_PORT GPIOA
233
#define ADC_1_GPIO_PIN GPIO4
234
#endif
235
236
// Per default for the board to sense voltage level via external sensor on ADC
237
//FIXME: test and fix if still not working
238
#ifndef USE_ADC_2
239
#define USE_ADC_2 1
240
#endif
241
#if USE_ADC_2
242
#define AD1_2_CHANNEL 2 // ADC123_IN2 (--> IN2 corresponds to channel 2)
243
#define ADC_2 AD1_2 // ADC123 means it can be used by ADC 1 and 2 and 3 (the f4 supports 3 adc's), does not matter which. Each ADC can address 4 pins, so in this case we are using ADC 1, on its second pin.
244
#define ADC_2_GPIO_PORT GPIOA
245
#define ADC_2_GPIO_PIN GPIO2
246
#endif
247
248
// Per default for the board to sense current via external sensor on ADC
249
#ifndef USE_ADC_3
250
#define USE_ADC_3 1
251
#endif
252
#if USE_ADC_3
253
#define AD1_3_CHANNEL 3 // ADC123_IN3
254
#define ADC_3 AD1_3
255
#define ADC_3_GPIO_PORT GPIOA
256
#define ADC_3_GPIO_PIN GPIO3
257
#endif
258
#define MilliAmpereOfAdc(adc)((float)adc) * (3.3f / 4096.0f) * (90.0f / 5.0f) //TODO: test if valid
259
260
/* Allow to define ADC_CHANNEL_VSUPPLY in the airframe file */
261
#ifndef ADC_CHANNEL_VSUPPLY
262
#define ADC_CHANNEL_VSUPPLY ADC_2
263
#endif
264
265
/* Allow to define another ADC for Current measurement in the airframe file */
266
#ifndef ADC_CHANNEL_CURRENT
267
#define ADC_CHANNEL_CURRENT ADC_3
268
#endif
269
270
//??FT = Five-volt tolerant. In order to sustain a voltage higher than VDD+0.3 the internal pull-up/pull-down resistors must be disabled.
271
//FIXME: Determine best stock values
272
#if USE_ADC_2
273
#define DefaultVoltageOfAdc(adc) (0.004f * (float)adc) // FIXME: Value scale for a common PowerBrick
274
#else
275
#define DefaultVoltageOfAdc(adc) (0.004f * (float)adc) // FIXME: Value scale internal vdd to 5V
276
#endif
277
278
/* I2C mapping */
279
#define I2C1_GPIO_PORT GPIOB
280
#define I2C1_GPIO_SCL GPIO8
281
#define I2C1_GPIO_SDA GPIO9
282
283
//Onboard Barometer
284
#ifndef USE_BARO_BOARD
285
#define USE_BARO_BOARD 1
286
#endif
287
288
/* Another Magnetometer on board a HMC5983 not the one in the IMU 9250*/
289
//FIXME: better default option for use of maybe fuse data
290
#ifndef USE_MAGNETOMETER_B
291
#define USE_MAGNETOMETER_B 0
292
#endif
293
294
/* Default actuators driver */
295
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
296
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
297
#define ActuatorsDefaultInit() ActuatorsPwmInit()
298
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
299
300
/* PWM */
301
#define PWM_USE_TIM1 1
302
#define PWM_USE_TIM4 1
303
304
305
//TODO: ifdef USE_SERVO6 for PPM out to e.g. servo extender board ...
306
// Basically a inter mcu Extra device;)
307
308
#define USE_PWM1 1
309
#define USE_PWM2 1
310
#define USE_PWM3 1
311
#define USE_PWM4 1
312
#define USE_PWM5 1
313
#define USE_PWM6 1
314
315
/* Servo 1 */
316
#if USE_PWM1
317
#define PWM_SERVO_1 0
318
#define PWM_SERVO_1_TIMER TIM1
319
#define PWM_SERVO_1_GPIO GPIOE
320
#define PWM_SERVO_1_PIN GPIO14
321
#define PWM_SERVO_1_AF GPIO_AF1
322
#define PWM_SERVO_1_OC TIM_OC4
323
#define PWM_SERVO_1_OC_BIT (1<<3)
324
#else
325
#define PWM_SERVO_1_OC_BIT 0
326
#endif
327
328
/* Servo 2 */
329
#if USE_PWM2
330
#define PWM_SERVO_2 1
331
#define PWM_SERVO_2_TIMER TIM1
332
#define PWM_SERVO_2_GPIO GPIOE
333
#define PWM_SERVO_2_PIN GPIO13
334
#define PWM_SERVO_2_AF GPIO_AF1
335
#define PWM_SERVO_2_OC TIM_OC3
336
#define PWM_SERVO_2_OC_BIT (1<<2)
337
#else
338
#define PWM_SERVO_2_OC_BIT 0
339
#endif
340
341
/* Servo 3 */
342
#if USE_PWM3
343
#define PWM_SERVO_3 2 //#define PWM_SERVO_3_IDX 2
344
#define PWM_SERVO_3_TIMER TIM1
345
#define PWM_SERVO_3_GPIO GPIOE
346
#define PWM_SERVO_3_PIN GPIO11
347
#define PWM_SERVO_3_AF GPIO_AF1
348
#define PWM_SERVO_3_OC TIM_OC2
349
#define PWM_SERVO_3_OC_BIT (1<<1)
350
#else
351
#define PWM_SERVO_3_OC_BIT 0
352
#endif
353
354
/* Servo 4 */
355
#if USE_PWM4
356
#define PWM_SERVO_4 3
357
#define PWM_SERVO_4_TIMER TIM1
358
#define PWM_SERVO_4_GPIO GPIOE
359
#define PWM_SERVO_4_PIN GPIO9
360
#define PWM_SERVO_4_AF GPIO_AF1
361
#define PWM_SERVO_4_OC TIM_OC1
362
#define PWM_SERVO_4_OC_BIT (1<<0)
363
#else
364
#define PWM_SERVO_4_OC_BIT 0
365
#endif
366
367
/* Servo 5 */
368
#if USE_PWM5
369
#define PWM_SERVO_5 4
370
#define PWM_SERVO_5_TIMER TIM4
371
#define PWM_SERVO_5_GPIO GPIOD
372
#define PWM_SERVO_5_PIN GPIO13
373
#define PWM_SERVO_5_AF GPIO_AF2
374
#define PWM_SERVO_5_OC TIM_OC2
375
#define PWM_SERVO_5_OC_BIT (1<<1)
376
#else
377
#define PWM_SERVO_5_OC_BIT 0
378
#endif
379
380
/* Servo 6 */
381
#if USE_PWM6
382
#define PWM_SERVO_6 5
383
#define PWM_SERVO_6_TIMER TIM4
384
#define PWM_SERVO_6_GPIO GPIOD
385
#define PWM_SERVO_6_PIN GPIO14
386
#define PWM_SERVO_6_AF GPIO_AF2
387
#define PWM_SERVO_6_OC TIM_OC3
388
#define PWM_SERVO_6_OC_BIT (1<<2)
389
#else
390
#define PWM_SERVO_6_OC_BIT 0
391
#endif
392
393
#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)
394
#define PWM_TIM4_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
395
396
/* Buzzer (A.k.a. Alarm) */
397
//TODO: Test
398
#if USE_BUZZER
399
#define PWM_BUZZER
400
#define PWM_BUZZER_TIMER TIM2
401
#define PWM_BUZZER_GPIO GPIOA
402
#define PWM_BUZZER_PIN GPIO15
403
#define PWM_BUZZER_AF GPIO_AF1
404
#define PWM_BUZZER_OC TIM_OC1
405
#define PWM_BUZZER_OC_BIT (1<<0)
406
#define PWM_TIM2_CHAN_MASK (PWM_BUZZER_OC_BIT)
407
#else
408
#define PWM_BUZZER_OC_BIT 0
409
#endif
410
411
#endif
/* CONFIG_PX4FMU_4_0_H */
sw
airborne
boards
px4fmu_4.0.h
Generated on Sat Feb 9 2019 06:43:48 for Paparazzi UAS by
1.8.8