Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
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 #define SPEKTRUM_BIND_PIN GPIO3
60 #define SPEKTRUM_BIND_PIN_PORT GPIOC
61 
62 #define SPEKTRUM_UART1_RCC_REG &RCC_APB2ENR
63 #define SPEKTRUM_UART1_RCC_DEV RCC_APB2ENR_USART1EN
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_REG &RCC_APB1ENR
72 #define SPEKTRUM_UART3_RCC_DEV RCC_APB1ENR_USART3EN
73 #define SPEKTRUM_UART3_BANK GPIO_BANK_USART3_PR_RX
74 #define SPEKTRUM_UART3_PIN GPIO_USART3_PR_RX
75 #define SPEKTRUM_UART3_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
76 #define SPEKTRUM_UART3_IRQ NVIC_USART3_IRQ
77 #define SPEKTRUM_UART3_ISR usart3_isr
78 #define SPEKTRUM_UART3_DEV USART3
79 
80 #define SPEKTRUM_UART5_RCC_REG &RCC_APB1ENR
81 #define SPEKTRUM_UART5_RCC_DEV RCC_APB1ENR_UART5EN
82 #define SPEKTRUM_UART5_BANK GPIO_BANK_UART5_RX
83 #define SPEKTRUM_UART5_PIN GPIO_UART5_RX
84 #define SPEKTRUM_UART5_AF 0
85 #define SPEKTRUM_UART5_IRQ NVIC_UART5_IRQ
86 #define SPEKTRUM_UART5_ISR uart5_isr
87 #define SPEKTRUM_UART5_DEV UART5
88 
89 
90 /* PPM
91  *
92  * Default is PPM config 2, input on GPIO01 (Servo pin 6)
93  */
94 
95 #ifndef PPM_CONFIG
96 #define PPM_CONFIG 2
97 #endif
98 
99 #if PPM_CONFIG == 1
100 /* input on PA01 (UART1_RX) */
101 #define USE_PPM_TIM1 1
102 #define PPM_CHANNEL TIM_IC3
103 #define PPM_TIMER_INPUT TIM_IC_IN_TI3
104 #define PPM_IRQ NVIC_TIM1_UP_IRQ
105 #define PPM_IRQ2 NVIC_TIM1_CC_IRQ
106 // Capture/Compare InteruptEnable and InterruptFlag
107 #define PPM_CC_IE TIM_DIER_CC3IE
108 #define PPM_CC_IF TIM_SR_CC3IF
109 #define PPM_GPIO_PORT GPIOA
110 #define PPM_GPIO_PIN GPIO10
111 #define PPM_GPIO_AF 0
112 
113 #elif PPM_CONFIG == 2
114 /* input on PA10 (Servo 6 pin) */
115 #define USE_PPM_TIM2 1
116 #define PPM_CHANNEL TIM_IC2
117 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
118 #define PPM_IRQ NVIC_TIM2_IRQ
119 // Capture/Compare InteruptEnable and InterruptFlag
120 #define PPM_CC_IE TIM_DIER_CC2IE
121 #define PPM_CC_IF TIM_SR_CC2IF
122 #define PPM_GPIO_PORT GPIOA
123 #define PPM_GPIO_PIN GPIO1
124 #define PPM_GPIO_AF 0
125 
126 // Move default ADC timer
127 #if USE_AD_TIM2
128 #undef USE_AD_TIM2
129 #endif
130 #define USE_AD_TIM1 1
131 
132 #else
133 #error "Unknown PPM config"
134 
135 #endif // PPM_CONFIG
136 
137 /* ADC */
138 
139 // active ADC
140 #define USE_AD1 1
141 #define USE_AD1_1 1
142 #define USE_AD1_2 1
143 #define USE_AD1_3 1
144 #define USE_AD1_4 1
145 
146 
147 /*
148  * I2C
149  *
150  */
151 #define I2C1_GPIO_PORT GPIOB
152 #define I2C1_GPIO_SCL GPIO6
153 #define I2C1_GPIO_SDA GPIO7
154 
155 #define I2C2_GPIO_PORT GPIOB
156 #define I2C2_GPIO_SCL GPIO10
157 #define I2C2_GPIO_SDA GPIO11
158 
159 
160 /*
161  * PWM
162  *
163  */
164 #define PWM_USE_TIM3 1
165 #define PWM_USE_TIM5 1
166 
167 #define USE_PWM1 1
168 #define USE_PWM2 1
169 #define USE_PWM3 1
170 #define USE_PWM4 1
171 #define USE_PWM5 1
172 #define USE_PWM6 1
173 
174 #if USE_SERVOS_7AND8
175  #if USE_I2C1
176  #error "You cannot USE_SERVOS_7AND8 and USE_I2C1 at the same time"
177  #else
178  #define ACTUATORS_PWM_NB 8
179  #define USE_PWM7 1
180  #define USE_PWM8 1
181  #define PWM_USE_TIM4 1
182  #endif
183 #else
184  #define ACTUATORS_PWM_NB 6
185 #endif
186 
187 // Servo numbering on LisaM silkscreen/docs starts with 1
188 
189 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
190 #if USE_PWM1
191 #define PWM_SERVO_1 0
192 #define PWM_SERVO_1_TIMER TIM3
193 #define PWM_SERVO_1_RCC_IOP RCC_APB2ENR_IOPCEN
194 #define PWM_SERVO_1_GPIO GPIOC
195 #define PWM_SERVO_1_PIN GPIO6
196 #define PWM_SERVO_1_AF 0
197 #define PWM_SERVO_1_OC TIM_OC1
198 #define PWM_SERVO_1_OC_BIT (1<<0)
199 #else
200 #define PWM_SERVO_1_OC_BIT 0
201 #endif
202 
203 #if USE_PWM2
204 #define PWM_SERVO_2 1
205 #define PWM_SERVO_2_TIMER TIM3
206 #define PWM_SERVO_2_RCC_IOP RCC_APB2ENR_IOPCEN
207 #define PWM_SERVO_2_GPIO GPIOC
208 #define PWM_SERVO_2_PIN GPIO7
209 #define PWM_SERVO_2_AF 0
210 #define PWM_SERVO_2_OC TIM_OC2
211 #define PWM_SERVO_2_OC_BIT (1<<1)
212 #else
213 #define PWM_SERVO_2_OC_BIT 0
214 #endif
215 
216 #if USE_PWM3
217 #define PWM_SERVO_3 2
218 #define PWM_SERVO_3_TIMER TIM3
219 #define PWM_SERVO_3_RCC_IOP RCC_APB2ENR_IOPCEN
220 #define PWM_SERVO_3_GPIO GPIOC
221 #define PWM_SERVO_3_PIN GPIO8
222 #define PWM_SERVO_3_AF 0
223 #define PWM_SERVO_3_OC TIM_OC3
224 #define PWM_SERVO_3_OC_BIT (1<<2)
225 #else
226 #define PWM_SERVO_3_OC_BIT 0
227 #endif
228 
229 #if USE_PWM4
230 #define PWM_SERVO_4 3
231 #define PWM_SERVO_4_TIMER TIM3
232 #define PWM_SERVO_4_RCC_IOP RCC_APB2ENR_IOPCEN
233 #define PWM_SERVO_4_GPIO GPIOC
234 #define PWM_SERVO_4_PIN GPIO9
235 #define PWM_SERVO_4_AF 0
236 #define PWM_SERVO_4_OC TIM_OC4
237 #define PWM_SERVO_4_OC_BIT (1<<3)
238 #else
239 #define PWM_SERVO_4_OC_BIT 0
240 #endif
241 
242 #if USE_PWM5
243 #define PWM_SERVO_5 4
244 #define PWM_SERVO_5_TIMER TIM5
245 #define PWM_SERVO_5_RCC_IOP RCC_APB2ENR_IOPAEN
246 #define PWM_SERVO_5_GPIO GPIOA
247 #define PWM_SERVO_5_PIN GPIO0
248 #define PWM_SERVO_5_AF 0
249 #define PWM_SERVO_5_OC TIM_OC1
250 #define PWM_SERVO_5_OC_BIT (1<<0)
251 #else
252 #define PWM_SERVO_5_OC_BIT 0
253 #endif
254 
255 #if USE_PWM6
256 #define PWM_SERVO_6 5
257 #define PWM_SERVO_6_TIMER TIM5
258 #define PWM_SERVO_6_RCC_IOP RCC_APB2ENR_IOPAEN
259 #define PWM_SERVO_6_GPIO GPIOA
260 #define PWM_SERVO_6_PIN GPIO1
261 #define PWM_SERVO_6_AF 0
262 #define PWM_SERVO_6_OC TIM_OC2
263 #define PWM_SERVO_6_OC_BIT (1<<1)
264 #else
265 #define PWM_SERVO_6_OC_BIT 0
266 #endif
267 
268 #if USE_PWM7
269 #define PWM_SERVO_7 6
270 #define PWM_SERVO_7_TIMER TIM4
271 #define PWM_SERVO_7_RCC_IOP RCC_APB2ENR_IOPBEN
272 #define PWM_SERVO_7_GPIO GPIOB
273 #define PWM_SERVO_7_PIN GPIO6
274 #define PWM_SERVO_7_AF 0
275 #define PWM_SERVO_7_OC TIM_OC1
276 #define PWM_SERVO_7_OC_BIT (1<<0)
277 #else
278 #define PWM_SERVO_7_OC_BIT 0
279 #endif
280 
281 #if USE_PWM8
282 #define PWM_SERVO_8 7
283 #define PWM_SERVO_8_TIMER TIM4
284 #define PWM_SERVO_8_RCC_IOP RCC_APB2ENR_IOPBEN
285 #define PWM_SERVO_8_GPIO GPIOB
286 #define PWM_SERVO_8_PIN GPIO7
287 #define PWM_SERVO_8_AF 0
288 #define PWM_SERVO_8_OC TIM_OC2
289 #define PWM_SERVO_8_OC_BIT (1<<1)
290 #else
291 #define PWM_SERVO_8_OC_BIT 0
292 #endif
293 
294 /* servos 1-4 on TIM3 */
295 #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)
296 /* servos 5-6 on TIM5 */
297 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
298 /* servos 7-8 on TIM4 if USE_SERVOS_7AND8 */
299 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
300 
301 
302 #endif
303