Paparazzi UAS  v5.15_devel-109-gee85905
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 // SLAVE0 on SPI connector
145 #define SPI_SELECT_SLAVE0_PORT GPIOB
146 #define SPI_SELECT_SLAVE0_PIN GPIO9
147 // SLAVE1 on AUX1
148 #define SPI_SELECT_SLAVE1_PORT GPIOB
149 #define SPI_SELECT_SLAVE1_PIN GPIO1
150 // SLAVE2 on AUX2
151 #define SPI_SELECT_SLAVE2_PORT GPIOC
152 #define SPI_SELECT_SLAVE2_PIN GPIO5
153 // SLAVE3 on AUX3
154 #define SPI_SELECT_SLAVE3_PORT GPIOC
155 #define SPI_SELECT_SLAVE3_PIN GPIO4
156 // SLAVE4 on AUX4
157 #define SPI_SELECT_SLAVE4_PORT GPIOB
158 #define SPI_SELECT_SLAVE4_PIN GPIO15
159 
160 
161 /* Onboard ADCs */
162 #define USE_AD_TIM4 1
163 
164 /* provide defines that can be used to access the ADC_x in the code or airframe file
165  * these directly map to the index number of the 4 adc channels defined above
166  * 4th (index 3) is used for bat monitoring by default
167  */
168 // AUX 1
169 #if USE_ADC_1
170 #define AD1_1_CHANNEL 9
171 #define ADC_1 AD1_1
172 #define ADC_1_GPIO_PORT GPIOB
173 #define ADC_1_GPIO_PIN GPIO1
174 #endif
175 
176 // AUX 2
177 #if USE_ADC_2
178 #define AD1_2_CHANNEL 15
179 #define ADC_2 AD1_2
180 #define ADC_2_GPIO_PORT GPIOC
181 #define ADC_2_GPIO_PIN GPIO5
182 #endif
183 
184 // AUX 3
185 #if USE_ADC_3
186 #define AD1_3_CHANNEL 14
187 #define ADC_3 AD1_3
188 #define ADC_3_GPIO_PORT GPIOC
189 #define ADC_3_GPIO_PIN GPIO4
190 #endif
191 
192 // Internal ADC for battery enabled by default
193 #ifndef USE_ADC_4
194 #define USE_ADC_4 1
195 #endif
196 #if USE_ADC_4
197 #define AD1_4_CHANNEL 4
198 #define ADC_4 AD1_4
199 #define ADC_4_GPIO_PORT GPIOA
200 #define ADC_4_GPIO_PIN GPIO4
201 #endif
202 
203 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
204 #ifndef ADC_CHANNEL_VSUPPLY
205 #define ADC_CHANNEL_VSUPPLY ADC_4
206 #endif
207 
208 
209 /* I2C mapping */
210 #define I2C1_GPIO_PORT GPIOB
211 #define I2C1_GPIO_SCL GPIO8
212 #define I2C1_GPIO_SDA GPIO7
213 
214 #define I2C2_GPIO_PORT GPIOB
215 #define I2C2_GPIO_SCL GPIO10
216 #define I2C2_GPIO_SDA GPIO11
217 
218 
219 /* by default activate onboard baro */
220 #ifndef USE_BARO_BOARD
221 #define USE_BARO_BOARD 1
222 #endif
223 
224 
225 /* PWM */
226 #define PWM_USE_TIM2 1
227 #define PWM_USE_TIM3 1
228 
229 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
230 // enable PWM connectors by default
231 
232 #ifndef USE_PWM0
233 #define USE_PWM0 1
234 #endif
235 #if USE_PWM0
236 #define PWM_SERVO_0 0
237 #define PWM_SERVO_0_TIMER TIM3
238 #define PWM_SERVO_0_GPIO GPIOB
239 #define PWM_SERVO_0_PIN GPIO0
240 #define PWM_SERVO_0_AF GPIO_AF2
241 #define PWM_SERVO_0_OC TIM_OC3
242 #define PWM_SERVO_0_OC_BIT (1<<2)
243 #else
244 #define PWM_SERVO_0_OC_BIT 0
245 #endif
246 
247 #ifndef USE_PWM1
248 #define USE_PWM1 1
249 #endif
250 #if USE_PWM1
251 #define PWM_SERVO_1 1
252 #define PWM_SERVO_1_TIMER TIM2
253 #define PWM_SERVO_1_GPIO GPIOA
254 #define PWM_SERVO_1_PIN GPIO2
255 #define PWM_SERVO_1_AF GPIO_AF1
256 #define PWM_SERVO_1_OC TIM_OC3
257 #define PWM_SERVO_1_OC_BIT (1<<2)
258 #else
259 #define PWM_SERVO_1_OC_BIT 0
260 #endif
261 
262 #ifndef USE_PWM2
263 #define USE_PWM2 1
264 #endif
265 #if USE_PWM2
266 #define PWM_SERVO_2 2
267 #define PWM_SERVO_2_TIMER TIM3
268 #define PWM_SERVO_2_GPIO GPIOB
269 #define PWM_SERVO_2_PIN GPIO5
270 #define PWM_SERVO_2_AF GPIO_AF2
271 #define PWM_SERVO_2_OC TIM_OC2
272 #define PWM_SERVO_2_OC_BIT (1<<1)
273 #else
274 #define PWM_SERVO_2_OC_BIT 0
275 #endif
276 
277 #ifndef USE_PWM3
278 #define USE_PWM3 1
279 #endif
280 #if USE_PWM3
281 #define PWM_SERVO_3 3
282 #define PWM_SERVO_3_TIMER TIM3
283 #define PWM_SERVO_3_GPIO GPIOB
284 #define PWM_SERVO_3_PIN GPIO4
285 #define PWM_SERVO_3_AF GPIO_AF2
286 #define PWM_SERVO_3_OC TIM_OC1
287 #define PWM_SERVO_3_OC_BIT (1<<0)
288 #else
289 #define PWM_SERVO_3_OC_BIT 0
290 #endif
291 
292 #ifndef USE_PWM4
293 #define USE_PWM4 1
294 #endif
295 #if USE_PWM4
296 #define PWM_SERVO_4 4
297 #define PWM_SERVO_4_TIMER TIM2
298 #define PWM_SERVO_4_GPIO GPIOB
299 #define PWM_SERVO_4_PIN GPIO3
300 #define PWM_SERVO_4_AF GPIO_AF1
301 #define PWM_SERVO_4_OC TIM_OC2
302 #define PWM_SERVO_4_OC_BIT (1<<1)
303 #else
304 #define PWM_SERVO_4_OC_BIT 0
305 #endif
306 
307 #ifndef USE_PWM5
308 #define USE_PWM5 1
309 #endif
310 #if USE_PWM5
311 #define PWM_SERVO_5 5
312 #define PWM_SERVO_5_TIMER TIM2
313 #define PWM_SERVO_5_GPIO GPIOA
314 #define PWM_SERVO_5_PIN GPIO15
315 #define PWM_SERVO_5_AF GPIO_AF1
316 #define PWM_SERVO_5_OC TIM_OC1
317 #define PWM_SERVO_5_OC_BIT (1<<0)
318 #else
319 #define PWM_SERVO_5_OC_BIT 0
320 #endif
321 
322 // PWM AUX1 (conflict with ADC0)
323 #if USE_PWM6
324 #define PWM_SERVO_6 6
325 #define PWM_SERVO_6_TIMER TIM3
326 #define PWM_SERVO_6_GPIO GPIOB
327 #define PWM_SERVO_6_PIN GPIO1
328 #define PWM_SERVO_6_AF GPIO_AF2
329 #define PWM_SERVO_6_OC TIM_OC4
330 #define PWM_SERVO_6_OC_BIT (1<<3)
331 #else
332 #define PWM_SERVO_6_OC_BIT 0
333 #endif
334 
335 
336 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_4_OC_BIT|PWM_SERVO_5_OC_BIT)
337 #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)
338 
339 /*
340  * PPM
341  */
342 #define USE_PPM_TIM1 1
343 
344 #define PPM_CHANNEL TIM_IC1
345 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
346 #define PPM_IRQ NVIC_TIM1_CC_IRQ
347 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
348 // Capture/Compare InteruptEnable and InterruptFlag
349 #define PPM_CC_IE TIM_DIER_CC1IE
350 #define PPM_CC_IF TIM_SR_CC1IF
351 #define PPM_GPIO_PORT GPIOA
352 #define PPM_GPIO_PIN GPIO8
353 #define PPM_GPIO_AF GPIO_AF1
354 
355 /*
356  * PWM input
357  */
358 // PWM_INPUT1 on TIM1
359 #define PWM_INPUT1_TIMER TIM1
360 #ifdef PWM_INPUT1_TICKS_PER_USEC
361 #define TIM1_TICKS_PER_USEC PWM_INPUT1_TICKS_PER_USEC
362 #endif
363 #define PWM_INPUT1_CHANNEL_PERIOD TIM_IC1
364 #define PWM_INPUT1_CHANNEL_DUTY TIM_IC2
365 #define PWM_INPUT1_TIMER_INPUT TIM_IC_IN_TI1
366 #define PWM_INPUT1_SLAVE_TRIG TIM_SMCR_TS_TI1FP1
367 #define PWM_INPUT1_IRQ NVIC_TIM1_CC_IRQ
368 #define PWM_INPUT1_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
369 #define PWM_INPUT1_CC_IE (TIM_DIER_CC1IE | TIM_DIER_CC2IE)
370 #define USE_PWM_INPUT_TIM1 TRUE
371 #define TIM1_PWM_INPUT_IDX 0
372 #define TIM1_CC_IF_PERIOD TIM_SR_CC1IF
373 #define TIM1_CC_IF_DUTY TIM_SR_CC2IF
374 #define TIM1_CCR_PERIOD TIM1_CCR1
375 #define TIM1_CCR_DUTY TIM1_CCR2
376 // PPM in (aka PA8) is used: not compatible with PPM RC receiver
377 #define PWM_INPUT1_GPIO_PORT GPIOA
378 #define PWM_INPUT1_GPIO_PIN GPIO8
379 #define PWM_INPUT1_GPIO_AF GPIO_AF1
380 
381 // PWM_INPUT2 on TIM9
382 #define PWM_INPUT2_TIMER TIM9
383 #ifdef PWM_INPUT2_TICKS_PER_USEC
384 #define TIM9_TICKS_PER_USEC PWM_INPUT2_TICKS_PER_USEC
385 #endif
386 #define PWM_INPUT2_CHANNEL_PERIOD TIM_IC1
387 #define PWM_INPUT2_CHANNEL_DUTY TIM_IC2
388 #define PWM_INPUT2_TIMER_INPUT TIM_IC_IN_TI1
389 #define PWM_INPUT2_SLAVE_TRIG TIM_SMCR_TS_TI1FP1
390 #define PWM_INPUT2_IRQ NVIC_TIM1_BRK_TIM9_IRQ
391 #define PWM_INPUT2_CC_IE (TIM_DIER_CC3IE | TIM_DIER_CC4IE)
392 #ifdef USE_PWM_INPUT2
393 #define USE_PWM_INPUT_TIM9 TRUE
394 #else
395 #define USE_PWM_INPUT_TIM9 FALSE
396 #endif
397 #define TIM9_PWM_INPUT_IDX 1
398 #define TIM9_CC_IF_PERIOD TIM_SR_CC1IF
399 #define TIM9_CC_IF_DUTY TIM_SR_CC2IF
400 #define TIM9_CCR_PERIOD TIM9_CCR1
401 #define TIM9_CCR_DUTY TIM9_CCR2
402 // Servo 1 (aka PA2) is used: not compatible with PWM1 (and should be disabled)
403 #if (USE_PWM1 && USE_PWM_INPUT2)
404 #error "PW1 and PWM_INPUT2 are not compatible"
405 #endif
406 #define PWM_INPUT2_GPIO_PORT GPIOA
407 #define PWM_INPUT2_GPIO_PIN GPIO2
408 #define PWM_INPUT2_GPIO_AF GPIO_AF3
409 
410 /*
411  * Spektrum
412  */
413 
414 /* The line that is pulled low at power up to initiate the bind process
415  * PB15: AUX4
416  */
417 #define SPEKTRUM_BIND_PIN GPIO15
418 #define SPEKTRUM_BIND_PIN_PORT GPIOB
419 
420 /* The line used to send the pulse train for the bind process
421  * When using UART2 on Apogee, this as to be a different pin than the uart2 rx
422  * Default pin for this is PA8: PPM_IN
423  */
424 #ifndef SPEKTRUM_PRIMARY_BIND_CONF_PORT
425 #define SPEKTRUM_PRIMARY_BIND_CONF_PORT GPIOA
426 #define SPEKTRUM_PRIMARY_BIND_CONF_PIN GPIO8
427 #endif
428 
429 /*
430  * IRQ Priorities
431  */
432 #define RTOS_PRIO 2
433 #define NVIC_TIM_IRQ_PRIO (RTOS_PRIO+1)
434 #define NVIC_I2C_IRQ_PRIO (RTOS_PRIO+2)
435 #define NVIC_SPI_IRQ_PRIO (RTOS_PRIO+3)
436 #define NVIC_UART_IRQ_PRIO (RTOS_PRIO+4)
437 #define NVIC_USART_IRQ_PRIO (RTOS_PRIO+4)
438 #define NVIC_ADC_IRQ_PRIO (RTOS_PRIO+5)
439 #define NVIC_TIM6_DAC_IRQ_PRIO (RTOS_PRIO+6)
440 
441 
442 #endif /* CONFIG_APOGEE_1_00_H */