Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
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_PIN GPIO0
20 #define LED_1_GPIO_ON gpio_clear
21 #define LED_1_GPIO_OFF gpio_set
22 #define LED_1_AFIO_REMAP ((void)0)
23 
24 /* green, on PC13 */
25 #ifndef USE_LED_2
26 #define USE_LED_2 1
27 #endif
28 #define LED_2_GPIO GPIOC
29 #define LED_2_GPIO_PIN GPIO13
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 /* Default actuators driver */
35 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
36 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
37 #define ActuatorsDefaultInit() ActuatorsPwmInit()
38 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
39 
40 #define DefaultVoltageOfAdc(adc) (0.006185*adc)
41 
42 /* UART */
43 #define UART1_GPIO_AF GPIO_AF7
44 #define UART1_GPIO_PORT_RX GPIOA
45 #define UART1_GPIO_RX GPIO10
46 #define UART1_GPIO_PORT_TX GPIOB
47 #define UART1_GPIO_TX GPIO6
48 
49 #define UART4_GPIO_AF GPIO_AF8
50 #define UART4_GPIO_PORT_RX GPIOA
51 #define UART4_GPIO_RX GPIO1
52 #define UART4_GPIO_PORT_TX GPIOA
53 #define UART4_GPIO_TX GPIO0
54 
55 #define UART6_GPIO_AF GPIO_AF8
56 #define UART6_GPIO_PORT_RX GPIOC
57 #define UART6_GPIO_RX GPIO7
58 #define UART6_GPIO_PORT_TX GPIOC
59 #define UART6_GPIO_TX GPIO6
60 
61 /* SPI */
62 #define SPI1_GPIO_AF GPIO_AF5
63 #define SPI1_GPIO_PORT_MISO GPIOA
64 #define SPI1_GPIO_MISO GPIO6
65 #define SPI1_GPIO_PORT_MOSI GPIOA
66 #define SPI1_GPIO_MOSI GPIO7
67 #define SPI1_GPIO_PORT_SCK GPIOA
68 #define SPI1_GPIO_SCK GPIO5
69 
70 #define SPI_SELECT_SLAVE0_PORT GPIOB
71 #define SPI_SELECT_SLAVE0_PIN GPIO9
72 
73 
74 /* Onboard ADCs */
75 #define USE_AD_TIM4 1
76 
77 /* provide defines that can be used to access the ADC_x in the code or airframe file
78  * these directly map to the index number of the 4 adc channels defined above
79  * 4th (index 3) is used for bat monitoring by default
80  */
81 #if USE_ADC_1
82 #define AD1_1_CHANNEL 8
83 #define ADC_1 AD1_1
84 #define ADC_1_GPIO_PORT GPIOB
85 #define ADC_1_GPIO_PIN GPIO0
86 #endif
87 
88 #if USE_ADC_2
89 #define AD1_2_CHANNEL 9
90 #define ADC_2 AD1_2
91 #define ADC_2_GPIO_PORT GPIOB
92 #define ADC_2_GPIO_PIN GPIO1
93 #endif
94 
95 #if USE_ADC_3
96 #define AD1_3_CHANNEL 14
97 #define ADC_3 AD1_3
98 #define ADC_3_GPIO_PORT GPIOC
99 #define ADC_3_GPIO_PIN GPIO4
100 #endif
101 
102 // Internal ADC for battery enabled by default
103 #ifndef USE_ADC_4
104 #define USE_ADC_4 1
105 #endif
106 #if USE_ADC_4
107 #define AD1_4_CHANNEL 4
108 #define ADC_4 AD1_4
109 #define ADC_4_GPIO_PORT GPIOA
110 #define ADC_4_GPIO_PIN GPIO4
111 #endif
112 
113 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
114 #ifndef ADC_CHANNEL_VSUPPLY
115 #define ADC_CHANNEL_VSUPPLY ADC_4
116 #endif
117 
118 
119 /* I2C mapping */
120 #define I2C1_GPIO_PORT GPIOB
121 #define I2C1_GPIO_SCL GPIO8
122 #define I2C1_GPIO_SDA GPIO7
123 
124 #define I2C2_GPIO_PORT GPIOB
125 #define I2C2_GPIO_SCL GPIO10
126 #define I2C2_GPIO_SDA GPIO11
127 
128 
129 /* SPI slave pin declaration */
130 //#define SPI_SELECT_SLAVE0_PORT GPIOA
131 //#define SPI_SELECT_SLAVE0_PIN GPIO15
132 //
133 //#define SPI_SELECT_SLAVE1_PORT GPIOA
134 //#define SPI_SELECT_SLAVE1_PIN GPIO4
135 
136 #define SPI_SELECT_SLAVE2_PORT GPIOB
137 #define SPI_SELECT_SLAVE2_PIN GPIO12
138 
139 //#define SPI_SELECT_SLAVE3_PORT GPIOC
140 //#define SPI_SELECT_SLAVE3_PIN GPIO13
141 //
142 //#define SPI_SELECT_SLAVE4_PORT GPIOC
143 //#define SPI_SELECT_SLAVE4_PIN GPIO12
144 //
145 //#define SPI_SELECT_SLAVE5_PORT GPIOC
146 //#define SPI_SELECT_SLAVE5_PIN GPIO4
147 
148 /* by default activate onboard baro */
149 #ifndef USE_BARO_BOARD
150 #define USE_BARO_BOARD 1
151 #endif
152 
153 /* PWM */
154 #define PWM_USE_TIM2 1
155 #define PWM_USE_TIM3 1
156 
157 #define USE_PWM0 1
158 #define USE_PWM1 1
159 #define USE_PWM2 1
160 #define USE_PWM3 1
161 #define USE_PWM4 1
162 #define USE_PWM5 1
163 
164 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
165 #if USE_PWM0
166 #define PWM_SERVO_0 0
167 #define PWM_SERVO_0_TIMER TIM2
168 #define PWM_SERVO_0_GPIO GPIOA
169 #define PWM_SERVO_0_PIN GPIO3
170 #define PWM_SERVO_0_AF GPIO_AF1
171 #define PWM_SERVO_0_OC TIM_OC4
172 #define PWM_SERVO_0_OC_BIT (1<<3)
173 #else
174 #define PWM_SERVO_0_OC_BIT 0
175 #endif
176 
177 #if USE_PWM1
178 #define PWM_SERVO_1 1
179 #define PWM_SERVO_1_TIMER TIM2
180 #define PWM_SERVO_1_GPIO GPIOA
181 #define PWM_SERVO_1_PIN GPIO2
182 #define PWM_SERVO_1_AF GPIO_AF1
183 #define PWM_SERVO_1_OC TIM_OC3
184 #define PWM_SERVO_1_OC_BIT (1<<2)
185 #else
186 #define PWM_SERVO_1_OC_BIT 0
187 #endif
188 
189 #if USE_PWM2
190 #define PWM_SERVO_2 2
191 #define PWM_SERVO_2_TIMER TIM3
192 #define PWM_SERVO_2_GPIO GPIOB
193 #define PWM_SERVO_2_PIN GPIO5
194 #define PWM_SERVO_2_AF GPIO_AF2
195 #define PWM_SERVO_2_OC TIM_OC2
196 #define PWM_SERVO_2_OC_BIT (1<<1)
197 #else
198 #define PWM_SERVO_2_OC_BIT 0
199 #endif
200 
201 #if USE_PWM3
202 #define PWM_SERVO_3_IDX 3
203 #define PWM_SERVO_3_TIMER TIM3
204 #define PWM_SERVO_3_GPIO GPIOB
205 #define PWM_SERVO_3_PIN GPIO4
206 #define PWM_SERVO_3_AF GPIO_AF2
207 #define PWM_SERVO_3_OC TIM_OC1
208 #define PWM_SERVO_3_OC_BIT (1<<0)
209 #else
210 #define PWM_SERVO_3_OC_BIT 0
211 #endif
212 
213 #if USE_PWM4
214 #define PWM_SERVO_4 4
215 #define PWM_SERVO_4_TIMER TIM2
216 #define PWM_SERVO_4_GPIO GPIOB
217 #define PWM_SERVO_4_PIN GPIO3
218 #define PWM_SERVO_4_AF GPIO_AF1
219 #define PWM_SERVO_4_OC TIM_OC2
220 #define PWM_SERVO_4_OC_BIT (1<<1)
221 #else
222 #define PWM_SERVO_4_OC_BIT 0
223 #endif
224 
225 #if USE_PWM5
226 #define PWM_SERVO_5 5
227 #define PWM_SERVO_5_TIMER TIM2
228 #define PWM_SERVO_5_GPIO GPIOA
229 #define PWM_SERVO_5_PIN GPIO15
230 #define PWM_SERVO_5_AF GPIO_AF1
231 #define PWM_SERVO_5_OC TIM_OC1
232 #define PWM_SERVO_5_OC_BIT (1<<0)
233 #else
234 #define PWM_SERVO_5_OC_BIT 0
235 #endif
236 
237 // TODO PWM AUX
238 
239 #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)
240 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT)
241 
242 /*
243  * PPM
244  */
245 #define USE_PPM_TIM1 1
246 
247 #define PPM_CHANNEL TIM_IC1
248 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
249 #define PPM_IRQ NVIC_TIM1_CC_IRQ
250 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
251 // Capture/Compare InteruptEnable and InterruptFlag
252 #define PPM_CC_IE TIM_DIER_CC1IE
253 #define PPM_CC_IF TIM_SR_CC1IF
254 #define PPM_GPIO_PORT GPIOA
255 #define PPM_GPIO_PIN GPIO8
256 #define PPM_GPIO_AF GPIO_AF1
257 
258 /*
259  * Spektrum
260  */
261 /* The line that is pulled low at power up to initiate the bind process */
262 #define SPEKTRUM_BIND_PIN GPIO8
263 #define SPEKTRUM_BIND_PIN_PORT GPIOA
264 
265 #define SPEKTRUM_UART2_RCC RCC_USART2
266 #define SPEKTRUM_UART2_BANK GPIOA
267 #define SPEKTRUM_UART2_PIN GPIO3
268 #define SPEKTRUM_UART2_AF GPIO_AF7
269 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
270 #define SPEKTRUM_UART2_ISR usart2_isr
271 #define SPEKTRUM_UART2_DEV USART2
272 
273 #endif /* CONFIG_APOGEE_0_99_H */