Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lisa_m_common.h
Go to the documentation of this file.
1 #ifndef CONFIG_LISA_M_COMMON_H
2 #define CONFIG_LISA_M_COMMON_H
3 
4 /* SPI slave mapping */
5 
6 #define SPI_SELECT_SLAVE0_PORT GPIOA
7 #define SPI_SELECT_SLAVE0_PIN GPIO15
8 
9 #define SPI_SELECT_SLAVE1_PORT GPIOA
10 #define SPI_SELECT_SLAVE1_PIN GPIO4
11 
12 #define SPI_SELECT_SLAVE2_PORT GPIOB
13 #define SPI_SELECT_SLAVE2_PIN GPIO12
14 
15 #define SPI_SELECT_SLAVE3_PORT GPIOC
16 #define SPI_SELECT_SLAVE3_PIN GPIO13
17 
18 #define SPI_SELECT_SLAVE4_PORT GPIOC
19 #define SPI_SELECT_SLAVE4_PIN GPIO12
20 
21 #define SPI_SELECT_SLAVE5_PORT GPIOC
22 #define SPI_SELECT_SLAVE5_PIN GPIO4
23 
24 
25 
26 /*
27  * UART pin configuration
28  *
29  * sets on which pins the UARTs are connected
30  */
31 #define UART1_GPIO_AF 0
32 #define UART1_GPIO_PORT_RX GPIO_BANK_USART1_RX
33 #define UART1_GPIO_RX GPIO_USART1_RX
34 #define UART1_GPIO_PORT_TX GPIO_BANK_USART1_TX
35 #define UART1_GPIO_TX GPIO_USART1_TX
36 
37 #define UART2_GPIO_AF 0
38 #define UART2_GPIO_PORT_RX GPIO_BANK_USART2_RX
39 #define UART2_GPIO_RX GPIO_USART2_RX
40 #define UART2_GPIO_PORT_TX GPIO_BANK_USART2_TX
41 #define UART2_GPIO_TX GPIO_USART2_TX
42 
43 #if REMAP_UART3 // For UART4 we need to remap UART 3
44 #define UART3_GPIO_AF 0
45 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_RX
46 #define UART3_GPIO_RX GPIO_USART3_RX
47 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_TX
48 #define UART3_GPIO_TX GPIO_USART3_TX
49 
50 #define UART4_GPIO_AF 0
51 #define UART4_GPIO_PORT_RX GPIOC
52 #define UART4_GPIO_RX GPIO10
53 #define UART4_GPIO_PORT_TX GPIOC
54 #define UART4_GPIO_TX GPIO11
55 
56 #else
57 #define UART3_GPIO_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
58 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_PR_RX
59 #define UART3_GPIO_RX GPIO_USART3_PR_RX
60 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_PR_TX
61 #define UART3_GPIO_TX GPIO_USART3_PR_TX
62 #endif
63 
64 #define UART5_GPIO_AF 0
65 #define UART5_GPIO_PORT_RX GPIO_BANK_UART5_RX
66 #define UART5_GPIO_RX GPIO_UART5_RX
67 #define UART5_GPIO_PORT_TX GPIO_BANK_UART5_TX
68 #define UART5_GPIO_TX GPIO_UART5_TX
69 
70 
71 /*
72  * Spektrum
73  */
74 /* The line that is pulled low at power up to initiate the bind process */
75 /* It was common for all Lisa/M up to version 2.1. */
76 /* #define SPEKTRUM_BIND_PIN GPIO3 */
77 /* #define SPEKTRUM_BIND_PIN_PORT GPIOC */
78 
79 #define SPEKTRUM_UART1_RCC RCC_USART1
80 #define SPEKTRUM_UART1_BANK GPIO_BANK_USART1_RX
81 #define SPEKTRUM_UART1_PIN GPIO_USART1_RX
82 #define SPEKTRUM_UART1_AF 0
83 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
84 #define SPEKTRUM_UART1_ISR usart1_isr
85 #define SPEKTRUM_UART1_DEV USART1
86 
87 #define SPEKTRUM_UART3_RCC RCC_USART3
88 #define SPEKTRUM_UART3_BANK GPIO_BANK_USART3_PR_RX
89 #define SPEKTRUM_UART3_PIN GPIO_USART3_PR_RX
90 #define SPEKTRUM_UART3_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
91 #define SPEKTRUM_UART3_IRQ NVIC_USART3_IRQ
92 #define SPEKTRUM_UART3_ISR usart3_isr
93 #define SPEKTRUM_UART3_DEV USART3
94 
95 #define SPEKTRUM_UART5_RCC RCC_UART5
96 #define SPEKTRUM_UART5_BANK GPIO_BANK_UART5_RX
97 #define SPEKTRUM_UART5_PIN GPIO_UART5_RX
98 #define SPEKTRUM_UART5_AF 0
99 #define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
100 #define SPEKTRUM_UART5_ISR uart5_isr
101 #define SPEKTRUM_UART5_DEV UART5
102 
103 
104 /* PPM
105  *
106  * Default is PPM config 2, input on GPIO01 (Servo pin 6)
107  */
108 
109 #ifndef PPM_CONFIG
110 #define PPM_CONFIG 2
111 #endif
112 
113 #if PPM_CONFIG == 1
114 /* input on PA01 (UART1_RX) */
115 #define USE_PPM_TIM1 1
116 #define PPM_CHANNEL TIM_IC3
117 #define PPM_TIMER_INPUT TIM_IC_IN_TI3
118 #define PPM_IRQ NVIC_TIM1_UP_IRQ
119 #define PPM_IRQ2 NVIC_TIM1_CC_IRQ
120 // Capture/Compare InteruptEnable and InterruptFlag
121 #define PPM_CC_IE TIM_DIER_CC3IE
122 #define PPM_CC_IF TIM_SR_CC3IF
123 #define PPM_GPIO_PORT GPIOA
124 #define PPM_GPIO_PIN GPIO10
125 #define PPM_GPIO_AF 0
126 
127 #elif PPM_CONFIG == 2
128 /* input on PA10 (Servo 6 pin) */
129 #define USE_PPM_TIM2 1
130 #define PPM_CHANNEL TIM_IC2
131 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
132 #define PPM_IRQ NVIC_TIM2_IRQ
133 // Capture/Compare InteruptEnable and InterruptFlag
134 #define PPM_CC_IE TIM_DIER_CC2IE
135 #define PPM_CC_IF TIM_SR_CC2IF
136 #define PPM_GPIO_PORT GPIOA
137 #define PPM_GPIO_PIN GPIO1
138 #define PPM_GPIO_AF 0
139 
140 // Move default ADC timer
141 #if USE_AD_TIM2
142 #undef USE_AD_TIM2
143 #endif
144 #define USE_AD_TIM1 1
145 
146 #else
147 #error "Unknown PPM config"
148 
149 #endif // PPM_CONFIG
150 
151 /*
152  * ADC
153  */
154 
155 /* Onboard ADCs */
156 /*
157  ADC1 PC3/ADC13
158  ADC2 PC0/ADC10
159  ADC3 PC1/ADC11
160  ADC4 PC5/ADC15
161  ADC6 PC2/ADC12
162  BATT PC4/ADC14 (ADC5)
163 */
164 
165 /* provide defines that can be used to access the ADC_x in the code or airframe file
166  * these directly map to the index number of the 4 adc channels defined above
167  * 4th (index 3) is used for bat monitoring by default
168  */
169 #if USE_ADC_1
170 #define AD1_1_CHANNEL 13
171 #define ADC_1 AD1_1
172 #define ADC_1_GPIO_PORT GPIOC
173 #define ADC_1_GPIO_PIN GPIO3
174 #endif
175 
176 #if USE_ADC_2
177 #define AD1_2_CHANNEL 10
178 #define ADC_2 AD1_2
179 #define ADC_2_GPIO_PORT GPIOC
180 #define ADC_2_GPIO_PIN GPIO0
181 #endif
182 
183 #if USE_ADC_3
184 #define AD1_3_CHANNEL 11
185 #define ADC_3 AD1_3
186 #define ADC_3_GPIO_PORT GPIOC
187 #define ADC_3_GPIO_PIN GPIO1
188 #endif
189 
190 #if USE_ADC_4
191 #define AD2_1_CHANNEL 15
192 #define ADC_4 AD2_1
193 #define ADC_4_GPIO_PORT GPIOC
194 #define ADC_4_GPIO_PIN GPIO5
195 #endif
196 
197 // Internal ADC for battery enabled by default
198 #ifndef USE_ADC_5
199 #define USE_ADC_5 1
200 #endif
201 #if USE_ADC_5
202 #define AD1_4_CHANNEL 14
203 #define ADC_5 AD1_4
204 #define ADC_5_GPIO_PORT GPIOC
205 #define ADC_5_GPIO_PIN GPIO4
206 #endif
207 
208 #if USE_ADC_6
209 #define AD2_2_CHANNEL 12
210 #define ADC_6 AD2_2
211 #define ADC_6_GPIO_PORT GPIOC
212 #define ADC_6_GPIO_PIN GPIO2
213 #endif
214 
215 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
216 #ifndef ADC_CHANNEL_VSUPPLY
217 #define ADC_CHANNEL_VSUPPLY ADC_5
218 #endif
219 
220 /*
221  * I2C
222  *
223  */
224 #define I2C1_GPIO_PORT GPIOB
225 #define I2C1_GPIO_SCL GPIO6
226 #define I2C1_GPIO_SDA GPIO7
227 
228 #define I2C2_GPIO_PORT GPIOB
229 #define I2C2_GPIO_SCL GPIO10
230 #define I2C2_GPIO_SDA GPIO11
231 
232 
233 /*
234  * PWM
235  *
236  */
237 #define PWM_USE_TIM3 1
238 #define PWM_USE_TIM5 1
239 
240 #define USE_PWM1 1
241 #define USE_PWM2 1
242 #define USE_PWM3 1
243 #define USE_PWM4 1
244 
245 #if DUAL_PWM_ON
246 #define DUAL_PWM_USE_TIM5 1
247 
248 #define USE_DUAL_PWM5 1
249 #define USE_DUAL_PWM6 1
250 #else
251 #define USE_PWM5 1
252 #define USE_PWM6 1
253 #endif
254 
255 
256 
257 #if USE_SERVOS_7AND8
258 #if USE_I2C1
259 #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
260 #else
261 #define ACTUATORS_PWM_NB 8
262 #define USE_PWM7 1
263 #define USE_PWM8 1
264 #define PWM_USE_TIM4 1
265 #endif
266 #else
267 #define ACTUATORS_PWM_NB 6
268 #endif
269 
270 // Servo numbering on LisaM silkscreen/docs starts with 1
271 
272 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
273 #if USE_PWM1
274 #define PWM_SERVO_1 0
275 #define PWM_SERVO_1_TIMER TIM3
276 #define PWM_SERVO_1_GPIO GPIOC
277 #define PWM_SERVO_1_PIN GPIO6
278 #define PWM_SERVO_1_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
279 #define PWM_SERVO_1_OC TIM_OC1
280 #define PWM_SERVO_1_OC_BIT (1<<0)
281 #else
282 #define PWM_SERVO_1_OC_BIT 0
283 #endif
284 
285 #if USE_PWM2
286 #define PWM_SERVO_2 1
287 #define PWM_SERVO_2_TIMER TIM3
288 #define PWM_SERVO_2_GPIO GPIOC
289 #define PWM_SERVO_2_PIN GPIO7
290 #define PWM_SERVO_2_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
291 #define PWM_SERVO_2_OC TIM_OC2
292 #define PWM_SERVO_2_OC_BIT (1<<1)
293 #else
294 #define PWM_SERVO_2_OC_BIT 0
295 #endif
296 
297 #if USE_PWM3
298 #define PWM_SERVO_3 2
299 #define PWM_SERVO_3_TIMER TIM3
300 #define PWM_SERVO_3_GPIO GPIOC
301 #define PWM_SERVO_3_PIN GPIO8
302 #define PWM_SERVO_3_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
303 #define PWM_SERVO_3_OC TIM_OC3
304 #define PWM_SERVO_3_OC_BIT (1<<2)
305 #else
306 #define PWM_SERVO_3_OC_BIT 0
307 #endif
308 
309 #if USE_PWM4
310 #define PWM_SERVO_4 3
311 #define PWM_SERVO_4_TIMER TIM3
312 #define PWM_SERVO_4_GPIO GPIOC
313 #define PWM_SERVO_4_PIN GPIO9
314 #define PWM_SERVO_4_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
315 #define PWM_SERVO_4_OC TIM_OC4
316 #define PWM_SERVO_4_OC_BIT (1<<3)
317 #else
318 #define PWM_SERVO_4_OC_BIT 0
319 #endif
320 
321 #if USE_PWM5
322 #define PWM_SERVO_5 4
323 #define PWM_SERVO_5_TIMER TIM5
324 #define PWM_SERVO_5_GPIO GPIOA
325 #define PWM_SERVO_5_PIN GPIO0
326 #define PWM_SERVO_5_AF 0
327 #define PWM_SERVO_5_OC TIM_OC1
328 #define PWM_SERVO_5_OC_BIT (1<<0)
329 #elif USE_DUAL_PWM5
330 #define DUAL_PWM_SERVO_5 4
331 
332 #define DUAL_PWM_SERVO_5_P1 0
333 #define DUAL_PWM_SERVO_5_P2 1
334 
335 #define DUAL_PWM_SERVO_5_TIMER TIM5
336 #define DUAL_PWM_SERVO_5_GPIO GPIOA
337 #define DUAL_PWM_SERVO_5_PIN GPIO0
338 #define DUAL_PWM_SERVO_5_AF 0
339 #define DUAL_PWM_SERVO_5_OC TIM_OC1
340 #define PWM_SERVO_5_OC_BIT (1<<0)
341 #else
342 #define PWM_SERVO_5_OC_BIT 0
343 #endif
344 
345 #if USE_PWM6
346 #define PWM_SERVO_6 5
347 #define PWM_SERVO_6_TIMER TIM5
348 #define PWM_SERVO_6_GPIO GPIOA
349 #define PWM_SERVO_6_PIN GPIO1
350 #define PWM_SERVO_6_AF 0
351 #define PWM_SERVO_6_OC TIM_OC2
352 #define PWM_SERVO_6_OC_BIT (1<<1)
353 #elif USE_DUAL_PWM6
354 #define DUAL_PWM_SERVO_6 5
355 
356 #define DUAL_PWM_SERVO_6_P1 0
357 #define DUAL_PWM_SERVO_6_P2 1
358 
359 #define DUAL_PWM_SERVO_6_TIMER TIM5
360 #define DUAL_PWM_SERVO_6_GPIO GPIOA
361 #define DUAL_PWM_SERVO_6_PIN GPIO1
362 #define DUAL_PWM_SERVO_6_AF 0
363 #define DUAL_PWM_SERVO_6_OC TIM_OC2
364 #define PWM_SERVO_6_OC_BIT (1<<1)
365 #else
366 #define PWM_SERVO_6_OC_BIT 0
367 #endif
368 
369 
370 
371 
372 
373 
374 #if USE_PWM7
375 #define PWM_SERVO_7 6
376 #define PWM_SERVO_7_TIMER TIM4
377 #define PWM_SERVO_7_GPIO GPIOB
378 #define PWM_SERVO_7_PIN GPIO6
379 #define PWM_SERVO_7_AF 0
380 #define PWM_SERVO_7_OC TIM_OC1
381 #define PWM_SERVO_7_OC_BIT (1<<0)
382 #else
383 #define PWM_SERVO_7_OC_BIT 0
384 #endif
385 
386 #if USE_PWM8
387 #define PWM_SERVO_8 7
388 #define PWM_SERVO_8_TIMER TIM4
389 #define PWM_SERVO_8_GPIO GPIOB
390 #define PWM_SERVO_8_PIN GPIO7
391 #define PWM_SERVO_8_AF 0
392 #define PWM_SERVO_8_OC TIM_OC2
393 #define PWM_SERVO_8_OC_BIT (1<<1)
394 #else
395 #define PWM_SERVO_8_OC_BIT 0
396 #endif
397 
398 /* servos 1-4 on TIM3 */
399 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
400 /* servos 5-6 on TIM5 */
401 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
402 /* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
403 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
404 
405 
406 #endif
407