Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
naze32_common.h
Go to the documentation of this file.
1 #ifndef CONFIG_NAZE32_COMMON_H
2 #define CONFIG_NAZE32_COMMON_H
3 
4 #define BOARD_NAZE32
5 
6 /*
7  * Onboard LEDs
8  */
9 
10 
11 /* L0 red status led, on PB4 */
12 #ifndef USE_LED_1
13 #define USE_LED_1 1
14 #endif
15 #define LED_1_GPIO GPIOB
16 #define LED_1_GPIO_PIN GPIO4
17 #define LED_1_GPIO_ON gpio_clear
18 #define LED_1_GPIO_OFF gpio_set
19 #define LED_1_AFIO_REMAP { \
20  rcc_periph_clock_enable(RCC_AFIO); \
21  AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON; \
22  }
23 
24 /* L1 green status led, on PB3 */
25 #ifndef USE_LED_2
26 #define USE_LED_2 1
27 #endif
28 #define LED_2_GPIO GPIOB
29 #define LED_2_GPIO_PIN GPIO3
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 /*
35  * UART pin configuration
36  *
37  * sets on which pins the UARTs are connected
38  */
39 /* UART1 on main port, TX (PA9), RX (PA10) */
40 #define UART1_GPIO_AF 0
41 #define UART1_GPIO_PORT_RX GPIO_BANK_USART1_RX
42 #define UART1_GPIO_RX GPIO_USART1_RX
43 #define UART1_GPIO_PORT_TX GPIO_BANK_USART1_TX
44 #define UART1_GPIO_TX GPIO_USART1_TX
45 
46 /* UART2 on RC I/O, TX (PA2) pin 5/id "3", RX (PA3) pin 6/id "4" */
47 #define UART2_GPIO_AF 0
48 #define UART2_GPIO_PORT_RX GPIO_BANK_USART2_RX
49 #define UART2_GPIO_RX GPIO_USART2_RX
50 #define UART2_GPIO_PORT_TX GPIO_BANK_USART2_TX
51 #define UART2_GPIO_TX GPIO_USART2_TX
52 
53 /*
54  * Spektrum
55  */
56 /* The line that is pulled low at power up to initiate the bind process */
57 /* set to ppm/servo6 input pin on RC connector for now */
58 #define SPEKTRUM_BIND_PIN GPIO1
59 #define SPEKTRUM_BIND_PIN_PORT GPIOA
60 
61 #define SPEKTRUM_UART1_RCC RCC_USART1
62 #define SPEKTRUM_UART1_BANK GPIO_BANK_USART1_RX
63 #define SPEKTRUM_UART1_PIN GPIO_USART1_RX
64 #define SPEKTRUM_UART1_AF 0
65 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
66 #define SPEKTRUM_UART1_ISR usart1_isr
67 #define SPEKTRUM_UART1_DEV USART1
68 
69 #define SPEKTRUM_UART2_RCC RCC_USART2
70 #define SPEKTRUM_UART2_BANK GPIO_BANK_USART2_RX
71 #define SPEKTRUM_UART2_PIN GPIO_USART2_RX
72 #define SPEKTRUM_UART2_AF 0
73 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
74 #define SPEKTRUM_UART2_ISR usart2_isr
75 #define SPEKTRUM_UART2_DEV USART2
76 
77 
78 
79 /* PPM
80  *
81  * Default: PPM_CONFIG 1: servos 3-6, input on PA0: RC I/O rx_ppm pin 3/id "1"
82  * PPM_CONFIG 2: servos 1-6, input on PA7: RC I/O unused pin 8/id "6"
83  */
84 
85 #ifndef PPM_CONFIG
86 #define PPM_CONFIG 1
87 #endif
88 
89 #if PPM_CONFIG == 1
90 /* input on PA0 (ppm_in), TIM2 CH1 */
91 #define USE_PPM_TIM2 1
92 #define PPM_CHANNEL TIM_IC1
93 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
94 #define PPM_IRQ NVIC_TIM2_IRQ
95 // Capture/Compare InteruptEnable and InterruptFlag
96 #define PPM_CC_IE TIM_DIER_CC1IE
97 #define PPM_CC_IF TIM_SR_CC1IF
98 #define PPM_GPIO_PORT GPIOA
99 #define PPM_GPIO_PIN GPIO0
100 #define PPM_GPIO_AF 0
101 
102 // Move default ADC timer
103 #if USE_AD_TIM2
104 #undef USE_AD_TIM2
105 #endif
106 #define USE_AD_TIM1 1
107 
108 #elif PPM_CONFIG == 2
109 /* input on PA7 (unused), TIM3 CH2 */
110 #define USE_PPM_TIM3 1
111 #define PPM_CHANNEL TIM_IC2
112 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
113 #define PPM_IRQ NVIC_TIM3_IRQ
114 // Capture/Compare InteruptEnable and InterruptFlag
115 #define PPM_CC_IE TIM_DIER_CC2IE
116 #define PPM_CC_IF TIM_SR_CC2IF
117 #define PPM_GPIO_PORT GPIOA
118 #define PPM_GPIO_PIN GPIO7
119 #define PPM_GPIO_AF 0
120 
121 // Move default ADC timer
122 #if USE_AD_TIM1
123 #undef USE_AD_TIM1
124 #endif
125 #define USE_AD_TIM2 1
126 
127 #else
128 #error "Unknown PPM config"
129 
130 #endif // PPM_CONFIG
131 
132 
133 /*
134  * ADC
135  */
136 
137 // Internal ADC for battery enabled by default
138 #ifndef USE_ADC_4
139 #define USE_ADC_4 1
140 #endif
141 #if USE_ADC_4
142 #define AD1_4_CHANNEL 4
143 #define ADC_4 AD1_4
144 #define ADC_4_GPIO_PORT GPIOA
145 #define ADC_4_GPIO_PIN GPIO4
146 #endif
147 
148 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
149 #ifndef ADC_CHANNEL_VSUPPLY
150 #define ADC_CHANNEL_VSUPPLY ADC_4
151 #endif
152 
153 /* 10k/1k resistor divider, 11 * 3.3V / 4096 */
154 #define DefaultVoltageOfAdc(adc) (0.008862*adc)
155 
156 
157 /* by default activate onboard baro */
158 #ifndef USE_BARO_BOARD
159 #define USE_BARO_BOARD 1
160 #endif
161 
162 /*
163  * I2C
164  */
165 /* RC port */
166 #define I2C2_GPIO_PORT GPIOB
167 #define I2C2_GPIO_SCL GPIO10
168 #define I2C2_GPIO_SDA GPIO11
169 
170 
171 /*
172  * PWM
173  *
174  * Servo output numbering on silkscreen starts with '1'
175  *
176  * silk default PPM_CONFIG=2 (PPM_PIN=PA7)
177  *
178  * '1' PA8 - servo1
179  * '2' PA11 - servo2
180  * '3' PB6 servo3 servo3
181  * '4' PB7 servo4 servo4
182  * '5' PB8 servo5 servo5
183  * '6' PB9 servo6 servo6
184  *
185  * PPM_in: PA0 PA7
186  *
187  */
188 
189 #if PPM_CONFIG == 2
190 
191 /* use all servos */
192 #define ACTUATORS_PWM_NB 6
193 #define PWM_USE_TIM1 1
194 #define USE_PWM1 1
195 #define USE_PWM2 1
196 #define PWM_SERVO_1 0
197 #define PWM_SERVO_2 1
198 #define PWM_SERVO_3 2
199 #define PWM_SERVO_4 3
200 #define PWM_SERVO_5 4
201 #define PWM_SERVO_6 5
202 
203 #else // PPM_CONFIG == 1
204 
205 /* servos 1-2 not usable */
206 #define ACTUATORS_PWM_NB 4
207 /* servos 1-2 not usable */
208 #define PWM_USE_TIM1 0
209 #define USE_PWM1 0
210 #define USE_PWM2 0
211 #define PWM_SERVO_3 0
212 #define PWM_SERVO_4 1
213 #define PWM_SERVO_5 2
214 #define PWM_SERVO_6 3
215 
216 #endif
217 
218 /* servos 3-6 */
219 #define PWM_USE_TIM4 1
220 #define USE_PWM3 1
221 #define USE_PWM4 1
222 #define USE_PWM5 1
223 #define USE_PWM6 1
224 
225 #if USE_PWM1
226 #define PWM_SERVO_1_TIMER TIM1
227 #define PWM_SERVO_1_GPIO GPIOA
228 #define PWM_SERVO_1_PIN GPIO8
229 #define PWM_SERVO_1_AF 0
230 #define PWM_SERVO_1_OC TIM_OC1
231 #define PWM_SERVO_1_OC_BIT (1<<0)
232 #else
233 #define PWM_SERVO_1_OC_BIT 0
234 #endif
235 
236 #if USE_PWM2
237 #define PWM_SERVO_2_TIMER TIM1
238 #define PWM_SERVO_2_GPIO GPIOA
239 #define PWM_SERVO_2_PIN GPIO11
240 #define PWM_SERVO_2_AF 0
241 #define PWM_SERVO_2_OC TIM_OC4
242 #define PWM_SERVO_2_OC_BIT (1<<3)
243 #else
244 #define PWM_SERVO_2_OC_BIT 0
245 #endif
246 
247 #if USE_PWM3
248 #define PWM_SERVO_3_TIMER TIM4
249 #define PWM_SERVO_3_GPIO GPIOB
250 #define PWM_SERVO_3_PIN GPIO6
251 #define PWM_SERVO_3_AF 0
252 #define PWM_SERVO_3_OC TIM_OC1
253 #define PWM_SERVO_3_OC_BIT (1<<0)
254 #else
255 #define PWM_SERVO_3_OC_BIT 0
256 #endif
257 
258 #if USE_PWM4
259 #define PWM_SERVO_4_TIMER TIM4
260 #define PWM_SERVO_4_GPIO GPIOB
261 #define PWM_SERVO_4_PIN GPIO7
262 #define PWM_SERVO_4_AF 0
263 #define PWM_SERVO_4_OC TIM_OC2
264 #define PWM_SERVO_4_OC_BIT (1<<1)
265 #else
266 #define PWM_SERVO_4_OC_BIT 0
267 #endif
268 
269 #if USE_PWM5
270 #define PWM_SERVO_5_TIMER TIM4
271 #define PWM_SERVO_5_GPIO GPIOB
272 #define PWM_SERVO_5_PIN GPIO8
273 #define PWM_SERVO_5_AF 0
274 #define PWM_SERVO_5_OC TIM_OC3
275 #define PWM_SERVO_5_OC_BIT (1<<2)
276 #else
277 #define PWM_SERVO_5_OC_BIT 0
278 #endif
279 
280 #if USE_PWM6
281 #define PWM_SERVO_6_TIMER TIM4
282 #define PWM_SERVO_6_GPIO GPIOB
283 #define PWM_SERVO_6_PIN GPIO9
284 #define PWM_SERVO_6_AF 0
285 #define PWM_SERVO_6_OC TIM_OC4
286 #define PWM_SERVO_6_OC_BIT (1<<3)
287 #else
288 #define PWM_SERVO_6_OC_BIT 0
289 #endif
290 
291 /* servos 1-2 on TIM1 */
292 #define PWM_TIM1_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT)
293 /* servos 3-6 on TIM4 */
294 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT|PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
295 
296 
297 /* Default actuators driver */
298 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
299 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
300 #define ActuatorsDefaultInit() ActuatorsPwmInit()
301 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
302 
303 
304 #endif /* CONFIG_NAZE32_COMMON_H */
305