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
apogee_0.99.h
Go to the documentation of this file.
1 #ifndef CONFIG_APOGEE_0_99_H
2 #define CONFIG_APOGEE_0_99_H
3 
4 #define BOARD_APOGEE
5 
6 /* Apogee has a 16MHz external clock and 168MHz internal. */
7 #define EXT_CLK 16000000
8 #define AHB_CLK 168000000
9 
10 /*
11  * Onboard LEDs
12  */
13 
14 /* red, on PC0 */
15 #ifndef USE_LED_1
16 #define USE_LED_1 1
17 #endif
18 #define LED_1_GPIO GPIOC
19 #define LED_1_GPIO_CLK RCC_AHB1ENR_IOPCEN
20 #define LED_1_GPIO_PIN GPIO0
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, on PC13 */
26 #ifndef USE_LED_2
27 #define USE_LED_2 1
28 #endif
29 #define LED_2_GPIO GPIOC
30 #define LED_2_GPIO_CLK RCC_AHB1ENR_IOPCEN
31 #define LED_2_GPIO_PIN GPIO13
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 /* Default actuators driver */
37 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
38 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
39 #define ActuatorsDefaultInit() ActuatorsPwmInit()
40 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
41 
42 #define DefaultVoltageOfAdc(adc) (0.006185*adc)
43 
44 /* UART */
45 #define UART1_GPIO_AF GPIO_AF7
46 #define UART1_GPIO_PORT_RX GPIOA
47 #define UART1_GPIO_RX GPIO10
48 #define UART1_GPIO_PORT_TX GPIOB
49 #define UART1_GPIO_TX GPIO6
50 
51 #define UART4_GPIO_AF GPIO_AF8
52 #define UART4_GPIO_PORT_RX GPIOA
53 #define UART4_GPIO_RX GPIO1
54 #define UART4_GPIO_PORT_TX GPIOA
55 #define UART4_GPIO_TX GPIO0
56 
57 #define UART6_GPIO_AF GPIO_AF8
58 #define UART6_GPIO_PORT_RX GPIOC
59 #define UART6_GPIO_RX GPIO7
60 #define UART6_GPIO_PORT_TX GPIOC
61 #define UART6_GPIO_TX GPIO6
62 
63 
64 /* Onboard ADCs */
65 #define USE_AD_TIM4 1
66 
67 #define BOARD_ADC_CHANNEL_1 8
68 #define BOARD_ADC_CHANNEL_2 9
69 #define BOARD_ADC_CHANNEL_3 14
70 #define BOARD_ADC_CHANNEL_4 4
71 
72 #ifndef USE_AD1
73 #define USE_AD1 1
74 #endif
75 /* provide defines that can be used to access the ADC_x in the code or airframe file
76  * these directly map to the index number of the 4 adc channels defined above
77  * 4th (index 3) is used for bat monitoring by default
78  */
79 #define ADC_1 ADC1_C1
80 #ifdef USE_ADC_1
81 #ifndef ADC_1_GPIO_CLOCK_PORT
82 #define ADC_1_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPBEN
83 #define ADC_1_INIT() gpio_mode_setup(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0)
84 #endif
85 #define USE_AD1_1 1
86 #else
87 #define ADC_1_GPIO_CLOCK_PORT 0
88 #define ADC_1_INIT() {}
89 #endif
90 
91 #define ADC_2 ADC1_C2
92 #ifdef USE_ADC_2
93 #ifndef ADC_2_GPIO_CLOCK_PORT
94 #define ADC_2_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPBEN
95 #define ADC_2_INIT() gpio_mode_setup(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1)
96 #endif
97 #define USE_AD1_2 1
98 #else
99 #define ADC_2_GPIO_CLOCK_PORT 0
100 #define ADC_2_INIT() {}
101 #endif
102 
103 #define ADC_3 ADC1_C3
104 #ifdef USE_ADC_3
105 #ifndef ADC_3_GPIO_CLOCK_PORT
106 #define ADC_3_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
107 #define ADC_3_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4)
108 #endif
109 #define USE_AD1_3 1
110 #else
111 #define ADC_3_GPIO_CLOCK_PORT 0
112 #define ADC_3_INIT() {}
113 #endif
114 
115 #define ADC_4 ADC1_C4
116 //#ifdef USE_ADC_4
117 #ifndef ADC_4_GPIO_CLOCK_PORT
118 #define ADC_4_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPAEN
119 #define ADC_4_INIT() gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4)
120 #endif
121 #define USE_AD1_4 1
122 //#else
123 //#define ADC_4_GPIO_CLOCK_PORT 0
124 //#define ADC_4_INIT() {}
125 //#endif
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_GPIO_CLOCK_PORT (ADC_1_GPIO_CLOCK_PORT | ADC_2_GPIO_CLOCK_PORT | ADC_3_GPIO_CLOCK_PORT | ADC_4_GPIO_CLOCK_PORT)
133 
134 /* GPIO mapping for ADC1 pins, overwrites the default in arch/stm32/mcu_periph/adc_arch.c */
135 #ifdef USE_AD1
136 #define ADC1_GPIO_INIT(gpio) { \
137  ADC_1_INIT(); \
138  ADC_2_INIT(); \
139  ADC_3_INIT(); \
140  ADC_4_INIT(); \
141 }
142 #endif // USE_AD1
143 
144 
145 /* I2C mapping */
146 #define I2C1_GPIO_PORT GPIOB
147 #define I2C1_GPIO_SCL GPIO8
148 #define I2C1_GPIO_SDA GPIO7
149 
150 #define I2C2_GPIO_PORT GPIOB
151 #define I2C2_GPIO_SCL GPIO10
152 #define I2C2_GPIO_SDA GPIO11
153 
154 
155 /* SPI slave pin declaration */
156 //#define SPI_SELECT_SLAVE0_PORT GPIOA
157 //#define SPI_SELECT_SLAVE0_PIN GPIO15
158 //
159 //#define SPI_SELECT_SLAVE1_PORT GPIOA
160 //#define SPI_SELECT_SLAVE1_PIN GPIO4
161 
162 #define SPI_SELECT_SLAVE2_PORT GPIOB
163 #define SPI_SELECT_SLAVE2_PIN GPIO12
164 
165 //#define SPI_SELECT_SLAVE3_PORT GPIOC
166 //#define SPI_SELECT_SLAVE3_PIN GPIO13
167 //
168 //#define SPI_SELECT_SLAVE4_PORT GPIOC
169 //#define SPI_SELECT_SLAVE4_PIN GPIO12
170 //
171 //#define SPI_SELECT_SLAVE5_PORT GPIOC
172 //#define SPI_SELECT_SLAVE5_PIN GPIO4
173 
174 /* Activate onboard baro */
175 #define BOARD_HAS_BARO 1
176 
177 /* PWM */
178 #define PWM_USE_TIM2 1
179 #define PWM_USE_TIM3 1
180 
181 #define USE_PWM0 1
182 #define USE_PWM1 1
183 #define USE_PWM2 1
184 #define USE_PWM3 1
185 #define USE_PWM4 1
186 #define USE_PWM5 1
187 
188 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
189 #if USE_PWM0
190 #define PWM_SERVO_0 0
191 #define PWM_SERVO_0_TIMER TIM2
192 #define PWM_SERVO_0_RCC_IOP RCC_AHB1ENR_IOPAEN
193 #define PWM_SERVO_0_GPIO GPIOA
194 #define PWM_SERVO_0_PIN GPIO3
195 #define PWM_SERVO_0_AF GPIO_AF1
196 #define PWM_SERVO_0_OC TIM_OC4
197 #define PWM_SERVO_0_OC_BIT (1<<3)
198 #else
199 #define PWM_SERVO_0_OC_BIT 0
200 #endif
201 
202 #if USE_PWM1
203 #define PWM_SERVO_1 1
204 #define PWM_SERVO_1_TIMER TIM2
205 #define PWM_SERVO_1_RCC_IOP RCC_AHB1ENR_IOPAEN
206 #define PWM_SERVO_1_GPIO GPIOA
207 #define PWM_SERVO_1_PIN GPIO2
208 #define PWM_SERVO_1_AF GPIO_AF1
209 #define PWM_SERVO_1_OC TIM_OC3
210 #define PWM_SERVO_1_OC_BIT (1<<2)
211 #else
212 #define PWM_SERVO_1_OC_BIT 0
213 #endif
214 
215 #if USE_PWM2
216 #define PWM_SERVO_2 2
217 #define PWM_SERVO_2_TIMER TIM3
218 #define PWM_SERVO_2_RCC_IOP RCC_AHB1ENR_IOPBEN
219 #define PWM_SERVO_2_GPIO GPIOB
220 #define PWM_SERVO_2_PIN GPIO5
221 #define PWM_SERVO_2_AF GPIO_AF2
222 #define PWM_SERVO_2_OC TIM_OC2
223 #define PWM_SERVO_2_OC_BIT (1<<1)
224 #else
225 #define PWM_SERVO_2_OC_BIT 0
226 #endif
227 
228 #if USE_PWM3
229 #define PWM_SERVO_3_IDX 3
230 #define PWM_SERVO_3_TIMER TIM3
231 #define PWM_SERVO_3_RCC_IOP RCC_AHB1ENR_IOPBEN
232 #define PWM_SERVO_3_GPIO GPIOB
233 #define PWM_SERVO_3_PIN GPIO4
234 #define PWM_SERVO_3_AF GPIO_AF2
235 #define PWM_SERVO_3_OC TIM_OC1
236 #define PWM_SERVO_3_OC_BIT (1<<0)
237 #else
238 #define PWM_SERVO_3_OC_BIT 0
239 #endif
240 
241 #if USE_PWM4
242 #define PWM_SERVO_4 4
243 #define PWM_SERVO_4_TIMER TIM2
244 #define PWM_SERVO_4_RCC_IOP RCC_AHB1ENR_IOPBEN
245 #define PWM_SERVO_4_GPIO GPIOB
246 #define PWM_SERVO_4_PIN GPIO3
247 #define PWM_SERVO_4_AF GPIO_AF1
248 #define PWM_SERVO_4_OC TIM_OC2
249 #define PWM_SERVO_4_OC_BIT (1<<1)
250 #else
251 #define PWM_SERVO_4_OC_BIT 0
252 #endif
253 
254 #if USE_PWM5
255 #define PWM_SERVO_5 5
256 #define PWM_SERVO_5_TIMER TIM2
257 #define PWM_SERVO_5_RCC_IOP RCC_AHB1ENR_IOPAEN
258 #define PWM_SERVO_5_GPIO GPIOA
259 #define PWM_SERVO_5_PIN GPIO15
260 #define PWM_SERVO_5_AF GPIO_AF1
261 #define PWM_SERVO_5_OC TIM_OC1
262 #define PWM_SERVO_5_OC_BIT (1<<0)
263 #else
264 #define PWM_SERVO_5_OC_BIT 0
265 #endif
266 
267 // TODO PWM AUX
268 
269 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_0_OC_BIT|PWM_SERVO_1_OC_BIT|PWM_SERVO_4_OC_BIT|PWM_SERVO_5_OC_BIT)
270 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT)
271 
272 /*
273  * PPM
274  */
275 #define USE_PPM_TIM1 1
276 
277 #define PPM_CHANNEL TIM_IC1
278 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
279 #define PPM_IRQ NVIC_TIM1_CC_IRQ
280 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
281 // Capture/Compare InteruptEnable and InterruptFlag
282 #define PPM_CC_IE TIM_DIER_CC1IE
283 #define PPM_CC_IF TIM_SR_CC1IF
284 #define PPM_GPIO_PORT GPIOA
285 #define PPM_GPIO_PIN GPIO8
286 #define PPM_GPIO_AF GPIO_AF1
287 
288 /*
289  * Spektrum
290  */
291 /* The line that is pulled low at power up to initiate the bind process */
292 #define SPEKTRUM_BIND_PIN GPIO8
293 #define SPEKTRUM_BIND_PIN_PORT GPIOA
294 
295 #define SPEKTRUM_UART2_RCC_REG &RCC_APB1ENR
296 #define SPEKTRUM_UART2_RCC_DEV RCC_APB1ENR_USART2EN
297 #define SPEKTRUM_UART2_BANK GPIOA
298 #define SPEKTRUM_UART2_PIN GPIO3
299 #define SPEKTRUM_UART2_AF GPIO_AF7
300 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
301 #define SPEKTRUM_UART2_ISR usart2_isr
302 #define SPEKTRUM_UART2_DEV USART2
303 
304 #endif /* CONFIG_APOGEE_0_99_H */