Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
crazyflie.h
Go to the documentation of this file.
1
#ifndef CONFIG_CRAZYFLIE_2_1_H
2
#define CONFIG_CRAZYFLIE_2_1_H
3
4
#define BOARD_CRAZYFLIE
5
9
#include "
boards/crazyflie/chibios/v2.1/board.h
"
10
15
/*
16
* AHB_CLK
17
*/
18
#define AHB_CLK STM32_HCLK
19
20
/*
21
* LEDs
22
*/
23
#ifndef USE_LED_1
24
#define USE_LED_1 1
25
#endif
26
#define LED_1_GPIO PAL_PORT(LINE_LED_RED_R)
27
#define LED_1_GPIO_PIN PAL_PAD(LINE_LED_RED_R)
28
#define LED_1_GPIO_ON gpio_clear
29
#define LED_1_GPIO_OFF gpio_set
30
31
#ifndef USE_LED_2
32
#define USE_LED_2 1
33
#endif
34
#define LED_2_GPIO PAL_PORT(LINE_LED_RED_L)
35
#define LED_2_GPIO_PIN PAL_PAD(LINE_LED_RED_L)
36
#define LED_2_GPIO_ON gpio_clear
37
#define LED_2_GPIO_OFF gpio_set
38
39
#ifndef USE_LED_3
40
#define USE_LED_3 1
41
#endif
42
#define LED_3_GPIO PAL_PORT(LINE_LED_GREEN_R)
43
#define LED_3_GPIO_PIN PAL_PAD(LINE_LED_GREEN_R)
44
#define LED_3_GPIO_ON gpio_clear
45
#define LED_3_GPIO_OFF gpio_set
46
47
#ifndef USE_LED_4
48
#define USE_LED_4 1
49
#endif
50
#define LED_4_GPIO PAL_PORT(LINE_LED_GREEN_L)
51
#define LED_4_GPIO_PIN PAL_PAD(LINE_LED_GREEN_L)
52
#define LED_4_GPIO_ON gpio_clear
53
#define LED_4_GPIO_OFF gpio_set
54
55
#ifndef USE_LED_5
56
#define USE_LED_5 1
57
#endif
58
#define LED_5_GPIO PAL_PORT(LINE_LED_BLUE_L)
59
#define LED_5_GPIO_PIN PAL_PAD(LINE_LED_BLUE_L)
60
#define LED_5_GPIO_ON gpio_set
61
#define LED_5_GPIO_OFF gpio_clear
62
63
/*
64
* ADCs
65
*/
66
// TODO for AUX
67
// No VBAT monitoring ?
68
69
/*
70
* PWM TIM defines
71
* enable TIM2 and TIM4 by default
72
*/
73
#ifndef USE_PWM_TIM2
74
#define USE_PWM_TIM2 1
75
#endif
76
77
#ifndef USE_PWM_TIM4
78
#define USE_PWM_TIM4 1
79
#endif
80
81
/*
82
* PWM defines
83
*/
84
85
// SRVa connectors, activated in PWM mode by default
86
87
#ifndef USE_PWM1
88
#define USE_PWM1 1
89
#endif
90
#if USE_PWM1
91
#define PWM_SERVO_1 1
92
#define PWM_SERVO_1_GPIO PAL_PORT(LINE_MOTOR1)
93
#define PWM_SERVO_1_PIN PAL_PAD(LINE_MOTOR1)
94
#define PWM_SERVO_1_AF AF_MOTOR1
95
#define PWM_SERVO_1_DRIVER PWMD2
96
#define PWM_SERVO_1_CHANNEL 1
97
#define PWM_SERVO_1_CONF pwmcfg2
98
#endif
99
100
#ifndef USE_PWM2
101
#define USE_PWM2 1
102
#endif
103
#if USE_PWM2
104
#define PWM_SERVO_2 2
105
#define PWM_SERVO_2_GPIO PAL_PORT(LINE_MOTOR2)
106
#define PWM_SERVO_2_PIN PAL_PAD(LINE_MOTOR2)
107
#define PWM_SERVO_2_AF AF_MOTOR2
108
#define PWM_SERVO_2_DRIVER PWMD2
109
#define PWM_SERVO_2_CHANNEL 3
110
#define PWM_SERVO_2_CONF pwmcfg2
111
#endif
112
113
#ifndef USE_PWM3
114
#define USE_PWM3 1
115
#endif
116
#if USE_PWM3
117
#define PWM_SERVO_3 3
118
#define PWM_SERVO_3_GPIO PAL_PORT(LINE_MOTOR3)
119
#define PWM_SERVO_3_PIN PAL_PAD(LINE_MOTOR3)
120
#define PWM_SERVO_3_AF AF_MOTOR3
121
#define PWM_SERVO_3_DRIVER PWMD2
122
#define PWM_SERVO_3_CHANNEL 0
123
#define PWM_SERVO_3_CONF pwmcfg2
124
#endif
125
126
#ifndef USE_PWM4
127
#define USE_PWM4 1
128
#endif
129
#if USE_PWM4
130
#define PWM_SERVO_4 4
131
#define PWM_SERVO_4_GPIO PAL_PORT(LINE_MOTOR4)
132
#define PWM_SERVO_4_PIN PAL_PAD(LINE_MOTOR4)
133
#define PWM_SERVO_4_AF AF_MOTOR4
134
#define PWM_SERVO_4_DRIVER PWMD4
135
#define PWM_SERVO_4_CHANNEL 3
136
#define PWM_SERVO_4_CONF pwmcfg4
137
#endif
138
139
// servo index starting at 1 + regular servos + aux servos
140
// so NB = 1+4
141
#define ACTUATORS_PWM_NB 5
142
143
144
// PWM control of brushed motors
145
// Freq = 84 MHz (corresponding to prescaler of 0)
146
// Period = 256 (corresponding to 8bit resolution for command at ~328 kHz))
147
// as indicated in Crazyflie source code, 328 kHz offers better natural filtering
148
// than 128 kHz
149
// It is also needed to redefined PWM_CMD_TO_US to get the proper converstion
150
// from command to clock pulses number
151
#define PWM_CMD_TO_US(_t) (_t)
152
#define PWM_FREQUENCY 84000000
153
#define SERVO_HZ (PWM_FREQUENCY / 256)
// 328125
154
158
#define UART2_GPIO_PORT_TX PAL_PORT(LINE_E_TX2)
159
#define UART2_GPIO_TX PAL_PAD(LINE_E_TX2)
160
#define UART2_GPIO_PORT_RX PAL_PORT(LINE_E_RX2)
161
#define UART2_GPIO_RX PAL_PAD(LINE_E_RX2)
162
#define UART2_GPIO_AF AF_E_RX2
163
#ifndef UART2_HW_FLOW_CONTROL
164
#define UART2_HW_FLOW_CONTROL FALSE
165
#endif
166
170
#define UART3_GPIO_PORT_TX PAL_PORT(LINE_E_TX1)
171
#define UART3_GPIO_TX PAL_PAD(LINE_E_TX1)
172
#define UART3_GPIO_PORT_RX PAL_PORT(LINE_E_RX1)
173
#define UART3_GPIO_RX PAL_PAD(LINE_E_RX1)
174
#define UART3_GPIO_AF AF_E_RX1
175
179
#define UART6_GPIO_PORT_TX PAL_PORT(LINE_NRF_TX)
180
#define UART6_GPIO_TX PAL_PAD(LINE_NRF_TX)
181
#define UART6_GPIO_PORT_RX PAL_PORT(LINE_NRF_RX)
182
#define UART6_GPIO_RX PAL_PAD(LINE_NRF_RX)
183
#define UART6_GPIO_AF AF_NRF_RX
184
#define UART6_GPIO_PORT_CTS PAL_PORT(LINE_NRF_FLOW_CTRL)
185
#define UART6_GPIO_CTS NRF_FLOW_CTRL
186
191
// Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
192
#define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
193
// Timing register
194
#define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
195
STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
196
STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
197
#define I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(1U) | \
198
STM32_TIMINGR_SCLDEL(9U) | STM32_TIMINGR_SDADEL(0U) | \
199
STM32_TIMINGR_SCLH(105U) | STM32_TIMINGR_SCLL(153U))
200
201
202
// Internal I2C (IMU, baro)
203
204
#ifndef I2C3_CLOCK_SPEED
205
#define I2C3_CLOCK_SPEED 400000
206
#endif
207
#if I2C3_CLOCK_SPEED == 400000
208
#define I2C3_DUTY_CYCLE FAST_DUTY_CYCLE_2
209
#elif I2C3_CLOCK_SPEED == 100000
210
#define I2C3_DUTY_CYCLE STD_DUTY_CYCLE
211
#else
212
#error "Invalid I2C3 clock speed"
213
#endif
214
#define I2C3_CFG_DEF { \
215
OPMODE_I2C, \
216
I2C3_CLOCK_SPEED, \
217
I2C3_DUTY_CYCLE, \
218
}
219
220
// External I2C
221
222
#ifndef I2C1_CLOCK_SPEED
223
#define I2C1_CLOCK_SPEED 400000
224
#endif
225
#if I2C1_CLOCK_SPEED == 400000
226
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
227
#elif I2C1_CLOCK_SPEED == 100000
228
#define I2C1_DUTY_CYCLE STD_DUTY_CYCLE
229
#else
230
#error "Invalid I2C1 clock speed"
231
#endif
232
#define I2C1_CFG_DEF { \
233
OPMODE_I2C, \
234
I2C1_CLOCK_SPEED, \
235
I2C1_DUTY_CYCLE, \
236
}
237
238
/*
239
#ifndef I2C3_CLOCK_SPEED
240
#define I2C3_CLOCK_SPEED 400000
241
#endif
242
243
#if I2C3_CLOCK_SPEED == 400000
244
#define I2C3_CFG_DEF { \
245
.timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
246
.cr1 = STM32_CR1_DNF(0), \
247
.cr2 = 0 \
248
}
249
#elif I2C3_CLOCK_SPEED == 100000
250
#define I2C3_CFG_DEF { \
251
.timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
252
.cr1 = STM32_CR1_DNF(0), \
253
.cr2 = 0 \
254
}
255
#else
256
#error "Unknown I2C3 clock speed"
257
#endif
258
259
// External I2C
260
261
#ifndef I2C1_CLOCK_SPEED
262
#define I2C1_CLOCK_SPEED 400000
263
#endif
264
265
#if I2C1_CLOCK_SPEED == 400000
266
#define I2C1_CFG_DEF { \
267
.timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
268
.cr1 = STM32_CR1_DNF(0), \
269
.cr2 = 0 \
270
}
271
#elif I2C1_CLOCK_SPEED == 100000
272
#define I2C1_CFG_DEF { \
273
.timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
274
.cr1 = STM32_CR1_DNF(0), \
275
.cr2 = 0 \
276
}
277
#else
278
#error "Unknown I2C2 clock speed"
279
#endif
280
*/
281
286
// External SPI
287
#define SPI1_GPIO_AF AF_E_SCK
288
#define SPI1_GPIO_PORT_MISO PAL_PORT(LINE_E_MISO)
289
#define SPI1_GPIO_MISO PAL_PAD(LINE_E_MISO)
290
#define SPI1_GPIO_PORT_MOSI PAL_PORT(LINE_E_MOSI)
291
#define SPI1_GPIO_MOSI PAL_PAD(LINE_E_MOSI)
292
#define SPI1_GPIO_PORT_SCK PAL_PORT(LINE_E_SCK)
293
#define SPI1_GPIO_SCK PAL_PAD(LINE_E_SCK)
294
295
#define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_E_CS0)
296
#define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_E_CS0)
297
#define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_E_CS1)
298
#define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_E_CS1)
299
#define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_E_CS2)
300
#define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_E_CS2)
301
#define SPI_SELECT_SLAVE3_PORT PAL_PORT(LINE_E_CS3)
302
#define SPI_SELECT_SLAVE3_PIN PAL_PAD(LINE_E_CS3)
303
310
#ifndef USE_BARO_BOARD
311
#define USE_BARO_BOARD 0
312
#endif
313
314
/*
315
* Actuators for fixedwing
316
*/
317
/* Default actuators driver */
318
#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
319
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
320
#define ActuatorsDefaultInit() ActuatorsPwmInit()
321
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
322
323
#endif
/* CONFIG_TAWAKI_1_00_H */
324
board.h
sw
airborne
boards
crazyflie
chibios
v2.1
crazyflie.h
Generated on Thu Dec 5 2024 13:05:29 for Paparazzi UAS by
1.9.1