Paparazzi UAS  v5.15_devel-230-gc96ce27
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 
166 /* provide defines that can be used to access the ADC_x in the code or airframe file
167  * these directly map to the index number of the 4 adc channels defined above
168  * 4th (index 3) is used for bat monitoring by default
169  */
170 #if USE_ADC_1
171 #define AD1_1_CHANNEL 13
172 #define ADC_1 AD1_1
173 #define ADC_1_GPIO_PORT GPIOC
174 #define ADC_1_GPIO_PIN GPIO3
175 #endif
176 
177 #if USE_ADC_2
178 #define AD1_2_CHANNEL 10
179 #define ADC_2 AD1_2
180 #define ADC_2_GPIO_PORT GPIOC
181 #define ADC_2_GPIO_PIN GPIO0
182 #endif
183 
184 #if USE_ADC_3
185 #define AD1_3_CHANNEL 11
186 #define ADC_3 AD1_3
187 #define ADC_3_GPIO_PORT GPIOC
188 #define ADC_3_GPIO_PIN GPIO1
189 #endif
190 
191 #if USE_ADC_4
192 #define AD2_1_CHANNEL 15
193 #define ADC_4 AD2_1
194 #define ADC_4_GPIO_PORT GPIOC
195 #define ADC_4_GPIO_PIN GPIO5
196 #endif
197 
198 // Internal ADC for battery enabled by default
199 #ifndef USE_ADC_5
200 #define USE_ADC_5 1
201 #endif
202 #if USE_ADC_5
203 #define AD1_4_CHANNEL 14
204 #define ADC_5 AD1_4
205 #define ADC_5_GPIO_PORT GPIOC
206 #define ADC_5_GPIO_PIN GPIO4
207 #endif
208 
209 #if USE_ADC_6
210 #define AD2_2_CHANNEL 12
211 #define ADC_6 AD2_2
212 #define ADC_6_GPIO_PORT GPIOC
213 #define ADC_6_GPIO_PIN GPIO2
214 #endif
215 
216 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
217 #ifndef ADC_CHANNEL_VSUPPLY
218 #define ADC_CHANNEL_VSUPPLY ADC_5
219 #endif
220 
221 /*
222  * I2C
223  *
224  */
225 #define I2C1_GPIO_PORT GPIOB
226 #define I2C1_GPIO_SCL GPIO6
227 #define I2C1_GPIO_SDA GPIO7
228 
229 #define I2C2_GPIO_PORT GPIOB
230 #define I2C2_GPIO_SCL GPIO10
231 #define I2C2_GPIO_SDA GPIO11
232 
233 
234 /*
235  * PWM
236  *
237  */
238 #define PWM_USE_TIM3 1
239 #define PWM_USE_TIM5 1
240 
241 #define USE_PWM1 1
242 #define USE_PWM2 1
243 #define USE_PWM3 1
244 #define USE_PWM4 1
245 
246 #if DUAL_PWM_ON
247 #define DUAL_PWM_USE_TIM5 1
248 
249 #define USE_DUAL_PWM5 1
250 #define USE_DUAL_PWM6 1
251 #else
252 #define USE_PWM5 1
253 #define USE_PWM6 1
254 #endif
255 
256 
257 
258 #if USE_SERVOS_7AND8
259 #if USE_I2C1
260 #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
261 #else
262 #define ACTUATORS_PWM_NB 8
263 #define USE_PWM7 1
264 #define USE_PWM8 1
265 #define PWM_USE_TIM4 1
266 #endif
267 #else
268 #define ACTUATORS_PWM_NB 6
269 #endif
270 
271 // Servo numbering on LisaM silkscreen/docs starts with 1
272 
273 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
274 #if USE_PWM1
275 #define PWM_SERVO_1 0
276 #define PWM_SERVO_1_TIMER TIM3
277 #define PWM_SERVO_1_GPIO GPIOC
278 #define PWM_SERVO_1_PIN GPIO6
279 #define PWM_SERVO_1_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
280 #define PWM_SERVO_1_OC TIM_OC1
281 #define PWM_SERVO_1_OC_BIT (1<<0)
282 #else
283 #define PWM_SERVO_1_OC_BIT 0
284 #endif
285 
286 #if USE_PWM2
287 #define PWM_SERVO_2 1
288 #define PWM_SERVO_2_TIMER TIM3
289 #define PWM_SERVO_2_GPIO GPIOC
290 #define PWM_SERVO_2_PIN GPIO7
291 #define PWM_SERVO_2_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
292 #define PWM_SERVO_2_OC TIM_OC2
293 #define PWM_SERVO_2_OC_BIT (1<<1)
294 #else
295 #define PWM_SERVO_2_OC_BIT 0
296 #endif
297 
298 #if USE_PWM3
299 #define PWM_SERVO_3 2
300 #define PWM_SERVO_3_TIMER TIM3
301 #define PWM_SERVO_3_GPIO GPIOC
302 #define PWM_SERVO_3_PIN GPIO8
303 #define PWM_SERVO_3_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
304 #define PWM_SERVO_3_OC TIM_OC3
305 #define PWM_SERVO_3_OC_BIT (1<<2)
306 #else
307 #define PWM_SERVO_3_OC_BIT 0
308 #endif
309 
310 #if USE_PWM4
311 #define PWM_SERVO_4 3
312 #define PWM_SERVO_4_TIMER TIM3
313 #define PWM_SERVO_4_GPIO GPIOC
314 #define PWM_SERVO_4_PIN GPIO9
315 #define PWM_SERVO_4_AF AFIO_MAPR_TIM3_REMAP_FULL_REMAP
316 #define PWM_SERVO_4_OC TIM_OC4
317 #define PWM_SERVO_4_OC_BIT (1<<3)
318 #else
319 #define PWM_SERVO_4_OC_BIT 0
320 #endif
321 
322 #if USE_PWM5
323 #define PWM_SERVO_5 4
324 #define PWM_SERVO_5_TIMER TIM5
325 #define PWM_SERVO_5_GPIO GPIOA
326 #define PWM_SERVO_5_PIN GPIO0
327 #define PWM_SERVO_5_AF 0
328 #define PWM_SERVO_5_OC TIM_OC1
329 #define PWM_SERVO_5_OC_BIT (1<<0)
330 #elif USE_DUAL_PWM5
331 #define DUAL_PWM_SERVO_5 4
332 
333 #define DUAL_PWM_SERVO_5_P1 0
334 #define DUAL_PWM_SERVO_5_P2 1
335 
336 #define DUAL_PWM_SERVO_5_TIMER TIM5
337 #define DUAL_PWM_SERVO_5_GPIO GPIOA
338 #define DUAL_PWM_SERVO_5_PIN GPIO0
339 #define DUAL_PWM_SERVO_5_AF 0
340 #define DUAL_PWM_SERVO_5_OC TIM_OC1
341 #define PWM_SERVO_5_OC_BIT (1<<0)
342 #else
343 #define PWM_SERVO_5_OC_BIT 0
344 #endif
345 
346 #if USE_PWM6
347 #define PWM_SERVO_6 5
348 #define PWM_SERVO_6_TIMER TIM5
349 #define PWM_SERVO_6_GPIO GPIOA
350 #define PWM_SERVO_6_PIN GPIO1
351 #define PWM_SERVO_6_AF 0
352 #define PWM_SERVO_6_OC TIM_OC2
353 #define PWM_SERVO_6_OC_BIT (1<<1)
354 #elif USE_DUAL_PWM6
355 #define DUAL_PWM_SERVO_6 5
356 
357 #define DUAL_PWM_SERVO_6_P1 0
358 #define DUAL_PWM_SERVO_6_P2 1
359 
360 #define DUAL_PWM_SERVO_6_TIMER TIM5
361 #define DUAL_PWM_SERVO_6_GPIO GPIOA
362 #define DUAL_PWM_SERVO_6_PIN GPIO1
363 #define DUAL_PWM_SERVO_6_AF 0
364 #define DUAL_PWM_SERVO_6_OC TIM_OC2
365 #define PWM_SERVO_6_OC_BIT (1<<1)
366 #else
367 #define PWM_SERVO_6_OC_BIT 0
368 #endif
369 
370 
371 
372 
373 
374 
375 #if USE_PWM7
376 #define PWM_SERVO_7 6
377 #define PWM_SERVO_7_TIMER TIM4
378 #define PWM_SERVO_7_GPIO GPIOB
379 #define PWM_SERVO_7_PIN GPIO6
380 #define PWM_SERVO_7_AF 0
381 #define PWM_SERVO_7_OC TIM_OC1
382 #define PWM_SERVO_7_OC_BIT (1<<0)
383 #else
384 #define PWM_SERVO_7_OC_BIT 0
385 #endif
386 
387 #if USE_PWM8
388 #define PWM_SERVO_8 7
389 #define PWM_SERVO_8_TIMER TIM4
390 #define PWM_SERVO_8_GPIO GPIOB
391 #define PWM_SERVO_8_PIN GPIO7
392 #define PWM_SERVO_8_AF 0
393 #define PWM_SERVO_8_OC TIM_OC2
394 #define PWM_SERVO_8_OC_BIT (1<<1)
395 #else
396 #define PWM_SERVO_8_OC_BIT 0
397 #endif
398 
399 /* servos 1-4 on TIM3 */
400 #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)
401 /* servos 5-6 on TIM5 */
402 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
403 /* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
404 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
405 
406 
407 #endif
408