Paparazzi UAS  v5.15_devel-99-g2ff7410
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
chimera.h
Go to the documentation of this file.
1 #ifndef CONFIG_CHIMERA_1_00_H
2 #define CONFIG_CHIMERA_1_00_H
3 
4 #define BOARD_CHIMERA
5 
10 
15 /*
16  * AHB_CLK
17  */
18 #define AHB_CLK STM32_HCLK
19 
20 
21 /*
22  * LEDs
23  */
24 /* red, on PB12, 1 on LED_ON, 0 on LED_OFF */
25 #ifndef USE_LED_1
26 #define USE_LED_1 1
27 #endif
28 #define LED_1_GPIO GPIOB
29 #define LED_1_GPIO_PIN GPIO12
30 #define LED_1_GPIO_ON gpio_set
31 #define LED_1_GPIO_OFF gpio_clear
32 
33 /* orange, on PB13, 1 on LED_ON, 0 on LED_OFF */
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 GPIO13
39 #define LED_2_GPIO_ON gpio_set
40 #define LED_2_GPIO_OFF gpio_clear
41 
42 /* green, on PD10, 1 on LED_ON, 0 on LED_OFF */
43 #ifndef USE_LED_3
44 #define USE_LED_3 1
45 #endif
46 #define LED_3_GPIO GPIOD
47 #define LED_3_GPIO_PIN GPIO10
48 #define LED_3_GPIO_ON gpio_set
49 #define LED_3_GPIO_OFF gpio_clear
50 
51 /* yellow, on PD11, 1 on LED_ON, 0 on LED_OFF */
52 #ifndef USE_LED_4
53 #define USE_LED_4 1
54 #endif
55 #define LED_4_GPIO GPIOD
56 #define LED_4_GPIO_PIN GPIO11
57 #define LED_4_GPIO_ON gpio_set
58 #define LED_4_GPIO_OFF gpio_clear
59 
60 /* AUX0, on PA5, 1 on LED_ON, 0 on LED_OFF */
61 #ifndef USE_LED_5
62 #define USE_LED_5 0
63 #endif
64 #define LED_5_GPIO GPIOA
65 #define LED_5_GPIO_PIN GPIO5
66 #define LED_5_GPIO_ON gpio_set
67 #define LED_5_GPIO_OFF gpio_clear
68 
69 /* AUX1, on PA3, 1 on LED_ON, 0 on LED_OFF */
70 #ifndef USE_LED_6
71 #define USE_LED_6 0
72 #endif
73 #define LED_6_GPIO GPIOA
74 #define LED_6_GPIO_PIN GPIO3
75 #define LED_6_GPIO_ON gpio_set
76 #define LED_6_GPIO_OFF gpio_clear
77 
78 /* AUX2, on PA2, 1 on LED_ON, 0 on LED_OFF */
79 #ifndef USE_LED_7
80 #define USE_LED_7 0
81 #endif
82 #define LED_7_GPIO GPIOA
83 #define LED_7_GPIO_PIN GPIO2
84 #define LED_7_GPIO_ON gpio_set
85 #define LED_7_GPIO_OFF gpio_clear
86 
87 /* AUX3, on PA0, 1 on LED_ON, 0 on LED_OFF */
88 #ifndef USE_LED_8
89 #define USE_LED_8 0
90 #endif
91 #define LED_8_GPIO GPIOA
92 #define LED_8_GPIO_PIN GPIO0
93 #define LED_8_GPIO_ON gpio_set
94 #define LED_8_GPIO_OFF gpio_clear
95 
96 /* AUX4, on PC3, 1 on LED_ON, 0 on LED_OFF */
97 #ifndef USE_LED_9
98 #define USE_LED_9 0
99 #endif
100 #define LED_9_GPIO GPIOC
101 #define LED_9_GPIO_PIN GPIO3
102 #define LED_9_GPIO_ON gpio_set
103 #define LED_9_GPIO_OFF gpio_clear
104 
105 /* AUX5, on PC2, 1 on LED_ON, 0 on LED_OFF */
106 #ifndef USE_LED_10
107 #define USE_LED_10 0
108 #endif
109 #define LED_10_GPIO GPIOC
110 #define LED_10_GPIO_PIN GPIO2
111 #define LED_10_GPIO_ON gpio_set
112 #define LED_10_GPIO_OFF gpio_clear
113 
114 /* AUX6, on PC6, 1 on LED_ON, 0 on LED_OFF */
115 #ifndef USE_LED_11
116 #define USE_LED_11 0
117 #endif
118 #define LED_11_GPIO GPIOC
119 #define LED_11_GPIO_PIN GPIO6
120 #define LED_11_GPIO_ON gpio_set
121 #define LED_11_GPIO_OFF gpio_clear
122 
123 /* AUX7, on PC7, 1 on LED_ON, 0 on LED_OFF */
124 #ifndef USE_LED_12
125 #define USE_LED_12 0
126 #endif
127 #define LED_12_GPIO GPIOC
128 #define LED_12_GPIO_PIN GPIO7
129 #define LED_12_GPIO_ON gpio_set
130 #define LED_12_GPIO_OFF gpio_clear
131 
132 /*
133  * ADCs
134  */
135 // AUX0
136 #if USE_ADC_1
137 #define AD1_1_CHANNEL ADC_CHANNEL_IN5
138 #define ADC_1 AD1_1
139 #define ADC_1_GPIO_PORT GPIOA
140 #define ADC_1_GPIO_PIN GPIO5
141 #endif
142 
143 // AUX1
144 #if USE_ADC_2
145 #define AD1_2_CHANNEL ADC_CHANNEL_IN3
146 #define ADC_2 AD1_2
147 #define ADC_2_GPIO_PORT GPIOA
148 #define ADC_2_GPIO_PIN GPIO3
149 #endif
150 
151 // AUX2
152 #if USE_ADC_3
153 #define AD1_3_CHANNEL ADC_CHANNEL_IN2
154 #define ADC_3 AD1_3
155 #define ADC_3_GPIO_PORT GPIOA
156 #define ADC_3_GPIO_PIN GPIO2
157 #endif
158 
159 // AUX3
160 #if USE_ADC_4
161 #define AD1_4_CHANNEL ADC_CHANNEL_IN0
162 #define ADC_4 AD1_4
163 #define ADC_4_GPIO_PORT GPIOA
164 #define ADC_4_GPIO_PIN GPIO0
165 #endif
166 
167 // AUX4
168 #if USE_ADC_5
169 #define AD1_5_CHANNEL ADC_CHANNEL_IN13
170 #define ADC_5 AD1_5
171 #define ADC_5_GPIO_PORT GPIOC
172 #define ADC_5_GPIO_PIN GPIO3
173 #endif
174 
175 // AUX5
176 #if USE_ADC_6
177 #define AD1_6_CHANNEL ADC_CHANNEL_IN12
178 #define ADC_6 AD1_6
179 #define ADC_6_GPIO_PORT GPIOC
180 #define ADC_6_GPIO_PIN GPIO2
181 #endif
182 
183 // Internal ADC for battery enabled by default
184 #ifndef USE_ADC_7
185 #define USE_ADC_7 1
186 #endif
187 #if USE_ADC_7
188 #define AD1_7_CHANNEL ADC_CHANNEL_IN4
189 #define ADC_7 AD1_7
190 #define ADC_7_GPIO_PORT GPIOA
191 #define ADC_7_GPIO_PIN GPIO4
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_7
197 #endif
198 
199 /*
200  * R1 = 3.3k
201  * R2 = 22k
202  * adc * (3.3 / 2^12) * ((R1 + R2) / R1)
203  */
204 #define VBAT_R1 3300.0f
205 #define VBAT_R2 22000.0f
206 #define DefaultVoltageOfAdc(adc) ((3.3f/4096.0f)*((VBAT_R1+VBAT_R2)/VBAT_R1)*adc)
207 
208 //TODO configure DAC (ADC_1)
209 
210 /*
211  * PWM defines
212  */
213 #ifndef USE_PWM0
214 #define USE_PWM0 1
215 #endif
216 #if USE_PWM0
217 #define PWM_SERVO_0 0
218 #define PWM_SERVO_0_GPIO GPIOA
219 #define PWM_SERVO_0_PIN GPIO6
220 #define PWM_SERVO_0_AF GPIO_AF2
221 #define PWM_SERVO_0_DRIVER PWMD3
222 #define PWM_SERVO_0_CHANNEL 0
223 #define PWM_SERVO_0_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
224 #else
225 #define PWM_SERVO_0_ACTIVE PWM_OUTPUT_DISABLED
226 #endif
227 
228 #ifndef USE_PWM1
229 #define USE_PWM1 1
230 #endif
231 #if USE_PWM1
232 #define PWM_SERVO_1 1
233 #define PWM_SERVO_1_GPIO GPIOA
234 #define PWM_SERVO_1_PIN GPIO7
235 #define PWM_SERVO_1_AF GPIO_AF2
236 #define PWM_SERVO_1_DRIVER PWMD3
237 #define PWM_SERVO_1_CHANNEL 1
238 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
239 #else
240 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_DISABLED
241 #endif
242 
243 #ifndef USE_PWM2
244 #define USE_PWM2 1
245 #endif
246 #if USE_PWM2
247 #define PWM_SERVO_2 2
248 #define PWM_SERVO_2_GPIO GPIOB
249 #define PWM_SERVO_2_PIN GPIO0
250 #define PWM_SERVO_2_AF GPIO_AF2
251 #define PWM_SERVO_2_DRIVER PWMD3
252 #define PWM_SERVO_2_CHANNEL 2
253 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
254 #else
255 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_DISABLED
256 #endif
257 
258 #ifndef USE_PWM3
259 #define USE_PWM3 1
260 #endif
261 #if USE_PWM3
262 #define PWM_SERVO_3 3
263 #define PWM_SERVO_3_GPIO GPIOB
264 #define PWM_SERVO_3_PIN GPIO1
265 #define PWM_SERVO_3_AF GPIO_AF2
266 #define PWM_SERVO_3_DRIVER PWMD3
267 #define PWM_SERVO_3_CHANNEL 3
268 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
269 #else
270 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_DISABLED
271 #endif
272 
273 #ifndef USE_PWM4
274 #define USE_PWM4 1
275 #endif
276 #if USE_PWM4
277 #define PWM_SERVO_4 4
278 #define PWM_SERVO_4_GPIO GPIOD
279 #define PWM_SERVO_4_PIN GPIO12
280 #define PWM_SERVO_4_AF GPIO_AF2
281 #define PWM_SERVO_4_DRIVER PWMD4
282 #define PWM_SERVO_4_CHANNEL 0
283 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
284 #else
285 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_DISABLED
286 #endif
287 
288 #ifndef USE_PWM5
289 #define USE_PWM5 1
290 #endif
291 #if USE_PWM5
292 #define PWM_SERVO_5 5
293 #define PWM_SERVO_5_GPIO GPIOD
294 #define PWM_SERVO_5_PIN GPIO13
295 #define PWM_SERVO_5_AF GPIO_AF2
296 #define PWM_SERVO_5_DRIVER PWMD4
297 #define PWM_SERVO_5_CHANNEL 1
298 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
299 #else
300 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_DISABLED
301 #endif
302 
303 #ifndef USE_PWM6
304 #define USE_PWM6 1
305 #endif
306 #if USE_PWM6
307 #define PWM_SERVO_6 6
308 #define PWM_SERVO_6_GPIO GPIOD
309 #define PWM_SERVO_6_PIN GPIO14
310 #define PWM_SERVO_6_AF GPIO_AF2
311 #define PWM_SERVO_6_DRIVER PWMD4
312 #define PWM_SERVO_6_CHANNEL 2
313 #define PWM_SERVO_6_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
314 #else
315 #define PWM_SERVO_6_ACTIVE PWM_OUTPUT_DISABLED
316 #endif
317 
318 #ifndef USE_PWM6
319 #define USE_PWM6 1
320 #endif
321 #if USE_PWM7
322 #define PWM_SERVO_7 7
323 #define PWM_SERVO_7_GPIO GPIOD
324 #define PWM_SERVO_7_PIN GPIO15
325 #define PWM_SERVO_7_AF GPIO_AF2
326 #define PWM_SERVO_7_DRIVER PWMD4
327 #define PWM_SERVO_7_CHANNEL 3
328 #define PWM_SERVO_7_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
329 #else
330 #define PWM_SERVO_7_ACTIVE PWM_OUTPUT_DISABLED
331 #endif
332 
333 // TODO PWM on AUX pins
334 
335 #ifdef STM32_PWM_USE_TIM3
336 #define PWM_CONF_TIM3 STM32_PWM_USE_TIM3
337 #else
338 #define PWM_CONF_TIM3 1
339 #endif
340 #define PWM_CONF3_DEF { \
341  PWM_FREQUENCY, \
342  PWM_FREQUENCY/TIM3_SERVO_HZ, \
343  NULL, \
344  { \
345  { PWM_SERVO_0_ACTIVE, NULL }, \
346  { PWM_SERVO_1_ACTIVE, NULL }, \
347  { PWM_SERVO_2_ACTIVE, NULL }, \
348  { PWM_SERVO_3_ACTIVE, NULL }, \
349  }, \
350  0, \
351  0 \
352 }
353 
354 #ifdef STM32_PWM_USE_TIM4
355 #define PWM_CONF_TIM4 STM32_PWM_USE_TIM4
356 #else
357 #define PWM_CONF_TIM4 1
358 #endif
359 #define PWM_CONF4_DEF { \
360  PWM_FREQUENCY, \
361  PWM_FREQUENCY/TIM4_SERVO_HZ, \
362  NULL, \
363  { \
364  { PWM_SERVO_4_ACTIVE, NULL }, \
365  { PWM_SERVO_5_ACTIVE, NULL }, \
366  { PWM_SERVO_6_ACTIVE, NULL }, \
367  { PWM_SERVO_7_ACTIVE, NULL }, \
368  }, \
369  0, \
370  0 \
371 }
372 
376 #define UART2_GPIO_PORT_TX GPIOD
377 #define UART2_GPIO_TX GPIO5
378 #define UART2_GPIO_PORT_RX GPIOD
379 #define UART2_GPIO_RX GPIO6
380 #define UART2_GPIO_AF 7
381 #ifndef UART2_HW_FLOW_CONTROL
382 #define UART2_HW_FLOW_CONTROL TRUE
383 #endif
384 
390 #define UART1_GPIO_PORT_TX GPIOB
391 #define UART1_GPIO_TX GPIO6
392 #define UART1_GPIO_PORT_RX GPIOB
393 #define UART1_GPIO_RX GPIO7
394 #define UART1_GPIO_AF 7
395 
396 #define UART3_GPIO_PORT_TX GPIOD
397 #define UART3_GPIO_TX GPIO8
398 #define UART3_GPIO_PORT_RX GPIOD
399 #define UART3_GPIO_RX GPIO9
400 #define UART3_GPIO_AF 7
401 
402 #define UART8_GPIO_PORT_TX GPIOE
403 #define UART8_GPIO_TX GPIO0
404 #define UART8_GPIO_PORT_RX GPIOE
405 #define UART8_GPIO_RX GPIO1
406 #define UART8_GPIO_AF 8
407 
420 // In case, do dynamic config of UARTs
421 #define USE_UART7_RX TRUE
422 #ifndef USE_UART7_TX // may be used in half duplex mode
423 #define USE_UART7_TX FALSE
424 #endif
425 #define UART7_GPIO_PORT_RX GPIOE
426 #define UART7_GPIO_RX GPIO7
427 #define UART7_GPIO_AF 8
428 
429 #define USE_UART4_RX TRUE
430 #define USE_UART4_TX FALSE
431 #define UART4_GPIO_PORT_RX GPIOA
432 #define UART4_GPIO_RX GPIO1
433 #define UART4_GPIO_AF 8
434 
435 /* The line that is pulled low at power up to initiate the bind process
436  * PC7: AUX7
437  */
438 #define SPEKTRUM_BIND_PIN GPIO7
439 #define SPEKTRUM_BIND_PIN_PORT GPIOC
440 
441 // no wait with chibios as the RTC oscillator takes longer to stabilize
442 #define SPEKTRUM_BIND_WAIT 30000
443 
449 #define RC_PPM_TICKS_PER_USEC 6
450 #define PPM_TIMER_FREQUENCY 6000000
451 #define PPM_CHANNEL ICU_CHANNEL_2
452 #define PPM_TIMER ICUD5
453 
454 /*
455  * PWM input
456  */
457 // PWM_INPUT 1 on PA0 (AUX3)
458 #define PWM_INPUT1_ICU ICUD2
459 #define PWM_INPUT1_CHANNEL ICU_CHANNEL_1
460 #define PWM_INPUT1_GPIO_PORT GPIOA
461 #define PWM_INPUT1_GPIO_PIN GPIO0
462 #define PWM_INPUT1_GPIO_AF GPIO_AF1
463 
464 // PWM_INPUT 2 on PC7 (AUX7)
465 #define PWM_INPUT2_ICU ICUD8
466 #define PWM_INPUT2_CHANNEL ICU_CHANNEL_2
467 #define PWM_INPUT2_GPIO_PORT GPIOC
468 #define PWM_INPUT2_GPIO_PIN GPIO7
469 #define PWM_INPUT2_GPIO_AF GPIO_AF3
470 
474 // Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
475 #define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
476 // Timing register
477 #define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
478  STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
479  STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
480 #define I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(1U) | \
481  STM32_TIMINGR_SCLDEL(9U) | STM32_TIMINGR_SDADEL(0U) | \
482  STM32_TIMINGR_SCLH(105U) | STM32_TIMINGR_SCLL(153U))
483 
484 
485 #ifndef I2C1_CLOCK_SPEED
486 #define I2C1_CLOCK_SPEED 400000
487 #endif
488 
489 #if I2C1_CLOCK_SPEED == 400000
490 #define I2C1_CFG_DEF { \
491  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
492  .cr1 = STM32_CR1_DNF(0), \
493  .cr2 = 0 \
494 }
495 #elif I2C1_CLOCK_SPEED == 100000
496 #define I2C1_CFG_DEF { \
497  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
498  .cr1 = STM32_CR1_DNF(0), \
499  .cr2 = 0 \
500 }
501 #else
502 #error "Unknown I2C1 clock speed"
503 #endif
504 
505 
506 #ifndef I2C2_CLOCK_SPEED
507 #define I2C2_CLOCK_SPEED 400000
508 #endif
509 
510 #if I2C2_CLOCK_SPEED == 400000
511 #define I2C2_CFG_DEF { \
512  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
513  .cr1 = STM32_CR1_DNF(0), \
514  .cr2 = 0 \
515 }
516 #elif I2C2_CLOCK_SPEED == 100000
517 #define I2C2_CFG_DEF { \
518  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
519  .cr1 = STM32_CR1_DNF(0), \
520  .cr2 = 0 \
521 }
522 #else
523 #error "Unknown I2C2 clock speed"
524 #endif
525 
529 #define SPI1_GPIO_AF GPIO_AF5
530 #define SPI1_GPIO_PORT_MISO GPIOB
531 #define SPI1_GPIO_MISO GPIO4
532 #define SPI1_GPIO_PORT_MOSI GPIOB
533 #define SPI1_GPIO_MOSI GPIO5
534 #define SPI1_GPIO_PORT_SCK GPIO3
535 #define SPI1_GPIO_SCK GPIO3
536 
537 // SLAVE0 on SPI connector
538 #define SPI_SELECT_SLAVE0_PORT GPIOA
539 #define SPI_SELECT_SLAVE0_PIN GPIO15
540 // SLAVE1 on AUX0
541 #define SPI_SELECT_SLAVE1_PORT GPIOA
542 #define SPI_SELECT_SLAVE1_PIN GPIO5
543 // SLAVE2 on AUX1
544 #define SPI_SELECT_SLAVE2_PORT GPIOA
545 #define SPI_SELECT_SLAVE2_PIN GPIO3
546 // SLAVE3 on AUX2
547 #define SPI_SELECT_SLAVE3_PORT GPIOA
548 #define SPI_SELECT_SLAVE3_PIN GPIO2
549 // SLAVE4 on AUX3
550 #define SPI_SELECT_SLAVE4_PORT GPIOA
551 #define SPI_SELECT_SLAVE4_PIN GPIO0
552 // SLAVE5 on AUX4
553 #define SPI_SELECT_SLAVE5_PORT GPIOC
554 #define SPI_SELECT_SLAVE5_PIN GPIO3
555 
562 #ifndef USE_BARO_BOARD
563 #define USE_BARO_BOARD 1
564 #endif
565 
569 #define SDIO_D0_PORT GPIOC
570 #define SDIO_D0_PIN GPIO8
571 #define SDIO_D1_PORT GPIOC
572 #define SDIO_D1_PIN GPIO9
573 #define SDIO_D2_PORT GPIOC
574 #define SDIO_D2_PIN GPIO10
575 #define SDIO_D3_PORT GPIOC
576 #define SDIO_D3_PIN GPIO11
577 #define SDIO_CK_PORT GPIOC
578 #define SDIO_CK_PIN GPIO12
579 #define SDIO_CMD_PORT GPIOD
580 #define SDIO_CMD_PIN GPIO2
581 #define SDIO_AF 12
582 // bat monitoring for file closing
583 #define SDLOG_BAT_ADC ADCD1
584 #define SDLOG_BAT_CHAN AD1_7_CHANNEL
585 // usb led status
586 #define SDLOG_USB_LED 4
587 #define SDLOG_USB_VBUS_PORT GPIOA
588 #define SDLOG_USB_VBUS_PIN GPIO9
589 
590 
591 /*
592  * Actuators for fixedwing
593  */
594  /* Default actuators driver */
595 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
596 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
597 #define ActuatorsDefaultInit() ActuatorsPwmInit()
598 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
599 
600 #endif /* CONFIG_CHIMERA_1_00_H */
601