Paparazzi UAS  v5.15_devel-61-g9c6bcf9
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lisa_s_1.0.h
Go to the documentation of this file.
1 #ifndef CONFIG_LISA_S_1_0_H
2 #define CONFIG_LISA_S_1_0_H
3 
4 #define BOARD_LISA_S
5 
6 /* Lisa/S has a 12MHz external clock and 72MHz internal. */
7 #define EXT_CLK 12000000
8 #define AHB_CLK 72000000
9 
10 /*
11  * Onboard LEDs
12  */
13 
14 /* red */
15 #ifndef USE_LED_1
16 #define USE_LED_1 1
17 #endif
18 #define LED_1_GPIO GPIOC
19 #define LED_1_GPIO_PIN GPIO10
20 #define LED_1_GPIO_ON gpio_clear
21 #define LED_1_GPIO_OFF gpio_set
22 #define LED_1_AFIO_REMAP ((void)0)
23 
24 /* orange */
25 #ifndef USE_LED_2
26 #define USE_LED_2 1
27 #endif
28 #define LED_2_GPIO GPIOC
29 #define LED_2_GPIO_PIN GPIO11
30 #define LED_2_GPIO_ON gpio_clear
31 #define LED_2_GPIO_OFF gpio_set
32 #define LED_2_AFIO_REMAP ((void)0)
33 
34 /* yellow */
35 #ifndef USE_LED_3
36 #define USE_LED_3 1
37 #endif
38 #define LED_3_GPIO GPIOD
39 #define LED_3_GPIO_PIN GPIO2
40 #define LED_3_GPIO_ON gpio_clear
41 #define LED_3_GPIO_OFF gpio_set
42 #define LED_3_AFIO_REMAP ((void)0)
43 
44 /*
45  * not actual LEDS, used as GPIOs
46  */
47 
48 /* PB1, DRDY on EXT SPI connector*/
49 #define LED_BODY_GPIO GPIOB
50 #define LED_BODY_GPIO_PIN GPIO1
51 #define LED_BODY_GPIO_ON gpio_set
52 #define LED_BODY_GPIO_OFF gpio_clear
53 #define LED_BODY_AFIO_REMAP ((void)0)
54 
55 /* PC12, on GPIO connector*/
56 #define LED_12_GPIO GPIOC
57 #define LED_12_GPIO_PIN GPIO12
58 #define LED_12_GPIO_ON gpio_clear
59 #define LED_12_GPIO_OFF gpio_set
60 #define LED_12_AFIO_REMAP ((void)0)
61 
62 
63 /* Default actuators driver */
64 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
65 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
66 #define ActuatorsDefaultInit() ActuatorsPwmInit()
67 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
68 
69 
70 /*
71  * ADC
72  */
73 
74 // Internal ADC for battery enabled by default
75 #ifndef USE_ADC_1
76 #define USE_ADC_1 1
77 #endif
78 #if USE_ADC_1
79 #define AD1_1_CHANNEL 2
80 #define ADC_1 AD1_1
81 #define ADC_1_GPIO_PORT GPIOA
82 #define ADC_1_GPIO_PIN GPIO2
83 #endif
84 
85 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
86 #ifndef ADC_CHANNEL_VSUPPLY
87 #define ADC_CHANNEL_VSUPPLY ADC_1
88 #endif
89 
90 #define DefaultVoltageOfAdc(adc) (0.0049*adc)
91 
92 
93 /* by default activate onboard baro */
94 #ifndef USE_BARO_BOARD
95 #define USE_BARO_BOARD 1
96 #endif
97 
98 /* SPI slave mapping */
99 
100 /* IMU_MPU_CS */
101 #define SPI_SELECT_SLAVE0_PORT GPIOA
102 #define SPI_SELECT_SLAVE0_PIN GPIO4
103 
104 /* IMU_BARO_CS */
105 #define SPI_SELECT_SLAVE1_PORT GPIOC
106 #define SPI_SELECT_SLAVE1_PIN GPIO4
107 
108 /* RADIO_SS */
109 #define SPI_SELECT_SLAVE2_PORT GPIOB
110 #define SPI_SELECT_SLAVE2_PIN GPIO12
111 
112 /*
113  * UART pin configuration
114  *
115  * sets on which pins the UARTs are connected
116  */
117 /* DIAG port */
118 #define UART1_GPIO_AF 0
119 #define UART1_GPIO_PORT_RX GPIO_BANK_USART1_RX
120 #define UART1_GPIO_RX GPIO_USART1_RX
121 #define UART1_GPIO_PORT_TX GPIO_BANK_USART1_TX
122 #define UART1_GPIO_TX GPIO_USART1_TX
123 
124 /* GPS */
125 #define UART3_GPIO_AF 0
126 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_RX
127 #define UART3_GPIO_RX GPIO_USART3_RX
128 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_TX
129 #define UART3_GPIO_TX GPIO_USART3_TX
130 
131 /* LED1 & LED2 */
132 /*
133 #define UART3_GPIO_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
134 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_PR_RX
135 #define UART3_GPIO_RX GPIO_USART3_PR_RX
136 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_PR_TX
137 #define UART3_GPIO_TX GPIO_USART3_PR_TX
138 */
139 
140 /*
141  * Spektrum
142  */
143 /* The line that is pulled low at power up to initiate the bind process */
144 #define SPEKTRUM_BIND_PIN GPIO2
145 #define SPEKTRUM_BIND_PIN_PORT GPIOB
146 
147 /* Diag Port RX */
148 #define SPEKTRUM_UART1_RCC RCC_USART1
149 #define SPEKTRUM_UART1_BANK GPIO_BANK_USART1_RX
150 #define SPEKTRUM_UART1_PIN GPIO_USART1_RX
151 #define SPEKTRUM_UART1_AF 0
152 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
153 #define SPEKTRUM_UART1_ISR usart1_isr
154 #define SPEKTRUM_UART1_DEV USART1
155 
156 /* AUX Radio RX */
157 #define SPEKTRUM_UART2_RCC RCC_USART2
158 #define SPEKTRUM_UART2_BANK GPIO_BANK_USART2_RX
159 #define SPEKTRUM_UART2_PIN GPIO_USART2_RX
160 #define SPEKTRUM_UART2_AF 0
161 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
162 #define SPEKTRUM_UART2_ISR usart2_isr
163 #define SPEKTRUM_UART2_DEV USART2
164 
165 /* LED2 */
166 #define SPEKTRUM_UART3_RCC RCC_USART3
167 #define SPEKTRUM_UART3_BANK GPIO_BANK_USART3_PR_RX
168 #define SPEKTRUM_UART3_PIN GPIO_USART3_PR_RX
169 #define SPEKTRUM_UART3_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
170 #define SPEKTRUM_UART3_IRQ NVIC_USART3_IRQ
171 #define SPEKTRUM_UART3_ISR usart3_isr
172 #define SPEKTRUM_UART3_DEV USART3
173 
174 /* LED3 */
175 #define SPEKTRUM_UART5_RCC RCC_UART5
176 #define SPEKTRUM_UART5_BANK GPIO_BANK_UART5_RX
177 #define SPEKTRUM_UART5_PIN GPIO_UART5_RX
178 #define SPEKTRUM_UART5_AF 0
179 #define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
180 #define SPEKTRUM_UART5_ISR uart5_isr
181 #define SPEKTRUM_UART5_DEV UART5
182 
183 /* PPM
184  */
185 
186 /*
187  * On Lisa/S there is no really dedicated port available. But we could use a
188  * bunch of different pins to do PPM Input.
189  */
190 
191 /*
192  * Default is PPM config 3, input on PA3 (Aux RX pin)
193  */
194 
195 #ifndef PPM_CONFIG
196 #define PPM_CONFIG 3
197 #endif
198 
199 
200 #if PPM_CONFIG == 1
201 /* input on PA01 (UART1_RX) Diag port */
202 #define USE_PPM_TIM1 1
203 #define PPM_CHANNEL TIM_IC3
204 #define PPM_TIMER_INPUT TIM_IC_IN_TI3
205 #define PPM_IRQ NVIC_TIM1_UP_IRQ
206 #define PPM_IRQ2 NVIC_TIM1_CC_IRQ
207 // Capture/Compare InteruptEnable and InterruptFlag
208 #define PPM_CC_IE TIM_DIER_CC3IE
209 #define PPM_CC_IF TIM_SR_CC3IF
210 #define PPM_GPIO_PORT GPIOA
211 #define PPM_GPIO_PIN GPIO10
212 #define PPM_GPIO_AF 0
213 
214 #elif PPM_CONFIG == 2
215 /* input on PA1 (Servo 6 pin)
216  On Lisa/S we could also use TIM5 IC2 instead. */
217 #define USE_PPM_TIM2 1
218 #define PPM_CHANNEL TIM_IC2
219 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
220 #define PPM_IRQ NVIC_TIM2_IRQ
221 // Capture/Compare InteruptEnable and InterruptFlag
222 #define PPM_CC_IE TIM_DIER_CC2IE
223 #define PPM_CC_IF TIM_SR_CC2IF
224 #define PPM_GPIO_PORT GPIOA
225 #define PPM_GPIO_PIN GPIO1
226 #define PPM_GPIO_AF 0
227 
228 // Move default ADC timer
229 #if USE_AD_TIM2
230 #undef USE_AD_TIM2
231 #endif
232 #define USE_AD_TIM1 1
233 
234 #elif PPM_CONFIG == 3
235 /* input on PA3 (Aux RX pin)
236  On Lisa/S we could also use TIM5 IC4 instead. */
237 #define USE_PPM_TIM2 1
238 #define PPM_CHANNEL TIM_IC4
239 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
240 #define PPM_IRQ NVIC_TIM2_IRQ
241 // Capture/Compare InteruptEnable and InterruptFlag
242 #define PPM_CC_IE TIM_DIER_CC4IE
243 #define PPM_CC_IF TIM_SR_CC4IF
244 #define PPM_GPIO_PORT GPIOA
245 #define PPM_GPIO_PIN GPIO3
246 #define PPM_GPIO_AF 0
247 
248 // Move default ADC timer
249 #if USE_AD_TIM2
250 #undef USE_AD_TIM2
251 #endif
252 #define USE_AD_TIM1 1
253 
254 #elif PPM_CONFIG == 4
255 /* Input on PC9 (SUPERBIT_RST) */
256 #define USE_PPM_TIM3 1
257 #define PPM_CHANNEL TIM_IC4
258 #define PPM_TIMER_INPUT TIM_IC_IN_TI4
259 #define PPM_IRQ NVIC_TIM3_IRQ
260 // Capture/Compare InteruptEnable and InterruptFlag
261 #define PPM_CC_IE TIM_DIER_CC4IE
262 #define PPM_CC_IF TIM_SR_CC4IF
263 #define PPM_GPIO_PORT GPIOC
264 #define PPM_GPIO_PIN GPIO9
265 #define PPM_GPIO_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
266 
267 #else
268 #error "Unknown PPM config"
269 
270 #endif // PPM_CONFIG
271 
272 /*
273  * I2C
274  *
275  */
276 /* Servo1 & Servo2 */
277 #define I2C1_GPIO_PORT GPIOB
278 #define I2C1_GPIO_SCL GPIO6
279 #define I2C1_GPIO_SDA GPIO7
280 
281 /* GPS TX & RX */
282 #define I2C2_GPIO_PORT GPIOB
283 #define I2C2_GPIO_SCL GPIO10
284 #define I2C2_GPIO_SDA GPIO11
285 
286 /*
287  * PWM
288  *
289  */
290 #define PWM_USE_TIM4 1
291 #define PWM_USE_TIM5 1
292 
293 
294 #if USE_SERVOS_1AND2
295 #if USE_I2C1
296 #error "You cannot USE_SERVOS_1AND2 and USE_I2C1 at the same time"
297 #else
298 #define ACTUATORS_PWM_NB 6
299 #define USE_PWM1 1
300 #define USE_PWM2 1
301 #define PWM_USE_TIM4 1
302 #endif
303 #else
304 #define ACTUATORS_PWM_NB 4
305 #endif
306 
307 #define USE_PWM3 1
308 #define USE_PWM4 1
309 
310 //TODO : test that part
311 //TODO : merge the USE_SERVOS_1AND2 and DUAL_PWM_ON
312 #if DUAL_PWM_ON
313 #define DUAL_PWM_USE_TIM5 1
314 
315 #define USE_DUAL_PWM5 1
316 #define USE_DUAL_PWM6 1
317 #else
318 #define USE_PWM5 1
319 #define USE_PWM6 1
320 #endif
321 
322 // Servo numbering on LisaM silkscreen/docs starts with 1
323 
324 /* PWM_SERVO_x is the index of the servo in the actuators_pwm_values array */
325 /* Because PWM1 and 2 can be disabled we put them at the index 4 & 5 so that it
326  * is easy to disable.
327  */
328 #if USE_PWM1
329 #define PWM_SERVO_1 4
330 #define PWM_SERVO_1_TIMER TIM4
331 #define PWM_SERVO_1_GPIO GPIOB
332 #define PWM_SERVO_1_PIN GPIO6
333 #define PWM_SERVO_1_AF 0
334 #define PWM_SERVO_1_OC TIM_OC1
335 #define PWM_SERVO_1_OC_BIT (1<<0)
336 #else
337 #define PWM_SERVO_1_OC_BIT 0
338 #endif
339 
340 #if USE_PWM2
341 #define PWM_SERVO_2 5
342 #define PWM_SERVO_2_TIMER TIM4
343 #define PWM_SERVO_2_GPIO GPIOB
344 #define PWM_SERVO_2_PIN GPIO7
345 #define PWM_SERVO_2_AF 0
346 #define PWM_SERVO_2_OC TIM_OC2
347 #define PWM_SERVO_2_OC_BIT (1<<1)
348 #else
349 #define PWM_SERVO_2_OC_BIT 0
350 #endif
351 
352 #if USE_PWM3
353 #define PWM_SERVO_3 0
354 #define PWM_SERVO_3_TIMER TIM4
355 #define PWM_SERVO_3_GPIO GPIOB
356 #define PWM_SERVO_3_PIN GPIO8
357 #define PWM_SERVO_3_AF 0
358 #define PWM_SERVO_3_OC TIM_OC3
359 #define PWM_SERVO_3_OC_BIT (1<<2)
360 #else
361 #define PWM_SERVO_3_OC_BIT 0
362 #endif
363 
364 #if USE_PWM4
365 #define PWM_SERVO_4 1
366 #define PWM_SERVO_4_TIMER TIM4
367 #define PWM_SERVO_4_GPIO GPIOB
368 #define PWM_SERVO_4_PIN GPIO9
369 #define PWM_SERVO_4_AF 0
370 #define PWM_SERVO_4_OC TIM_OC4
371 #define PWM_SERVO_4_OC_BIT (1<<3)
372 #else
373 #define PWM_SERVO_4_OC_BIT 0
374 #endif
375 
376 #if USE_PWM5
377 #define PWM_SERVO_5 2
378 #define PWM_SERVO_5_TIMER TIM5
379 #define PWM_SERVO_5_GPIO GPIOA
380 #define PWM_SERVO_5_PIN GPIO0
381 #define PWM_SERVO_5_AF 0
382 #define PWM_SERVO_5_OC TIM_OC1
383 #define PWM_SERVO_5_OC_BIT (1<<0)
384 #elif USE_DUAL_PWM5
385 #define DUAL_PWM_SERVO_5_P1 0
386 #define DUAL_PWM_SERVO_5_P2 1
387 
388 #define DUAL_PWM_SERVO_5_TIMER TIM5
389 #define DUAL_PWM_SERVO_5_GPIO GPIOA
390 #define DUAL_PWM_SERVO_5_PIN GPIO0
391 #define DUAL_PWM_SERVO_5_AF 0
392 #define DUAL_PWM_SERVO_5_OC TIM_OC1
393 #define PWM_SERVO_5_OC_BIT (1<<0)
394 #else
395 #define PWM_SERVO_5_OC_BIT 0
396 #endif
397 
398 #if USE_PWM6
399 #define PWM_SERVO_6 3
400 #define PWM_SERVO_6_TIMER TIM5
401 #define PWM_SERVO_6_GPIO GPIOA
402 #define PWM_SERVO_6_PIN GPIO1
403 #define PWM_SERVO_6_AF 0
404 #define PWM_SERVO_6_OC TIM_OC2
405 #define PWM_SERVO_6_OC_BIT (1<<1)
406 #elif USE_DUAL_PWM6
407 #define DUAL_PWM_SERVO_6_P1 2
408 #define DUAL_PWM_SERVO_6_P2 3
409 
410 #define DUAL_PWM_SERVO_6_TIMER TIM5
411 #define DUAL_PWM_SERVO_6_GPIO GPIOA
412 #define DUAL_PWM_SERVO_6_PIN GPIO1
413 #define DUAL_PWM_SERVO_6_AF 0
414 #define DUAL_PWM_SERVO_6_OC TIM_OC2
415 #define PWM_SERVO_6_OC_BIT (1<<1)
416 #else
417 #define PWM_SERVO_6_OC_BIT 0
418 #endif
419 
420 
421 /* servos 1-4 or 3-4 on TIM4 depending on USE_SERVOS_1AND2 */
422 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
423 /* servos 5-6 on TIM5 */
424 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
425 
426 /* SuperbitRF mounted */
427 #define SUPERBITRF_SPI_DEV spi2
428 #define SUPERBITRF_RST_PORT GPIOC
429 #define SUPERBITRF_RST_PIN GPIO9
430 #define SUPERBITRF_DRDY_PORT GPIOC
431 #define SUPERBITRF_DRDY_PIN GPIO6
432 #define SUPERBITRF_FORCE_DSM2 FALSE
433 
434 /*
435  * RPM sensor on Superbit IRQ pin using TIM8 Channel 1
436  */
437 #ifdef USE_PWM_INPUT1
438 #define PWM_INPUT1_GPIO_PORT GPIOC
439 #define PWM_INPUT1_GPIO_PIN GPIO6
440 #define PWM_INPUT1_GPIO_AF 0
441 
442 #define PWM_INPUT1_TIMER TIM8
443 #define PWM_INPUT1_CHANNEL_PERIOD TIM_IC1
444 #define PWM_INPUT1_CHANNEL_DUTY TIM_IC2
445 #define PWM_INPUT1_TIMER_INPUT TIM_IC_IN_TI1
446 #define PWM_INPUT1_SLAVE_TRIG TIM_SMCR_TS_TI1FP1
447 #define PWM_INPUT1_IRQ NVIC_TIM8_CC_IRQ
448 #define PWM_INPUT1_CC_IE (TIM_DIER_CC1IE | TIM_DIER_CC2IE)
449 #define USE_PWM_INPUT_TIM8 TRUE
450 
451 #ifdef PWM_INPUT1_TICKS_PER_USEC
452 #define TIM8_TICKS_PER_USEC PWM_INPUT1_TICKS_PER_USEC
453 #endif
454 #define TIM8_PWM_INPUT_IDX 0
455 #define TIM8_CC_IF_PERIOD TIM_SR_CC1IF
456 #define TIM8_CC_IF_DUTY TIM_SR_CC2IF
457 #define TIM8_CCR_PERIOD TIM8_CCR1
458 #define TIM8_CCR_DUTY TIM8_CCR2
459 #endif
460 
461 #endif /* CONFIG_LISA_S_1_0_H */