Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
board.h
Go to the documentation of this file.
1 /*
2  ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef _BOARD_H_
18 #define _BOARD_H_
19 
20 /*
21  * Setup for STMicroelectronics STM32F1-Lia.
22  */
23 
24 /*
25  * Board identifier.
26  */
27 #define BOARD_LIA_STM32F105RC
28 #define BOARD_NAME "Lia 1.1 STM32F105RC"
29 
30 /*
31  * Board oscillators-related settings.
32  * NOTE: LSE not fitted.
33  */
34 #if !defined(STM32_LSECLK)
35 #define STM32_LSECLK 0
36 #endif
37 
38 #if !defined(STM32_HSECLK)
39 #define STM32_HSECLK 12000000
40 #endif
41 
42 
43 /*
44  * Board voltages.
45  * Required for performance limits calculation.
46  */
47 #define STM32_VDD 330
48 
49 /*
50  * MCU type as defined in the ST header file stm32f4xx.h.
51  */
52 #define STM32F105xC
53 
54 
55 /*
56  * I/O ports initial setup, this configuration is established soon after reset
57  * in the initialization code.
58  *
59  * The digits have the following meaning:
60  * 0 - Analog input.
61  * 1 - Push Pull output 10MHz.
62  * 2 - Push Pull output 2MHz.
63  * 3 - Push Pull output 50MHz.
64  * 4 - Digital input.
65  * 5 - Open Drain output 10MHz.
66  * 6 - Open Drain output 2MHz.
67  * 7 - Open Drain output 50MHz.
68  * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
69  * 9 - Alternate Push Pull output 10MHz.
70  * A - Alternate Push Pull output 2MHz.
71  * B - Alternate Push Pull output 50MHz.
72  * C - Reserved.
73  * D - Alternate Open Drain output 10MHz.
74  * E - Alternate Open Drain output 2MHz.
75  * F - Alternate Open Drain output 50MHz.
76  * Please refer to the STM32 Reference Manual for details.
77  */
78 
79 /*
80  * Port A setup.
81  * PA0 - 4 - Digital input (PPM_IN)
82  * - B - Alternate Push Pull output 50MHz (SERVO5)
83  * PA1 - B - Alternate Push Pull output 50MHz (SERVO6)
84  * PA2 - B - Alternate Push Pull output 50MHz (UART2_TX)
85  * PA3 - 4 - Digital input (UART2_RX)
86  * PA4 - B - Alternate Push Pull output 50MHz (EXTSPI_SS)
87  * PA5 - B - Alternate Push Pull output 50MHz (EXTSPI_SCK)
88  * PA6 - 4 - Digital input. (EXTSPI_MISO)
89  * PA7 - B - Alternate Push Pull output 50MHz (EXTSPI_MOSI)
90  * PA8 - 7 - Open Drain output 50MHz (LED1)
91  * PA9 - 4 - Digital input. (USB_VBUS)
92  * PA10 - 4 - Digital input. (UART1_RX)/(PPM_IN TIM2_CH2)
93  * PA11 - 4 - Digital input (USB_DM)
94  * PA12 - 4 - Digital input (USB_DP)
95  * PA13 - 4 - Digital input (JTAG_TMS)
96  * PA14 - 4 - Digital input (JTAG_TCK)
97  * PA15 - 4 - Digital input (JTAG_TDI)
98  */
99 #define VAL_GPIOACRL 0xB4BB4BBB /* PA7...PA0 */
100 #define VAL_GPIOACRH 0x44444447 /* PA15...PA8 */
101 #define VAL_GPIOAODR 0xFFFFFFFF
102 
103 /*
104  * Port B setup:
105  * PB0 - 4 - Digital input (BARO_DRDY)
106  * PB1 - 4 - Digital input (EXTSPI_DRDY)
107  * PB2 - 4 - Digital input (IMU_ACC_DRDY)
108  * PB3 - 4 - Digital input (JTAG_TDO)
109  * PB4 - 7 - Open Drain output 50MHz (LED2)
110  * PB5 - 4 - Digital input (IMU_MAG_DRDY)
111  * PB6 - B - Alternate Push Pull output 50MHz (SERVO7)
112  * - 7 - Open Drain output 50MHz. (I2C1_SCL)
113  * PB7 - B - Alternate Push Pull output 50MHz (SERVO8)
114  * - 7 - Open Drain output 50MHz. (I2C1_SDA)
115  * PB8 - 4 - Digital input. (CAN_RX)
116  * PB9 - 7 - Open Drain output 50MHz. (CAN_TX)
117  * PB10 - E - Alternate Open Drain output 2MHz.(I2C2_SCL)
118  * PB11 - E - Alternate Open Drain output 2MHz.(I2C2_SDA)
119  * PB12 - 3 - Push Pull output 50MHz. (IMU_ACC_CS)
120  * PB13 - B - Alternate Push Pull output 50MHz (IMU_SPI_SCK)
121  * PB14 - 4 - Digital input (IMU_SPI_MISO)
122  * PB15 - B - Alternate Push Pull output 50MHz (IMU_SPI_MOSI)
123  */
124 #define VAL_GPIOBCRL 0xBB474444 /* PB7...PB0 */
125 #define VAL_GPIOBCRH 0xB4B3EE74 /* PB15...PB8 */
126 #define VAL_GPIOBODR 0xFFFFFFFF
127 
128 /*
129  * Port C setup:
130  * PC0 - 0 - Analog input (ADC2)
131  * PC1 - 0 - Analog input (ADC3)
132  * PC2 - 7 - Open Drain output 50MHz (LED3)
133  * PC3 - 0 - Analog input (ADC1)
134  * PC4 - 0 - Analog input (VBAT_MEAS)
135  * PC5 - 7 - Open Drain output 50MHz (LED4)
136  * PC6 - B - Alternate Push Pull output 50MHz (SERVO1)
137  * PC7 - B - Alternate Push Pull output 50MHz (SERVO2)
138  * PC8 - B - Alternate Push Pull output 50MHz (SERVO3)
139  * PC9 - B - Alternate Push Pull output 50MHz (SERVO4)
140  * PC10 - B - Alternate Push Pull output 50MHz (UART3_TX)
141  * PC11 - 4 - Digital input (UART3_RX)
142  * PC12 - B - Alternate Push Pull output 50MHz (PC12-UART5_TX)
143  * PC13 - 3 - Push Pull output 50MHz. (IMU_GYRO_SS)
144  * PC14 - 4 - Digital input (IMU_GYRO_DRDY)
145  * PC15 - 7 - Open Drain output 50MHz (LED5)
146  */
147 #define VAL_GPIOCCRL 0xBB700700 /* PC7...PC0 */
148 #define VAL_GPIOCCRH 0x743B4BBB /* PC15...PC8 */
149 #define VAL_GPIOCODR 0xFFFFFFFF
150 
151 /*
152  * Port D setup:
153  * PD0 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (OSC_IN).
154  * PD1 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (OSC_OUT).
155  * PD2 - 4 - Digital input (UART5_RX).
156  * PD3 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
157  * PD4 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
158  * PD5 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
159  * PD6 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
160  * PD7 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
161  * PD8 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
162  * PD9 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
163  * PD10 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
164  * PD11 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
165  * PD12 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
166  * PD13 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
167  * PD14 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
168  * PD15 - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).
169  */
170 #define VAL_GPIODCRL 0x88888488 /* PD7...PD0 */
171 #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
172 #define VAL_GPIODODR 0xFFFFFFFF
173 
174 /*
175  * Port E setup.
176  * ALL - 8 - Digital input with PullUp or PullDown resistor depending on ODR. (unconnected).)
177  */
178 #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
179 #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
180 #define VAL_GPIOEODR 0xFFFFFFFF
181 
185 #define AFIO_MAPR_VAL (AFIO_MAPR_USART3_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG_NOJNTRST | AFIO_MAPR_TIM3_REMAP_FULLREMAP)
186 
187 /*
188  * AHB_CLK
189  */
190 #define AHB_CLK STM32_HCLK
191 
192 
193 /*
194  * LEDs
195  */
196 /* 1 red, on PA8 */
197 #ifndef USE_LED_1
198 #define USE_LED_1 1
199 #endif
200 #define LED_1_GPIO GPIOA
201 #define LED_1_GPIO_PIN 8
202 #define LED_1_GPIO_ON gpio_clear
203 #define LED_1_GPIO_OFF gpio_set
204 
205 /* 2 green, shared with JTAG_TRST */
206 #ifndef USE_LED_2
207 #define USE_LED_2 1
208 #endif
209 #define LED_2_GPIO GPIOB
210 #define LED_2_GPIO_PIN 4
211 #define LED_2_GPIO_ON gpio_clear
212 #define LED_2_GPIO_OFF gpio_set
213 
214 /* 3 green, shared with ADC12 (ADC_6 on connector ANALOG2) */
215 #ifndef USE_LED_3
216 #define USE_LED_3 1
217 #endif
218 #define LED_3_GPIO GPIOC
219 #define LED_3_GPIO_PIN 2
220 #define LED_3_GPIO_ON gpio_clear
221 #define LED_3_GPIO_OFF gpio_set
222 
223 /* 4 red, shared with ADC15 (ADC_4 on connector ANALOG2) */
224 #ifndef USE_LED_4
225 #define USE_LED_4 1
226 #endif
227 #define LED_4_GPIO GPIOC
228 #define LED_4_GPIO_PIN 5
229 #define LED_4_GPIO_ON gpio_clear
230 #define LED_4_GPIO_OFF gpio_set
231 
232 /* 5 green, on PC15 */
233 #ifndef USE_LED_5
234 #define USE_LED_5 0
235 #endif
236 #define LED_5_GPIO GPIOC
237 #define LED_5_GPIO_PIN 15
238 #define LED_5_GPIO_ON gpio_set
239 #define LED_5_GPIO_OFF gpio_clear
240 
241 /*
242  * ADCs
243  */
244 // AUX 1
245 #if USE_ADC_1
246 #define AD1_1_CHANNEL ADC_CHANNEL_IN13
247 #define ADC_1 AD1_1
248 #define ADC_1_GPIO_PORT GPIOC
249 #define ADC_1_GPIO_PIN GPIO3
250 #endif
251 
252 // AUX 2
253 #if USE_ADC_2
254 #define AD1_2_CHANNEL ADC_CHANNEL_IN10
255 #define ADC_2 AD1_2
256 #define ADC_2_GPIO_PORT GPIOC
257 #define ADC_2_GPIO_PIN GPIO0
258 #endif
259 
260 // AUX 3
261 #if USE_ADC_3
262 #define AD1_3_CHANNEL ADC_CHANNEL_IN11
263 #define ADC_3 AD1_3
264 #define ADC_3_GPIO_PORT GPIOC
265 #define ADC_3_GPIO_PIN GPIO1
266 #endif
267 
268 // Internal ADC for battery enabled by default
269 #ifndef USE_ADC_4
270 #define USE_ADC_4 1
271 #endif
272 #if USE_ADC_4
273 #define AD1_4_CHANNEL ADC_CHANNEL_IN14
274 #define ADC_4 AD1_4
275 #define ADC_4_GPIO_PORT GPIOC
276 #define ADC_4_GPIO_PIN GPIO4
277 #endif
278 
279 // Internal Temperature sensor enabled by default
280 #ifndef USE_ADC_5
281 #define USE_ADC_5 1
282 #define USE_ADC_SENSOR 1
283 #endif
284 #if USE_ADC_5
285 #define AD1_5_CHANNEL ADC_CHANNEL_SENSOR
286 #define ADC_5 AD1_5
287 #define ADC_5_GPIO_PORT GPIOC
288 #define ADC_5_GPIO_PIN GPIO4
289 #endif
290 
291 
292 
293 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
294 #ifndef ADC_CHANNEL_VSUPPLY
295 #define ADC_CHANNEL_VSUPPLY ADC_4
296 #endif
297 
298 #define DefaultVoltageOfAdc(adc) (0.004489*adc)
299 
300 /*
301  * PWM TIM defines
302  * enable TIM3 and TIM5 by default
303  */
304 #ifndef USE_PWM_TIM3
305 #define USE_PWM_TIM3 1
306 #endif
307 
308 #ifndef USE_PWM_TIM5
309 #define USE_PWM_TIM5 1
310 #endif
311 
312 /*
313  * PWM defines
314  */
315 #ifndef USE_PWM0
316 #define USE_PWM0 1
317 #endif
318 #if USE_PWM0
319 #define PWM_SERVO_0 0
320 #define PWM_SERVO_0_GPIO GPIOC
321 #define PWM_SERVO_0_PIN GPIO6
322 #define PWM_SERVO_0_AF GPIO_AF2
323 #define PWM_SERVO_0_DRIVER PWMD3
324 #define PWM_SERVO_0_CHANNEL 0
325 #define PWM_SERVO_0_CONF pwmcfg3
326 #endif
327 
328 #ifndef USE_PWM1
329 #define USE_PWM1 1
330 #endif
331 #if USE_PWM1
332 #define PWM_SERVO_1 1
333 #define PWM_SERVO_1_GPIO GPIOC
334 #define PWM_SERVO_1_PIN GPIO7
335 #define PWM_SERVO_1_AF GPIO_AF1
336 #define PWM_SERVO_1_DRIVER PWMD3
337 #define PWM_SERVO_1_CHANNEL 1
338 #define PWM_SERVO_1_CONF pwmcfg3
339 #endif
340 
341 #ifndef USE_PWM2
342 #define USE_PWM2 1
343 #endif
344 #if USE_PWM2
345 #define PWM_SERVO_2 2
346 #define PWM_SERVO_2_GPIO GPIOC
347 #define PWM_SERVO_2_PIN GPIO8
348 #define PWM_SERVO_2_AF GPIO_AF2
349 #define PWM_SERVO_2_DRIVER PWMD3
350 #define PWM_SERVO_2_CHANNEL 2
351 #define PWM_SERVO_2_CONF pwmcfg3
352 #endif
353 
354 #ifndef USE_PWM3
355 #define USE_PWM3 1
356 #endif
357 #if USE_PWM3
358 #define PWM_SERVO_3 3
359 #define PWM_SERVO_3_GPIO GPIOC
360 #define PWM_SERVO_3_PIN GPIO9
361 #define PWM_SERVO_3_AF GPIO_AF2
362 #define PWM_SERVO_3_DRIVER PWMD3
363 #define PWM_SERVO_3_CHANNEL 3
364 #define PWM_SERVO_3_CONF pwmcfg3
365 #endif
366 
367 #ifndef USE_PWM4
368 #define USE_PWM4 1
369 #endif
370 #if USE_PWM4
371 #define PWM_SERVO_4 4
372 #define PWM_SERVO_4_GPIO GPIOA
373 #define PWM_SERVO_4_PIN GPIO0
374 #define PWM_SERVO_4_AF GPIO_AF2
375 #define PWM_SERVO_4_DRIVER PWMD5
376 #define PWM_SERVO_4_CHANNEL 0
377 #define PWM_SERVO4_CONF pwmcfg5
378 #endif
379 
380 #ifndef USE_PWM5
381 #define USE_PWM5 1
382 #endif
383 #if USE_PWM5
384 #define PWM_SERVO_5 5
385 #define PWM_SERVO_5_GPIO GPIOA
386 #define PWM_SERVO_5_PIN GPIO1
387 #define PWM_SERVO_5_AF GPIO_AF2
388 #define PWM_SERVO_5_DRIVER PWMD5
389 #define PWM_SERVO_5_CHANNEL 1
390 #define PWM_SERVO_5_CONF pwmcfg5
391 #endif
392 
393 
394 #if USE_SERVOS_7AND8
395  #if USE_I2C1
396  #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
397  #else /* !USE_I2C1 */
398  #if USE_PWM6
399  #define PWM_SERVO_6 6
400  #define PWM_SERVO_6_GPIO GPIOB
401  #define PWM_SERVO_6_PIN GPIO6
402  #define PWM_SERVO_6_AF GPIO_AF2
403  #define PWM_SERVO_6_DRIVER PWMD4
404  #define PWM_SERVO_6_CHANNEL 0
405  #define PWM_SERVO_6_CONF pwmcfg4
406  #endif
407 
408  #if USE_PWM7
409  #define PWM_SERVO_7 7
410  #define PWM_SERVO_7_GPIO GPIOB
411  #define PWM_SERVO_7_PIN GPIO7
412  #define PWM_SERVO_7_AF GPIO_AF2
413  #define PWM_SERVO_7_DRIVER PWMD4
414  #define PWM_SERVO_7_CHANNEL 1
415  #define PWM_SERVO_7_CONF pwmcfg4
416  #endif
417  #endif /* USE_I2C1 */
418 #endif /* USE_SERVOS_7AND8 */
419 
420 
424 #define RC_PPM_TICKS_PER_USEC 6
425 #define PPM_TIMER_FREQUENCY 6000000
426 #define PPM_CHANNEL ICU_CHANNEL_1
427 #define PPM_TIMER ICUD1
428 
432 #define I2C1_CLOCK_SPEED 400000
433 #define I2C1_CFG_DEF { \
434  OPMODE_I2C, \
435  I2C1_CLOCK_SPEED, \
436  FAST_DUTY_CYCLE_2, \
437  }
438 
439 #define I2C2_CLOCK_SPEED 400000
440 #define I2C2_CFG_DEF { \
441  OPMODE_I2C, \
442  I2C2_CLOCK_SPEED, \
443  FAST_DUTY_CYCLE_2, \
444  }
445 
449 #define SPI_SELECT_SLAVE0_PORT GPIOA
450 #define SPI_SELECT_SLAVE0_PIN GPIO15
451 
452 #define SPI_SELECT_SLAVE1_PORT GPIOA
453 #define SPI_SELECT_SLAVE1_PIN GPIO4
454 
455 #define SPI_SELECT_SLAVE2_PORT GPIOB
456 #define SPI_SELECT_SLAVE2_PIN GPIO12
457 
458 #define SPI_SELECT_SLAVE3_PORT GPIOC
459 #define SPI_SELECT_SLAVE3_PIN GPIO13
460 
461 #define SPI_SELECT_SLAVE4_PORT GPIOC
462 #define SPI_SELECT_SLAVE4_PIN GPIO12
463 
464 #define SPI_SELECT_SLAVE5_PORT GPIOC
465 #define SPI_SELECT_SLAVE5_PIN GPIO4
466 
467 #define SPI1_GPIO_PORT_NSS GPIOA
468 #define SPI1_GPIO_NSS GPIO4
469 
470 #define SPI2_GPIO_PORT_NSS GPIOB
471 #define SPI2_GPIO_NSS GPIO12
472 
473 #define SPI3_GPIO_PORT_NSS GPIO
474 
481 #ifndef USE_BARO_BOARD
482 #define USE_BARO_BOARD 1
483 #endif
484 
485 /*
486  * Actuators for fixedwing
487  */
488  /* Default actuators driver */
489 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
490 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
491 #define ActuatorsDefaultInit() ActuatorsPwmInit()
492 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
493 
494 #if !defined(_FROM_ASM_)
495 #ifdef __cplusplus
496 extern "C" {
497 #endif
498  void boardInit(void);
499 #ifdef __cplusplus
500 }
501 #endif
502 #endif /* _FROM_ASM_ */
503 
504 #endif /* _BOARD_H_ */
void boardInit(void)
Board-specific initialization code.
Definition: board.c:312