Paparazzi UAS  v6.2_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 defines
302  */
303 #ifndef USE_PWM0
304 #define USE_PWM0 1
305 #endif
306 #if USE_PWM0
307 #define PWM_SERVO_0 0
308 #define PWM_SERVO_0_GPIO GPIOC
309 #define PWM_SERVO_0_PIN GPIO6
310 #define PWM_SERVO_0_AF GPIO_AF2
311 #define PWM_SERVO_0_DRIVER PWMD3
312 #define PWM_SERVO_0_CHANNEL 0
313 #define PWM_SERVO_0_CONF pwmcfg3
314 #endif
315 
316 #ifndef USE_PWM1
317 #define USE_PWM1 1
318 #endif
319 #if USE_PWM1
320 #define PWM_SERVO_1 1
321 #define PWM_SERVO_1_GPIO GPIOC
322 #define PWM_SERVO_1_PIN GPIO7
323 #define PWM_SERVO_1_AF GPIO_AF1
324 #define PWM_SERVO_1_DRIVER PWMD3
325 #define PWM_SERVO_1_CHANNEL 1
326 #define PWM_SERVO_1_CONF pwmcfg3
327 #endif
328 
329 #ifndef USE_PWM2
330 #define USE_PWM2 1
331 #endif
332 #if USE_PWM2
333 #define PWM_SERVO_2 2
334 #define PWM_SERVO_2_GPIO GPIOC
335 #define PWM_SERVO_2_PIN GPIO8
336 #define PWM_SERVO_2_AF GPIO_AF2
337 #define PWM_SERVO_2_DRIVER PWMD3
338 #define PWM_SERVO_2_CHANNEL 2
339 #define PWM_SERVO_2_CONF pwmcfg3
340 #endif
341 
342 #ifndef USE_PWM3
343 #define USE_PWM3 1
344 #endif
345 #if USE_PWM3
346 #define PWM_SERVO_3 3
347 #define PWM_SERVO_3_GPIO GPIOC
348 #define PWM_SERVO_3_PIN GPIO9
349 #define PWM_SERVO_3_AF GPIO_AF2
350 #define PWM_SERVO_3_DRIVER PWMD3
351 #define PWM_SERVO_3_CHANNEL 3
352 #define PWM_SERVO_3_CONF pwmcfg3
353 #endif
354 
355 #ifndef USE_PWM4
356 #define USE_PWM4 1
357 #endif
358 #if USE_PWM4
359 #define PWM_SERVO_4 4
360 #define PWM_SERVO_4_GPIO GPIOA
361 #define PWM_SERVO_4_PIN GPIO0
362 #define PWM_SERVO_4_AF GPIO_AF2
363 #define PWM_SERVO_4_DRIVER PWMD5
364 #define PWM_SERVO_4_CHANNEL 0
365 #define PWM_SERVO4_CONF pwmcfg5
366 #endif
367 
368 #ifndef USE_PWM5
369 #define USE_PWM5 1
370 #endif
371 #if USE_PWM5
372 #define PWM_SERVO_5 5
373 #define PWM_SERVO_5_GPIO GPIOA
374 #define PWM_SERVO_5_PIN GPIO1
375 #define PWM_SERVO_5_AF GPIO_AF2
376 #define PWM_SERVO_5_DRIVER PWMD5
377 #define PWM_SERVO_5_CHANNEL 1
378 #define PWM_SERVO_5_CONF pwmcfg5
379 #endif
380 
381 
382 #if USE_SERVOS_7AND8
383  #if USE_I2C1
384  #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
385  #else /* !USE_I2C1 */
386  #if USE_PWM6
387  #define PWM_SERVO_6 6
388  #define PWM_SERVO_6_GPIO GPIOB
389  #define PWM_SERVO_6_PIN GPIO6
390  #define PWM_SERVO_6_AF GPIO_AF2
391  #define PWM_SERVO_6_DRIVER PWMD4
392  #define PWM_SERVO_6_CHANNEL 0
393  #define PWM_SERVO_6_CONF pwmcfg4
394  #endif
395 
396  #if USE_PWM7
397  #define PWM_SERVO_7 7
398  #define PWM_SERVO_7_GPIO GPIOB
399  #define PWM_SERVO_7_PIN GPIO7
400  #define PWM_SERVO_7_AF GPIO_AF2
401  #define PWM_SERVO_7_DRIVER PWMD4
402  #define PWM_SERVO_7_CHANNEL 1
403  #define PWM_SERVO_7_CONF pwmcfg4
404  #endif
405  #endif /* USE_I2C1 */
406 #endif /* USE_SERVOS_7AND8 */
407 
408 
412 #define RC_PPM_TICKS_PER_USEC 6
413 #define PPM_TIMER_FREQUENCY 6000000
414 #define PPM_CHANNEL ICU_CHANNEL_1
415 #define PPM_TIMER ICUD1
416 
420 #define I2C1_CLOCK_SPEED 400000
421 #define I2C1_CFG_DEF { \
422  OPMODE_I2C, \
423  I2C1_CLOCK_SPEED, \
424  FAST_DUTY_CYCLE_2, \
425  }
426 
427 #define I2C2_CLOCK_SPEED 400000
428 #define I2C2_CFG_DEF { \
429  OPMODE_I2C, \
430  I2C2_CLOCK_SPEED, \
431  FAST_DUTY_CYCLE_2, \
432  }
433 
437 #define SPI_SELECT_SLAVE0_PORT GPIOA
438 #define SPI_SELECT_SLAVE0_PIN GPIO15
439 
440 #define SPI_SELECT_SLAVE1_PORT GPIOA
441 #define SPI_SELECT_SLAVE1_PIN GPIO4
442 
443 #define SPI_SELECT_SLAVE2_PORT GPIOB
444 #define SPI_SELECT_SLAVE2_PIN GPIO12
445 
446 #define SPI_SELECT_SLAVE3_PORT GPIOC
447 #define SPI_SELECT_SLAVE3_PIN GPIO13
448 
449 #define SPI_SELECT_SLAVE4_PORT GPIOC
450 #define SPI_SELECT_SLAVE4_PIN GPIO12
451 
452 #define SPI_SELECT_SLAVE5_PORT GPIOC
453 #define SPI_SELECT_SLAVE5_PIN GPIO4
454 
455 #define SPI1_GPIO_PORT_NSS GPIOA
456 #define SPI1_GPIO_NSS GPIO4
457 
458 #define SPI2_GPIO_PORT_NSS GPIOB
459 #define SPI2_GPIO_NSS GPIO12
460 
461 #define SPI3_GPIO_PORT_NSS GPIO
462 
469 #ifndef USE_BARO_BOARD
470 #define USE_BARO_BOARD 1
471 #endif
472 
473 /*
474  * Actuators for fixedwing
475  */
476  /* Default actuators driver */
477 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
478 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
479 #define ActuatorsDefaultInit() ActuatorsPwmInit()
480 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
481 
482 #if !defined(_FROM_ASM_)
483 #ifdef __cplusplus
484 extern "C" {
485 #endif
486  void boardInit(void);
487 #ifdef __cplusplus
488 }
489 #endif
490 #endif /* _FROM_ASM_ */
491 
492 #endif /* _BOARD_H_ */
boardInit
void boardInit(void)
Board-specific initialization code.
Definition: board.c:312