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