Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 #else
255 #error "Unknown PPM config"
256 
257 #endif // PPM_CONFIG
258 
259 /*
260  * I2C
261  *
262  */
263 /* Servo1 & Servo2 */
264 #define I2C1_GPIO_PORT GPIOB
265 #define I2C1_GPIO_SCL GPIO6
266 #define I2C1_GPIO_SDA GPIO7
267 
268 /* GPS TX & RX */
269 #define I2C2_GPIO_PORT GPIOB
270 #define I2C2_GPIO_SCL GPIO10
271 #define I2C2_GPIO_SDA GPIO11
272 
273 /*
274  * PWM
275  *
276  */
277 #define PWM_USE_TIM4 1
278 #define PWM_USE_TIM5 1
279 
280 
281 #if USE_SERVOS_1AND2
282 #if USE_I2C1
283 #error "You cannot USE_SERVOS_1AND2 and USE_I2C1 at the same time"
284 #else
285 #define ACTUATORS_PWM_NB 6
286 #define USE_PWM1 1
287 #define USE_PWM2 1
288 #define PWM_USE_TIM4 1
289 #endif
290 #else
291 #define ACTUATORS_PWM_NB 4
292 #endif
293 
294 #define USE_PWM3 1
295 #define USE_PWM4 1
296 
297 //TODO : test that part
298 //TODO : merge the USE_SERVOS_1AND2 and DUAL_PWM_ON
299 #if DUAL_PWM_ON
300 #define DUAL_PWM_USE_TIM5 1
301 
302 #define USE_DUAL_PWM5 1
303 #define USE_DUAL_PWM6 1
304 #else
305 #define USE_PWM5 1
306 #define USE_PWM6 1
307 #endif
308 
309 // Servo numbering on LisaM silkscreen/docs starts with 1
310 
311 /* PWM_SERVO_x is the index of the servo in the actuators_pwm_values array */
312 /* Because PWM1 and 2 can be disabled we put them at the index 4 & 5 so that it
313  * is easy to disable.
314  */
315 #if USE_PWM1
316 #define PWM_SERVO_1 4
317 #define PWM_SERVO_1_TIMER TIM4
318 #define PWM_SERVO_1_GPIO GPIOB
319 #define PWM_SERVO_1_PIN GPIO6
320 #define PWM_SERVO_1_AF 0
321 #define PWM_SERVO_1_OC TIM_OC1
322 #define PWM_SERVO_1_OC_BIT (1<<0)
323 #else
324 #define PWM_SERVO_1_OC_BIT 0
325 #endif
326 
327 #if USE_PWM2
328 #define PWM_SERVO_2 5
329 #define PWM_SERVO_2_TIMER TIM4
330 #define PWM_SERVO_2_GPIO GPIOB
331 #define PWM_SERVO_2_PIN GPIO7
332 #define PWM_SERVO_2_AF 0
333 #define PWM_SERVO_2_OC TIM_OC2
334 #define PWM_SERVO_2_OC_BIT (1<<1)
335 #else
336 #define PWM_SERVO_2_OC_BIT 0
337 #endif
338 
339 #if USE_PWM3
340 #define PWM_SERVO_3 0
341 #define PWM_SERVO_3_TIMER TIM4
342 #define PWM_SERVO_3_GPIO GPIOB
343 #define PWM_SERVO_3_PIN GPIO8
344 #define PWM_SERVO_3_AF 0
345 #define PWM_SERVO_3_OC TIM_OC3
346 #define PWM_SERVO_3_OC_BIT (1<<2)
347 #else
348 #define PWM_SERVO_3_OC_BIT 0
349 #endif
350 
351 #if USE_PWM4
352 #define PWM_SERVO_4 1
353 #define PWM_SERVO_4_TIMER TIM4
354 #define PWM_SERVO_4_GPIO GPIOB
355 #define PWM_SERVO_4_PIN GPIO9
356 #define PWM_SERVO_4_AF 0
357 #define PWM_SERVO_4_OC TIM_OC4
358 #define PWM_SERVO_4_OC_BIT (1<<3)
359 #else
360 #define PWM_SERVO_4_OC_BIT 0
361 #endif
362 
363 #if USE_PWM5
364 #define PWM_SERVO_5 2
365 #define PWM_SERVO_5_TIMER TIM5
366 #define PWM_SERVO_5_GPIO GPIOA
367 #define PWM_SERVO_5_PIN GPIO0
368 #define PWM_SERVO_5_AF 0
369 #define PWM_SERVO_5_OC TIM_OC1
370 #define PWM_SERVO_5_OC_BIT (1<<0)
371 #elif USE_DUAL_PWM5
372 #define DUAL_PWM_SERVO_5_P1 0
373 #define DUAL_PWM_SERVO_5_P2 1
374 
375 #define DUAL_PWM_SERVO_5_TIMER TIM5
376 #define DUAL_PWM_SERVO_5_GPIO GPIOA
377 #define DUAL_PWM_SERVO_5_PIN GPIO0
378 #define DUAL_PWM_SERVO_5_AF 0
379 #define DUAL_PWM_SERVO_5_OC TIM_OC1
380 #define PWM_SERVO_5_OC_BIT (1<<0)
381 #else
382 #define PWM_SERVO_5_OC_BIT 0
383 #endif
384 
385 #if USE_PWM6
386 #define PWM_SERVO_6 3
387 #define PWM_SERVO_6_TIMER TIM5
388 #define PWM_SERVO_6_GPIO GPIOA
389 #define PWM_SERVO_6_PIN GPIO1
390 #define PWM_SERVO_6_AF 0
391 #define PWM_SERVO_6_OC TIM_OC2
392 #define PWM_SERVO_6_OC_BIT (1<<1)
393 #elif USE_DUAL_PWM6
394 #define DUAL_PWM_SERVO_6_P1 2
395 #define DUAL_PWM_SERVO_6_P2 3
396 
397 #define DUAL_PWM_SERVO_6_TIMER TIM5
398 #define DUAL_PWM_SERVO_6_GPIO GPIOA
399 #define DUAL_PWM_SERVO_6_PIN GPIO1
400 #define DUAL_PWM_SERVO_6_AF 0
401 #define DUAL_PWM_SERVO_6_OC TIM_OC2
402 #define PWM_SERVO_6_OC_BIT (1<<1)
403 #else
404 #define PWM_SERVO_6_OC_BIT 0
405 #endif
406 
407 
408 /* servos 1-4 or 3-4 on TIM4 depending on USE_SERVOS_1AND2 */
409 #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)
410 /* servos 5-6 on TIM5 */
411 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
412 
413 /* SuperbitRF mounted */
414 #define SUPERBITRF_SPI_DEV spi2
415 #define SUPERBITRF_RST_PORT GPIOC
416 #define SUPERBITRF_RST_PIN GPIO9
417 #define SUPERBITRF_DRDY_PORT GPIOC
418 #define SUPERBITRF_DRDY_PIN GPIO6
419 #define SUPERBITRF_FORCE_DSM2 FALSE
420 
421 #endif /* CONFIG_LISA_S_1_0_H */