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
apogee_1.0.h
Go to the documentation of this file.
1 #ifndef CONFIG_APOGEE_1_00_H
2 #define CONFIG_APOGEE_1_00_H
3 
4 #define BOARD_APOGEE
5 
6 /* Apogee has a 16MHz external clock and 168MHz internal. */
7 #define EXT_CLK 16000000
8 #define AHB_CLK 168000000
9 
10 /*
11  * Onboard LEDs
12  */
13 
14 /* red, on PC0 */
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 GPIO0
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, on PC13 */
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 GPIO13
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 /* green, on PC1 */
35 #ifndef USE_LED_3
36 #define USE_LED_3 1
37 #endif
38 #define LED_3_GPIO GPIOC
39 #define LED_3_GPIO_PIN GPIO1
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 /* yellow, on PC3 */
45 #ifndef USE_LED_4
46 #define USE_LED_4 1
47 #endif
48 #define LED_4_GPIO GPIOC
49 #define LED_4_GPIO_PIN GPIO3
50 #define LED_4_GPIO_ON gpio_clear
51 #define LED_4_GPIO_OFF gpio_set
52 #define LED_4_AFIO_REMAP ((void)0)
53 
54 /* AUX1, on PB1, 1 on LED_ON, 0 on LED_OFF */
55 #ifndef USE_LED_5
56 #define USE_LED_5 0
57 #endif
58 #define LED_5_GPIO GPIOB
59 #define LED_5_GPIO_PIN GPIO1
60 #define LED_5_GPIO_ON gpio_set
61 #define LED_5_GPIO_OFF gpio_clear
62 #define LED_5_AFIO_REMAP ((void)0)
63 
64 /* AUX2, on PC5, 1 on LED_ON, 0 on LED_OFF */
65 #ifndef USE_LED_6
66 #define USE_LED_6 0
67 #endif
68 #define LED_6_GPIO GPIOC
69 #define LED_6_GPIO_PIN GPIO5
70 #define LED_6_GPIO_ON gpio_set
71 #define LED_6_GPIO_OFF gpio_clear
72 #define LED_6_AFIO_REMAP ((void)0)
73 
74 /* AUX3, on PC4, 1 on LED_ON, 0 on LED_OFF */
75 #ifndef USE_LED_7
76 #define USE_LED_7 0
77 #endif
78 #define LED_7_GPIO GPIOC
79 #define LED_7_GPIO_PIN GPIO4
80 #define LED_7_GPIO_ON gpio_set
81 #define LED_7_GPIO_OFF gpio_clear
82 #define LED_7_AFIO_REMAP ((void)0)
83 
84 /* AUX4, on PB15, 1 on LED_ON, 0 on LED_OFF */
85 #ifndef USE_LED_8
86 #define USE_LED_8 0
87 #endif
88 #define LED_8_GPIO GPIOB
89 #define LED_8_GPIO_PIN GPIO15
90 #define LED_8_GPIO_ON gpio_set
91 #define LED_8_GPIO_OFF gpio_clear
92 #define LED_8_AFIO_REMAP ((void)0)
93 
94 /* Power Switch, on PB12 */
95 #define POWER_SWITCH_GPIO GPIOB,GPIO12
96 
97 
98 /* Pint to set Uart2 RX polarity, on PB13, output high inverts, low doesn't */
99 #define RC_POLARITY_GPIO_PORT GPIOB
100 #define RC_POLARITY_GPIO_PIN GPIO13
101 
102 
103 /* Default actuators driver */
104 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
105 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
106 #define ActuatorsDefaultInit() ActuatorsPwmInit()
107 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
108 
109 #define DefaultVoltageOfAdc(adc) (0.006185*adc)
110 
111 /* UART */
112 #define UART1_GPIO_AF GPIO_AF7
113 #define UART1_GPIO_PORT_RX GPIOA
114 #define UART1_GPIO_RX GPIO10
115 #define UART1_GPIO_PORT_TX GPIOB
116 #define UART1_GPIO_TX GPIO6
117 
118 #define UART2_GPIO_AF GPIO_AF7
119 #define UART2_GPIO_PORT_RX GPIOA
120 #define UART2_GPIO_RX GPIO3
121 #define USE_UART2_TX FALSE
122 
123 #define UART4_GPIO_AF GPIO_AF8
124 #define UART4_GPIO_PORT_RX GPIOA
125 #define UART4_GPIO_RX GPIO1
126 #define UART4_GPIO_PORT_TX GPIOA
127 #define UART4_GPIO_TX GPIO0
128 
129 #define UART6_GPIO_AF GPIO_AF8
130 #define UART6_GPIO_PORT_RX GPIOC
131 #define UART6_GPIO_RX GPIO7
132 #define UART6_GPIO_PORT_TX GPIOC
133 #define UART6_GPIO_TX GPIO6
134 
135 /* SPI */
136 #define SPI1_GPIO_AF GPIO_AF5
137 #define SPI1_GPIO_PORT_MISO GPIOA
138 #define SPI1_GPIO_MISO GPIO6
139 #define SPI1_GPIO_PORT_MOSI GPIOA
140 #define SPI1_GPIO_MOSI GPIO7
141 #define SPI1_GPIO_PORT_SCK GPIOA
142 #define SPI1_GPIO_SCK GPIO5
143 
144 #define SPI_SELECT_SLAVE0_PORT GPIOB
145 #define SPI_SELECT_SLAVE0_PIN GPIO9
146 
147 
148 /* Onboard ADCs */
149 #define USE_AD_TIM4 1
150 
151 /* provide defines that can be used to access the ADC_x in the code or airframe file
152  * these directly map to the index number of the 4 adc channels defined above
153  * 4th (index 3) is used for bat monitoring by default
154  */
155 // AUX 1
156 #if USE_ADC_1
157 #define AD1_1_CHANNEL 9
158 #define ADC_1 AD1_1
159 #define ADC_1_GPIO_PORT GPIOB
160 #define ADC_1_GPIO_PIN GPIO1
161 #endif
162 
163 // AUX 2
164 #if USE_ADC_2
165 #define AD1_2_CHANNEL 15
166 #define ADC_2 AD1_2
167 #define ADC_2_GPIO_PORT GPIOC
168 #define ADC_2_GPIO_PIN GPIO5
169 #endif
170 
171 // AUX 3
172 #if USE_ADC_3
173 #define AD1_3_CHANNEL 14
174 #define ADC_3 AD1_3
175 #define ADC_3_GPIO_PORT GPIOC
176 #define ADC_3_GPIO_PIN GPIO4
177 #endif
178 
179 // Internal ADC for battery enabled by default
180 #ifndef USE_ADC_4
181 #define USE_ADC_4 1
182 #endif
183 #if USE_ADC_4
184 #define AD1_4_CHANNEL 4
185 #define ADC_4 AD1_4
186 #define ADC_4_GPIO_PORT GPIOA
187 #define ADC_4_GPIO_PIN GPIO4
188 #endif
189 
190 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
191 #ifndef ADC_CHANNEL_VSUPPLY
192 #define ADC_CHANNEL_VSUPPLY ADC_4
193 #endif
194 
195 
196 /* I2C mapping */
197 #define I2C1_GPIO_PORT GPIOB
198 #define I2C1_GPIO_SCL GPIO8
199 #define I2C1_GPIO_SDA GPIO7
200 
201 #define I2C2_GPIO_PORT GPIOB
202 #define I2C2_GPIO_SCL GPIO10
203 #define I2C2_GPIO_SDA GPIO11
204 
205 
206 /* by default activate onboard baro */
207 #ifndef USE_BARO_BOARD
208 #define USE_BARO_BOARD 1
209 #endif
210 
211 
212 /* PWM */
213 #define PWM_USE_TIM2 1
214 #define PWM_USE_TIM3 1
215 
216 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
217 // enable PWM connectors by default
218 
219 #ifndef USE_PWM0
220 #define USE_PWM0 1
221 #endif
222 #if USE_PWM0
223 #define PWM_SERVO_0 0
224 #define PWM_SERVO_0_TIMER TIM3
225 #define PWM_SERVO_0_GPIO GPIOB
226 #define PWM_SERVO_0_PIN GPIO0
227 #define PWM_SERVO_0_AF GPIO_AF2
228 #define PWM_SERVO_0_OC TIM_OC3
229 #define PWM_SERVO_0_OC_BIT (1<<2)
230 #else
231 #define PWM_SERVO_0_OC_BIT 0
232 #endif
233 
234 #ifndef USE_PWM1
235 #define USE_PWM1 1
236 #endif
237 #if USE_PWM1
238 #define PWM_SERVO_1 1
239 #define PWM_SERVO_1_TIMER TIM2
240 #define PWM_SERVO_1_GPIO GPIOA
241 #define PWM_SERVO_1_PIN GPIO2
242 #define PWM_SERVO_1_AF GPIO_AF1
243 #define PWM_SERVO_1_OC TIM_OC3
244 #define PWM_SERVO_1_OC_BIT (1<<2)
245 #else
246 #define PWM_SERVO_1_OC_BIT 0
247 #endif
248 
249 #ifndef USE_PWM2
250 #define USE_PWM2 1
251 #endif
252 #if USE_PWM2
253 #define PWM_SERVO_2 2
254 #define PWM_SERVO_2_TIMER TIM3
255 #define PWM_SERVO_2_GPIO GPIOB
256 #define PWM_SERVO_2_PIN GPIO5
257 #define PWM_SERVO_2_AF GPIO_AF2
258 #define PWM_SERVO_2_OC TIM_OC2
259 #define PWM_SERVO_2_OC_BIT (1<<1)
260 #else
261 #define PWM_SERVO_2_OC_BIT 0
262 #endif
263 
264 #ifndef USE_PWM3
265 #define USE_PWM3 1
266 #endif
267 #if USE_PWM3
268 #define PWM_SERVO_3 3
269 #define PWM_SERVO_3_TIMER TIM3
270 #define PWM_SERVO_3_GPIO GPIOB
271 #define PWM_SERVO_3_PIN GPIO4
272 #define PWM_SERVO_3_AF GPIO_AF2
273 #define PWM_SERVO_3_OC TIM_OC1
274 #define PWM_SERVO_3_OC_BIT (1<<0)
275 #else
276 #define PWM_SERVO_3_OC_BIT 0
277 #endif
278 
279 #ifndef USE_PWM4
280 #define USE_PWM4 1
281 #endif
282 #if USE_PWM4
283 #define PWM_SERVO_4 4
284 #define PWM_SERVO_4_TIMER TIM2
285 #define PWM_SERVO_4_GPIO GPIOB
286 #define PWM_SERVO_4_PIN GPIO3
287 #define PWM_SERVO_4_AF GPIO_AF1
288 #define PWM_SERVO_4_OC TIM_OC2
289 #define PWM_SERVO_4_OC_BIT (1<<1)
290 #else
291 #define PWM_SERVO_4_OC_BIT 0
292 #endif
293 
294 #ifndef USE_PWM5
295 #define USE_PWM5 1
296 #endif
297 #if USE_PWM5
298 #define PWM_SERVO_5 5
299 #define PWM_SERVO_5_TIMER TIM2
300 #define PWM_SERVO_5_GPIO GPIOA
301 #define PWM_SERVO_5_PIN GPIO15
302 #define PWM_SERVO_5_AF GPIO_AF1
303 #define PWM_SERVO_5_OC TIM_OC1
304 #define PWM_SERVO_5_OC_BIT (1<<0)
305 #else
306 #define PWM_SERVO_5_OC_BIT 0
307 #endif
308 
309 // PWM AUX1 (conflict with ADC0)
310 #if USE_PWM6
311 #define PWM_SERVO_6 6
312 #define PWM_SERVO_6_TIMER TIM3
313 #define PWM_SERVO_6_GPIO GPIOB
314 #define PWM_SERVO_6_PIN GPIO1
315 #define PWM_SERVO_6_AF GPIO_AF2
316 #define PWM_SERVO_6_OC TIM_OC4
317 #define PWM_SERVO_6_OC_BIT (1<<3)
318 #else
319 #define PWM_SERVO_6_OC_BIT 0
320 #endif
321 
322 
323 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_4_OC_BIT|PWM_SERVO_5_OC_BIT)
324 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_0_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_6_OC_BIT)
325 
326 /*
327  * PPM
328  */
329 #define USE_PPM_TIM1 1
330 
331 #define PPM_CHANNEL TIM_IC1
332 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
333 #define PPM_IRQ NVIC_TIM1_CC_IRQ
334 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
335 // Capture/Compare InteruptEnable and InterruptFlag
336 #define PPM_CC_IE TIM_DIER_CC1IE
337 #define PPM_CC_IF TIM_SR_CC1IF
338 #define PPM_GPIO_PORT GPIOA
339 #define PPM_GPIO_PIN GPIO8
340 #define PPM_GPIO_AF GPIO_AF1
341 
342 /*
343  * PWM input
344  */
345 #define PWM_INPUT1_TIMER TIM1
346 #define PWM_INPUT1_CHANNEL_PERIOD TIM_IC1
347 #define PWM_INPUT1_CHANNEL_DUTY TIM_IC2
348 #define PWM_INPUT1_TIMER_INPUT TIM_IC_IN_TI1
349 #define PWM_INPUT1_SLAVE_TRIG TIM_SMCR_TS_IT1FP1
350 #define PWM_INPUT1_IRQ NVIC_TIM1_CC_IRQ
351 #define PWM_INPUT1_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
352 #define PWM_INPUT1_CC_IE (TIM_DIER_CC1IE | TIM_DIER_CC2IE)
353 #define USE_PWM_INPUT_TIM1 TRUE
354 #define TIM1_PWM_INPUT_IDX 0
355 #define TIM1_CC_IF_PERIOD TIM_SR_CC1IF
356 #define TIM1_CC_IF_DUTY TIM_SR_CC2IF
357 #define TIM1_CCR_PERIOD TIM1_CCR1
358 #define TIM1_CCR_DUTY TIM1_CCR2
359 // PPM in (aka PA8) is used: not compatible with PPM RC receiver
360 #define PWM_INPUT1_GPIO_PORT GPIOA
361 #define PWM_INPUT1_GPIO_PIN GPIO8
362 #define PWM_INPUT1_GPIO_AF GPIO_AF1
363 
364 /*
365  * Spektrum
366  */
367 
368 /* The line that is pulled low at power up to initiate the bind process
369  * PB15: AUX4
370  */
371 #define SPEKTRUM_BIND_PIN GPIO15
372 #define SPEKTRUM_BIND_PIN_PORT GPIOB
373 
374 /* The line used to send the pulse train for the bind process
375  * When using UART2 on Apogee, this as to be a different pin than the uart2 rx
376  * Default pin for this is PA8: PPM_IN
377  */
378 #ifndef SPEKTRUM_PRIMARY_BIND_CONF_PORT
379 #define SPEKTRUM_PRIMARY_BIND_CONF_PORT GPIOA
380 #define SPEKTRUM_PRIMARY_BIND_CONF_PIN GPIO8
381 #endif
382 
383 /* Configuration of UART2 for Spektrum */
384 #define SPEKTRUM_UART2_RCC RCC_USART2
385 #define SPEKTRUM_UART2_BANK GPIOA
386 #define SPEKTRUM_UART2_PIN GPIO3
387 #define SPEKTRUM_UART2_AF GPIO_AF7
388 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
389 #define SPEKTRUM_UART2_ISR usart2_isr
390 #define SPEKTRUM_UART2_DEV USART2
391 
392 
393 /*
394  * IRQ Priorities
395  */
396 #define RTOS_PRIO 2
397 #define NVIC_TIM_IRQ_PRIO (RTOS_PRIO+1)
398 #define NVIC_I2C_IRQ_PRIO (RTOS_PRIO+2)
399 #define NVIC_SPI_IRQ_PRIO (RTOS_PRIO+3)
400 #define NVIC_UART_IRQ_PRIO (RTOS_PRIO+4)
401 #define NVIC_USART_IRQ_PRIO (RTOS_PRIO+4)
402 #define NVIC_ADC_IRQ_PRIO (RTOS_PRIO+5)
403 #define NVIC_TIM6_DAC_IRQ_PRIO (RTOS_PRIO+6)
404 
405 
406 #endif /* CONFIG_APOGEE_1_00_H */