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
krooz_sd.h
Go to the documentation of this file.
1 #ifndef CONFIG_KROOZ_1_0_H
2 #define CONFIG_KROOZ_1_0_H
3 
4 #define BOARD_KROOZ
5 
6 /* KroozSD has a 12MHz external clock and 168MHz internal. */
7 #define EXT_CLK 12000000
8 #define AHB_CLK 168000000
9 
10 /*
11  * Onboard LEDs
12  */
13 
14 /* red, on PA8 */
15 #ifndef USE_LED_1
16 #define USE_LED_1 1
17 #endif
18 #define LED_1_GPIO GPIOA
19 #define LED_1_GPIO_CLK RCC_AHB1ENR_IOPAEN
20 #define LED_1_GPIO_PIN GPIO13
21 #define LED_1_GPIO_ON gpio_clear
22 #define LED_1_GPIO_OFF gpio_set
23 #define LED_1_AFIO_REMAP ((void)0)
24 
25 /* green, shared with JTAG_TRST */
26 #ifndef USE_LED_2
27 #define USE_LED_2 1
28 #endif
29 #define LED_2_GPIO GPIOA
30 #define LED_2_GPIO_CLK RCC_AHB1ENR_IOPAEN
31 #define LED_2_GPIO_PIN GPIO14
32 #define LED_2_GPIO_ON gpio_clear
33 #define LED_2_GPIO_OFF gpio_set
34 #define LED_2_AFIO_REMAP ((void)0)
35 
36 /* green, shared with ADC12 (ADC_6 on connector ANALOG2) */
37 #ifndef USE_LED_3
38 #define USE_LED_3 1
39 #endif
40 #define LED_3_GPIO GPIOA
41 #define LED_3_GPIO_CLK RCC_AHB1ENR_IOPAEN
42 #define LED_3_GPIO_PIN GPIO15
43 #define LED_3_GPIO_ON gpio_clear
44 #define LED_3_GPIO_OFF gpio_set
45 #define LED_3_AFIO_REMAP ((void)0)
46 
47 /*
48  * not actual LEDS, used as GPIOs
49  */
50 
51 /* PB4, Camera power On/Off */
52 #define CAM_SW_GPIO GPIOB
53 #define CAM_SW_GPIO_CLK RCC_AHB1ENR_IOPBEN
54 #define CAM_SW_GPIO_PIN GPIO4
55 #define CAM_SW_AFIO_REMAP ((void)0)
56 
57 /* PC2, Camera shot */
58 #define CAM_SH_GPIO GPIOC
59 #define CAM_SH_GPIO_CLK RCC_AHB1ENR_IOPCEN
60 #define CAM_SH_GPIO_PIN GPIO2
61 #define CAM_SH_AFIO_REMAP ((void)0)
62 
63 /* PC15, Camera video */
64 #define CAM_V_GPIO GPIOC
65 #define CAM_V_GPIO_CLK RCC_AHB1ENR_IOPCEN
66 #define CAM_V_GPIO_PIN GPIO15
67 #define CAM_V_AFIO_REMAP ((void)0)
68 
69 #define BEEPER_GPIO GPIOC
70 #define BEEPER_GPIO_CLK RCC_AHB1ENR_IOPCEN
71 #define BEEPER_GPIO_PIN GPIO14
72 #define BEEPER_AFIO_REMAP ((void)0)
73 
74 
75 /* Default actuators driver */
76 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
77 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
78 #define ActuatorsDefaultInit() ActuatorsPwmInit()
79 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
80 
81 #define DefaultVoltageOfAdc(adc) (0.008874*adc)
82 
83 /* UART */
84 #define UART1_GPIO_AF GPIO_AF7
85 #define UART1_GPIO_PORT_RX GPIOA
86 #define UART1_GPIO_RX GPIO10
87 #define UART1_GPIO_PORT_TX GPIOA
88 #define UART1_GPIO_TX GPIO9
89 
90 #define UART3_GPIO_AF GPIO_AF7
91 #define UART3_GPIO_PORT_RX GPIOC
92 #define UART3_GPIO_RX GPIO11
93 #define UART3_GPIO_PORT_TX GPIOC
94 #define UART3_GPIO_TX GPIO10
95 
96 #define UART5_GPIO_AF GPIO_AF8
97 #define UART5_GPIO_PORT_RX GPIOD
98 #define UART5_GPIO_RX GPIO2
99 #define UART5_GPIO_PORT_TX GPIOC
100 #define UART5_GPIO_TX GPIO12
101 
102 
103 /* I2C mapping */
104 #define I2C1_GPIO_PORT GPIOB
105 #define I2C1_GPIO_SCL GPIO8
106 #define I2C1_GPIO_SDA GPIO7
107 
108 #define I2C2_GPIO_PORT GPIOB
109 #define I2C2_GPIO_SCL GPIO10
110 #define I2C2_GPIO_SDA GPIO11
111 
112 
113 /* Onboard ADCs */
114 #define USE_AD_TIM1 1
115 
116 #define BOARD_ADC_CHANNEL_1 12
117 #define BOARD_ADC_CHANNEL_2 10
118 #define BOARD_ADC_CHANNEL_3 11
119 #define BOARD_ADC_CHANNEL_4 13
120 #define BOARD_ADC_CHANNEL_5 14
121 #define BOARD_ADC_CHANNEL_6 15
122 
123 /* provide defines that can be used to access the ADC_x in the code or airframe file
124  * these directly map to the index number of the 4 adc channels defined above
125  * 4th (index 3) is used for bat monitoring by default
126  */
127 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
128 #ifndef ADC_CHANNEL_VSUPPLY
129 #define ADC_CHANNEL_VSUPPLY ADC_4
130 #endif
131 
132 #define ADC_CHANNEL_CAM1 ADC_1
133 
134 #ifndef USE_AD1
135 #define USE_AD1 1
136 #endif
137 /* provide defines that can be used to access the ADC_x in the code or airframe file
138  * these directly map to the index number of the 4 adc channels defined above
139  * 4th (index 3) is used for bat monitoring by default
140  */
141 #define ADC_1 ADC1_C1
142 #ifdef USE_ADC_1
143 #ifndef ADC_1_GPIO_CLOCK_PORT
144 #define ADC_1_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
145 #define ADC_1_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2)
146 #endif
147 #define USE_AD1_1 1
148 #else
149 #define ADC_1_GPIO_CLOCK_PORT 0
150 #define ADC_1_INIT() {}
151 #endif
152 
153 #define ADC_2 ADC1_C2
154 #ifdef USE_ADC_2
155 #ifndef ADC_2_GPIO_CLOCK_PORT
156 #define ADC_2_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
157 #define ADC_2_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0)
158 #endif
159 #define USE_AD1_2 1
160 #else
161 #define ADC_2_GPIO_CLOCK_PORT 0
162 #define ADC_2_INIT() {}
163 #endif
164 
165 #define ADC_3 ADC1_C3
166 #ifdef USE_ADC_3
167 #ifndef ADC_3_GPIO_CLOCK_PORT
168 #define ADC_3_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
169 #define ADC_3_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1)
170 #endif
171 #define USE_AD1_3 1
172 #else
173 #define ADC_3_GPIO_CLOCK_PORT 0
174 #define ADC_3_INIT() {}
175 #endif
176 
177 #define ADC_4 ADC1_C4
178 //#ifdef USE_ADC_4
179 #ifndef ADC_4_GPIO_CLOCK_PORT
180 #define ADC_4_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
181 #define ADC_4_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO3)
182 #endif
183 #define USE_AD1_4 1
184 //#else
185 //#define ADC_4_GPIO_CLOCK_PORT 0
186 //#define ADC_4_INIT() {}
187 //#endif
188 
189 #define ADC_GPIO_CLOCK_PORT (ADC_1_GPIO_CLOCK_PORT | ADC_2_GPIO_CLOCK_PORT | ADC_3_GPIO_CLOCK_PORT | ADC_4_GPIO_CLOCK_PORT)
190 
191 #ifdef USE_AD1
192 #define ADC1_GPIO_INIT(gpio) { \
193  ADC_1_INIT(); \
194  ADC_2_INIT(); \
195  ADC_3_INIT(); \
196  ADC_4_INIT(); \
197  }
198 #endif // USE_AD1
199 
200 
201 /* I2C mapping */
202 #define GPIO_I2C1_SCL GPIO8
203 #define GPIO_I2C1_SDA GPIO9
204 #define GPIO_I2C2_SCL GPIO10
205 #define GPIO_I2C2_SDA GPIO11
206 #define GPIO_I2C3_SCL GPIO8 //PA8
207 #define GPIO_I2C3_SDA GPIO9 //PC9
208 
209 /* Activate onboard baro */
210 #define BOARD_HAS_BARO 1
211 
212 /* PWM */
213 //#define PWM_USE_TIM2 1
214 #define PWM_USE_TIM3 1
215 #define PWM_USE_TIM4 1
216 #define PWM_USE_TIM5 1
217 
218 #define USE_PWM0 1
219 #define USE_PWM1 1
220 #define USE_PWM2 1
221 #define USE_PWM3 1
222 #define USE_PWM4 1
223 #define USE_PWM5 1
224 #define USE_PWM6 1
225 #define USE_PWM7 1
226 #define USE_PWM8 1
227 #define USE_PWM9 1
228 //#define USE_PWM10 1
229 
230 #define ACTUATORS_PWM_NB 10
231 
232 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
233 #if USE_PWM0
234 #define PWM_SERVO_0 0
235 #define PWM_SERVO_0_TIMER TIM3
236 #define PWM_SERVO_0_RCC_IOP RCC_AHB1ENR_IOPCEN
237 #define PWM_SERVO_0_GPIO GPIOC
238 #define PWM_SERVO_0_PIN GPIO6
239 #define PWM_SERVO_0_AF GPIO_AF1
240 #define PWM_SERVO_0_OC TIM_OC1
241 #define PWM_SERVO_0_OC_BIT (1<<0)
242 #else
243 #define PWM_SERVO_0_OC_BIT 0
244 #endif
245 
246 #if USE_PWM1
247 #define PWM_SERVO_1 1
248 #define PWM_SERVO_1_TIMER TIM3
249 #define PWM_SERVO_1_RCC_IOP RCC_AHB1ENR_IOPCEN
250 #define PWM_SERVO_1_GPIO GPIOC
251 #define PWM_SERVO_1_PIN GPIO7
252 #define PWM_SERVO_1_AF GPIO_AF1
253 #define PWM_SERVO_1_OC TIM_OC2
254 #define PWM_SERVO_1_OC_BIT (1<<1)
255 #else
256 #define PWM_SERVO_1_OC_BIT 0
257 #endif
258 
259 #if USE_PWM2
260 #define PWM_SERVO_2 2
261 #define PWM_SERVO_2_TIMER TIM3
262 #define PWM_SERVO_2_RCC_IOP RCC_AHB1ENR_IOPCEN
263 #define PWM_SERVO_2_GPIO GPIOC
264 #define PWM_SERVO_2_PIN GPIO8
265 #define PWM_SERVO_2_AF GPIO_AF1
266 #define PWM_SERVO_2_OC TIM_OC3
267 #define PWM_SERVO_2_OC_BIT (1<<2)
268 #else
269 #define PWM_SERVO_2_OC_BIT 0
270 #endif
271 
272 #if USE_PWM3
273 #define PWM_SERVO_3_IDX 3
274 #define PWM_SERVO_3_TIMER TIM3
275 #define PWM_SERVO_3_RCC_IOP RCC_AHB1ENR_IOPCEN
276 #define PWM_SERVO_3_GPIO GPIOC
277 #define PWM_SERVO_3_PIN GPIO9
278 #define PWM_SERVO_3_AF GPIO_AF1
279 #define PWM_SERVO_3_OC TIM_OC4
280 #define PWM_SERVO_3_OC_BIT (1<<3)
281 #else
282 #define PWM_SERVO_3_OC_BIT 0
283 #endif
284 
285 #if USE_PWM4
286 #define PWM_SERVO_4 4
287 #define PWM_SERVO_4_TIMER TIM4
288 #define PWM_SERVO_4_RCC_IOP RCC_AHB1ENR_IOPBEN
289 #define PWM_SERVO_4_GPIO GPIOB
290 #define PWM_SERVO_4_PIN GPIO6
291 #define PWM_SERVO_4_AF GPIO_AF1
292 #define PWM_SERVO_4_OC TIM_OC1
293 #define PWM_SERVO_4_OC_BIT (1<<0)
294 #else
295 #define PWM_SERVO_4_OC_BIT 0
296 #endif
297 
298 #if USE_PWM5
299 #define PWM_SERVO_5 5
300 #define PWM_SERVO_5_TIMER TIM4
301 #define PWM_SERVO_5_RCC_IOP RCC_AHB1ENR_IOPBEN
302 #define PWM_SERVO_5_GPIO GPIOB
303 #define PWM_SERVO_5_PIN GPIO7
304 #define PWM_SERVO_5_AF GPIO_AF1
305 #define PWM_SERVO_5_OC TIM_OC2
306 #define PWM_SERVO_5_OC_BIT (1<<1)
307 #else
308 #define PWM_SERVO_5_OC_BIT 0
309 #endif
310 
311 #if USE_PWM6
312 #define PWM_SERVO_6 6
313 #define PWM_SERVO_6_TIMER TIM5
314 #define PWM_SERVO_6_RCC_IOP RCC_AHB1ENR_IOPAEN
315 #define PWM_SERVO_6_GPIO GPIOA
316 #define PWM_SERVO_6_PIN GPIO0
317 #define PWM_SERVO_6_AF GPIO_AF1
318 #define PWM_SERVO_6_OC TIM_OC1
319 #define PWM_SERVO_6_OC_BIT (1<<0)
320 #else
321 #define PWM_SERVO_6_OC_BIT 0
322 #endif
323 
324 #if USE_PWM7
325 #define PWM_SERVO_7 7
326 #define PWM_SERVO_7_TIMER TIM5
327 #define PWM_SERVO_7_RCC_IOP RCC_AHB1ENR_IOPAEN
328 #define PWM_SERVO_7_GPIO GPIOA
329 #define PWM_SERVO_7_PIN GPIO1
330 #define PWM_SERVO_7_AF GPIO_AF1
331 #define PWM_SERVO_7_OC TIM_OC2
332 #define PWM_SERVO_7_OC_BIT (1<<1)
333 #else
334 #define PWM_SERVO_7_OC_BIT 0
335 #endif
336 
337 #if USE_PWM8
338 #define PWM_SERVO_8 8
339 #define PWM_SERVO_8_TIMER TIM5
340 #define PWM_SERVO_8_RCC_IOP RCC_AHB1ENR_IOPAEN
341 #define PWM_SERVO_8_GPIO GPIOA
342 #define PWM_SERVO_8_PIN GPIO2
343 #define PWM_SERVO_8_AF GPIO_AF1
344 #define PWM_SERVO_8_OC TIM_OC3
345 #define PWM_SERVO_8_OC_BIT (1<<2)
346 #else
347 #define PWM_SERVO_8_OC_BIT 0
348 #endif
349 
350 #if USE_PWM9
351 #define PWM_SERVO_9 9
352 #define PWM_SERVO_9_TIMER TIM5
353 #define PWM_SERVO_9_RCC_IOP RCC_AHB1ENR_IOPAEN
354 #define PWM_SERVO_9_GPIO GPIOA
355 #define PWM_SERVO_9_PIN GPIO3
356 #define PWM_SERVO_9_AF GPIO_AF1
357 #define PWM_SERVO_9_OC TIM_OC4
358 #define PWM_SERVO_9_OC_BIT (1<<3)
359 #else
360 #define PWM_SERVO_9_OC_BIT 0
361 #endif
362 
363 #if USE_PWM10
364 #define PWM_SERVO_10 10
365 #define PWM_SERVO_10_TIMER TIM2
366 #define PWM_SERVO_10_RCC_IOP RCC_AHB1ENR_IOPBEN
367 #define PWM_SERVO_10_GPIO GPIOB
368 #define PWM_SERVO_10_PIN GPIO3
369 #define PWM_SERVO_10_AF GPIO_AF1
370 #define PWM_SERVO_10_OC TIM_OC2
371 #define PWM_SERVO_10_OC_BIT (1<<1)
372 #else
373 #define PWM_SERVO_10_OC_BIT 0
374 #endif
375 
376 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_10_OC_BIT)
377 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_0_OC_BIT|PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT)
378 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_4_OC_BIT|PWM_SERVO_5_OC_BIT)
379 #define PWM_TIM5_CHAN_MASK (PWM_SERVO_6_OC_BIT|PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT|PWM_SERVO_9_OC_BIT)
380 
381 /* PPM */
382 
383 #define USE_PPM_TIM2 1
384 
385 #define PPM_CHANNEL TIM_IC2
386 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
387 #define PPM_IRQ NVIC_TIM2_IRQ
388 //#define PPM_IRQ2 NVIC_TIM2_UP_TIM10_IRQ
389 // Capture/Compare InteruptEnable and InterruptFlag
390 #define PPM_CC_EN TIM_DIER_CC2IE
391 #define PPM_CC_IF TIM_SR_CC2IF
392 #define PPM_GPIO_PORT GPIOB
393 #define PPM_GPIO_PIN GPIO3
394 #define PPM_GPIO_AF GPIO_AF1
395 
396 /*
397  * Spektrum
398  */
399 /* The line that is pulled low at power up to initiate the bind process */
400 #define SPEKTRUM_BIND_PIN GPIO8
401 #define SPEKTRUM_BIND_PIN_PORT GPIOA
402 
403 #endif /* CONFIG_KROOZ_1_0_H */