Paparazzi UAS  v5.12_stable-4-g9b43e9b
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 
397 // In case, do dynamic config of UARTs
398 #define USE_UART7_RX TRUE
399 #ifndef USE_UART7_TX // may be used in half duplex mode
400 #define USE_UART7_TX FALSE
401 #endif
402 #define UART7_GPIO_PORT_RX GPIOE
403 #define UART7_GPIO_RX GPIO7
404 #define UART7_GPIO_AF 8
405 
406 #define USE_UART4_RX TRUE
407 #define USE_UART4_TX FALSE
408 #define UART4_GPIO_PORT_RX GPIOE
409 #define UART4_GPIO_RX GPIO7
410 #define UART4_GPIO_AF 8
411 
412 /*
413  * Spektrum
414  *
415  * Not supported yet in chibios arch
416  * Only here for future reference
417  *
418  * primary Spektrum port is UART4, a.k.a. RC1 on Chimera board
419  * secondary port is UART7, a.k.a. RC2 on Chimera board
420  */
421 /* The line that is pulled low at power up to initiate the bind process */
422 /* These are not common between versions of lisa/mx and thus defined in the
423  * version specific header files. */
424 #define SPEKTRUM_UART4_BANK UART4_GPIO_PORT_RX
425 #define SPEKTRUM_UART4_PIN UART4_GPIO_RX
426 #define SPEKTRUM_UART4_AF UART4_GPIO_AF
427 #define SPEKTRUM_UART4_DEV SD4
428 
429 #define SPEKTRUM_UART7_BANK UART7_GPIO_PORT_RX
430 #define SPEKTRUM_UART7_PIN UART7_GPIO_RX
431 #define SPEKTRUM_UART7_AF UART7_GPIO_AF
432 #define SPEKTRUM_UART7_DEV SD7
433 
439 #define RC_PPM_TICKS_PER_USEC 6
440 #define PPM_TIMER_FREQUENCY 6000000
441 #define PPM_CHANNEL ICU_CHANNEL_2
442 #define PPM_TIMER ICUD5
443 
444 /*
445  * PWM input
446  */
447 // PWM_INPUT 1 on PA0 (AUX3)
448 #define PWM_INPUT1_ICU ICUD2
449 #define PWM_INPUT1_CHANNEL ICU_CHANNEL_1
450 #define PWM_INPUT1_GPIO_PORT GPIOA
451 #define PWM_INPUT1_GPIO_PIN GPIO0
452 #define PWM_INPUT1_GPIO_AF GPIO_AF1
453 
454 // PWM_INPUT 2 on PC7 (AUX7)
455 #define PWM_INPUT2_ICU ICUD8
456 #define PWM_INPUT2_CHANNEL ICU_CHANNEL_2
457 #define PWM_INPUT2_GPIO_PORT GPIOC
458 #define PWM_INPUT2_GPIO_PIN GPIO7
459 #define PWM_INPUT2_GPIO_AF GPIO_AF3
460 
464 // Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
465 #define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
466 // Timing register
467 #define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
468  STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
469  STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
470 
471 #define I2C1_CLOCK_SPEED 400000
472 #define I2C1_CFG_DEF { \
473  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
474  .cr1 = STM32_CR1_DNF(0), \
475  .cr2 = 0 \
476 }
477 
478 #define I2C2_CLOCK_SPEED 400000
479 #define I2C2_CFG_DEF { \
480  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
481  .cr1 = STM32_CR1_DNF(0), \
482  .cr2 = 0 \
483 }
484 
488 #define SPI1_GPIO_AF GPIO_AF5
489 #define SPI1_GPIO_PORT_MISO GPIOB
490 #define SPI1_GPIO_MISO GPIO4
491 #define SPI1_GPIO_PORT_MOSI GPIOB
492 #define SPI1_GPIO_MOSI GPIO5
493 #define SPI1_GPIO_PORT_SCK GPIO3
494 #define SPI1_GPIO_SCK GPIO3
495 
496 // SLAVE0 on SPI connector
497 #define SPI_SELECT_SLAVE0_PORT GPIOA
498 #define SPI_SELECT_SLAVE0_PIN GPIO15
499 // SLAVE1 on AUX0
500 #define SPI_SELECT_SLAVE1_PORT GPIOA
501 #define SPI_SELECT_SLAVE1_PIN GPIO5
502 // SLAVE2 on AUX1
503 #define SPI_SELECT_SLAVE2_PORT GPIOA
504 #define SPI_SELECT_SLAVE2_PIN GPIO3
505 // SLAVE3 on AUX2
506 #define SPI_SELECT_SLAVE3_PORT GPIOA
507 #define SPI_SELECT_SLAVE3_PIN GPIO2
508 // SLAVE4 on AUX3
509 #define SPI_SELECT_SLAVE4_PORT GPIOA
510 #define SPI_SELECT_SLAVE4_PIN GPIO0
511 // SLAVE5 on AUX4
512 #define SPI_SELECT_SLAVE5_PORT GPIOC
513 #define SPI_SELECT_SLAVE5_PIN GPIO3
514 
521 #ifndef USE_BARO_BOARD
522 #define USE_BARO_BOARD 1
523 #endif
524 
528 #define SDIO_D0_PORT GPIOC
529 #define SDIO_D0_PIN GPIO8
530 #define SDIO_D1_PORT GPIOC
531 #define SDIO_D1_PIN GPIO9
532 #define SDIO_D2_PORT GPIOC
533 #define SDIO_D2_PIN GPIO10
534 #define SDIO_D3_PORT GPIOC
535 #define SDIO_D3_PIN GPIO11
536 #define SDIO_CK_PORT GPIOC
537 #define SDIO_CK_PIN GPIO12
538 #define SDIO_CMD_PORT GPIOD
539 #define SDIO_CMD_PIN GPIO2
540 #define SDIO_AF 12
541 // bat monitoring for file closing
542 #define SDLOG_BAT_ADC ADCD1
543 #define SDLOG_BAT_CHAN AD1_7_CHANNEL
544 // usb led status
545 #define SDLOG_USB_LED 4
546 #define SDLOG_USB_VBUS_PORT GPIOA
547 #define SDLOG_USB_VBUS_PIN GPIO9
548 
549 
550 /*
551  * Actuators for fixedwing
552  */
553  /* Default actuators driver */
554 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
555 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
556 #define ActuatorsDefaultInit() ActuatorsPwmInit()
557 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
558 
559 #endif /* CONFIG_CHIMERA_1_00_H */
560