Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
crazybee_f4_1.0.h
Go to the documentation of this file.
1
/* Since there is atm no schematic of the board, many pin to pin io was deducted
2
* by measuring on the PCB.
3
* Not all, e.g. the Volt and Current values are measured for the moment
4
* Would be great if one could determine the resitor bridge true values
5
*/
6
7
#ifndef CONFIG_CRAZYBEE_F4_1_0_H
8
#define CONFIG_CRAZYBEE_F4_1_0_H
9
10
#define BOARD_CRAZYBEE_F4_V1
11
13
#define SYSTEM_MEMORY_BASE 0x1FFF0000
14
16
#define EXT_CLK 8000000
// 8mHz
17
#define AHB_CLK 84000000
18
20
/* Green LED on flight controller */
21
#ifndef USE_LED_1
22
#define USE_LED_1 1
23
#endif
24
#define LED_1_GPIO GPIOC
25
#define LED_1_GPIO_PIN GPIO13
26
#define LED_1_GPIO_ON gpio_clear
27
#define LED_1_GPIO_OFF gpio_set
28
#define LED_1_AFIO_REMAP ((void)0)
29
30
/* Red/white RX LEDs */
31
/* Note: all LEDs are connected to a single pin */
32
#ifndef USE_LED_2
33
#define USE_LED_2 1
34
#endif
35
#define LED_2_GPIO GPIOB
36
#define LED_2_GPIO_PIN GPIO9
37
#define LED_2_GPIO_ON gpio_set
38
#define LED_2_GPIO_OFF gpio_clear
39
#define LED_2_AFIO_REMAP ((void)0)
40
42
/* UART1 */
43
#define UART1_GPIO_AF GPIO_AF7
44
#define UART1_GPIO_PORT_TX GPIOA
45
#define UART1_GPIO_TX GPIO9
46
#define UART1_GPIO_PORT_RX GPIOA
47
#define UART1_GPIO_RX GPIO10
48
49
/* UART2 */
50
//Can connect to built-in DSMX receiver is availabe on UART RX
51
//Not to be confused with DSMX over SPI, that is unrelated
52
#define UART2_GPIO_AF GPIO_AF7
53
#define UART2_GPIO_PORT_TX GPIOA
54
#define UART2_GPIO_TX GPIO2
55
#define UART2_GPIO_PORT_RX GPIOA
56
#define UART2_GPIO_RX GPIO3
57
58
/* SBUS inverted on UARTx is a separate physical pad on the board
59
* To be used for an receiverv that gives an inverted SBUS out signal */
60
61
/* FIXME: (re)setting UART based (e.g. Spektum) Serial RADIO_CONTROL_POWER_PORT
62
#define RADIO_CONTROL_POWER_PORT GPIOA
63
#define RADIO_CONTROL_POWER_PIN GPIO10
64
#define RADIO_CONTROL_POWER_ON gpio_clear // yes, inverted
65
#define RADIO_CONTROL_POWER_OFF gpio_set
66
*/
67
68
/* FIXME: Soft binding Spektrum */
69
/*
70
#define SPEKTRUM_UART2_RCC RCC_USART1 //But uard 2 if embedded CYRF chip Speksat can be on UART1
71
#define SPEKTRUM_UART2_BANK GPIOA
72
#define SPEKTRUM_UART2_PIN GPIO10
73
#define SPEKTRUM_UART2_AF GPIO_AF7
74
#define SPEKTRUM_UART2_IRQ NVIC_USART1_IRQ
75
#define SPEKTRUM_UART2_ISR usart1_isr
76
#define SPEKTRUM_UART2_DEV USART1
77
*/
78
79
/* FIXME to relate this to ifddefs of PPM config possibilities
80
*/
81
#ifndef USE_LED_STRIP
82
#define USE_LED_STRIP 1
83
#endif
84
85
#if USE_LED_STRIP
86
#define LED_STRIP_GPIO_PORT GPIOA
87
#define LED_STRIP_GPIO_PIN GPIO0
88
#endif
89
90
/* PPM
91
*
92
* FIXME: Default is PPM config 1, alternative 2 is CPPM input on RX2 pin but
93
* than no UART RX at the same time, but a need for that scenario is unlikely anyhow
94
*
95
* Originaly intended for 2812LED board - DMA1_ST2
96
* Can be re- used for input to connect a receiver that outputs CPPM pulsestrain
97
*/
98
99
#ifndef PPM_CONFIG
100
#define PPM_CONFIG 1
101
#endif
102
103
#ifdef PPM_CONFIG
104
#define USE_PPM_TIM5 1
105
#define PPM_CHANNEL TIM_IC1
106
#define PPM_TIMER_INPUT TIM_IC_IN_TI1
107
#define PPM_IRQ NVIC_TIM5_IRQ
108
//#define PPM_IRQ NVIC_TIM5_CC_IRQ
109
// Capture/Compare InteruptEnable and InterruptFlag
110
#define PPM_CC_IE TIM_DIER_CC1IE
111
#define PPM_CC_IF TIM_SR_CC1IF
112
#define PPM_GPIO_PORT GPIOA
113
#define PPM_GPIO_PIN GPIO0
114
#define PPM_GPIO_AF GPIO_AF2
115
116
//#elif PPM_CONFIG == 2
118
//#define USE_PPM_TIM9 1
119
//#define PPM_CHANNEL TIM_IC2
120
//#define PPM_TIMER_INPUT TIM_IC_IN_TI2
121
//#define PPM_IRQ NVIC_TIM9_IRQ
123
//#define PPM_CC_IE TIM_DIER_CC2IE
124
//#define PPM_CC_IF TIM_SR_CC2IF
125
//#define PPM_GPIO_PORT GPIOA
126
//#define PPM_GPIO_PIN GPIO3
127
//#define PPM_GPIO_AF GPIO_AF3
129
//#else
130
//#error "Unknown PPM config"
131
132
#endif
// PPM_CONFIG
133
135
/* SPI1 for MPU accel/gyro (MPU6000*/
136
#define SPI1_GPIO_AF GPIO_AF5
137
#define SPI1_GPIO_PORT_SCK GPIOA
138
#define SPI1_GPIO_SCK GPIO5
139
#define SPI1_GPIO_PORT_MISO GPIOA
140
#define SPI1_GPIO_MISO GPIO6
141
#define SPI1_GPIO_PORT_MOSI GPIOA
142
#define SPI1_GPIO_MOSI GPIO7
143
144
/* SPI slave pin declaration ACC_GYRO_CS on SPI1 ICM 20609-G*/
145
#define SPI_SELECT_SLAVE0_PORT GPIOA
146
#define SPI_SELECT_SLAVE0_PIN GPIO4
147
148
/* SPI2 for embedded OSD MAX chip*/
149
//#ifndef USE_MAX7456
150
//#define USE_MAX7456 0
151
//#endif
152
153
//#if USE_MAX7456
154
#define SPI2_GPIO_AF GPIO_AF5
//TODO check datasheet
155
#define SPI2_GPIO_PORT_SCK GPIOB
156
#define SPI2_GPIO_SCK GPIO13
157
#define SPI2_GPIO_PORT_MISO GPIOB
158
#define SPI2_GPIO_MISO GPIO14
159
#define SPI2_GPIO_PORT_MOSI GPIOB
160
#define SPI2_GPIO_MOSI GPIO15
161
162
/* SPI slave pin declaration OSD */
163
#define SPI_SELECT_SLAVE1_PORT GPIOB
164
#define SPI_SELECT_SLAVE1_PIN GPIO12
165
//#endif
166
167
/* Used SPI3 for RX direct, if RX solution is implemented in AP */
168
#define SPI3_GPIO_AF GPIO_AF6
169
#define SPI3_GPIO_PORT_SCK GPIOB
170
#define SPI3_GPIO_SCK GPIO3
171
#define SPI3_GPIO_PORT_MISO GPIOB
172
#define SPI3_GPIO_MISO GPIO4
173
#define SPI3_GPIO_PORT_MOSI GPIOB
174
#define SPI3_GPIO_MOSI GPIO5
175
176
/* SPI slave pin declaration for Receiver */
177
#define SPI_SELECT_SLAVE2_PORT GPIOA
178
#define SPI_SELECT_SLAVE2_PIN GPIO15
179
180
/* GDO0 pin for receiver */
181
#define CC2500_GDO0_GPIO GPIOC
182
#define CC2500_GDO0_PIN GPIO14
183
184
/* Bind button */
185
#define BIND_BUTTON_GPIO GPIOB
186
#define BIND_BUTTON_PIN GPIO2
187
190
#define USE_AD_TIM1 1
191
192
/* Voltage */
193
#ifndef USE_ADC_1
194
#define USE_ADC_1 1
195
#endif
196
197
#if USE_ADC_1
198
#define AD1_1_CHANNEL 8
199
#define ADC_1 AD1_1
200
#define ADC_1_GPIO_PORT GPIOB
201
#define ADC_1_GPIO_PIN GPIO0
202
203
#define ADC_CHANNEL_VSUPPLY ADC_1
204
#define DefaultVoltageOfAdc(adc) (0.009*adc)
// TODO: determine 100% correct value
205
#endif
206
207
/* Current */
208
#ifndef USE_ADC_2
209
#define USE_ADC_2 1
210
#endif
211
212
#if USE_ADC_2
213
#define AD1_2_CHANNEL 9
214
#define ADC_2 AD1_2
215
#define ADC_2_GPIO_PORT GPIOB
216
#define ADC_2_GPIO_PIN GPIO1
217
218
#define ADC_CHANNEL_CURRENT ADC_2
219
#define MilliAmpereOfAdc(adc)((float)adc) * (3.3f / 4096.0f) * (90.0f / 5.0f)
// TODO: determine 100% correct value
220
#endif
221
222
/* TODO: Somehere on the board find PHiSICAL easily reachable I2C SDL SDA so to connect e.g. GNSS, Baro, Magneto
223
* TODO: Finish the I2C mapping if Pins found */
224
225
//#define I2C1_GPIO_AF GPIO_AF4
226
//#define I2C1_GPIO_PORT GPIOB
227
//#define I2C1_GPIO_SCL GPIO8
228
//#define I2C1_GPIO_SDA GPIO9
229
230
/* Default actuators driver */
231
#define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
232
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
233
#define ActuatorsDefaultInit() ActuatorsPwmInit()
234
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
235
236
/* PWM */
237
#define PWM_USE_TIM2 1
238
#define PWM_USE_TIM4 1
239
240
#define USE_PWM1 1
241
#define USE_PWM2 1
242
#define USE_PWM3 1
243
#define USE_PWM4 1
244
245
/* ESC 1 (B10, TIM2, CH3)*/
246
#if USE_PWM1
247
#define PWM_SERVO_1 0
248
#define PWM_SERVO_1_TIMER TIM2
249
#define PWM_SERVO_1_GPIO GPIOB
250
#define PWM_SERVO_1_PIN GPIO10
251
#define PWM_SERVO_1_AF GPIO_AF1
252
#define PWM_SERVO_1_OC TIM_OC3
253
#define PWM_SERVO_1_OC_BIT (1<<2)
254
#else
255
#define PWM_SERVO_1_OC_BIT 0
256
#endif
257
258
/* ESC 2 (B6, TIM4, CH1)*/
259
#if USE_PWM2
260
#define PWM_SERVO_2 1
261
#define PWM_SERVO_2_TIMER TIM4
262
#define PWM_SERVO_2_GPIO GPIOB
263
#define PWM_SERVO_2_PIN GPIO6
264
#define PWM_SERVO_2_AF GPIO_AF2
265
#define PWM_SERVO_2_OC TIM_OC1
266
#define PWM_SERVO_2_OC_BIT (1<<0)
267
#else
268
#define PWM_SERVO_2_OC_BIT 0
269
#endif
270
271
/* ESC 3 (B7, TIM4, CH2) */
272
#if USE_PWM3
273
#define PWM_SERVO_3 2
274
#define PWM_SERVO_3_TIMER TIM4
275
#define PWM_SERVO_3_GPIO GPIOB
276
#define PWM_SERVO_3_PIN GPIO7
277
#define PWM_SERVO_3_AF GPIO_AF2
278
#define PWM_SERVO_3_OC TIM_OC2
279
#define PWM_SERVO_3_OC_BIT (1<<1)
280
#else
281
#define PWM_SERVO_3_OC_BIT 0
282
#endif
283
284
/* ESC 4 (B8, TIM4, CH3) */
285
#if USE_PWM4
286
#define PWM_SERVO_4 3
287
#define PWM_SERVO_4_TIMER TIM4
288
#define PWM_SERVO_4_GPIO GPIOB
289
#define PWM_SERVO_4_PIN GPIO8
290
#define PWM_SERVO_4_AF GPIO_AF2
291
#define PWM_SERVO_4_OC TIM_OC3
292
#define PWM_SERVO_4_OC_BIT (1<<2)
293
#else
294
#define PWM_SERVO_4_OC_BIT 0
295
#endif
296
297
#define PWM_TIM2_CHAN_MASK (PWM_SERVO_1_OC_BIT)
298
#define PWM_TIM4_CHAN_MASK (PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
299
300
/* Buzzer (C15, inverted) */
301
#if USE_BUZZER
302
#define PWM_BUZZER
303
#define PWM_BUZZER_GPIO GPIOC
304
#define PWM_BUZZER_PIN GPI15
305
#define PWM_BUZZER_GPIO_ON gpio_clear
306
#define PWM_BUZZER_GPIO_OFF gpio_set
307
#endif
308
309
#endif
/* CONFIG_CRAZYBEE_F4_1_0_H */
sw
airborne
boards
crazybee_f4_1.0.h
Generated on Fri Nov 8 2024 14:10:45 for Paparazzi UAS by
1.9.1