Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
holybro_kakute_f7.h
Go to the documentation of this file.
1 #ifndef CONFIG_HOLYBRO_KAKUTE_F7_H
2 #define CONFIG_HOLYBRO_KAKUTE_F7_H
3 
4 #define BOARD_HOLYBRO_KAKUTE_F7
5 
9 #include "board.h"
10 
15 /*
16  * AHB_CLK
17  */
18 #define AHB_CLK STM32_HCLK
19 
20 /*
21  * Concat macro
22  */
23 #define _CONCAT_BOARD_PARAM(_s1, _s2) _s1 ## _s2
24 #define CONCAT_BOARD_PARAM(_s1, _s2) _CONCAT_BOARD_PARAM(_s1, _s2)
25 
26 /*
27  * LEDs
28  */
29 /* blue, 1 on LED_ON, 0 on LED_OFF */
30 #ifndef USE_LED_1
31 #define USE_LED_1 1
32 #endif
33 #define LED_1_GPIO PAL_PORT(LINE_LED1)
34 #define LED_1_GPIO_PIN PAL_PAD(LINE_LED1)
35 #define LED_1_GPIO_ON gpio_set
36 #define LED_1_GPIO_OFF gpio_clear
37 
38 /*
39  * ADCs
40  */
41 // RSSI
42 #if USE_ADC_1
43 #define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, RSSI_ADC_IN)
44 #define ADC_1 AD1_1
45 #define ADC_1_GPIO_PORT PAL_PORT(LINE_RSSI)
46 #define ADC_1_GPIO_PIN PAL_PAD(LINE_RSSI)
47 #endif
48 
49 // VBAT enabled by default
50 #ifndef USE_ADC_2
51 #define USE_ADC_2 1
52 #endif
53 #if USE_ADC_2
54 #define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, VBAT_MEAS_ADC_IN)
55 #define ADC_2 AD1_2
56 #define ADC_2_GPIO_PORT PAL_PORT(LINE_VBAT_MEAS)
57 #define ADC_2_GPIO_PIN PAL_PAD(LINE_VBAT_MEAS)
58 #endif
59 
60 // CURRENT
61 #if USE_ADC_3
62 #define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, CURRENT_MEAS_ADC_IN)
63 #define ADC_3 AD1_3
64 #define ADC_3_GPIO_PORT PAL_PORT(LINE_CURRENT_MEAS)
65 #define ADC_3_GPIO_PIN PAL_PAD(LINE_CURRENT_MEAS)
66 #endif
67 
68 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
69 #ifndef ADC_CHANNEL_VSUPPLY
70 #define ADC_CHANNEL_VSUPPLY ADC_2
71 #endif
72 
73 /*
74  * R1 = 1k
75  * R2 = 10k
76  * adc * (3.3 / 2^12) * ((R1 + R2) / R1)
77  */
78 #define VBAT_R1 1000.0f
79 #define VBAT_R2 10000.0f
80 #define DefaultVoltageOfAdc(adc) ((3.3f/4096.0f)*((VBAT_R1+VBAT_R2)/VBAT_R1)*adc)
81 
82 /*
83  * current sensor: 132A, 3.3V 12bits ADC -> 40 A/V -> 40000 * 3.3/2^12 mA/ADC
84  */
85 #define DefaultMilliAmpereOfAdc(adc) ((40000.f*3.3f/4096.f)*adc)
86 
87 /*
88  * PWM TIM defines
89  * enable TIM 1, 3, 4, 5, 8 by default
90  */
91 #ifndef USE_PWM_TIM1
92 #define USE_PWM_TIM1 1
93 #endif
94 
95 #ifndef USE_PWM_TIM3
96 #define USE_PWM_TIM3 1
97 #endif
98 
99 #ifndef USE_PWM_TIM4
100 #define USE_PWM_TIM4 1
101 #endif
102 
103 #ifndef USE_PWM_TIM5
104 #define USE_PWM_TIM5 1
105 #endif
106 
107 #ifndef USE_PWM_TIM8
108 #define USE_PWM_TIM8 1
109 #endif
110 
111 /*
112  * PWM defines
113  */
114 
115 #ifndef USE_PWM1
116 #define USE_PWM1 1
117 #endif
118 #if USE_PWM1
119 #define PWM_SERVO_1 1
120 #define PWM_SERVO_1_GPIO PAL_PORT(LINE_S1)
121 #define PWM_SERVO_1_PIN PAL_PAD(LINE_S1)
122 #define PWM_SERVO_1_AF AF_S1
123 #define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, S1_TIM)
124 #define PWM_SERVO_1_CHANNEL (S1_TIM_CH-1)
125 #define PWM_SERVO_1_CONF CONCAT_BOARD_PARAM(pwmcfg, S1_TIM)
126 #endif
127 
128 #ifndef USE_PWM2
129 #define USE_PWM2 1
130 #endif
131 #if USE_PWM2
132 #define PWM_SERVO_2 2
133 #define PWM_SERVO_2_GPIO PAL_PORT(LINE_S2)
134 #define PWM_SERVO_2_PIN PAL_PAD(LINE_S2)
135 #define PWM_SERVO_2_AF AF_S2
136 #define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, S2_TIM)
137 #define PWM_SERVO_2_CHANNEL (S2_TIM_CH-1)
138 #define PWM_SERVO_2_CONF CONCAT_BOARD_PARAM(pwmcfg, S2_TIM)
139 #endif
140 
141 #ifndef USE_PWM3
142 #define USE_PWM3 1
143 #endif
144 #if USE_PWM3
145 #define PWM_SERVO_3 3
146 #define PWM_SERVO_3_GPIO PAL_PORT(LINE_S3)
147 #define PWM_SERVO_3_PIN PAL_PAD(LINE_S3)
148 #define PWM_SERVO_3_AF AF_S3
149 #define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, S3_TIM)
150 #define PWM_SERVO_3_CHANNEL (S3_TIM_CH-1)
151 #define PWM_SERVO_3_CONF CONCAT_BOARD_PARAM(pwmcfg, S3_TIM)
152 #endif
153 
154 #ifndef USE_PWM4
155 #define USE_PWM4 1
156 #endif
157 #if USE_PWM4
158 #define PWM_SERVO_4 4
159 #define PWM_SERVO_4_GPIO PAL_PORT(LINE_S4)
160 #define PWM_SERVO_4_PIN PAL_PAD(LINE_S4)
161 #define PWM_SERVO_4_AF AF_S4
162 #define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, S4_TIM)
163 #define PWM_SERVO_4_CHANNEL (S4_TIM_CH-1)
164 #define PWM_SERVO_4_CONF CONCAT_BOARD_PARAM(pwmcfg, S4_TIM)
165 #endif
166 
167 #ifndef USE_PWM5
168 #define USE_PWM5 1
169 #endif
170 #if USE_PWM5
171 #define PWM_SERVO_5 5
172 #define PWM_SERVO_5_GPIO PAL_PORT(LINE_S5)
173 #define PWM_SERVO_5_PIN PAL_PAD(LINE_S5)
174 #define PWM_SERVO_5_AF AF_S5
175 #define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, S5_TIM)
176 #define PWM_SERVO_5_CHANNEL (S5_TIM_CH-1)
177 #define PWM_SERVO_5_CONF CONCAT_BOARD_PARAM(pwmcfg, S5_TIM)
178 #endif
179 
180 #ifndef USE_PWM6
181 #define USE_PWM6 1
182 #endif
183 #if USE_PWM6
184 #define PWM_SERVO_6 6
185 #define PWM_SERVO_6_GPIO PAL_PORT(LINE_S6)
186 #define PWM_SERVO_6_PIN PAL_PAD(LINE_S6)
187 #define PWM_SERVO_6_AF AF_S6
188 #define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, S6_TIM)
189 #define PWM_SERVO_6_CHANNEL (S6_TIM_CH-1)
190 #define PWM_SERVO_6_CONF CONCAT_BOARD_PARAM(pwmcfg, S6_TIM)
191 #endif
192 
193 // servo index starting at 1 + regular servos
194 // so NB = 1+6
195 #define ACTUATORS_PWM_NB 7
196 
200 #ifndef DSHOT_TELEMETRY_DEV
201 #define DSHOT_TELEMETRY_DEV NULL
202 #endif
203 
204 #ifndef USE_DSHOT_TIM
205 #define USE_DSHOT_TIM 0
206 #endif
207 
208 #if USE_DSHOT_TIM
209 
210 #define DSHOT_SERVO_1 1
211 #define DSHOT_SERVO_1_GPIO PAL_PORT(LINE_S1)
212 #define DSHOT_SERVO_1_PIN PAL_PAD(LINE_S1)
213 #define DSHOT_SERVO_1_AF AF_S1
214 #define DSHOT_SERVO_1_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S1_TIM)
215 #define DSHOT_SERVO_1_CHANNEL S1_TIM_CH
216 
217 #define DSHOT_SERVO_2 2
218 #define DSHOT_SERVO_2_GPIO PAL_PORT(LINE_S2)
219 #define DSHOT_SERVO_2_PIN PAL_PAD(LINE_S2)
220 #define DSHOT_SERVO_2_AF AF_S2
221 #define DSHOT_SERVO_2_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S2_TIM)
222 #define DSHOT_SERVO_2_CHANNEL S2_TIM_CH
223 
224 #define DSHOT_SERVO_3 3
225 #define DSHOT_SERVO_3_GPIO PAL_PORT(LINE_S3)
226 #define DSHOT_SERVO_3_PIN PAL_PAD(LINE_S3)
227 #define DSHOT_SERVO_3_AF AF_S3
228 #define DSHOT_SERVO_3_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S3_TIM)
229 #define DSHOT_SERVO_3_CHANNEL S3_TIM_CH
230 
231 #define DSHOT_SERVO_4 4
232 #define DSHOT_SERVO_4_GPIO PAL_PORT(LINE_S4)
233 #define DSHOT_SERVO_4_PIN PAL_PAD(LINE_S4)
234 #define DSHOT_SERVO_4_AF AF_S4
235 #define DSHOT_SERVO_4_DRIVER CONCAT_BOARD_PARAM(DSHOTD, S4_TIM)
236 #define DSHOT_SERVO_4_CHANNEL S4_TIM_CH
237 
238 #define DSHOT_CONF_TIM1 1
239 #define DSHOT_CONF4_DEF { \
240  .dma_stream = STM32_PWM1_UP_DMA_STREAM, \
241  .dma_channel = STM32_PWM1_UP_DMA_CHANNEL, \
242  .pwmp = &PWMD1, \
243  .tlm_sd = DSHOT_TELEMETRY_DEV, \
244  .dma_buf = &dshot4DmaBuffer, \
245  .dcache_memory_in_use = false \
246 }
247 
248 #define DSHOT_CONF_TIM3 1
249 #define DSHOT_CONF3_DEF { \
250  .dma_stream = STM32_PWM3_UP_DMA_STREAM, \
251  .dma_channel = STM32_PWM3_UP_DMA_CHANNEL, \
252  .pwmp = &PWMD3, \
253  .tlm_sd = DSHOT_TELEMETRY_DEV, \
254  .dma_buf = &dshot4DmaBuffer, \
255  .dcache_memory_in_use = false \
256 }
257 
258 #endif
259 
263 #define UART1_GPIO_PORT_TX PAL_PORT(LINE_UART1_TX)
264 #define UART1_GPIO_TX PAL_PAD(LINE_UART1_TX)
265 #define UART1_GPIO_PORT_RX PAL_PORT(LINE_UART1_RX)
266 #define UART1_GPIO_RX PAL_PAD(LINE_UART1_RX)
267 #define UART1_GPIO_AF AF_UART1_TX
268 
273 #define UART2_GPIO_PORT_TX PAL_PORT(LINE_UART2_TX)
274 #define UART2_GPIO_TX PAL_PAD(LINE_UART2_TX)
275 #define UART2_GPIO_PORT_RX PAL_PORT(LINE_UART2_RX)
276 #define UART2_GPIO_RX PAL_PAD(LINE_UART2_RX)
277 #define UART2_GPIO_AF AF_UART2_TX
278 
282 #define UART3_GPIO_PORT_TX PAL_PORT(LINE_UART3_TX)
283 #define UART3_GPIO_TX PAL_PAD(LINE_UART3_TX)
284 #define UART3_GPIO_PORT_RX PAL_PORT(LINE_UART3_RX)
285 #define UART3_GPIO_RX PAL_PAD(LINE_UART3_RX)
286 #define UART3_GPIO_AF AF_UART3_TX
287 
291 #define UART4_GPIO_PORT_TX PAL_PORT(LINE_UART4_TX)
292 #define UART4_GPIO_TX PAL_PAD(LINE_UART4_TX)
293 #define UART4_GPIO_PORT_RX PAL_PORT(LINE_UART4_RX)
294 #define UART4_GPIO_RX PAL_PAD(LINE_UART4_RX)
295 #define UART4_GPIO_AF AF_UART4_TX
296 
301 #define USE_UART6_RX TRUE
302 #define USE_UART6_TX FALSE
303 #define UART6_GPIO_PORT_RX PAL_PORT(LINE_RC1)
304 #define UART6_GPIO_RX PAL_PAD(LINE_RC1)
305 #define UART6_GPIO_AF RC1_USART_AF
306 
307 /* The line that is pulled low at power up to initiate the bind process
308  */
309 #define SPEKTRUM_BIND_PIN PAL_PORT(LINE_XXX)
310 #define SPEKTRUM_BIND_PIN_PORT PAL_PAD(LINE_XXX)
311 
312 // no wait with chibios as the RTC oscillator takes longer to stabilize
313 #define SPEKTRUM_BIND_WAIT 30000
314 
320 #define RC_PPM_TICKS_PER_USEC 6
321 #define PPM_TIMER_FREQUENCY 6000000
322 #define PPM_CHANNEL CONCAT_BOARD_PARAM(ICU_CHANNEL_, RC2_TIM_CH)
323 #define PPM_TIMER CONCAT_BOARD_PARAM(ICUD, RC2_TIM)
324 
328 // Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
329 #define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
330 // Timing register
331 #define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
332  STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
333  STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
334 #define I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(1U) | \
335  STM32_TIMINGR_SCLDEL(9U) | STM32_TIMINGR_SDADEL(0U) | \
336  STM32_TIMINGR_SCLH(105U) | STM32_TIMINGR_SCLL(153U))
337 
338 
339 #ifndef I2C1_CLOCK_SPEED
340 #define I2C1_CLOCK_SPEED 400000
341 #endif
342 
343 #if I2C1_CLOCK_SPEED == 400000
344 #define I2C1_CFG_DEF { \
345  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
346  .cr1 = STM32_CR1_DNF(0), \
347  .cr2 = 0 \
348 }
349 #elif I2C1_CLOCK_SPEED == 100000
350 #define I2C1_CFG_DEF { \
351  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
352  .cr1 = STM32_CR1_DNF(0), \
353  .cr2 = 0 \
354 }
355 #else
356 #error "Unknown I2C1 clock speed"
357 #endif
358 
363 // Internal SPI (SDCARD)
364 #define SPI1_GPIO_AF AF_SPI1_CLK
365 #define SPI1_GPIO_PORT_MISO PAL_PORT(LINE_SPI1_MISO)
366 #define SPI1_GPIO_MISO PAL_PAD(LINE_SPI1_MISO)
367 #define SPI1_GPIO_PORT_MOSI PAL_PORT(LINE_SPI1_MOSI)
368 #define SPI1_GPIO_MOSI PAL_PAD(LINE_SPI1_MOSI)
369 #define SPI1_GPIO_PORT_SCK PAL_PORT(LINE_SPI1_CLK)
370 #define SPI1_GPIO_SCK PAL_PAD(LINE_SPI1_CLK)
371 
372 // Internal SPI (OSD)
373 #define SPI2_GPIO_AF AF_SPI2_CLK
374 #define SPI2_GPIO_PORT_MISO PAL_PORT(LINE_SPI2_MISO)
375 #define SPI2_GPIO_MISO PAL_PAD(LINE_SPI2_MISO)
376 #define SPI2_GPIO_PORT_MOSI PAL_PORT(LINE_SPI2_MOSI)
377 #define SPI2_GPIO_MOSI PAL_PAD(LINE_SPI2_MOSI)
378 #define SPI2_GPIO_PORT_SCK PAL_PORT(LINE_SPI2_CLK)
379 #define SPI2_GPIO_SCK PAL_PAD(LINE_SPI2_CLK)
380 
381 // Internal SPI (IMU)
382 #define SPI4_GPIO_AF AF_SPI4_INTERNAL_CLK
383 #define SPI4_GPIO_PORT_MISO PAL_PORT(LINE_SPI4_INTERNAL_MISO)
384 #define SPI4_GPIO_MISO PAL_PAD(LINE_SPI4_INTERNAL_MISO)
385 #define SPI4_GPIO_PORT_MOSI PAL_PORT(LINE_SPI4_INTERNAL_MOSI)
386 #define SPI4_GPIO_MOSI PAL_PAD(LINE_SPI4_INTERNAL_MOSI)
387 #define SPI4_GPIO_PORT_SCK PAL_PORT(LINE_SPI4_INTERNAL_CLK)
388 #define SPI4_GPIO_SCK PAL_PAD(LINE_SPI4_INTERNAL_CLK)
389 
390 // SLAVE0 on IMU1 (MPU6000)
391 #define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_IMU_CS)
392 #define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_IMU_CS)
393 // SLAVE1 on SDCARD
394 #define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_SDCARD_CS)
395 #define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_SDCARD_CS)
396 // SLAVE2 on OSD
397 #define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_OSD_CS)
398 #define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_OSD_CS)
399 
406 #ifndef USE_BARO_BOARD
407 #define USE_BARO_BOARD 0
408 #endif
409 
410 /*
411  * Actuators for fixedwing
412  */
413  /* Default actuators driver */
414 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
415 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
416 #define ActuatorsDefaultInit() ActuatorsPwmInit()
417 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
418 
419 #endif /* CONFIG_HOLYBRO_KAKUTE_F7_H */
420